allow single crons to run manually
This commit is contained in:
parent
27c4c21cd9
commit
b6e32ac971
@ -58,6 +58,33 @@ class cron {
|
|||||||
return \SYSTEM\LOG\JsonResult::ok();
|
return \SYSTEM\LOG\JsonResult::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function run_class($class){
|
||||||
|
$cron = \SYSTEM\SQL\SYS_SAIMOD_CRON_SINGLE_SELECT::Q1(array($class));
|
||||||
|
if(!$cron){
|
||||||
|
return \SYSTEM\LOG\JsonResult::fail();}
|
||||||
|
//check module
|
||||||
|
if(!self::check($cron[\SYSTEM\SQL\system_cron::FIELD_CLASS])){
|
||||||
|
self::status($cron[\SYSTEM\SQL\system_cron::FIELD_CLASS], \SYSTEM\CRON\cronstatus::CRON_STATUS_FAIL_CLASS);
|
||||||
|
return \SYSTEM\LOG\JsonResult::fail();}
|
||||||
|
//time to execute?
|
||||||
|
if(!\SYSTEM\CRON\crontime::check_now( strtotime($cron[\SYSTEM\SQL\system_cron::FIELD_LAST_RUN]),
|
||||||
|
$cron[\SYSTEM\SQL\system_cron::FIELD_MIN],
|
||||||
|
$cron[\SYSTEM\SQL\system_cron::FIELD_HOUR],
|
||||||
|
$cron[\SYSTEM\SQL\system_cron::FIELD_DAY],
|
||||||
|
$cron[\SYSTEM\SQL\system_cron::FIELD_DAY_WEEK],
|
||||||
|
$cron[\SYSTEM\SQL\system_cron::FIELD_MONTH])){
|
||||||
|
return \SYSTEM\LOG\JsonResult::fail();}
|
||||||
|
//Status is ok?
|
||||||
|
if($cron[\SYSTEM\SQL\system_cron::FIELD_STATUS] != \SYSTEM\CRON\cronstatus::CRON_STATUS_SUCCESFULLY){
|
||||||
|
new \SYSTEM\LOG\CRON('Cron for Class '.$cron[\SYSTEM\SQL\system_cron::FIELD_CLASS].' could not execute cuz Status aint good: '. \SYSTEM\CRON\cronstatus::text($cron[\SYSTEM\SQL\system_cron::FIELD_STATUS]));
|
||||||
|
return \SYSTEM\LOG\JsonResult::fail();}
|
||||||
|
//set running
|
||||||
|
self::status($cron[\SYSTEM\SQL\system_cron::FIELD_CLASS], \SYSTEM\CRON\cronstatus::CRON_STATUS_RUNNING);
|
||||||
|
self::status($cron[\SYSTEM\SQL\system_cron::FIELD_CLASS], call_user_func(array($cron[\SYSTEM\SQL\system_cron::FIELD_CLASS],'run')));
|
||||||
|
|
||||||
|
return \SYSTEM\LOG\JsonResult::ok();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine next run of a given Cronjob
|
* Determine next run of a given Cronjob
|
||||||
*
|
*
|
||||||
|
|||||||
@ -4,6 +4,23 @@ function init_saimod_sys_cron() {
|
|||||||
register_cron_del();
|
register_cron_del();
|
||||||
register_cron_edit();
|
register_cron_edit();
|
||||||
register_cron_change();
|
register_cron_change();
|
||||||
|
register_cron_run();
|
||||||
|
}
|
||||||
|
|
||||||
|
function register_cron_run(){
|
||||||
|
$('.btn_cron_run').click(function(){
|
||||||
|
$.ajax({ type :'GET',
|
||||||
|
url : './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_cron&action=run'+
|
||||||
|
'&cls='+$(this).attr('_class'),
|
||||||
|
success : function(data) {
|
||||||
|
if(data.status){
|
||||||
|
alert('ok');
|
||||||
|
}else{
|
||||||
|
alert('fail');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function register_cron_change(){
|
function register_cron_change(){
|
||||||
|
|||||||
@ -50,6 +50,12 @@ class saimod_sys_cron extends \SYSTEM\SAI\SaiModule {
|
|||||||
return \SYSTEM\LOG\JsonResult::ok();
|
return \SYSTEM\LOG\JsonResult::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function sai_mod__system_sai_saimod_sys_cron_action_run($cls){
|
||||||
|
if(!\SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_CRON)){
|
||||||
|
throw new \SYSTEM\LOG\ERROR("You dont have edit Rights - Cant proceeed");}
|
||||||
|
return \SYSTEM\CRON\cron::run_class($cls);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Cron Entry
|
* Add a new Cron Entry
|
||||||
*
|
*
|
||||||
|
|||||||
@ -21,6 +21,9 @@
|
|||||||
<td>
|
<td>
|
||||||
<button type="button" class="btn-sm btn btn-success btn_cron_edit" _class="${class}" _min="${min}" _hour="${hour}" _day="${day}" _day_week="${day_week}" _month="${month}"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></button>
|
<button type="button" class="btn-sm btn btn-success btn_cron_edit" _class="${class}" _min="${min}" _hour="${hour}" _day="${day}" _day_week="${day_week}" _month="${month}"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></button>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<button type="button" class="btn-sm btn btn-success btn_cron_run" _class="${class}"><span class="glyphicon glyphicon-time" aria-hidden="true"></span></button>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button type="button" class="btn-sm btn btn-danger btn_cron_del" _class="${class}"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
|
<button type="button" class="btn-sm btn btn-danger btn_cron_del" _class="${class}"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@ -16,6 +16,7 @@ Last Visit: ${last_visit}<br/>
|
|||||||
<th>next_run</th>
|
<th>next_run</th>
|
||||||
<th>status</th>
|
<th>status</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
<th></th>
|
||||||
<th>action</th>
|
<th>action</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -35,6 +36,7 @@ Last Visit: ${last_visit}<br/>
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
<td></td>
|
||||||
<td><button type="button" class="btn-sm btn btn-success" id="btn_cron_add"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> ${basic_add}</button></td>
|
<td><button type="button" class="btn-sm btn btn-success" id="btn_cron_add"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> ${basic_add}</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@ -201,6 +201,7 @@ REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `na
|
|||||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1209, 42, 2, 1200, 'deldialog', 'cls', 'STRING');
|
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1209, 42, 2, 1200, 'deldialog', 'cls', 'STRING');
|
||||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1210, 42, 2, 1200, 'change', 'cls', 'STRING');
|
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1210, 42, 2, 1200, 'change', 'cls', 'STRING');
|
||||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1211, 42, 2, 1200, 'change', 'status', 'INT');
|
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1211, 42, 2, 1200, 'change', 'status', 'INT');
|
||||||
|
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1220, 42, 2, 1200, 'run', 'cls', 'STRING');
|
||||||
|
|
||||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1300, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_page', 'action', NULL);
|
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1300, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_page', 'action', NULL);
|
||||||
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1301, 42, 2, 1300, 'addcall', 'ID', 'INT');
|
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1301, 42, 2, 1300, 'addcall', 'ID', 'INT');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user