diff --git a/client-nuxt/components/DataTableActions.vue b/client-nuxt/components/DataTableActions.vue index 7c8d7c68cf1c45cfc7eb480e566c9da79c1b8b52..800ce4c3284ae255330ba4b7b582aae47f29d13b 100644 --- a/client-nuxt/components/DataTableActions.vue +++ b/client-nuxt/components/DataTableActions.vue @@ -16,6 +16,7 @@ :sort-desc="sortDesc" :search="search" :item-class="getRowClass" + :loading="loading" multi-sort @click:row="goToItemPage" > @@ -105,6 +106,7 @@ export default { itemType: { type: String, required: true, default: 'object' }, addRoute: { type: Object, default: () => null }, selectedItem: { type: Number, default: null }, + loading: { type: Boolean, default: false }, }, data() { return { diff --git a/client-nuxt/pages/projects/_id/analysis/index.vue b/client-nuxt/pages/projects/_id/analysis/index.vue index 498ddfcadc91d5747688f456d4b942337c494fdb..c16d73cfcab944545132b1e37f5610194ee76429 100644 --- a/client-nuxt/pages/projects/_id/analysis/index.vue +++ b/client-nuxt/pages/projects/_id/analysis/index.vue @@ -9,6 +9,7 @@ :headers="headers" :add-route="addAnalysisRoute" :selected-item="selectedItem" + :loading="$fetchState.pending" @delete="deleteAnalysis" ></data-table-actions> <ProgressBar :waiting="waiting" message="Deleting Analysis" /> @@ -21,18 +22,6 @@ import ProgressBar from '@/components/ProgressBar' import ErrorAlert from '@/components/ErrorAlert' import DataTableActions from '~/components/DataTableActions.vue' -function fetchAnalysis($axios, params) { - try { - return $axios.$get(`/api/projects/${params.id}/analysis/`) - } catch (error) { - if (error.response.status === 403) { - return [] - } else { - throw error - } - } -} - export default { components: { ErrorAlert, @@ -42,8 +31,25 @@ export default { loading: { continuous: true, }, + async fetch() { + try { + this.analysis = await this.$axios.$get( + `/api/projects/${this.$route.params.id}/analysis/` + ) + } catch (error) { + if (error.response.status === 403) { + return [] + } else { + throw error + } + } + }, async asyncData({ params, $axios }) { - return { analysis: await fetchAnalysis($axios, params) } + return { + permissions: await $axios.$get( + `/api/projects/${params.id}/analysis/permissions/` + ), + } }, data() { return { @@ -89,6 +95,10 @@ export default { return parseInt(this.$route.params?.analysisId) }, }, + mounted() { + this.$fetch() + }, + methods: { getItemRoute({ id: analysisId }) { return { @@ -107,7 +117,7 @@ export default { await this.$axios.$delete( `/api/projects/${params.id}/analysis/${analysisId}` ) - this.analysis = await fetchAnalysis(this.$axios, params) + this.$fetch() this.updateAnalysisCount() this.$emit('update-analysis') } catch (error) {