From 3aeb75e3d930ee85b3aca5f399115609d82c5f18 Mon Sep 17 00:00:00 2001 From: kekefreedog <70959083+kekefreedog@users.noreply.github.com> Date: Sun, 9 Jun 2024 00:12:43 +0200 Subject: [PATCH] Implement viewer in runner --- src/Front/Library/Utility/Runner.ts | 80 ++++++++++++++++++++++++++++- src/Front/Types/index.d.ts | 1 + 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/src/Front/Library/Utility/Runner.ts b/src/Front/Library/Utility/Runner.ts index af52272..0d732bd 100644 --- a/src/Front/Library/Utility/Runner.ts +++ b/src/Front/Library/Utility/Runner.ts @@ -25,18 +25,25 @@ import {default as UtilityProcess} from "./Process"; */ export default class Runner { + /** Public parameter + ****************************************************** + */ + + public viewer:object|null = null; + /** * Constructor * * @param extra */ - public constructor(extra:any = null) { + public constructor(extra:any = null, viewer:object|null = null) { // Set options let options:RunnerOption = { result: null, _info: { status: "Waiting", + name: "", run: { total: 0, current: 0, @@ -45,6 +52,16 @@ export default class Runner { } } + // Set viewer + this.viewer = viewer; + + // Check viewer + if(this.viewer !== null) + + // Setup viewer + // @ts-ignore + this.viewer = new viewer(); + // Check extra if(extra && extra !== null) @@ -55,6 +72,24 @@ export default class Runner { } + /** Public methods | Runner Info + ****************************************************** + */ + + /** + * Set Name + * + * Set the name of the runner + * + * @param name Name + */ + public setName = (name:string):void => { + + // Set name + this._options._info.name = name; + + } + /** Parameters ****************************************************** */ @@ -115,6 +150,18 @@ export default class Runner { // Start prevent close this._navigatorClient.preventClose(); + // Check viewer + if(this.viewer){ + + // Open viewer + // @ts-ignore + this.viewer.open({ + progression: `${options._info.run.current}/${options._info.run.total}`, + text: `Starting ${options._info.name.toLowerCase()}` + }); + + } + // Return "abstract" class return this.setUpBeforeClass(options); @@ -133,8 +180,23 @@ export default class Runner { if(options._info.run.current>0) options._info.status = "In Progress"; + // Check viewer + if(this.viewer){ + + // Open viewer + // @ts-ignore + this.viewer.update({ + progression: `${options._info.run.current}/${options._info.run.total}`, + text: `${options._info.run.name[options._info.run.current-1]?options._info.run.name[options._info.run.current-1].label:"Oups"}` + }); + + } + + // Let result + let result = this.setUpBeforeMethod(options); + // Run setup - return this.setUpBeforeMethod(options) + return result }) .then(this[method]) .then( @@ -155,8 +217,22 @@ export default class Runner { // Final teardown after all methods chain = chain.then(options => { + + // Check viewer + if(this.viewer){ + + // Open viewer + // @ts-ignore + this.viewer.close(); + + } + + // Set status options._info.status = "Complete"; + + // Return custom last method return this.tearDownAfterClass(options) + }); // Catch any errors diff --git a/src/Front/Types/index.d.ts b/src/Front/Types/index.d.ts index 7ce183c..8b027be 100644 --- a/src/Front/Types/index.d.ts +++ b/src/Front/Types/index.d.ts @@ -261,6 +261,7 @@ declare global { result:Object|Array|string|null, _info:{ status:"Waiting"|"Ready"|"In Progress"|"Error"|"Complete", + name:string, run:{ total:number, current:number,