Refactor pagination components to use provide and usePaginatedList, optimize fast link handling with queuing and concurrency limits, and update XLVask content generation logic and caching.

This commit is contained in:
Jeppe Bundgaard
2026-05-12 15:03:03 +02:00
parent c657ec57ad
commit fba85a72c1
5 changed files with 61 additions and 15 deletions
@@ -56,7 +56,8 @@ import { useRoute } from "vue-router";
import { departments, getDepartments, isLoading, getDepartmentName } from "@/components/pagination/departmentTabs.vue";
import { showPopper, removePopperIfOpen, popperBox } from "@/components/displays/PopperDefault.vue";
import { SessionUser } from "@/components/session/token/SessionUser.vue";
import { orderBy, orderDirection, setOrder, loadList } from "@/components/pagination/paginatedList.vue";
import { usePaginatedListInstance } from "@/components/pagination/paginatedList.vue";
const { orderBy, orderDirection, setOrder, loadList } = usePaginatedListInstance();
import ActionSettingsWheelItem from "@/components/displays/buttons/ActionSettingsWheelItem.vue";
import OrderContentTable from "@/components/displays/superuser/tables/OrderContentTable.vue";
import InvoiceMultipleCollectionsModal from "@/components/displays/modals/InvoiceMultipleCollectionsModal.vue";
@@ -37,6 +37,32 @@ import {
getCachedXlvaskUsageAmount,
setCachedXlvaskUsageAmount
} from "@/components/displays/department/pos/sync/xlvaskUsageAmountCache.js";
import { REQUEST_QUEUE_CONFIG } from "@/config.js";
const FAST_LINK_MAX_CONCURRENT = Math.ceil(REQUEST_QUEUE_CONFIG.concurrency.GET / 2);
let fastLinkInFlight = 0;
const fastLinkQueue = [];
const drainFastLinkQueue = () => {
while (fastLinkInFlight < FAST_LINK_MAX_CONCURRENT && fastLinkQueue.length > 0) {
const object = fastLinkQueue.shift();
if (object.loading) {
continue;
}
fastLinkInFlight++;
generateContent(object).finally(() => {
fastLinkInFlight--;
drainFastLinkQueue();
});
}
};
const scheduleFastLink = (object) => {
if (!fastLinkQueue.includes(object) && object.fast_link_key && !object.loading) {
fastLinkQueue.push(object);
}
drainFastLinkQueue();
};
const redirectDepartmentOrderPage = (orderId, departmentId) => {
// Send the user to the order page (In a new tab)
@@ -218,10 +244,12 @@ const applyGeneratedContent = (object, data) => {
const potentialDuplicates = Array.isArray(data?.potential_duplicates) ? data.potential_duplicates : [];
object.items = orderItems;
object.selectedDuplicateId = potentialDuplicates.length ? parseInt(potentialDuplicates[0].id) : null;
object.duplicates = potentialDuplicates;
if (orderItems.length > 0) {
object.total_net_amount = getPriceFromOrderItems(orderItems);
if (potentialDuplicates.length > 0) {
object.selectedDuplicateId = parseInt(potentialDuplicates[0].id);
object.duplicates = potentialDuplicates;
}
if (data?.automation !== undefined) {
object.automation = data.automation;
}
object.fast_link_key = undefined;
object.loading = false;
@@ -239,15 +267,15 @@ const applyCachedGeneratedContent = (object) => {
const generateContent = (object) => {
if (applyCachedGeneratedContent(object)) {
return;
return Promise.resolve();
}
if (!object.fast_link_key || object.loading) {
return; // If no fast link key, do not generate content
return Promise.resolve(); // If no fast link key, do not generate content
}
object.loading = true; // Set loading state to true
// Generate content based on the object
SessionUser.request(
return SessionUser.request(
'/modules/xlvask/services/usage/orders/fast-link?fast_link_key=' + object.fast_link_key,
'GET'
).then((response) => {
@@ -256,6 +284,7 @@ const generateContent = (object) => {
setCachedXlvaskUsageAmount(object, {
order_items: object.items,
potential_duplicates: object.duplicates,
automation: object.automation,
});
}
).catch((error) => {
@@ -354,8 +383,8 @@ watch(() => props.objects, (newObjects) => {
return;
}
if (isHighlightedUsageLog(object) && object.fast_link_key && !object.loading) {
generateContent(object);
if (object.fast_link_key && !object.loading) {
scheduleFastLink(object);
}
});
}, { immediate: true, deep: true });
@@ -876,7 +905,6 @@ const filteredObjects = computed(() => {
</template>
</div>
</div>
<span v-if="!object.loading">{{generateContent(object)}}</span>
<template v-if="object.items">
<div class="columns xlvask-order-comparison-columns">
<div class="column" :class="{ 'is-12': (!object.duplicates?.length && !isComparingOrders(object)), 'is-6': (object.duplicates?.length && isComparingOrders(object)) }">
@@ -24,8 +24,17 @@ const props = defineProps({
}
})
import { provide } from "vue";
import { useRouter } from "vue-router";
import {
usePaginatedList,
PaginatedListKey,
} from "@/components/pagination/paginatedList.vue";
const paginatedList = usePaginatedList();
provide(PaginatedListKey, paginatedList);
const {
isLoaded,
isLoading,
list,
@@ -42,7 +51,7 @@ import {
setOrder,
hideSearchField,
setHideSearchField,
} from "@/components/pagination/paginatedList.vue";
} = paginatedList;
import PaginationNavigation from "@/components/displays/pagination/PaginationNavigation.vue";
import LoadButtonWhileAwait from "@/components/request/LoadButtonWhileAwait.vue";
@@ -81,9 +81,17 @@ const props = defineProps({
}
})
const emit = defineEmits(["flagStatusChanged", "flagCreated"]);
import { computed, ref } from "vue";
import { computed, ref, provide } from "vue";
import { useRouter } from "vue-router";
import {
usePaginatedList,
PaginatedListKey,
} from "@/components/pagination/paginatedList.vue";
const paginatedList = usePaginatedList();
provide(PaginatedListKey, paginatedList);
const {
isLoading,
list,
loadList,
@@ -96,7 +104,7 @@ import {
setAdditionalQueryParameters,
setOrder,
setHideSearchField,
} from "@/components/pagination/paginatedList.vue";
} = paginatedList;
import OrdersTable from "@/components/displays/department/pos/orders/ordersTable.vue";
import {SessionUser} from "@/components/session/token/SessionUser.vue";
import PaginationDisplayFilters from "@/components/displays/pagination/PaginationDisplayFilters.vue";
+1 -1
View File
@@ -87,7 +87,7 @@ export default defineConfig(({ mode }) => {
const bearer = `Bearer ${token}`
console.log(`Calling URL: ${url}`)
try {
execSync(`curl -f -X GET "${url}" -H "Authorization: ${bearer}"`)
execSync(`curl -f --ssl-no-revoke -X GET "${url}" -H "Authorization: ${bearer}"`)
console.log('Successfully updated server with new version.')
} catch (error) {
console.error('Failed to update server with new version:', error.message)