From b7e980e71b5a0486cdcd5ced9d033ab6e07ba5bc Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Fri, 12 May 2023 15:57:12 -0400 Subject: [PATCH] [WIP] Paginate History Store Trying an approach with v-infinite-scroll in selector modal --- client/src/components/Dataset/DatasetList.vue | 3 +- .../History/Modals/SelectorModal.vue | 173 +++++++++++------- client/src/stores/historyStore.ts | 29 ++- .../src/stores/services/history.services.js | 22 ++- lib/galaxy/webapps/galaxy/api/histories.py | 11 ++ .../webapps/galaxy/services/histories.py | 17 ++ 6 files changed, 176 insertions(+), 79 deletions(-) diff --git a/client/src/components/Dataset/DatasetList.vue b/client/src/components/Dataset/DatasetList.vue index 8e379340e3b..174e34207c6 100644 --- a/client/src/components/Dataset/DatasetList.vue +++ b/client/src/components/Dataset/DatasetList.vue @@ -114,11 +114,10 @@ export default { }, }, created() { - this.loadHistories(); this.load(); }, methods: { - ...mapActions(useHistoryStore, ["loadHistories", "applyFilters"]), + ...mapActions(useHistoryStore, ["applyFilters"]), load(concat = false) { this.loading = true; getDatasets({ diff --git a/client/src/components/History/Modals/SelectorModal.vue b/client/src/components/History/Modals/SelectorModal.vue index d9acdb78b4a..85e8b48521a 100644 --- a/client/src/components/History/Modals/SelectorModal.vue +++ b/client/src/components/History/Modals/SelectorModal.vue @@ -22,8 +22,13 @@ import { useRouter } from "vue-router/composables"; import { useHistoryStore } from "@/stores/historyStore"; import { library } from "@fortawesome/fontawesome-svg-core"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; -import { faColumns, faSignInAlt } from "@fortawesome/free-solid-svg-icons"; +import { faColumns, faSignInAlt, faCaretRight } from "@fortawesome/free-solid-svg-icons"; import { faListAlt } from "@fortawesome/free-regular-svg-icons"; +import Vue from "vue"; +//@ts-ignore missing typedefs +import infiniteScroll from "vue-infinite-scroll"; + +Vue.use(infiniteScroll); type AdditionalOptions = "set-current" | "multi" | "center"; @@ -40,10 +45,13 @@ const emit = defineEmits<{ (e: "selectHistories", histories: HistorySummary[]): void; }>(); -library.add(faColumns, faSignInAlt, faListAlt); +// @ts-ignore bad library types +library.add(faColumns, faSignInAlt, faListAlt, faCaretRight); const filter = ref(""); const currentPage = ref(1); +const busy = ref(false); +const allLoaded = ref(false); const modal: Ref = ref(null); // reactive proxy for props.histories, as the prop is not @@ -75,8 +83,8 @@ watch( } ); -const paginated = computed(() => - filtered.value.slice((currentPage.value - 1) * props.perPage, currentPage.value * props.perPage) +const paginated = computed( + () => filtered.value //.slice((currentPage.value - 1) * props.perPage, currentPage.value * props.perPage) ); const totalRows = computed(() => filtered.value.length); @@ -121,11 +129,24 @@ function openInMulti(history: HistorySummary) { historyStore.pinHistory(history.id); modal.value?.hide(); } + +async function loadMore() { + if (!allLoaded.value) { + busy.value = true; + await historyStore.loadHistories(); + busy.value = false; + await historyStore.getTotalHistoryCount.then((count) => { + if (count <= paginated.value.length) { + allLoaded.value = true; + } + }); + } +}