-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardizes + Improves Related-Analysis Display
- Loading branch information
Showing
6 changed files
with
287 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<script setup lang="ts"> | ||
import { AnalysisType, type Analysis } from '@/openapi/generated/pacta' | ||
const { humanReadableTimeFromStandardString } = useTime() | ||
const i18n = useI18n() | ||
const localePath = useLocalePath() | ||
const { t } = i18n | ||
const prefix = 'components/analysis/ContextualListView' | ||
const tt = (s: string) => t(`${prefix}.${s}`) | ||
interface Props { | ||
analyses: Analysis[] | ||
name: string | ||
portfolioId?: string | undefined | ||
portfolioGroupId?: string | undefined | ||
initiativeId?: string | undefined | ||
} | ||
const props = defineProps<Props>() | ||
interface Emits { | ||
(e: 'refresh'): void | ||
} | ||
const emit = defineEmits<Emits>() | ||
const items = computed(() => props.analyses.map((a) => { | ||
let status = tt('Running') | ||
let statusBg = 'bg-yellow-200' | ||
if (a.completedAt !== undefined) { | ||
if (a.failureMessage !== undefined) { | ||
status = tt('Failed') | ||
statusBg = 'bg-red-400' | ||
} else { | ||
status = tt('Completed') | ||
statusBg = 'bg-green-200' | ||
} | ||
} else if (new Date().getTime() - new Date(a.createdAt).getTime() > 1000 * 60 * 10) { | ||
status = tt('PotentialTimeout') | ||
statusBg = 'bg-red-200' | ||
} | ||
return { | ||
...a, | ||
status, | ||
statusBg, | ||
} | ||
})) | ||
const hasAnyAudits = computed(() => items.value.some((a) => a.analysisType === AnalysisType.ANALYSIS_TYPE_AUDIT)) | ||
const hasAnyReports = computed(() => items.value.some((a) => a.analysisType === AnalysisType.ANALYSIS_TYPE_REPORT)) | ||
const showPromptToRunAudit = computed(() => { | ||
return !hasAnyAudits.value && !hasAnyReports.value | ||
}) | ||
const showPromptToRunReport = computed(() => { | ||
return hasAnyAudits.value && !hasAnyReports.value | ||
}) | ||
const auditButtonClasses = computed(() => { | ||
return !hasAnyAudits.value && !hasAnyReports.value ? '' : 'p-button-outlined' | ||
}) | ||
const reportButtonClasses = computed(() => { | ||
return !hasAnyReports.value && hasAnyAudits.value ? '' : 'p-button-outlined' | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-column gap-2"> | ||
<PVDataTable | ||
:value="items" | ||
data-key="id" | ||
size="medium" | ||
sort-field="createdAt" | ||
:sort-order="-1" | ||
> | ||
<template #empty> | ||
<div class="p-3"> | ||
{{ tt('No Analyses Message') }} | ||
</div> | ||
</template> | ||
<PVColumn | ||
field="createdAt" | ||
:header="tt('Ran At')" | ||
> | ||
<template #body="slotProps"> | ||
{{ humanReadableTimeFromStandardString(slotProps.data.createdAt).value }} | ||
</template> | ||
</PVColumn> | ||
<PVColumn | ||
field="status" | ||
:header="tt('Status')" | ||
> | ||
<template #body="slotProps"> | ||
<AnalysisStatusChip | ||
:analysis="slotProps.data" | ||
/> | ||
</template> | ||
</PVColumn> | ||
<PVColumn | ||
field="analysisType" | ||
:header="tt('Type')" | ||
> | ||
<template #body="slotProps"> | ||
{{ tt(slotProps.data.analysisType) }} | ||
</template> | ||
</PVColumn> | ||
<PVColumn | ||
field="name" | ||
:header="tt('Name')" | ||
/> | ||
<PVColumn | ||
field="Access" | ||
:header="tt('Access')" | ||
> | ||
<template #body="slotProps"> | ||
<AnalysisAccessButtons | ||
class="py-2" | ||
:analysis="slotProps.data" | ||
/> | ||
</template> | ||
</PVColumn> | ||
<PVColumn :header="tt('Details')"> | ||
<template #body="slotProps"> | ||
<LinkButton | ||
class="p-button-outlined p-button-xs p-button-secondary" | ||
icon="pi pi-arrow-right" | ||
:to="localePath(`/my-data?tab=a&analyses=${slotProps.data.id}`)" | ||
/> | ||
</template> | ||
</PVColumn> | ||
</PVDataTable> | ||
<PVMessage | ||
v-if="showPromptToRunAudit" | ||
severity="info" | ||
class="m-0" | ||
:closable="false" | ||
> | ||
{{ tt('No Audits Message') }} | ||
</PVMessage> | ||
<PVMessage | ||
v-if="showPromptToRunReport" | ||
severity="info" | ||
class="m-0" | ||
:closable="false" | ||
> | ||
{{ tt('No Reports Message') }} | ||
</PVMessage> | ||
<div class="flex gap-2"> | ||
<AnalysisRunButton | ||
:analysis-type="AnalysisType.ANALYSIS_TYPE_AUDIT" | ||
:name="props.name" | ||
:class="auditButtonClasses" | ||
:portfolio-id="props.portfolioId" | ||
:portfolio-group-id="props.portfolioGroupId" | ||
:initiative-id="props.initiativeId" | ||
class="p-button-sm" | ||
@started="() => emit('refresh')" | ||
/> | ||
<AnalysisRunButton | ||
:analysis-type="AnalysisType.ANALYSIS_TYPE_REPORT" | ||
:name="props.name" | ||
:class="reportButtonClasses" | ||
:portfolio-id="props.portfolioId" | ||
:portfolio-group-id="props.portfolioGroupId" | ||
:initiative-id="props.initiativeId" | ||
class="p-button-sm" | ||
@started="() => emit('refresh')" | ||
/> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script setup lang="ts"> | ||
import { type Analysis } from '@/openapi/generated/pacta' | ||
const { t } = useI18n() | ||
const prefix = 'components/analysis/StatusChip' | ||
const tt = (s: string) => t(`${prefix}.${s}`) | ||
interface Props { | ||
analysis: Analysis | ||
} | ||
const props = defineProps<Props>() | ||
const isStale = (a: Analysis): boolean => new Date().getTime() - new Date(a.createdAt).getTime() > 1000 * 60 * 10 | ||
const status = computed(() => { | ||
if (props.analysis.completedAt !== undefined) { | ||
if (props.analysis.failureMessage !== undefined) { | ||
return tt('Failed') | ||
} else { | ||
return tt('Completed') | ||
} | ||
} | ||
if (isStale(props.analysis)) { | ||
return tt('PotentialTimeout') | ||
} | ||
return tt('Running') | ||
}) | ||
const bg = computed(() => { | ||
if (props.analysis.completedAt !== undefined) { | ||
if (props.analysis.failureMessage !== undefined) { | ||
return 'bg-red-400' | ||
} else { | ||
return 'bg-green-200' | ||
} | ||
} | ||
if (isStale(props.analysis)) { | ||
return 'bg-red-200' | ||
} | ||
return 'bg-yellow-200' | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div | ||
:class="bg" | ||
class="p-1 align-self-stretch flex align-items-center justify-content-center border-round-lg" | ||
> | ||
<span> | ||
{{ status }} | ||
</span> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.