tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-11-08 18:13:40 +03:00
parent 9831b863ea
commit 0a3140f888
2 changed files with 30 additions and 11 deletions

View File

@ -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'

View File

@ -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