From 0a3140f88865f28689463ffa6e71161bbb532451 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 8 Nov 2020 18:13:40 +0300 Subject: [PATCH] tweaking... Signed-off-by: Alex A. Naanou --- Viewer/features/core.js | 34 +++++++++++++++++++++++----------- Viewer/lib/tasks.js | 7 +++++++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Viewer/features/core.js b/Viewer/features/core.js index 4b6d1816..487fcf23 100755 --- a/Viewer/features/core.js +++ b/Viewer/features/core.js @@ -2442,7 +2442,7 @@ function(title, func){ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - var makeTaskAction = -function(name, state, callback){ +function(name, from, to, callback){ return function(title, task='all'){ title = title == '*' || title == 'all' ? [...(this.__running_tasks || new Map()).keys()] @@ -2454,17 +2454,24 @@ function(name, state, callback){ .forEach(function(title){ [...(this.__running_tasks || new Map()).get(title) || []] .forEach(function(t){ + // filter task... ;(task == 'all' || task == '*' || task === t || (task instanceof Array && task.includes(t))) + // filter states... + && (from == '*' + || from == 'all' + || t.state == from) + // XXX do we retrigger??? + //&& t.state != to // call handler... && t[name] && t[name]() !== false // state... - && state - && (t.state = state) }) + && to + && (t.state = to) }) callback && callback.call(this, title, task) }.bind(this)) // cleanup... @@ -2501,6 +2508,8 @@ var TaskActions = actions.Actions({ // XXX might be a good idea to make this compatible with tasks.Queue(..) // ...and return a queue if not task is given?? Task: ['- System/', + doc` + `, function(title, task){ // reserved titles... if(title == 'all' || title == '*'){ @@ -2572,17 +2581,20 @@ var TaskActions = actions.Actions({ get tasks(){ return this.actions.filter(function(action){ return !!this.getActionAttr(action, '__task__') }.bind(this)) }, - get running(){ + + get tasksActive(){ + return this.getTasks() }, + get tasksRunning(){ return this.getTasks('all', 'running') }, - get paused(){ + get tasksPaused(){ return this.getTasks('all', 'paused') }, - pause: ['- System/', - makeTaskAction('pause', 'paused')], - resume: ['- System/', - makeTaskAction('resume', 'running')], - _abort: ['- System/', - makeTaskAction('abort', null, + pauseTask: ['- System/', + makeTaskAction('pause', 'running', 'paused')], + resumeTask: ['- System/', + makeTaskAction('resume', 'paused', 'running')], + abortTask: ['- System/', + makeTaskAction('abort', 'all', null, function(title, task='all'){ this.__running_tasks && (task == 'all' diff --git a/Viewer/lib/tasks.js b/Viewer/lib/tasks.js index 5fc95a84..1f32cd1b 100755 --- a/Viewer/lib/tasks.js +++ b/Viewer/lib/tasks.js @@ -156,6 +156,13 @@ module.QueueActions = actions.Actions(QueuePrototype, { : e[0] == tag && e[1] === task){ delete ready[i] that.taskDropped(e[0], e[1], e[2]) } }) }], + // prioritize tasks by bumping them to start of queue... + // XXX + prioritize: ['', + function(){ + // XXX + }], + // delay tasks by pushing then to end of queue... delay: ['', function(a, b){ var ready = this.__ready