Loading client/src/components/Upload/DefaultBox.vue +7 −4 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ const props = defineProps({ }, lazyLoad: { type: Number, default: 50, default: 150, }, listDbKeys: { type: Array, Loading @@ -84,6 +84,7 @@ const uploadCompleted = ref(0); const uploadFile = ref(null); const uploadItems = ref({}); const uploadSize = ref(0); const queue = ref(createUploadQueue()); const counterNonRunning = computed(() => counterAnnounce.value + counterSuccess.value + counterError.value); const enableBuild = computed( Loading @@ -99,8 +100,6 @@ const listExtensions = computed(() => props.effectiveExtensions.filter((ext) => const showHelper = computed(() => Object.keys(uploadItems.value).length === 0); const uploadValues = computed(() => Object.values(uploadItems.value)); const queue = computed(() => createUploadQueue()); function createUploadQueue() { return new UploadQueue({ announce: eventAnnounce, Loading @@ -108,7 +107,6 @@ function createUploadQueue() { complete: eventComplete, error: eventError, get: (index) => uploadItems.value[index], historyId: historyId.value, multiple: props.multiple, progress: eventProgress, success: eventSuccess, Loading Loading @@ -268,6 +266,11 @@ function eventStart() { uploadValues.value.forEach((model) => { if (model.status === "init") { model.status = "queued"; if (!model.targetHistoryId) { // Associate with current history once upload starts // This will not change if the current history is changed during upload model.targetHistoryId = historyId.value; } uploadSize.value += model.fileSize; } }); Loading client/src/components/Upload/UploadModal.vue +10 −5 Original line number Diff line number Diff line <script setup> import { setIframeEvents } from "components/Upload/utils"; import { useConfig } from "composables/config"; import { useUserHistories } from "composables/userHistories"; import { storeToRefs } from "pinia"; import { ref, watch } from "vue"; import { setIframeEvents } from "@/components/Upload/utils"; import { useConfig } from "@/composables/config"; import { useUserHistories } from "@/composables/userHistories"; import { useUserStore } from "@/stores/userStore"; import { wait } from "@/utils/utils"; import UploadContainer from "./UploadContainer.vue"; const { currentUser } = storeToRefs(useUserStore()); const { currentHistoryId } = useUserHistories(currentUser); const { currentHistoryId, currentHistory } = useUserHistories(currentUser); const { config, isConfigLoaded } = useConfig(); Loading Loading @@ -81,7 +81,12 @@ defineExpose({ no-enforce-focus hide-footer> <template v-slot:modal-header> <h2 class="title h-sm" tabindex="0">{{ options.title }}</h2> <h2 class="title h-sm" tabindex="0"> {{ options.title }} <span v-if="currentHistory"> to <b>{{ currentHistory.name }}</b> </span> </h2> </template> <UploadContainer v-if="currentHistoryId" Loading client/src/composables/userHistories.js +5 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,10 @@ export function useUserHistories(user) { ); const currentHistoryId = computed(() => historyStore.currentHistoryId); const currentHistory = computed(() => historyStore.currentHistory); return { currentHistoryId }; return { currentHistoryId, currentHistory, }; } client/src/utils/upload-queue.js +18 −6 Original line number Diff line number Diff line Loading @@ -96,7 +96,11 @@ export class UploadQueue { // Remove item from queue this.remove(index); // Collect upload request data const data = uploadPayload([this.opts.get(index)], this.opts.historyId); const item = this.opts.get(index); if (!item.targetHistoryId) { throw new Error(`Missing target history for upload item [${index}] ${item.fileName}`); } const data = uploadPayload([item], item.targetHistoryId); // Initiate upload request this._processSubmit(index, data); } catch (e) { Loading @@ -107,19 +111,27 @@ export class UploadQueue { } } // Submit remote files as single batch request // Submit remote files as single batch request per target history _processUrls() { const list = []; const batchByHistory = {}; for (const index of this.queue.keys()) { const model = this.opts.get(index); if (model.status === "queued" && model.fileMode === "url") { list.push({ index, ...model }); if (!model.targetHistoryId) { throw new Error(`Missing target history for upload item [${index}] ${model.fileName}`); } if (!batchByHistory[model.targetHistoryId]) { batchByHistory[model.targetHistoryId] = []; } batchByHistory[model.targetHistoryId].push({ index, ...model }); this.remove(index); } } if (list.length > 0) { for (const historyId in batchByHistory) { const list = batchByHistory[historyId]; try { const data = uploadPayload(list, this.opts.historyId); const data = uploadPayload(list, historyId); sendPayload(data, { success: (message) => { list.forEach((model) => { Loading client/src/utils/upload-queue.test.js +1 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,7 @@ describe("UploadQueue", () => { spaceToTab: true, status: "queued", toPosixLines: false, targetHistoryId: "historyId", }; }, get: (index) => fileEntries[index], Loading Loading
client/src/components/Upload/DefaultBox.vue +7 −4 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ const props = defineProps({ }, lazyLoad: { type: Number, default: 50, default: 150, }, listDbKeys: { type: Array, Loading @@ -84,6 +84,7 @@ const uploadCompleted = ref(0); const uploadFile = ref(null); const uploadItems = ref({}); const uploadSize = ref(0); const queue = ref(createUploadQueue()); const counterNonRunning = computed(() => counterAnnounce.value + counterSuccess.value + counterError.value); const enableBuild = computed( Loading @@ -99,8 +100,6 @@ const listExtensions = computed(() => props.effectiveExtensions.filter((ext) => const showHelper = computed(() => Object.keys(uploadItems.value).length === 0); const uploadValues = computed(() => Object.values(uploadItems.value)); const queue = computed(() => createUploadQueue()); function createUploadQueue() { return new UploadQueue({ announce: eventAnnounce, Loading @@ -108,7 +107,6 @@ function createUploadQueue() { complete: eventComplete, error: eventError, get: (index) => uploadItems.value[index], historyId: historyId.value, multiple: props.multiple, progress: eventProgress, success: eventSuccess, Loading Loading @@ -268,6 +266,11 @@ function eventStart() { uploadValues.value.forEach((model) => { if (model.status === "init") { model.status = "queued"; if (!model.targetHistoryId) { // Associate with current history once upload starts // This will not change if the current history is changed during upload model.targetHistoryId = historyId.value; } uploadSize.value += model.fileSize; } }); Loading
client/src/components/Upload/UploadModal.vue +10 −5 Original line number Diff line number Diff line <script setup> import { setIframeEvents } from "components/Upload/utils"; import { useConfig } from "composables/config"; import { useUserHistories } from "composables/userHistories"; import { storeToRefs } from "pinia"; import { ref, watch } from "vue"; import { setIframeEvents } from "@/components/Upload/utils"; import { useConfig } from "@/composables/config"; import { useUserHistories } from "@/composables/userHistories"; import { useUserStore } from "@/stores/userStore"; import { wait } from "@/utils/utils"; import UploadContainer from "./UploadContainer.vue"; const { currentUser } = storeToRefs(useUserStore()); const { currentHistoryId } = useUserHistories(currentUser); const { currentHistoryId, currentHistory } = useUserHistories(currentUser); const { config, isConfigLoaded } = useConfig(); Loading Loading @@ -81,7 +81,12 @@ defineExpose({ no-enforce-focus hide-footer> <template v-slot:modal-header> <h2 class="title h-sm" tabindex="0">{{ options.title }}</h2> <h2 class="title h-sm" tabindex="0"> {{ options.title }} <span v-if="currentHistory"> to <b>{{ currentHistory.name }}</b> </span> </h2> </template> <UploadContainer v-if="currentHistoryId" Loading
client/src/composables/userHistories.js +5 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,10 @@ export function useUserHistories(user) { ); const currentHistoryId = computed(() => historyStore.currentHistoryId); const currentHistory = computed(() => historyStore.currentHistory); return { currentHistoryId }; return { currentHistoryId, currentHistory, }; }
client/src/utils/upload-queue.js +18 −6 Original line number Diff line number Diff line Loading @@ -96,7 +96,11 @@ export class UploadQueue { // Remove item from queue this.remove(index); // Collect upload request data const data = uploadPayload([this.opts.get(index)], this.opts.historyId); const item = this.opts.get(index); if (!item.targetHistoryId) { throw new Error(`Missing target history for upload item [${index}] ${item.fileName}`); } const data = uploadPayload([item], item.targetHistoryId); // Initiate upload request this._processSubmit(index, data); } catch (e) { Loading @@ -107,19 +111,27 @@ export class UploadQueue { } } // Submit remote files as single batch request // Submit remote files as single batch request per target history _processUrls() { const list = []; const batchByHistory = {}; for (const index of this.queue.keys()) { const model = this.opts.get(index); if (model.status === "queued" && model.fileMode === "url") { list.push({ index, ...model }); if (!model.targetHistoryId) { throw new Error(`Missing target history for upload item [${index}] ${model.fileName}`); } if (!batchByHistory[model.targetHistoryId]) { batchByHistory[model.targetHistoryId] = []; } batchByHistory[model.targetHistoryId].push({ index, ...model }); this.remove(index); } } if (list.length > 0) { for (const historyId in batchByHistory) { const list = batchByHistory[historyId]; try { const data = uploadPayload(list, this.opts.historyId); const data = uploadPayload(list, historyId); sendPayload(data, { success: (message) => { list.forEach((model) => { Loading
client/src/utils/upload-queue.test.js +1 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,7 @@ describe("UploadQueue", () => { spaceToTab: true, status: "queued", toPosixLines: false, targetHistoryId: "historyId", }; }, get: (index) => fileEntries[index], Loading