50
50
:minValue =" 0"
51
51
:maxValue =" historicalAverage"
52
52
:showValues =" false"
53
- :progressFormatter =" (value: number, percentage: number) => `${ formatTime(loadingTimer) } ( ${ Math.floor( (
53
+ :progressFormatter =" (value: number, percentage: number) => `${ formatTime(loadingTimer) } ( ~ ${ Math.floor( (
54
54
loadingTimer < historicalAverage ? loadingTimer : historicalAverage
55
55
) / historicalAverage * 100) }% )`"
56
56
/>
@@ -252,15 +252,10 @@ async function confirmImage() {
252
252
253
253
const loadingTimer: Ref <number | null > = ref (null );
254
254
255
- const historicalRuns: Ref <number []> = ref ([]);
256
255
257
256
const errorMessage: Ref <string | null > = ref (null );
258
257
259
- const historicalAverage: Ref <number | null > = computed (() => {
260
- if (historicalRuns .value .length === 0 ) return null ;
261
- const sum = historicalRuns .value .reduce ((a , b ) => a + b , 0 );
262
- return Math .floor (sum / historicalRuns .value .length );
263
- });
258
+ const historicalAverage: Ref <number | null > = ref (null );
264
259
265
260
266
261
function formatTime(seconds : number ): string {
@@ -269,6 +264,14 @@ function formatTime(seconds: number): string {
269
264
}
270
265
271
266
267
+ async function getHistoricalAverage() {
268
+ const resp = await callAdminForthApi ({
269
+ path: ` /plugin/${props .meta .pluginInstanceId }/averageDuration ` ,
270
+ method: ' GET' ,
271
+ });
272
+ historicalAverage .value = resp ?.averageDuration || null ;
273
+ }
274
+
272
275
async function generateImages() {
273
276
errorMessage .value = null ;
274
277
loading .value = true ;
@@ -279,7 +282,8 @@ async function generateImages() {
279
282
loadingTimer .value = elapsed ;
280
283
}, 100 );
281
284
const currentIndex = caurosel .value ?.getActiveItem ()?.position || 0 ;
282
-
285
+
286
+ await getHistoricalAverage ();
283
287
let resp = null ;
284
288
let error = null ;
285
289
try {
@@ -294,7 +298,6 @@ async function generateImages() {
294
298
} catch (e ) {
295
299
console .error (e );
296
300
} finally {
297
- historicalRuns .value .push (loadingTimer .value );
298
301
clearInterval (ticker );
299
302
loadingTimer .value = null ;
300
303
loading .value = false ;
@@ -330,12 +333,17 @@ async function generateImages() {
330
333
// ];
331
334
await nextTick ();
332
335
336
+
333
337
caurosel .value = new Carousel (
334
338
document .getElementById (' gallery' ),
335
- images .value .map ((img , index ) => ({
336
- el: document .getElementById (' gallery' ).querySelector (` [data-carousel-item]:nth-child(${index + 1 }) ` ),
337
- position: index ,
338
- })),
339
+ images .value .map ((img , index ) => {
340
+ console .log (' mapping image' , img , index );
341
+ return {
342
+ image: img ,
343
+ el: document .getElementById (' gallery' ).querySelector (` [data-carousel-item]:nth-child(${index + 1 }) ` ),
344
+ position: index ,
345
+ };
346
+ }),
339
347
{
340
348
internal: 0 ,
341
349
defaultPosition: currentIndex ,
@@ -345,6 +353,7 @@ async function generateImages() {
345
353
}
346
354
);
347
355
await nextTick ();
356
+
348
357
loading .value = false ;
349
358
}
350
359
0 commit comments