Skip to content

Commit

Permalink
Implement viewer in runner
Browse files Browse the repository at this point in the history
  • Loading branch information
kekefreedog committed Jun 8, 2024
1 parent af3819a commit 3aeb75e
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 2 deletions.
80 changes: 78 additions & 2 deletions src/Front/Library/Utility/Runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)

Expand All @@ -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
******************************************************
*/
Expand Down Expand Up @@ -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);

Expand All @@ -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(
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/Front/Types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ declare global {
result:Object|Array<any>|string|null,
_info:{
status:"Waiting"|"Ready"|"In Progress"|"Error"|"Complete",
name:string,
run:{
total:number,
current:number,
Expand Down

0 comments on commit 3aeb75e

Please sign in to comment.