Skip to content

Commit 8802582

Browse files
committed
feat: add progress bar
1 parent a089a52 commit 8802582

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

custom/VisionAction.vue

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,32 @@
6868
>
6969
<div class="bulk-vision-table flex flex-col items-center gap-3 md:gap-4 overflow-y-auto">
7070
<template v-if="recordsList.length && popupMode === 'generation'" >
71+
72+
73+
<div class="w-full">
74+
<div
75+
class="w-full h-[30px] rounded-md bg-gray-200 dark:bg-gray-700 overflow-hidden relative"
76+
role="progressbar"
77+
:aria-valuenow="displayedProcessedCount"
78+
:aria-valuemin="0"
79+
:aria-valuemax="totalRecords"
80+
>
81+
<div
82+
class="h-full bg-gradient-to-r from-purple-500 via-purple-600 to-purple-700 transition-all duration-200"
83+
:style="{ width: `${displayedProgressPercent}%` }"
84+
></div>
85+
<div class="absolute inset-0 flex items-center justify-center text-sm font-medium text-white drop-shadow">
86+
<template v-if="isProcessingAny">
87+
{{ displayedProcessedCount }} / {{ totalRecords }}
88+
</template>
89+
<template v-else>
90+
{{ t('Processed') }}
91+
</template>
92+
</div>
93+
</div>
94+
</div>
95+
96+
7197
<VisionTable
7298
class="md:max-h-[75vh] max-w-[1560px] w-full h-full"
7399
:records="recordsList"
@@ -217,6 +243,33 @@ const isDataSaved = ref(false);
217243
const overwriteExistingValues = ref<boolean>(false);
218244
219245
const checkedCount = computed(() => recordIds.value.length - uncheckedRecordIds.size);
246+
const totalRecords = computed(() => recordIds.value.length);
247+
const processedCount = computed(() => {
248+
recordsVersion.value;
249+
return Array.from(recordsById.values()).filter(record => record.status === 'completed' || record.status === 'failed').length;
250+
});
251+
const progressStep = computed(() => {
252+
if (!totalRecords.value || totalRecords.value < 100) {
253+
return 1;
254+
}
255+
return Math.max(1, Math.floor(totalRecords.value / 100));
256+
});
257+
const displayedProcessedCount = computed(() => {
258+
const step = progressStep.value;
259+
if (step <= 1) {
260+
return processedCount.value;
261+
}
262+
if (processedCount.value >= totalRecords.value) {
263+
return totalRecords.value;
264+
}
265+
return Math.floor(processedCount.value / step) * step;
266+
});
267+
const displayedProgressPercent = computed(() => {
268+
if (!totalRecords.value) {
269+
return 0;
270+
}
271+
return Math.min(100, Math.round((displayedProcessedCount.value / totalRecords.value) * 100));
272+
});
220273
const isProcessingAny = computed(() => {
221274
recordsVersion.value;
222275
return Array.from(recordsById.values()).some(record => record.status === 'processing');

0 commit comments

Comments
 (0)