sys cron mod proto

This commit is contained in:
Ulf Gebhardt 2014-06-08 05:43:15 +02:00
parent 29738f079a
commit 32355fadec
10 changed files with 357 additions and 1 deletions

View File

@ -12,3 +12,4 @@ SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_cache','SYSTEM\SA
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_docu','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_todo','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_files','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_cron','SYSTEM\SAI');

View File

@ -7,6 +7,7 @@
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_locale');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_files');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_cache');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_cron');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_todo');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_docu');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_login');

View File

@ -0,0 +1,26 @@
<div id="api_deletedialog">
<h5>Api Call: ${ID}</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>
</tr>
<tr>
<td>${ID}</td>
<td>${group}</td>
<td>${type}</td>
<td>${parentID}</td>
<td>${parentValue}</td>
<td>${name}</td>
<td>${verify}</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>

View File

@ -0,0 +1,10 @@
<tr class="${tr_class} cron_entries">
<td>${class}</td>
<td>${min}</td>
<td>${hour}</td>
<td>${day}</td>
<td>${day_week}</td>
<td>${month}</td>
<td>${last_run}</td>
<td>${status}</td>
</tr>

View File

@ -0,0 +1,64 @@
p {
font-size: 90%;
}
.tree {
min-height:20px;
padding:19px;
margin-bottom:20px;
background-color:#fbfbfb;
border:1px solid #999;
-webkit-border-radius:4px;
-moz-border-radius:4px;
border-radius:4px;
-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);
-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05)
}
.tree li {
list-style-type:none;
margin:0;
padding:10px 5px 0 5px;
position:relative
}
.tree li::before, .tree li::after {
content:'';
left:-20px;
position:absolute;
right:auto
}
.tree li::before {
border-left:1px solid #999;
bottom:50px;
height:100%;
top:0;
width:1px
}
.tree li::after {
border-top:1px solid #999;
height:20px;
top:25px;
width:25px
}
.tree li span {
-moz-border-radius:5px;
-webkit-border-radius:5px;
border:1px solid #999;
border-radius:5px;
display:inline-block;
padding:3px 8px;
text-decoration:none
}
.tree li.parent_li>span {
cursor:pointer
}
.tree>ul>li::before, .tree>ul>li::after {
border:0
}
.tree li:last-child::before {
height:30px
}
.tree li.parent_li>span:hover, .tree li.parent_li>span:hover+ul li span {
background:#eee;
border:1px solid #94a0b4;
color:#000
}

View File

@ -0,0 +1,98 @@
var currentID = '';
function init__SYSTEM_SAI_saimod_sys_api() {
saimod_sys_api_tree();
saimod_sys_api_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() {
console.log("ahsf");
currentID = $(this).attr("id");
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_api',
action: 'deletedialog',
ID: currentID},
type: 'GET',
success: function(data) {
console.log("works");
$('#api_content').html(data);
$('#del_api_close').click(function() {
console.log("olenski");
$('#del_api_description').hide();
$('#del_api_del').show();
saimod_sys_api_loadcontent();
});
$('#del_api_del').click(function() {
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_api',
action: 'deletecall',
ID: currentID},
type: 'GET',
success: function(data) {
console.log("api call deleted");
$('#api_deletedialog').html('<p>Api call deleted!</p>');
$('#del_api_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();
$.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},
type: 'GET',
success: function(data) {
console.log("new api call added");
saimod_sys_api_loadcontent();
}
});
});
$('#del_api_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();
});
}

View File

@ -0,0 +1,102 @@
<?php
namespace SYSTEM\SAI;
class saimod_sys_cron extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_cron(){
//$last_group = -1;
$vars = array();
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT "group", count(*) as "count" FROM system.api GROUP BY "group" ORDER BY "group" ASC;');
} else {
$res = $con->query('SELECT `group`, count(*) as `count` FROM system_api GROUP BY `group` ORDER BY `group` ASC;');
}
$vars['tabopts'] = '';
$first = true;
while($r = $res->next()){
$vars2 = array( 'active' => ($first ? 'active' : ''),
'tab_id' => $r['group']);
$first = false;
$vars['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/tabopt.tpl'), $vars2);
}
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT * FROM system.api ORDER BY "group", "ID" ASC;');
} else {
$res = $con->query('SELECT * FROM system_api ORDER BY `group`, `ID` ASC;');
}
while($r = $res->next()){
$tabs[$r['group']]['tab_id'] = $r['group'];
$tabs[$r['group']]['content'] = isset($tabs[$r['group']]['content']) ? $tabs[$r['group']]['content'] : '';
$r['tr_class'] = self::tablerow_class($r['type']);
$r['type'] = self::type_names($r['type']);
$tabs[$r['group']]['content'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/list_entry.tpl'), $r);
}
$vars['tabs'] = '';
$first = true;
foreach($tabs as $tab){
$tab['active'] = ($first ? 'active' : '');
$first = false;
$vars['tabs'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/tab.tpl'), $tab);}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/tabs.tpl'), $vars);
/* $result = "";
$result .= '<tr class="'.self::tablerow_class($r['type']).'">'.'<td>'.$r['ID'].'</td>'.'<td>'.$r['group'].'</td>'.'<td>'.$r['type'].'</td>'.'<td>'.$r['parentID'].'</td>'.'<td>'.$r['parentValue'].'</td>'.'<td>'.$r['name'].'</td>'.'<td>'.$r['verify'].'</td>'.'</tr>';
return $result;*/
}
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_api_action_addcall($ID,$group,$type,$parentID,$parentValue,$name,$verify){
if(!\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_API)){
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));
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)){
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 type_names($type){
switch($type){
case 0: return 'COMMAND';
case 1: return 'COMMAND_FLAG';
case 2: return 'PARAMETER';
case 3: return 'PARAMETER_OPT';
case 4: return 'STATIC';
default: return 'Problem unknown type';
}
}
private static function tablerow_class($flag){
switch($flag){
case 0: return 'info';
case 1: return '';
case 4: return 'warning';
default: return 'success';
}
}
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 sai_mod__SYSTEM_SAI_saimod_sys_cron_flag_css(){
return \SYSTEM\LOG\JsonResult::toString(
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/saimod_sys_cron.css')));}
public static function sai_mod__SYSTEM_SAI_saimod_sys_cron_flag_js(){
return \SYSTEM\LOG\JsonResult::toString(
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_cron/saimod_sys_cron.js')));}
}

View File

@ -0,0 +1,15 @@
<div class="tab-pane ${active}" id="tab_${tab_id}">
<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>

View File

@ -0,0 +1 @@
<li class="${active}"><a href="#tab_${tab_id}">Group ${tab_id}</a></li>

View File

@ -0,0 +1,38 @@
<div id="cron_wrapper">
<h4>System Cron</h4>
<hr>
<div id="cron_content">
<div class="tabbable">
<ul class="nav nav-tabs" id="localetab">
${tabopts}
</ul>
<div class="tab-content">
${tabs}
</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>