new saimod page, proto, saimod api fixes

This commit is contained in:
Ulf Gebhardt 2015-04-11 22:40:06 +02:00
parent 22b6d8cc2c
commit 7dc77d4e15
20 changed files with 335 additions and 66 deletions

View File

@ -152,4 +152,18 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
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');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1210, 42, 2, 1200, 'change', 'cls', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1211, 42, 2, 1200, 'change', 'status', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1211, 42, 2, 1200, 'change', 'status', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1300, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_page', 'action', NULL);
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1301, 42, 2, 1300, 'addcall', 'ID', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1302, 42, 2, 1300, 'addcall', 'group', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1303, 42, 2, 1300, 'addcall', 'type', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1304, 42, 2, 1300, 'addcall', 'parentID', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1305, 42, 2, 1300, 'addcall', 'parentValue', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1306, 42, 2, 1300, 'addcall', 'name', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1307, 42, 2, 1300, 'addcall', 'verify', 'ALL');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1308, 42, 2, 1300, 'deletecall', 'ID', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1309, 42, 2, 1300, 'deletecall', 'group', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1310, 42, 2, 1300, 'deletedialog', 'ID', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1311, 42, 2, 1300, 'deletedialog', 'group', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1320, 42, 3, 1300, 'list', 'group', 'INT');

View File

