diff --git a/front/components/DropdownSelector.vue b/front/components/DropdownSelector.vue index c8fc5a215..1f7f9faaa 100644 --- a/front/components/DropdownSelector.vue +++ b/front/components/DropdownSelector.vue @@ -7,20 +7,31 @@ left v-bind="$attrs" > - + + @@ -392,6 +438,8 @@ import ReportsDialog from '~/components/ReportsDialog.vue'; import HarvestMatrixDialog from '~/components/HarvestMatrixDialog.vue'; import ConfirmDialog from '~/components/ConfirmDialog.vue'; import LocalDate from '~/components/LocalDate.vue'; +import DropdownSelector from '~/components/DropdownSelector.vue'; +import SimpleMetric from '~/components/SimpleMetric.vue'; export default { layout: 'space', @@ -407,6 +455,8 @@ export default { HarvestMatrixDialog, ConfirmDialog, LocalDate, + DropdownSelector, + SimpleMetric, }, async asyncData({ $axios, @@ -445,6 +495,9 @@ export default { institution, sushiItems: [], selected: [], + filters: { + sushiStatuses: [], + }, refreshing: false, deleting: false, search: '', @@ -487,6 +540,14 @@ export default { return this.$dateFunctions.format(localDate, 'P'); }, + availableSushiStatuses() { + return [ + { text: this.$t('institutions.sushi.untested'), value: 'untested' }, + { text: this.$t('institutions.sushi.operational'), value: 'success' }, + { text: this.$t('institutions.sushi.invalidCredentials'), value: 'unauthorized' }, + { text: this.$t('error'), value: 'failed' }, + ]; + }, tableHeaders() { return [ { @@ -510,6 +571,13 @@ export default { value: 'connection', align: 'right', width: '160px', + filter: (value) => { + if (this.filters.sushiStatuses.length === 0) { + return true; + } + + return this.filters.sushiStatuses.includes(value?.status || 'untested'); + }, }, { text: this.$t('institutions.sushi.updatedAt'), @@ -538,10 +606,35 @@ export default { hasUntestedItems() { return this.untestedItems.length > 0; }, + hasUnauthorizedItems() { + return this.unauthorizedItems.length > 0; + }, + hasFailedItems() { + return this.failedItems.length > 0; + }, untestedItems() { - return this.sushiItems.filter((item) => ( - typeof item?.connection?.status !== 'string' - )); + return this.itemsByStatus.untested || []; + }, + unauthorizedItems() { + return this.itemsByStatus.unauthorized || []; + }, + failedItems() { + return this.itemsByStatus.failed || []; + }, + operationalItems() { + return this.itemsByStatus.success || []; + }, + itemsByStatus() { + return this.sushiItems.reduce((acc, item) => { + const status = item?.connection?.status || 'untested'; + + if (!Array.isArray(acc[status])) { + acc[status] = []; + } + + acc[status].push(item); + return acc; + }, {}); }, testingConnection() { return Object.keys(this.loadingItems).length > 0; @@ -640,6 +733,9 @@ export default { showSushiItemFiles(item) { this.$refs.sushiFiles.showFiles(item); }, + filterByStatus(status) { + this.filters.sushiStatuses = [status]; + }, async refreshSushiItems() { if (!this.hasInstitution) { return; }