diff --git a/Viewer/features/core.js b/Viewer/features/core.js index 52c4e0f4..e8c68465 100755 --- a/Viewer/features/core.js +++ b/Viewer/features/core.js @@ -2531,6 +2531,8 @@ function(func){ // during the later form 'sync' is passed to .Task(..) in the correct // position... // (see ig-types' runner.TaskManager(..) for more info) +// +// XXX use action.name to identify the task instead of the title... var taskAction = module.taskAction = function(title, func){ @@ -2542,8 +2544,8 @@ function(title, func){ .pop() var action - return (action = object.mixin( - Task(function(...args){ + return (object.mixin( + action = Task(function(...args){ if(args[0] == 'sync' || args[0] == 'async'){ pre_args = [args.shift(), title] } return this.tasks.Task(...pre_args, func.bind(this), ...args) }), @@ -2604,15 +2606,18 @@ function(name, func){ func = args.pop() var [name, opts] = args + var action return object.mixin( - Queued(function(...args){ + action = Queued(function(...args){ var that = this return new Promise(function(resolve, reject){ - that.queue(name, opts || {}) - .push(function(){ - var res = func.call(that, ...args) - resolve(res) - return res }) }) }), + Object.assign( + that.queue(name, opts || {}) + .push(function(){ + var res = func.call(that, ...args) + resolve(res) + return res }), + { title: action.name }) }) }), { toString: function(){ return `core.queuedAction('${name}',\n\t${ @@ -2683,8 +2688,9 @@ function(name, func){ && args.pop() var [name, opts] = args + var action return object.mixin( - Queued(function(items, ...args){ + action = Queued(function(items, ...args){ var that = this // sync start... if(arguments[0] == 'sync'){ @@ -2715,10 +2721,12 @@ function(name, func){ {}, opts || {}, { - auto_stop: true, + // XXX not sure about this... + //auto_stop: true, handler: function([item, args]){ return func.call(that, item, ...(args || [])) }, })) + q.title = action.name // pre-process args... arg_handler && ([items, ...args] = @@ -2780,6 +2788,7 @@ var TaskActions = actions.Actions({ this.__tasks || this.__task_manager__()) }, // session tasks are stopped when the index is cleared... + // XXX need to get running tasks by action name... get sessionTasks(){ return this.tasks.titled(...this.sessionTaskActions) }, @@ -2789,6 +2798,7 @@ var TaskActions = actions.Actions({ isQueued: function(action){ return !!this.getActionAttr(action, '__queued__') }, // XXX cache this??? + // XXX need to get running tasks by action name... get queuedActions(){ var test = this.isQueued.bind(this) return this.actions.filter(test) }, @@ -2867,7 +2877,7 @@ var TaskActions = actions.Actions({ // cleanup... queue .then( - cleanup('done'), + cleanup('done'), cleanup('error')) } // add queue as task... diff --git a/Viewer/features/examples.js b/Viewer/features/examples.js index 1bf65b6a..598b598f 100755 --- a/Viewer/features/examples.js +++ b/Viewer/features/examples.js @@ -280,14 +280,14 @@ var ExampleActions = actions.Actions({ this.exampleQueuedAction(timeout) } }], exampleQueueHandlerAction: ['- Test/', - core.queueHandler('exampleQueueHandlerAction', + core.queueHandler('Example queue handler action', {quiet: true}, function(item, ...args){ console.log('Queue handler action!!', item, ...args) return new Promise(function(resolve){ setTimeout(resolve, 100) }) })], exampleQueueHandlerActionWArgs: ['- Test/', - core.queueHandler('exampleQueueHandlerActionWArgs', + core.queueHandler('Example queue handler with arguments', {quiet: true}, function(queue, from=0, to=100, ...args){ var items = [] diff --git a/Viewer/package-lock.json b/Viewer/package-lock.json index 8fa30d0c..31ddbda8 100755 --- a/Viewer/package-lock.json +++ b/Viewer/package-lock.json @@ -1073,9 +1073,9 @@ "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" }, "ig-actions": { - "version": "3.24.20", - "resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.20.tgz", - "integrity": "sha512-V5jOhwxjRMoNS1vT6O0nZKh9063FAxtnQoo4G/iH1Kf9jKGqDNlXY4WhoimxGdJF9cdYs+LGxLFjkjek+jaAcg==", + "version": "3.24.21", + "resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.21.tgz", + "integrity": "sha512-fPdi3BEKxKDVcYiO9+Utg3NCqCATQUXPU+wIbdAsA4+AT8zx1EPKZl+vLUn3V0VPKAh9O4bvlWxqNn4GNjC2fQ==", "requires": { "ig-object": "^5.4.12" } @@ -1110,9 +1110,9 @@ "integrity": "sha512-9kZM80Js9/eTwXN9VXwLDC1wDJ7gIAdYU9GIzb5KJmNcLAMaW+zhgFrwFFMrcSfggUuadgnqSrS41E4XLe8JZw==" }, "ig-types": { - "version": "5.0.37", - "resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.37.tgz", - "integrity": "sha512-VLMCgpWTNXhNOW57WZh2jaMdcth3iRqz3DIlaezpIWaMURTsldmqIS5UMqf7EzZ5E1ZW1b/342P8ccJIUEB+cQ==", + "version": "5.0.38", + "resolved": "https://registry.npmjs.org/ig-types/-/ig-types-5.0.38.tgz", + "integrity": "sha512-eiDnadPddsSlq68wulCGMl00nL8MLrwFrBhw2peioXWwvJHkS1tA4qUiYaNYZDK3tEFo1B3idx3nBQ8jiATWAA==", "requires": { "ig-object": "^5.4.12", "object-run": "^1.0.1" diff --git a/Viewer/package.json b/Viewer/package.json index 6df88d51..d07b59dd 100755 --- a/Viewer/package.json +++ b/Viewer/package.json @@ -28,11 +28,11 @@ "generic-walk": "^1.4.0", "glob": "^7.1.6", "guarantee-events": "^1.0.0", - "ig-actions": "^3.24.20", + "ig-actions": "^3.24.21", "ig-argv": "^2.15.0", "ig-features": "^3.4.2", "ig-object": "^5.4.12", - "ig-types": "^5.0.37", + "ig-types": "^5.0.38", "moment": "^2.29.1", "object-run": "^1.0.1", "requirejs": "^2.3.6",