@ -39,4 +39,9 @@ INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`,
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (123, 'stats', 42, 'todo', 120, 1, '#tab_todo', '/sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=stats', 'init_saimod_sys_todo_stats', '\\SYSTEM\\SAI\\saimod_sys_todo');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (124, 'todoopen', 42, 'todo', 120, 1, '#tab_todo', '/sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=todo&todo=${todo}', 'init_saimod_sys_todo_todoopen', '\\SYSTEM\\SAI\\saimod_sys_todo');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (125, 'todoclose', 42, 'todo', 120, 1, '#tab_todo', '/sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=todo&todo=${todo}', 'init_saimod_sys_todo_todoclose', '\\SYSTEM\\SAI\\saimod_sys_todo');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (126, 'new', 42, 'todo', 120, 1, '#tab_todo', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=new', 'init_saimod_sys_todo_new', '\\SYSTEM\\SAI\\saimod_sys_todo');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (126, 'new', 42, 'todo', 120, 1, '#tab_todo', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=new', 'init_saimod_sys_todo_new', '\\SYSTEM\\SAI\\saimod_sys_todo');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (130, 'page', 42, 'page', -1, 0, '#content', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_page', 'init_saimod_sys_page', '\\SYSTEM\\SAI\\saimod_sys_page');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (131, 'all', 42, 'page', 130, 0, '#tab_page', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_page&action=list&group=${group}', 'init_saimod_sys_page_list', '\\SYSTEM\\SAI\\saimod_sys_page');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (132, 'delete', 42, 'page', 130, 1, '#tab_page', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_page&action=deletedialog&group=${group}&ID=${id}', 'init_saimod_sys_page_delete', '\\SYSTEM\\SAI\\saimod_sys_page');
INSERT INTO `system_page` (`id`, `name`, `group`, `state`, `parent_id`, `type`, `div`, `url`, `func`, `php_class`) VALUES (133, 'new', 42, 'page', 130, 1, '#tab_page', './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_page&action=newdialog', 'init_saimod_sys_page_new', '\\SYSTEM\\SAI\\saimod_sys_page');

View File

@ -7,6 +7,7 @@ require_once dirname(__FILE__).'/saimod_sys_security/autoload.inc';
require_once dirname(__FILE__).'/saimod_sys_mod/autoload.inc';
require_once dirname(__FILE__).'/saimod_sys_config/autoload.inc';
require_once dirname(__FILE__).'/saimod_sys_api/autoload.inc';
require_once dirname(__FILE__).'/saimod_sys_page/autoload.inc';
require_once dirname(__FILE__).'/saimod_sys_text/autoload.inc';
require_once dirname(__FILE__).'/saimod_sys_files/autoload.inc';
require_once dirname(__FILE__).'/saimod_sys_cache/autoload.inc';

View File

@ -1,64 +0,0 @@
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

@ -3,21 +3,27 @@
<th>ID</th>
<td><input type="text" id="new_call_id" placeholder="new id" style="width: 140px;"></td>
</tr>
<tr>
<th>Group</th>
<td><input type="text" id="new_call_group" placeholder="new group" style="width: 140px;"></td>
</tr>
<tr>
<th>Type</th>
<td><input type="text" id="new_call_type" placeholder="new type" style="width: 140px;"></td>
</tr>
<tr>
<th>ParentID</th>
<td><input type="text" id="new_call_parentid" placeholder="parent id" style="width: 140px;"></td>
</tr>
<tr>
<th>ParentValue</th>
<td><input type="text" id="new_call_parentvalue" placeholder="parent value" style="width: 140px;"></td>
</tr>
<tr>
<th>Name</th>
<td><input type="text" id="new_call_name" placeholder="name" style="width: 140px;"></td>
</tr>
<tr>
<th>Verify</th>
<td><input type="text" id="new_call_verify" placeholder="verify" style="width: 140px;"></td>
</tr>

View File

@ -0,0 +1,5 @@
<?php
\SYSTEM\autoload::registerFolder(dirname(__FILE__),'SYSTEM\SAI');
\SYSTEM\autoload::registerFolder(dirname(__FILE__).'/qq/','SYSTEM\DBD');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_page');

View File

@ -0,0 +1,54 @@
function init_saimod_sys_page() {
$('#tabs_page a').click(function (e) {
$('#tabs_page li').each(function(){
$(this).removeClass('active');});
$(this).parent().addClass('active');
});
api_menu();
}
function init_saimod_sys_page_new(){
$('#addpage').click(function() {
$.ajax({ url: './sai.php',
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_page',
action: 'addcall',
ID: $('#new_page_id').val(),
group: $('#new_page_group').val(),
type: $('#new_page_type').val(),
parentID: $('#new_page_parentid').val(),
parentValue : $('#new_page_parentvalue').val(),
name: $('#new_page_name').val(),
verify: $('#new_page_verify').val()},
type: 'GET',
success: function(data) {
system.load('page;group.'+$('#new_page_group').val());}
});
});
}
function api_menu(){
$('#tabs_page li').each(function(){
$(this).removeClass('active');});
if($('#menu_group_'+system.cur_state().split('.')[1]).length){
$('#menu_group_'+system.cur_state().split('.')[1]).parent().addClass('active');
} else {
$('#menu_all').parent().addClass('active');}
}
function init_saimod_sys_page_list(){
api_menu();}
function init_saimod_sys_page_delete(){
$('#del_page_del').click(function() {
$.ajax({ url: './sai.php',
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_page',
action: 'deletecall',
ID: $(this).attr('page_id'),
group: $(this).attr('page_group')},
type: 'GET',
success: function(data) {
console.log("page call deleted");
$('#page_deletedialog').html('<p>Api call deleted!</p>');
$('#del_page_del').hide();
}
});
});
}

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_PAGE_ADD extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'INSERT INTO '.\SYSTEM\DBD\system_page::NAME_PG.' (ID, group, type, parentID, parentValue, name, verify) VALUES ($1, $2, $3, $4, $5, $6, $7);',
//mys
'INSERT INTO '.\SYSTEM\DBD\system_page::NAME_MYS.' (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (?, ?, ?, ?, ?, ?, ?);'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_PAGE_DEL extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'DELETE FROM '.\SYSTEM\DBD\system_page::NAME_PG.' WHERE `ID` = $1 AND group = $2;',
//mys
'DELETE FROM '.\SYSTEM\DBD\system_page::NAME_MYS.' WHERE `ID` = ? AND `group` = ?;'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_PAGE_GET extends \SYSTEM\DB\QQ {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'SELECT * FROM system_page ORDER BY `group`, `ID` ASC;',
//mys
'SELECT * FROM system_page ORDER BY `group`, `ID` ASC;'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_PAGE_GROUPS extends \SYSTEM\DB\QQ {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'SELECT "group", count(*) as "count" FROM system.page GROUP BY "group" ORDER BY "group" ASC;',
//mys
'SELECT `group`, count(*) as `count` FROM system_page GROUP BY `group` ORDER BY `group` ASC;'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
class SYS_SAIMOD_PAGE_SINGLE_SELECT extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'SELECT * FROM '.\SYSTEM\DBD\system_page::NAME_PG.' WHERE ID = $1 AND group = $2;',
//mys
'SELECT * FROM '.\SYSTEM\DBD\system_page::NAME_MYS.' WHERE ID = ? AND `group` = ?;'
);}}

View File

@ -0,0 +1,77 @@
<?php
namespace SYSTEM\SAI;
class saimod_sys_page extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_page(){
$vars = array();
$vars['tabopts'] = '';
$res = \SYSTEM\DBD\SYS_SAIMOD_PAGE_GROUPS::QQ();
while($r = $res->next()){
$vars['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_page/tpl/tabopt.tpl'), array( 'tab_id' => $r['group']));}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_page/tpl/saimod_sys_page.tpl'), $vars);
}
public static function sai_mod__system_sai_saimod_sys_page_action_list($group=null){
$res = \SYSTEM\DBD\SYS_SAIMOD_PAGE_GET::QQ();
$tab = array('content' => '');
while($r = $res->next()){
if($group != null && $r['group'] != $group){
continue;}
$tab['tab_id'] = $r['group'];
$r['tr_class'] = self::tablerow_class($r['type']);
$r['type'] = self::type_names($r['type']);
$tab['content'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_page/tpl/list_entry.tpl'), $r);
}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_page/tpl/saimod_sys_page_list.tpl'), $tab);
}
public static function sai_mod__system_sai_saimod_sys_page_action_deletedialog($ID,$group){
$res = \SYSTEM\DBD\SYS_SAIMOD_PAGE_SINGLE_SELECT::Q1(array($ID,$group));
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_page/tpl/delete_dialog.tpl'), $res);
}
public static function sai_mod__system_sai_saimod_sys_page_action_newdialog(){
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_page/tpl/new_dialog.tpl'));}
public static function sai_mod__system_sai_saimod_sys_page_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");}
if($parentValue == ''){ $parentValue = NULL;}
if($verify == ''){ $verify = NULL;}
\SYSTEM\DBD\SYS_SAIMOD_PAGE_ADD::QI(array($ID,$group,$type,$parentID,$parentValue,$name,$verify));
return \SYSTEM\LOG\JsonResult::ok();
}
public static function sai_mod__system_sai_saimod_sys_page_action_deletecall($ID,$group){
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_PAGE_DEL::QI(array($ID,$group));
return \SYSTEM\LOG\JsonResult::ok();
}
private static function type_names($type){
switch($type){
case 0: return 'STATIC';
case 1: return 'DYNAMIC';
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 id="menu_page" href="#!page">Page</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI) && \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_API);}
public static function css(){
return array(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_page/css/saimod_sys_page.css'));}
public static function js(){
return array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_page/js/saimod_sys_page.js'));}
}

View File

@ -0,0 +1,32 @@
<div id="page_deletedialog">
<h5>Page: ${id}</h5>
<hr>
<table class="table table-hover table-condensed" style="overflow: auto;">
<tr>
<th>id</th>
<th>name</th>
<th>group</th>
<th>state</th>
<th>parent_id</th>
<th>type</th>
<th>div</th>
<th>url</th>
<th>func</th>
<th>php_class</th>
</tr>
<tr>
<td>${id}</td>
<td>${name}</td>
<td>${group}</td>
<td>${state}</td>
<td>${parent_id}</td>
<td>${type}</td>
<td>${div}</td>
<td>${url}</td>
<td>${func}</td>
<td>${php_class}</td>
</tr>
</table>
</div>
<button type="button" class="btn btn-small btn-danger" id="del_page_del" page_id="${ID}" page_group="${group}">Delete</button>
<button type="button" class="btn btn-small" onClick="system.load('page;group.${group}');">Close</button>

View File

@ -0,0 +1,12 @@
<tr class="${tr_class} page_entries" onClick="system.load('page(delete);group.${group};id.${id};name.${name};state.${state}');">
<td>${id}</td>
<td>${name}</td>
<td>${group}</td>
<td>${state}</td>
<td>${parent_id}</td>
<td>${type}</td>
<td>${div}</td>
<td>${url}</td>
<td>${func}</td>
<td>${php_class}</td>
</tr>

View File

@ -0,0 +1,44 @@
<table class="table table-hover table-condensed" style="overflow: auto;">
<tr>
<th>id</th>
<td><input type="text" id="new_page_id" placeholder="new id" style="width: 140px;"></td>
</tr>
<tr>
<th>name</th>
<td><input type="text" id="new_page_name" placeholder="name" style="width: 140px;"></td>
</tr>
<tr>
<th>group</th>
<td><input type="text" id="new_page_group" placeholder="new group" style="width: 140px;"></td>
</tr>
<tr>
<th>state</th>
<td><input type="text" id="new_page_state" placeholder="new state" style="width: 140px;"></td>
</tr>
<tr>
<th>parent_id</th>
<td><input type="text" id="new_page_parentid" placeholder="parent id" style="width: 140px;"></td>
</tr>
<tr>
<th>type</th>
<td><input type="text" id="new_page_type" placeholder="new type" style="width: 140px;"></td>
</tr>
<tr>
<th>div</th>
<td><input type="text" id="new_page_div" placeholder="div" style="width: 140px;"></td>
</tr>
<tr>
<th>url</th>
<td><input type="text" id="new_page_url" placeholder="url" style="width: 140px;"></td>
</tr>
<tr>
<th>func</th>
<td><input type="text" id="new_page_func" placeholder="func" style="width: 140px;"></td>
</tr>
<tr>
<th>php_class</th>
<td><input type="text" id="new_page_php_class" placeholder="php class" style="width: 140px;"></td>
</tr>
</table>
<button type="button" class="btn-small" onClick="system.load('page');">Back</button>
<button type="button" class="btn-small btn-success" id="addpage" style="float: right;">Add</button>

View File

@ -0,0 +1,12 @@
<h4>System Page</h4>
<hr>
<div class="tabbable">
<ul class="nav nav-tabs" id="tabs_page">
<li><a href="#!page" id="menu_all">All</a></li>
${tabopts}
<button onClick="system.load('page(new)',true);" class="btn-success" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">New</button>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_page"></div>
</div>
</div>

View File

@ -0,0 +1,15 @@
<table class="table table-hover table-condensed" style="overflow: auto;">
<tr>
<th>id</th>
<th>name</th>
<th>group</th>
<th>state</th>
<th>parent_id</th>
<th>type</th>
<th>div</th>
<th>url</th>
<th>func</th>
<th>php_class</th>
</tr>
${content}
</table>

View File

@ -0,0 +1 @@
<li><a href="#!page;group.${tab_id}" id="menu_group_${tab_id}">Group ${tab_id}</a></li>