cron saimod improvements
This commit is contained in:
parent
83e275af9f
commit
d67ae0ef45
11
dbd/qq/SYS_SAIMOD_CRON_ADD.php
Normal file
11
dbd/qq/SYS_SAIMOD_CRON_ADD.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace SYSTEM\DBD;
|
||||
|
||||
class SYS_SAIMOD_CRON_ADD extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'INSERT INTO '.\SYSTEM\DBD\system_cron::NAME_PG.' (class, min, hour, day, day_week, month) VALUES ($1, $2, $3, $4, $5, $6);',
|
||||
//mys
|
||||
'INSERT INTO '.\SYSTEM\DBD\system_cron::NAME_MYS.' (class, min, hour, day, day_week, month) VALUES (?, ?, ?, ?, ?, ?);'
|
||||
);}}
|
||||
11
dbd/qq/SYS_SAIMOD_CRON_DEL.php
Normal file
11
dbd/qq/SYS_SAIMOD_CRON_DEL.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace SYSTEM\DBD;
|
||||
|
||||
class SYS_SAIMOD_CRON_DEL extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'DELETE FROM '.\SYSTEM\DBD\system_cron::NAME_PG.' WHERE class = $1;',
|
||||
//mys
|
||||
'DELETE FROM '.\SYSTEM\DBD\system_cron::NAME_MYS.' WHERE class = ?;'
|
||||
);}}
|
||||
11
dbd/qq/SYS_SAIMOD_CRON_SINGLE_SELECT.php
Normal file
11
dbd/qq/SYS_SAIMOD_CRON_SINGLE_SELECT.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace SYSTEM\DBD;
|
||||
|
||||
class SYS_SAIMOD_CRON_SINGLE_SELECT extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'SELECT * FROM '.\SYSTEM\DBD\system_cron::NAME_PG.' WHERE class = $1;',
|
||||
//mys
|
||||
'SELECT * FROM '.\SYSTEM\DBD\system_cron::NAME_MYS.' WHERE class = ?;'
|
||||
);}}
|
||||
@ -128,4 +128,14 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
|
||||
-- INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1000, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_todo', 'action', NULL);
|
||||
|
||||
|
||||
-- INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1100, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_docu', 'action', NULL);
|
||||
-- INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1100, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_docu', 'action', NULL);
|
||||
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1200, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_cron', 'action', NULL);
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1201, 42, 2, 1200, 'add', 'cls', 'STRING');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1202, 42, 2, 1200, 'add', 'min', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1203, 42, 2, 1200, 'add', 'hour', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1204, 42, 2, 1200, 'add', 'day', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1205, 42, 2, 1200, 'add', 'day_week', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1206, 42, 2, 1200, 'add', 'month', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1208, 42, 2, 1200, 'del', 'cls', 'STRING');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1209, 42, 2, 1200, 'deldialog', 'cls', 'STRING');
|
||||
@ -8,4 +8,6 @@ INSERT INTO `system_rights` (`ID`, `name`, `description`) VALUES (10, 'SYS_SAI_L
|
||||
INSERT INTO `system_rights` (`ID`, `name`, `description`) VALUES (15, 'SYS_SAI_IMG', 'Allows access to the Image Module in SAI to delete or add Pictures');
|
||||
|
||||
INSERT INTO `system_rights` (`ID`, `name`, `description`) VALUES (20, 'SYS_SAI_API', 'SAI API Access right');
|
||||
INSERT INTO `system_rights` (`ID`, `name`, `description`) VALUES (21, 'SYS_SAI_API_EDIT', 'SAI API Edit right');
|
||||
INSERT INTO `system_rights` (`ID`, `name`, `description`) VALUES (21, 'SYS_SAI_API_EDIT', 'SAI API Edit right');
|
||||
|
||||
INSERT INTO `system_rights` (`ID`, `name`, `description`) VALUES (25, 'SYS_SAI_CRON', 'SAI Cron Access right');
|
||||
@ -1,26 +1,24 @@
|
||||
<div id="api_deletedialog">
|
||||
<h5>Api Call: ${ID}</h5>
|
||||
<div id="cron_deletedialog">
|
||||
<h5>Cron Job: ${class}</h5>
|
||||
<hr>
|
||||
<table class="table sai_table">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Group</th>
|
||||
<th>Type</th>
|
||||
<th>ParentID</th>
|
||||
<th>ParentValue</th>
|
||||
<th>Name</th>
|
||||
<th>Verify</th>
|
||||
<th>class</th>
|
||||
<th>min</th>
|
||||
<th>hour</th>
|
||||
<th>day</th>
|
||||
<th>day_week</th>
|
||||
<th>month</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>${ID}</td>
|
||||
<td>${group}</td>
|
||||
<td>${type}</td>
|
||||
<td>${parentID}</td>
|
||||
<td>${parentValue}</td>
|
||||
<td>${name}</td>
|
||||
<td>${verify}</td>
|
||||
<td>${class}</td>
|
||||
<td>${min}</td>
|
||||
<td>${hour}</td>
|
||||
<td>${day}</td>
|
||||
<td>${day_week}</td>
|
||||
<td>${month}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<button type="button" class="btn btn-small btn-danger" id="del_api_del">Delete</button>
|
||||
<button type="button" class="btn btn-small" id="del_api_close">Close</button>
|
||||
<button type="button" class="btn btn-small btn-danger" cls="${class}" id="del_cron_del">Delete</button>
|
||||
<button type="button" class="btn btn-small" id="del_cron_close">Close</button>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<tr class="${tr_class} cron_entries">
|
||||
<tr class="${tr_class} cron_entries" cls="${class}">
|
||||
<td>${class}</td>
|
||||
<td>${min}</td>
|
||||
<td>${hour}</td>
|
||||
|
||||
@ -1,98 +1,63 @@
|
||||
var currentID = '';
|
||||
|
||||
function init__SYSTEM_SAI_saimod_sys_api() {
|
||||
saimod_sys_api_tree();
|
||||
saimod_sys_api_register_clickevents();
|
||||
|
||||
}
|
||||
function init__SYSTEM_SAI_saimod_sys_cron() {
|
||||
saimod_sys_cron_register_clickevents();}
|
||||
|
||||
function saimod_sys_api_loadcontent(){
|
||||
$('#api_wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_api', function(){
|
||||
console.log('api module loaded');
|
||||
saimod_sys_api_register_clickevents();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function saimod_sys_api_register_clickevents(){
|
||||
$('tr.api_entries').click(function() {
|
||||
function saimod_sys_cron_register_clickevents(){
|
||||
$('tr.cron_entries').click(function() {
|
||||
console.log("ahsf");
|
||||
currentID = $(this).attr("id");
|
||||
$.ajax({
|
||||
url: SAI_ENDPOINT,
|
||||
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_api',
|
||||
action: 'deletedialog',
|
||||
ID: currentID},
|
||||
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_cron',
|
||||
action: 'deldialog',
|
||||
cls: $(this).attr("cls")},
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
console.log("works");
|
||||
$('#api_content').html(data);
|
||||
$('#del_api_close').click(function() {
|
||||
$('#cron_content').html(data);
|
||||
$('#del_cron_close').click(function() {
|
||||
console.log("olenski");
|
||||
$('#del_api_description').hide();
|
||||
$('#del_api_del').show();
|
||||
saimod_sys_api_loadcontent();
|
||||
});
|
||||
$('#del_api_del').click(function() {
|
||||
$('#del_cron_del').click(function() {
|
||||
$.ajax({
|
||||
url: SAI_ENDPOINT,
|
||||
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_api',
|
||||
action: 'deletecall',
|
||||
ID: currentID},
|
||||
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_cron',
|
||||
action: 'del',
|
||||
cls: $(this).attr("cls")},
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
console.log("api call deleted");
|
||||
$('#api_deletedialog').html('<p>Api call deleted!</p>');
|
||||
$('#del_api_del').hide();
|
||||
console.log("cron call deleted");
|
||||
$('#cron_deletedialog').html('<p>Api call deleted!</p>');
|
||||
$('#del_cron_del').hide();
|
||||
}});});}});});
|
||||
|
||||
$('#addcall').click(function() {
|
||||
var id = $('#new_call_id').val();
|
||||
var group = $('#new_call_group').val();
|
||||
var type = $('#new_call_type').val();
|
||||
var parentid = $('#new_call_parentid').val();
|
||||
var parentvalue = $('#new_call_parentvalue').val();
|
||||
var name = $('#new_call_name').val();
|
||||
var verify = $('#new_call_verify').val();
|
||||
$('#addcron').click(function() {
|
||||
var cls = $('#new_cron_class').val();
|
||||
var min = $('#new_cron_min').val();
|
||||
var hour = $('#new_cron_hour').val();
|
||||
var day = $('#new_cron_day').val();
|
||||
var day_week = $('#new_cron_day_week').val();
|
||||
var month = $('#new_cron_month').val();
|
||||
$.ajax({
|
||||
url: SAI_ENDPOINT,
|
||||
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_api',
|
||||
action: 'addcall',
|
||||
ID: id,
|
||||
group: group,
|
||||
type: type,
|
||||
parentID: parentid,
|
||||
parentValue : parentvalue,
|
||||
name: name,
|
||||
verify: verify},
|
||||
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_cron',
|
||||
action: 'add',
|
||||
cls: cls,
|
||||
min: min,
|
||||
hour: hour,
|
||||
day: day,
|
||||
day_week: day_week,
|
||||
month: month},
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
console.log("new api call added");
|
||||
saimod_sys_api_loadcontent();
|
||||
console.log("new cronjob added");
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
$('#del_api_close').click(function() {
|
||||
$('#del_cron_close').click(function() {
|
||||
console.log("olenski");
|
||||
$('#del_api_description').hide();
|
||||
$('#del_api_del').show();
|
||||
saimod_sys_api_loadcontent();
|
||||
});
|
||||
$('#localetab a').click(function (e) {e.preventDefault(); $(this).tab('show');});
|
||||
}
|
||||
|
||||
function saimod_sys_api_tree(){
|
||||
$('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
|
||||
$('.tree li.parent_li > span').on('click', function (e) {
|
||||
var children = $(this).parent('li.parent_li').find(' > ul > li');
|
||||
if (children.is(":visible")) {
|
||||
children.hide('fast');
|
||||
$(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
|
||||
} else {
|
||||
children.show('fast');
|
||||
$(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
|
||||
}
|
||||
e.stopPropagation();
|
||||
$('#del_cron_description').hide();
|
||||
$('#del_cron_del').show();
|
||||
});
|
||||
}
|
||||
@ -4,48 +4,33 @@ namespace SYSTEM\SAI;
|
||||
class saimod_sys_cron extends \SYSTEM\SAI\SaiModule {
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_cron(){
|
||||
$vars = array();
|
||||
$vars['tabopts'] = \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/tabopt.tpl'), array());
|
||||
$vars['content'] = '';
|
||||
|
||||
$res = \SYSTEM\DBD\SYS_SAIMOD_CRON::QQ();
|
||||
while($r = $res->next()){
|
||||
$vars['content'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/list_entry.tpl'), $r);}
|
||||
|
||||
$vars['tabs'] = \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/tab.tpl'), $vars);
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/tabs.tpl'), $vars);
|
||||
}
|
||||
|
||||
public static function sai_mod__system_sai_saimod_sys_api_action_deletedialog($ID){
|
||||
$res = \SYSTEM\DBD\SYS_SAIMOD_API_SINGLE_SELECT::Q1(array($ID));
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/delete_dialog.tpl'), $res);
|
||||
}
|
||||
public static function sai_mod__system_sai_saimod_sys_cron_action_deldialog($cls){
|
||||
$res = \SYSTEM\DBD\SYS_SAIMOD_CRON_SINGLE_SELECT::Q1(array($cls));
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/delete_dialog.tpl'), $res);}
|
||||
|
||||
public static function sai_mod__system_sai_saimod_sys_api_action_addcall($ID,$group,$type,$parentID,$parentValue,$name,$verify){
|
||||
if(!\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_API)){
|
||||
public static function sai_mod__system_sai_saimod_sys_cron_action_add($cls,$min,$hour,$day,$day_week,$month){
|
||||
if(!\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_CRON)){
|
||||
throw new \SYSTEM\LOG\ERROR("You dont have edit Rights - Cant proceeed");}
|
||||
\SYSTEM\DBD\SYS_SAIMOD_API_ADD::QI(array($ID,$group,$type,$parentID,$parentValue,$name,$verify));
|
||||
\SYSTEM\DBD\SYS_SAIMOD_CRON_ADD::QI(array($cls,$min,$hour,$day,$day_week,$month));
|
||||
return \SYSTEM\LOG\JsonResult::ok();
|
||||
}
|
||||
|
||||
public static function sai_mod__system_sai_saimod_sys_api_action_deletecall($ID){
|
||||
if(!\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_API)){
|
||||
public static function sai_mod__system_sai_saimod_sys_cron_action_del($cls){
|
||||
if(!\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_CRON)){
|
||||
throw new \SYSTEM\LOG\ERROR("You dont have edit Rights - Cant proceeed");}
|
||||
\SYSTEM\DBD\SYS_SAIMOD_API_DEL::QI(array($ID));
|
||||
return \SYSTEM\LOG\JsonResult::ok();
|
||||
}
|
||||
|
||||
private static function tablerow_class($flag){
|
||||
switch($flag){
|
||||
case 0: return 'info';
|
||||
case 1: return '';
|
||||
case 4: return 'warning';
|
||||
default: return 'success';
|
||||
}
|
||||
}
|
||||
\SYSTEM\DBD\SYS_SAIMOD_CRON_DEL::QI(array($cls));
|
||||
return \SYSTEM\LOG\JsonResult::ok();}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_cron">Cron</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_CRON);}
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_cron_flag_css(){
|
||||
return \SYSTEM\LOG\JsonResult::toString(
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
<div class="tab-pane active" id="tab_cron">
|
||||
<table class="table table-hover table-condensed" style="overflow: auto;">
|
||||
<tr>
|
||||
<th>class</th>
|
||||
<th>min</th>
|
||||
<th>hour</th>
|
||||
<th>day</th>
|
||||
<th>day_week</th>
|
||||
<th>month</th>
|
||||
<th>last_run</th>
|
||||
<th>status</th>
|
||||
</tr>
|
||||
${content}
|
||||
</table>
|
||||
</div>
|
||||
@ -1 +0,0 @@
|
||||
<li class="active"><a href="#tab_cron">Cron</a></li>
|
||||
@ -1,38 +1,29 @@
|
||||
<div id="cron_wrapper">
|
||||
<h4>System Cron</h4>
|
||||
<hr>
|
||||
<div id="cron_content">
|
||||
<div class="tabbable">
|
||||
<ul class="nav nav-tabs" id="crontab">
|
||||
${tabopts}
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
${tabs}
|
||||
<h4>System Cron</h4>
|
||||
<hr>
|
||||
<div id="cron_content">
|
||||
<table class="table table-hover table-condensed" style="overflow: auto;">
|
||||
<tr>
|
||||
<th>class</th>
|
||||
<th>min</th>
|
||||
<th>hour</th>
|
||||
<th>day</th>
|
||||
<th>day_week</th>
|
||||
<th>month</th>
|
||||
<th>last_run</th>
|
||||
<th>status</th>
|
||||
</tr>
|
||||
${content}
|
||||
<tr>
|
||||
<td><input type="text" id="new_cron_class" placeholder="class" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_cron_min" placeholder="min" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_cron_hour" placeholder="hour" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_cron_day" placeholder="day" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_cron_day_week" placeholder="day_week" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_cron_month" placeholder="month" style="width: 140px;"></td>
|
||||
<td></td>
|
||||
<td><button type="button" class="btn-small btn-success" id="addcron">Add</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table table-hover table-condensed" style="overflow: auto;">
|
||||
<tr>
|
||||
<th>class</th>
|
||||
<th>min</th>
|
||||
<th>hour</th>
|
||||
<th>day</th>
|
||||
<th>day_week</th>
|
||||
<th>month</th>
|
||||
<th>last_run</th>
|
||||
<th>status</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="text" id="new_cron_class" placeholder="class" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_cron_min" placeholder="min" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_cron_hour" placeholder="hour" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_cron_day" placeholder="day" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_cron_day" placeholder="day_week" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_cron_month" placeholder="month" style="width: 140px;"></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<!--<button type="button" class="btn-small btn-success" id="addcron">Add</button>-->
|
||||
</div><!-- /.modal -->
|
||||
</div>
|
||||
|
||||
@ -15,7 +15,9 @@ class RIGHTS {
|
||||
const SYS_SAI_FILES = 15;
|
||||
//Api Module
|
||||
const SYS_SAI_API = 20;
|
||||
const SYS_SAI_API_EDIT = 21;
|
||||
//const SYS_SAI_API_EDIT = 21;
|
||||
|
||||
const SYS_SAI_CRON = 25;
|
||||
|
||||
//Reserve first 1000 ids.
|
||||
const RESERVED_SYS_0_999 = 999;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user