From cd15c1b368e2f09c7f103b975af399d439fd7daa Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Thu, 14 Mar 2024 16:15:09 -0500 Subject: [PATCH] add overlay as loading indicator on `GridList`s Fixes https://github.com/galaxyproject/galaxy/issues/17666 --- client/src/components/Grid/GridList.vue | 190 +++++++++++++----------- 1 file changed, 102 insertions(+), 88 deletions(-) diff --git a/client/src/components/Grid/GridList.vue b/client/src/components/Grid/GridList.vue index acf7dd58d470..618fffaf5100 100644 --- a/client/src/components/Grid/GridList.vue +++ b/client/src/components/Grid/GridList.vue @@ -3,7 +3,7 @@ import { library } from "@fortawesome/fontawesome-svg-core"; import { faCaretDown, faCaretUp, faShieldAlt } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { useDebounceFn, useEventBus } from "@vueuse/core"; -import { BAlert, BButton, BFormCheckbox, BPagination } from "bootstrap-vue"; +import { BAlert, BButton, BFormCheckbox, BOverlay, BPagination } from "bootstrap-vue"; import { computed, onMounted, onUnmounted, ref, watch } from "vue"; import { useRouter } from "vue-router/composables"; @@ -64,11 +64,12 @@ const selectedIndeterminate = computed(() => ![0, gridData.value.length].include const currentPage = ref(1); const totalRows = ref(0); -// loading indicator -const loading = ref(true); +// loading indicators +const initDataLoading = ref(true); +const resultsLoading = ref(false); -// check if loading has completed and data rows are available -const isAvailable = computed(() => !loading.value && totalRows.value > 0); +// check if `initDataLoading` has completed and data rows are available +const isAvailable = computed(() => !initDataLoading.value && totalRows.value > 0); // sort references const sortBy = ref(props.gridConfig ? props.gridConfig.sortBy : ""); @@ -112,11 +113,13 @@ function displayInitialMessage() { * Request grid data */ async function getGridData() { + resultsLoading.value = true; selected.value = new Set(); if (props.gridConfig) { if (Object.keys(invalidFilters.value).length > 0) { // there are invalid filters, so we don't want to search - loading.value = false; + initDataLoading.value = false; + resultsLoading.value = false; return; } try { @@ -131,10 +134,11 @@ async function getGridData() { gridData.value = responseData; totalRows.value = responseTotal; errorMessage.value = ""; - loading.value = false; } catch (e) { errorMessage.value = `Failed to obtain grid data: ${e}`; - loading.value = false; + } finally { + initDataLoading.value = false; + resultsLoading.value = false; } } } @@ -229,7 +233,7 @@ function validatedFilterText() { */ onMounted(() => { if (props.usernameSearch) { - filterText.value = filterClass.setFilterValue(filterText.value, "user", props.usernameSearch); + filterText.value = filterClass.setFilterValue(filterText.value, "user", `'${props.usernameSearch}'`); } getGridData(); eventBus.on(onRouterPush); @@ -282,11 +286,11 @@ watch(operationMessage, () => { :placeholder="`search ${gridConfig.plural.toLowerCase()}`" :filter-class="filterClass" :filter-text.sync="filterText" - :loading="loading" + :loading="initDataLoading || resultsLoading" :show-advanced.sync="showAdvanced" />
- + @@ -308,83 +312,93 @@ watch(operationMessage, () => { - - - - - - - - - -
- - - - - {{ fieldEntry.title || fieldEntry.key }} - - - - - - - {{ fieldEntry.title || fieldEntry.key }} -
- - -
- - - - - - - - - Not available. -
- -
+ + + + + + + + + + +
+ + + + + {{ fieldEntry.title || fieldEntry.key }} + + + + + + + {{ fieldEntry.title || fieldEntry.key }} +
+ + +
+ + + + + + + + + Not available. +
+ +
+