saimod cron add, delete, edit
This commit is contained in:
parent
e84826e6d3
commit
4cef40ea0a
57
sai/modules/saimod_sys_cron/js/saimod_sys_cron.js
Normal file
57
sai/modules/saimod_sys_cron/js/saimod_sys_cron.js
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
function init__SYSTEM_SAI_saimod_sys_cron() {
|
||||||
|
register_cron_add();
|
||||||
|
register_cron_del();
|
||||||
|
register_cron_edit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function register_cron_del(){
|
||||||
|
$('.btn_cron_del').click(function(){
|
||||||
|
$.ajax({ type :'GET',
|
||||||
|
url : SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_cron&action=del'+
|
||||||
|
'&cls='+$(this).attr('_class'),
|
||||||
|
success : function(data) {
|
||||||
|
if(data.status){
|
||||||
|
alert('Sucess');
|
||||||
|
}else{
|
||||||
|
alert('Problem: '+data);}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function register_cron_edit(){
|
||||||
|
$('.btn_cron_edit').click(function(){
|
||||||
|
$('#input_cron_class').val($(this).attr('_class'));
|
||||||
|
$('#input_cron_min').val($(this).attr('_min'));
|
||||||
|
$('#input_cron_hour').val($(this).attr('_hour'));
|
||||||
|
$('#input_cron_day').val($(this).attr('_day'));
|
||||||
|
$('#input_cron_day_week').val($(this).attr('_day_week'));
|
||||||
|
$('#input_cron_month').val($(this).attr('_month'));
|
||||||
|
$("#btn_cron_add").focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function register_cron_add(){
|
||||||
|
$('#btn_cron_add').click(function() {
|
||||||
|
var cls = $('#input_cron_class').val();
|
||||||
|
var min = $('#input_cron_min').val();
|
||||||
|
var hour = $('#input_cron_hour').val();
|
||||||
|
var day = $('#input_cron_day').val();
|
||||||
|
var day_week = $('#input_cron_day_week').val();
|
||||||
|
var month = $('#input_cron_month').val();
|
||||||
|
$.ajax({url: SAI_ENDPOINT,
|
||||||
|
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 cronjob added");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -7,5 +7,6 @@ class SYS_SAIMOD_CRON_ADD extends \SYSTEM\DB\QP {
|
|||||||
//pg
|
//pg
|
||||||
'INSERT INTO '.\SYSTEM\DBD\system_cron::NAME_PG.' (class, min, hour, day, day_week, month) VALUES ($1, $2, $3, $4, $5, $6);',
|
'INSERT INTO '.\SYSTEM\DBD\system_cron::NAME_PG.' (class, min, hour, day, day_week, month) VALUES ($1, $2, $3, $4, $5, $6);',
|
||||||
//mys
|
//mys
|
||||||
'INSERT INTO '.\SYSTEM\DBD\system_cron::NAME_MYS.' (class, min, hour, day, day_week, month) VALUES (?, ?, ?, ?, ?, ?);'
|
'INSERT INTO '.\SYSTEM\DBD\system_cron::NAME_MYS.' (class, min, hour, day, day_week, month) VALUES (?, ?, ?, ?, ?, ?)'.
|
||||||
|
' ON DUPLICATE KEY UPDATE `min`=VALUES(`min`),`hour`=VALUES(`hour`),`day`=VALUES(`day`),`day_week`=VALUES(`day_week`),`month`=VALUES(`month`);'
|
||||||
);}}
|
);}}
|
||||||
|
|||||||
@ -1,63 +0,0 @@
|
|||||||
function init__SYSTEM_SAI_saimod_sys_cron() {
|
|
||||||
saimod_sys_cron_register_clickevents();}
|
|
||||||
|
|
||||||
function saimod_sys_cron_register_clickevents(){
|
|
||||||
$('tr.cron_entries').click(function() {
|
|
||||||
console.log("ahsf");
|
|
||||||
$.ajax({
|
|
||||||
url: SAI_ENDPOINT,
|
|
||||||
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_cron',
|
|
||||||
action: 'deldialog',
|
|
||||||
cls: $(this).attr("cls")},
|
|
||||||
type: 'GET',
|
|
||||||
success: function(data) {
|
|
||||||
console.log("works");
|
|
||||||
$('#cron_content').html(data);
|
|
||||||
$('#del_cron_close').click(function() {
|
|
||||||
console.log("olenski");
|
|
||||||
$('#del_api_description').hide();
|
|
||||||
$('#del_api_del').show();
|
|
||||||
});
|
|
||||||
$('#del_cron_del').click(function() {
|
|
||||||
$.ajax({
|
|
||||||
url: SAI_ENDPOINT,
|
|
||||||
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_cron',
|
|
||||||
action: 'del',
|
|
||||||
cls: $(this).attr("cls")},
|
|
||||||
type: 'GET',
|
|
||||||
success: function(data) {
|
|
||||||
console.log("cron call deleted");
|
|
||||||
$('#cron_deletedialog').html('<p>Api call deleted!</p>');
|
|
||||||
$('#del_cron_del').hide();
|
|
||||||
}});});}});});
|
|
||||||
|
|
||||||
$('#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_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 cronjob added");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
$('#del_cron_close').click(function() {
|
|
||||||
console.log("olenski");
|
|
||||||
$('#del_cron_description').hide();
|
|
||||||
$('#del_cron_del').show();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -14,10 +14,6 @@ class saimod_sys_cron extends \SYSTEM\SAI\SaiModule {
|
|||||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/tpl/tabs.tpl'), $vars);
|
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/tpl/tabs.tpl'), $vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
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/tpl/delete_dialog.tpl'), $res);}
|
|
||||||
|
|
||||||
public static function sai_mod__system_sai_saimod_sys_cron_action_add($cls,$min,$hour,$day,$day_week,$month){
|
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)){
|
if(!\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_CRON)){
|
||||||
throw new \SYSTEM\LOG\ERROR("You dont have edit Rights - Cant proceeed");}
|
throw new \SYSTEM\LOG\ERROR("You dont have edit Rights - Cant proceeed");}
|
||||||
@ -37,8 +33,8 @@ class saimod_sys_cron extends \SYSTEM\SAI\SaiModule {
|
|||||||
|
|
||||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_cron_flag_css(){
|
public static function sai_mod__SYSTEM_SAI_saimod_sys_cron_flag_css(){
|
||||||
return \SYSTEM\LOG\JsonResult::toString(
|
return \SYSTEM\LOG\JsonResult::toString(
|
||||||
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/saimod_sys_cron.css')));}
|
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/css/saimod_sys_cron.css')));}
|
||||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_cron_flag_js(){
|
public static function sai_mod__SYSTEM_SAI_saimod_sys_cron_flag_js(){
|
||||||
return \SYSTEM\LOG\JsonResult::toString(
|
return \SYSTEM\LOG\JsonResult::toString(
|
||||||
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/saimod_sys_cron.js')));}
|
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/js/saimod_sys_cron.js')));}
|
||||||
}
|
}
|
||||||
@ -1,24 +0,0 @@
|
|||||||
<div id="cron_deletedialog">
|
|
||||||
<h5>Cron Job: ${class}</h5>
|
|
||||||
<hr>
|
|
||||||
<table class="table sai_table">
|
|
||||||
<tr>
|
|
||||||
<th>class</th>
|
|
||||||
<th>min</th>
|
|
||||||
<th>hour</th>
|
|
||||||
<th>day</th>
|
|
||||||
<th>day_week</th>
|
|
||||||
<th>month</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<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" cls="${class}" id="del_cron_del">Delete</button>
|
|
||||||
<button type="button" class="btn btn-small" id="del_cron_close">Close</button>
|
|
||||||
@ -8,4 +8,8 @@
|
|||||||
<td>${last_run}</td>
|
<td>${last_run}</td>
|
||||||
<td>${next}</td>
|
<td>${next}</td>
|
||||||
<td>${status}</td>
|
<td>${status}</td>
|
||||||
|
<td>
|
||||||
|
<button type="button" class="btn-small btn-success btn_cron_edit" _class="${class}" _min="${min}" _hour="${hour}" _day="${day}" _day_week="${day_week}" _month="${month}">Edit</button>
|
||||||
|
<button type="button" class="btn-small btn-danger btn_cron_del" _class="${class}">Del</button>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -1,7 +1,8 @@
|
|||||||
<div id="cron_wrapper">
|
<div id="cron_wrapper">
|
||||||
<h4>System Cron</h4>
|
<h4>System Cron</h4>
|
||||||
<hr>
|
<hr>
|
||||||
Last Visit: ${last_visit}
|
Last Visit: ${last_visit}<br/>
|
||||||
|
<a href="./sai.php?call=cron" target="_blank">Start Cron</a>
|
||||||
<div id="cron_content">
|
<div id="cron_content">
|
||||||
<table class="table table-hover table-condensed sai_table" style="overflow: auto;">
|
<table class="table table-hover table-condensed sai_table" style="overflow: auto;">
|
||||||
<tr>
|
<tr>
|
||||||
@ -14,18 +15,20 @@
|
|||||||
<th>last_run</th>
|
<th>last_run</th>
|
||||||
<th>next_run</th>
|
<th>next_run</th>
|
||||||
<th>status</th>
|
<th>status</th>
|
||||||
|
<th>action</th>
|
||||||
</tr>
|
</tr>
|
||||||
${content}
|
${content}
|
||||||
<tr>
|
<tr>
|
||||||
<td><input type="text" id="new_cron_class" placeholder="class" style="width: 200px;"></td>
|
<td><input type="text" id="input_cron_class" placeholder="class" style="width: 200px;"></td>
|
||||||
<td><input type="text" id="new_cron_min" placeholder="min" style="width: 40px;"></td>
|
<td><input type="text" id="input_cron_min" placeholder="min" style="width: 40px;"></td>
|
||||||
<td><input type="text" id="new_cron_hour" placeholder="hour" style="width: 40px;"></td>
|
<td><input type="text" id="input_cron_hour" placeholder="hour" style="width: 40px;"></td>
|
||||||
<td><input type="text" id="new_cron_day" placeholder="day" style="width: 40px;"></td>
|
<td><input type="text" id="input_cron_day" placeholder="day" style="width: 40px;"></td>
|
||||||
<td><input type="text" id="new_cron_day_week" placeholder="day_week" style="width: 40px;"></td>
|
<td><input type="text" id="input_cron_day_week" placeholder="day_week" style="width: 40px;"></td>
|
||||||
<td><input type="text" id="new_cron_month" placeholder="month" style="width: 40px;"></td>
|
<td><input type="text" id="input_cron_month" placeholder="month" style="width: 40px;"></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><button type="button" class="btn-small btn-success" id="addcron">Add</button></td>
|
<td></td>
|
||||||
|
<td><button type="button" class="btn-small btn-success" id="btn_cron_add">Add</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user