2016-05-04 02:28:50 +00:00
|
|
|
"use strict";
|
2017-06-09 21:26:23 +00:00
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
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({
|
2017-02-15 21:52:29 +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-02-15 21:52:29 +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) => {
|
2017-02-15 21:52:29 +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 {
|
2017-02-15 21:52:29 +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;
|
2017-02-15 21:52:29 +00:00
|
|
|
this._oraObject = plugins.beautylog.ora;
|
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) {
|
2017-02-15 21:52:29 +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;
|
2017-06-09 21:26:23 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2tjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rhc2tidWZmZXIuY2xhc3Nlcy50YXNrY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxnREFBZ0Q7QUFDaEQsdUVBQWlEO0FBR2pELGVBQXVCLFNBQVEsOEJBQ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