55 lines
4.2 KiB
JavaScript
55 lines
4.2 KiB
JavaScript
"use strict";
|
|
const plugins = require("./taskbuffer.plugins");
|
|
const taskbuffer_classes_task_1 = require("./taskbuffer.classes.task");
|
|
const helpers = require("./taskbuffer.classes.helpers");
|
|
class Taskchain extends taskbuffer_classes_task_1.Task {
|
|
constructor(optionsArg) {
|
|
let options = plugins.lodash.assign({
|
|
name: "unnamed Taskchain",
|
|
log: false
|
|
}, optionsArg, {
|
|
taskFunction: () => {
|
|
let done = plugins.Q.defer(); // this is the starting Deferred object
|
|
let taskCounter = 0;
|
|
let iterateTasks = () => {
|
|
if (typeof this.taskArray[taskCounter] != "undefined") {
|
|
this._oraObject.text(this.name + " running: Task" + this.taskArray[taskCounter].name);
|
|
this.taskArray[taskCounter].trigger()
|
|
.then(() => {
|
|
this._oraObject.log(this.taskArray[taskCounter].name, "ok");
|
|
taskCounter++;
|
|
iterateTasks();
|
|
});
|
|
}
|
|
else {
|
|
this._oraObject.endOk("Taskchain \"" + this.name + "\" completed successfully");
|
|
done.resolve();
|
|
}
|
|
};
|
|
iterateTasks();
|
|
return done.promise;
|
|
}
|
|
});
|
|
super(options);
|
|
this.taskArray = optionsArg.taskArray;
|
|
this._oraObject = new plugins.beautylog.Ora("Taskchain idle", "blue");
|
|
}
|
|
addTask(taskArg) {
|
|
this.taskArray.push(taskArg);
|
|
}
|
|
;
|
|
removeTask(taskArg) {
|
|
//TODO
|
|
}
|
|
;
|
|
shiftTask() {
|
|
}
|
|
;
|
|
trigger() {
|
|
this._oraObject.start(this.name + " running...");
|
|
return helpers.runTask(this);
|
|
}
|
|
}
|
|
exports.Taskchain = Taskchain;
|
|
;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2tjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rhc2tidWZmZXIuY2xhc3Nlcy50YXN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