From 2f77db0d2c40dc833ed0985057d2f302a2511179 Mon Sep 17 00:00:00 2001 From: Grady Ward Date: Sat, 20 Jan 2024 13:14:19 -0700 Subject: [PATCH 1/2] Standardizes + Improves Related-Analysis Display --- .../analysis/ContextualListView.vue | 167 ++++++++++++++++++ frontend/components/analysis/ListView.vue | 13 +- frontend/components/analysis/StatusChip.vue | 51 ++++++ frontend/components/portfolio/ListView.vue | 73 +------- .../components/portfolio/group/ListView.vue | 26 ++- frontend/lang/en.json | 30 +++- 6 files changed, 287 insertions(+), 73 deletions(-) create mode 100644 frontend/components/analysis/ContextualListView.vue create mode 100644 frontend/components/analysis/StatusChip.vue diff --git a/frontend/components/analysis/ContextualListView.vue b/frontend/components/analysis/ContextualListView.vue new file mode 100644 index 0000000..50ff7d2 --- /dev/null +++ b/frontend/components/analysis/ContextualListView.vue @@ -0,0 +1,167 @@ + + + diff --git a/frontend/components/analysis/ListView.vue b/frontend/components/analysis/ListView.vue index 227375b..9b18e80 100644 --- a/frontend/components/analysis/ListView.vue +++ b/frontend/components/analysis/ListView.vue @@ -71,6 +71,10 @@ const deleteAnalysis = (id: string) => withLoading( `${prefix}.deleteAnalysis`, ) const deleteSelected = () => Promise.all([selectedRows.value.map((row) => deleteAnalysis(row.id))]).then(refresh) +const deleteSpecificAnalysis = async (id: string) => { + await deleteAnalysis(id) + refresh() +} + + + Promise.all([selectedRows.value.map((row) => delete icon="pi pi-trash" class="p-button-danger p-button-outlined" :label="tt('Delete')" - @click="() => deleteAnalysis(slotProps.data.id)" + @click="() => deleteSpecificAnalysis(slotProps.data.id)" />
+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() + +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' +}) + + + diff --git a/frontend/components/portfolio/ListView.vue b/frontend/components/portfolio/ListView.vue index 0a88347..9ddbef9 100644 --- a/frontend/components/portfolio/ListView.vue +++ b/frontend/components/portfolio/ListView.vue @@ -1,6 +1,6 @@