5050 :minValue =" 0"
5151 :maxValue =" historicalAverage"
5252 :showValues =" false"
53- :progressFormatter =" (value: number, percentage: number) => `${ formatTime(loadingTimer) } ( ${ Math.floor( (
53+ :progressFormatter =" (value: number, percentage: number) => `${ formatTime(loadingTimer) } ( ~ ${ Math.floor( (
5454 loadingTimer < historicalAverage ? loadingTimer : historicalAverage
5555 ) / historicalAverage * 100) }% )`"
5656 />
@@ -252,15 +252,10 @@ async function confirmImage() {
252252
253253const loadingTimer: Ref <number | null > = ref (null );
254254
255- const historicalRuns: Ref <number []> = ref ([]);
256255
257256const errorMessage: Ref <string | null > = ref (null );
258257
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 );
264259
265260
266261function formatTime(seconds : number ): string {
@@ -269,6 +264,14 @@ function formatTime(seconds: number): string {
269264}
270265
271266
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+
272275async function generateImages() {
273276 errorMessage .value = null ;
274277 loading .value = true ;
@@ -279,7 +282,8 @@ async function generateImages() {
279282 loadingTimer .value = elapsed ;
280283 }, 100 );
281284 const currentIndex = caurosel .value ?.getActiveItem ()?.position || 0 ;
282-
285+
286+ await getHistoricalAverage ();
283287 let resp = null ;
284288 let error = null ;
285289 try {
@@ -294,7 +298,6 @@ async function generateImages() {
294298 } catch (e ) {
295299 console .error (e );
296300 } finally {
297- historicalRuns .value .push (loadingTimer .value );
298301 clearInterval (ticker );
299302 loadingTimer .value = null ;
300303 loading .value = false ;
@@ -330,12 +333,17 @@ async function generateImages() {
330333 // ];
331334 await nextTick ();
332335
336+
333337 caurosel .value = new Carousel (
334338 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+ }),
339347 {
340348 internal: 0 ,
341349 defaultPosition: currentIndex ,
@@ -345,6 +353,7 @@ async function generateImages() {
345353 }
346354 );
347355 await nextTick ();
356+
348357 loading .value = false ;
349358}
350359
0 commit comments