2016-05-04 02:28:50 +00:00
|
|
|
"use strict";
|
2016-07-31 22:53:27 +00:00
|
|
|
const plugins = require("./taskbuffer.plugins");
|
|
|
|
const taskbuffer_classes_task_1 = require("./taskbuffer.classes.task");
|
|
|
|
class Taskchain extends taskbuffer_classes_task_1.Task {
|
|
|
|
constructor(optionsArg) {
|
2016-08-01 11:17:15 +00:00
|
|
|
let options = plugins.lodash.merge({
|
2016-05-15 13:52:59 +00:00
|
|
|
name: "unnamed Taskchain",
|
2016-05-15 01:16:50 +00:00
|
|
|
log: false
|
|
|
|
}, optionsArg, {
|
2016-08-02 09:09:42 +00:00
|
|
|
taskFunction: (x) => {
|
2016-07-31 22:53:27 +00:00
|
|
|
let done = plugins.Q.defer(); // this is the starting Deferred object
|
2016-08-02 09:09:42 +00:00
|
|
|
let taskCounter = 0; // counter for iterating async over the taskArray
|
|
|
|
let iterateTasks = (x) => {
|
2016-07-31 22:53:27 +00:00
|
|
|
if (typeof this.taskArray[taskCounter] != "undefined") {
|
|
|
|
this._oraObject.text(this.name + " running: Task" + this.taskArray[taskCounter].name);
|
2016-08-02 09:09:42 +00:00
|
|
|
this.taskArray[taskCounter].trigger(x)
|
|
|
|
.then((x) => {
|
2016-08-01 11:17:15 +00:00
|
|
|
plugins.beautylog.ok(this.taskArray[taskCounter].name);
|
2016-05-15 01:16:50 +00:00
|
|
|
taskCounter++;
|
2016-08-02 09:09:42 +00:00
|
|
|
iterateTasks(x);
|
2016-05-15 01:16:50 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
2016-07-31 22:53:27 +00:00
|
|
|
this._oraObject.endOk("Taskchain \"" + this.name + "\" completed successfully");
|
2016-08-02 09:09:42 +00:00
|
|
|
done.resolve(x);
|
2016-05-15 01:16:50 +00:00
|
|
|
}
|
2016-05-05 16:36:31 +00:00
|
|
|
};
|
2016-08-02 09:09:42 +00:00
|
|
|
iterateTasks(x);
|
2016-05-15 01:16:50 +00:00
|
|
|
return done.promise;
|
2016-05-05 16:36:31 +00:00
|
|
|
}
|
2016-05-04 02:28:50 +00:00
|
|
|
});
|
2016-07-31 22:53:27 +00:00
|
|
|
super(options);
|
2016-05-14 21:24:11 +00:00
|
|
|
this.taskArray = optionsArg.taskArray;
|
2016-05-15 01:16:50 +00:00
|
|
|
this._oraObject = new plugins.beautylog.Ora("Taskchain idle", "blue");
|
2016-08-01 11:17:15 +00:00
|
|
|
if (optionsArg.log === true) {
|
|
|
|
this._oraObject.start();
|
|
|
|
}
|
|
|
|
;
|
2016-05-04 02:28:50 +00:00
|
|
|
}
|
2016-07-31 22:53:27 +00:00
|
|
|
addTask(taskArg) {
|
2016-05-05 16:36:31 +00:00
|
|
|
this.taskArray.push(taskArg);
|
2016-07-31 22:53:27 +00:00
|
|
|
}
|
2016-05-05 16:36:31 +00:00
|
|
|
;
|
2016-07-31 22:53:27 +00:00
|
|
|
removeTask(taskArg) {
|
2016-05-05 16:36:31 +00:00
|
|
|
//TODO
|
2016-07-31 22:53:27 +00:00
|
|
|
}
|
2016-05-05 16:36:31 +00:00
|
|
|
;
|
2016-07-31 22:53:27 +00:00
|
|
|
shiftTask() {
|
|
|
|
}
|
2016-05-05 16:36:31 +00:00
|
|
|
;
|
2016-07-31 22:53:27 +00:00
|
|
|
}
|
2016-05-04 02:28:50 +00:00
|
|
|
exports.Taskchain = Taskchain;
|
2016-05-05 16:36:31 +00:00
|
|
|
;
|
2016-08-02 09:09:42 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2tjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rhc2tidWZmZXIuY2xhc3Nlcy50YXNrY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsMENBQW1CLDJCQUEyQixD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