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");
|
|
|
|
const helpers = require("./taskbuffer.classes.helpers");
|
|
|
|
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-07-31 22:53:27 +00:00
|
|
|
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(() => {
|
2016-08-01 11:17:15 +00:00
|
|
|
plugins.beautylog.ok(this.taskArray[taskCounter].name);
|
2016-05-15 01:16:50 +00:00
|
|
|
taskCounter++;
|
|
|
|
iterateTasks();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
2016-07-31 22:53:27 +00:00
|
|
|
this._oraObject.endOk("Taskchain \"" + this.name + "\" completed successfully");
|
2016-05-15 01:16:50 +00:00
|
|
|
done.resolve();
|
|
|
|
}
|
2016-05-05 16:36:31 +00:00
|
|
|
};
|
2016-05-15 01:16:50 +00:00
|
|
|
iterateTasks();
|
|
|
|
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
|
|
|
trigger() {
|
2016-05-15 01:16:50 +00:00
|
|
|
this._oraObject.start(this.name + " running...");
|
|
|
|
return helpers.runTask(this);
|
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-01 11:17:15 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2tjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rhc2tidWZmZXIuY2xhc3Nlcy50YXNrY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsMENBQW1CLDJCQUEyQixDQUFDLENBQUE7QUFDL0MsTUFBTyxPQUFPLFd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