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) => {
|
2017-01-19 16:26:35 +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
|
|
|
;
|
2017-01-19 16:26:35 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2tjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rhc2tidWZmZXIuY2xhc3Nlcy50YXNrY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLGdEQUFnRDtBQUNoRCx1RUFBK0M7QUFHL0MsZUFBdUIsU0FBUSw4QkFBSTtJQUcvQixZQ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