From c0f4ea859b6be7ce6fed0708b1d9041727ebc2a3 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 19 May 2020 08:07:21 +0200 Subject: [PATCH] add removal of task --- views/bootstrap/class.SchedulerTaskMgr.php | 69 ++++++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/views/bootstrap/class.SchedulerTaskMgr.php b/views/bootstrap/class.SchedulerTaskMgr.php index 0eb5458d5..8cb227173 100644 --- a/views/bootstrap/class.SchedulerTaskMgr.php +++ b/views/bootstrap/class.SchedulerTaskMgr.php @@ -44,6 +44,52 @@ $(document).ready( function() { $('#editaddtask.ajax').trigger('update', {taskid: $(this).data('id'), action: $(this).data('action')}); }); $('#listtasks.ajax').trigger('update', {}); + + $('body').on('click', '.removetask', function(ev){ + ev.preventDefault(); + ev.stopPropagation(); + id = $(ev.currentTarget).attr('rel'); + confirmmsg = $(ev.currentTarget).attr('confirmmsg'); + msg = $(ev.currentTarget).attr('msg'); + formtoken = ''; + bootbox.dialog(confirmmsg, [{ + "label" : " ", + "class" : "btn-danger", + "callback": function() { + $.post('../op/op.SchedulerTaskMgr.php', + { action: 'removetask', taskid: id, formtoken: formtoken }, + function(data) { + if(data.success) { + $('#table-row-task-'+id).hide('slow'); + noty({ + text: msg, + type: 'success', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 1500, + }); + } else { + noty({ + text: data.message, + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 3500, + }); + } + }, + 'json' + ); + } + }, { + "label" : "", + "class" : "btn-cancel", + "callback": function() { + } + }]); + }); }); params['taskid']; $task = $scheduler->getTask($taskid); + if(!isset($GLOBALS['SEEDDMS_SCHEDULER']['tasks'][$task->getExtension()])) { + $this->errorMsg(getMLText('scheduler_extension_not_available')); + return; + } + $taskobj = $GLOBALS['SEEDDMS_SCHEDULER']['tasks'][$task->getExtension()][$task->getTask()]; ?>
@@ -190,7 +241,7 @@ $(document).ready( function() { 'id'=>'params_'.$param['name'], 'name'=>'params['.$param['name'].']', 'value'=>'1', - 'checked'=>$task->getParameter()[$param['name']] == 1, + 'checked'=>$task->getParameter($param['name']) == 1, ) ); break; @@ -244,7 +295,11 @@ $(document).ready( function() { print "\n"; print "\n"; foreach($tasks as $task) { - echo "getDisabled() ? " class=\"success\"" : "").">"; + if(!isset($GLOBALS['SEEDDMS_SCHEDULER']['tasks'][$task->getExtension()])) + $class = 'error'; + else + $class = 'success'; + echo "getID()."\" class=\"".(!$task->getDisabled() ? " ".$class : "")."\">"; echo ""; echo $task->getExtension()."::".$task->getTask(); echo ""; @@ -263,9 +318,12 @@ $(document).ready( function() { echo ""; echo $task->getLastRun(); echo ""; - echo ""; + echo ""; print ""; echo ""; echo ""; @@ -280,6 +338,8 @@ $(document).ready( function() { $taskname = $this->params['taskname']; $scheduler = $this->params['scheduler']; + $this->htmlAddHeader(''."\n", 'js'); + $this->htmlStartPage(getMLText("admin_tools")); $this->globalNavigation(); $this->contentStart(); @@ -309,6 +369,7 @@ $(document).ready( function() { echo ""; echo ""; $params = $task->getAdditionalParams(); + $k = array(); foreach($params as $param) $k[] = $param['name']; echo implode(', ', $k);