saimod api statesystem implemented
This commit is contained in:
parent
066ad2f158
commit
41111f1f8b
@ -89,7 +89,10 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (606, 42, 2, 600, 'addcall', 'name', 'STRING');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (607, 42, 2, 600, 'addcall', 'verify', 'ALL');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (608, 42, 2, 600, 'deletecall', 'ID', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (609, 42, 2, 600, 'deletedialog', 'ID', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (609, 42, 2, 600, 'deletecall', 'group', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (610, 42, 2, 600, 'deletedialog', 'ID', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (611, 42, 2, 600, 'deletedialog', 'group', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (620, 42, 3, 600, 'list', 'group', 'INT');
|
||||
|
||||
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (700, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_text', 'action', NULL);
|
||||
|
||||
@ -1,97 +1,54 @@
|
||||
var currentID = '';
|
||||
|
||||
function init_saimod_sys_api() {
|
||||
saimod_sys_api_tree();
|
||||
saimod_sys_api_register_clickevents();
|
||||
|
||||
}
|
||||
|
||||
function saimod_sys_api_loadcontent(){
|
||||
$('#api_wrapper').load('./sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_api', function(){
|
||||
console.log('api module loaded');
|
||||
saimod_sys_api_register_clickevents();
|
||||
$('#tabs_log a').click(function (e) {
|
||||
$('#tabs_log li').each(function(){
|
||||
$(this).removeClass('active');});
|
||||
$(this).parent().addClass('active');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function saimod_sys_api_register_clickevents(){
|
||||
$('tr.api_entries').click(function() {
|
||||
currentID = $(this).attr("id");
|
||||
$.ajax({
|
||||
url: './sai.php',
|
||||
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.php',
|
||||
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();
|
||||
}});});}});});
|
||||
api_menu();
|
||||
|
||||
$('#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.php',
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({ url: './sai.php',
|
||||
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_api',
|
||||
action: 'addcall',
|
||||
ID: $('#new_call_id').val(),
|
||||
group: $('#new_call_group').val(),
|
||||
type: $('#new_call_type').val(),
|
||||
parentID: $('#new_call_parentid').val(),
|
||||
parentValue : $('#new_call_parentvalue').val(),
|
||||
name: $('#new_call_name').val(),
|
||||
verify: $('#new_call_verify').val()},
|
||||
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();
|
||||
function api_menu(){
|
||||
$('#tabs_log 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_api_list(){
|
||||
api_menu();}
|
||||
function init_saimod_sys_api_delete(){
|
||||
$('#del_api_del').click(function() {
|
||||
$.ajax({ url: './sai.php',
|
||||
data: { sai_mod: '.SYSTEM.SAI.saimod_sys_api',
|
||||
action: 'deletecall',
|
||||
ID: $(this).attr('api_id'),
|
||||
group: $(this).attr('api_group')},
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
console.log("api call deleted");
|
||||
$('#api_deletedialog').html('<p>Api call deleted!</p>');
|
||||
$('#del_api_del').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -5,7 +5,7 @@ class SYS_SAIMOD_API_DEL extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'DELETE FROM '.\SYSTEM\DBD\system_api::NAME_PG.' WHERE `ID` = $1;',
|
||||
'DELETE FROM '.\SYSTEM\DBD\system_api::NAME_PG.' WHERE `ID` = $1 AND group = $2;',
|
||||
//mys
|
||||
'DELETE FROM '.\SYSTEM\DBD\system_api::NAME_MYS.' WHERE `ID` = ?;'
|
||||
'DELETE FROM '.\SYSTEM\DBD\system_api::NAME_MYS.' WHERE `ID` = ? AND `group` = ?;'
|
||||
);}}
|
||||
|
||||
11
sai/modules/saimod_sys_api/qq/SYS_SAIMOD_API_GET.php
Normal file
11
sai/modules/saimod_sys_api/qq/SYS_SAIMOD_API_GET.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace SYSTEM\DBD;
|
||||
|
||||
class SYS_SAIMOD_API_GET extends \SYSTEM\DB\QQ {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'SELECT * FROM system_api ORDER BY `group`, `ID` ASC;',
|
||||
//mys
|
||||
'SELECT * FROM system_api ORDER BY `group`, `ID` ASC;'
|
||||
);}}
|
||||
@ -5,7 +5,7 @@ class SYS_SAIMOD_API_SINGLE_SELECT extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'SELECT * FROM '.\SYSTEM\DBD\system_api::NAME_PG.' WHERE ID = $1;',
|
||||
'SELECT * FROM '.\SYSTEM\DBD\system_api::NAME_PG.' WHERE ID = $1 AND group = $2;',
|
||||
//mys
|
||||
'SELECT * FROM '.\SYSTEM\DBD\system_api::NAME_MYS.' WHERE ID = ?;'
|
||||
'SELECT * FROM '.\SYSTEM\DBD\system_api::NAME_MYS.' WHERE ID = ? AND `group` = ?;'
|
||||
);}}
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
<?php
|
||||
namespace SYSTEM\SAI;
|
||||
|
||||
class saimod_sys_api extends \SYSTEM\SAI\SaiModule {
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_api(){
|
||||
//$last_group = -1;
|
||||
$vars = array();
|
||||
|
||||
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||
@ -16,13 +14,13 @@ class saimod_sys_api extends \SYSTEM\SAI\SaiModule {
|
||||
$vars['tabopts'] = '';
|
||||
$first = true;
|
||||
while($r = $res->next()){
|
||||
$vars2 = array( 'active' => ($first ? 'active' : ''),
|
||||
$vars2 = array( 'active' => ($first ? '' : ''),
|
||||
'tab_id' => $r['group']);
|
||||
$first = false;
|
||||
$vars['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/tabopt.tpl'), $vars2);
|
||||
}
|
||||
|
||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
||||
/*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;');
|
||||
@ -41,17 +39,27 @@ class saimod_sys_api extends \SYSTEM\SAI\SaiModule {
|
||||
foreach($tabs as $tab){
|
||||
$tab['active'] = ($first ? 'active' : '');
|
||||
$first = false;
|
||||
$vars['tabs'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/tab.tpl'), $tab);}
|
||||
$vars['tabs'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/tab.tpl'), $tab);}*/
|
||||
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/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));
|
||||
public static function sai_mod__system_sai_saimod_sys_api_action_list($group=null){
|
||||
$res = \SYSTEM\DBD\SYS_SAIMOD_API_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_api/tpl/list_entry.tpl'), $r);
|
||||
}
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/tab.tpl'), $tab);
|
||||
}
|
||||
|
||||
public static function sai_mod__system_sai_saimod_sys_api_action_deletedialog($ID,$group){
|
||||
$res = \SYSTEM\DBD\SYS_SAIMOD_API_SINGLE_SELECT::Q1(array($ID,$group));
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/tpl/delete_dialog.tpl'), $res);
|
||||
}
|
||||
|
||||
@ -64,10 +72,10 @@ class saimod_sys_api extends \SYSTEM\SAI\SaiModule {
|
||||
return \SYSTEM\LOG\JsonResult::ok();
|
||||
}
|
||||
|
||||
public static function sai_mod__system_sai_saimod_sys_api_action_deletecall($ID){
|
||||
public static function sai_mod__system_sai_saimod_sys_api_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_API_DEL::QI(array($ID));
|
||||
\SYSTEM\DBD\SYS_SAIMOD_API_DEL::QI(array($ID,$group));
|
||||
return \SYSTEM\LOG\JsonResult::ok();
|
||||
}
|
||||
|
||||
|
||||
@ -22,5 +22,5 @@
|
||||
</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" id="del_api_del" api_id="${ID}" api_group="${group}">Delete</button>
|
||||
<button type="button" class="btn btn-small" onClick="system.load('api;group.${group}');">Close</button>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<tr class="${tr_class} api_entries" id="${ID}" group="${group}" typ="${type}" parentID="${parentID}" parentValue="${parentValue}" name="${name}" verify="${verify}">
|
||||
<tr class="${tr_class} api_entries" onClick="system.load('api(delete);group.${group};id.${ID}');" id="${ID}" group="${group}" typ="${type}" parentID="${parentID}" parentValue="${parentValue}" name="${name}" verify="${verify}">
|
||||
<td>${ID}</td>
|
||||
<td>${group}</td>
|
||||
<td>${type}</td>
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
<div class="tab-pane ${active}" id="tab_${tab_id}">
|
||||
<table class="table table-hover table-condensed" style="overflow: auto;">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Group</th>
|
||||
<th>Type</th>
|
||||
<th>ParentID</th>
|
||||
<th>ParentValue</th>
|
||||
<th>Name</th>
|
||||
<th>Verify</th>
|
||||
</tr>
|
||||
${content}
|
||||
</table>
|
||||
</div>
|
||||
<table class="table table-hover table-condensed" style="overflow: auto;">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Group</th>
|
||||
<th>Type</th>
|
||||
<th>ParentID</th>
|
||||
<th>ParentValue</th>
|
||||
<th>Name</th>
|
||||
<th>Verify</th>
|
||||
</tr>
|
||||
${content}
|
||||
</table>
|
||||
@ -1 +1 @@
|
||||
<li class="${active}"><a href="#tab_${tab_id}">Group ${tab_id}</a></li>
|
||||
<li class="${active}"><a href="#!api;group.${tab_id}" id="menu_group_${tab_id}">Group ${tab_id}</a></li>
|
||||
@ -1,16 +1,15 @@
|
||||
<div id="api_wrapper">
|
||||
<h4>System API</h4>
|
||||
<hr>
|
||||
<div id="api_content">
|
||||
<div class="tabbable">
|
||||
<ul class="nav nav-tabs" id="localetab">
|
||||
${tabopts}
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
${tabs}
|
||||
<h4>System API</h4>
|
||||
<hr>
|
||||
<div class="tabbable">
|
||||
<ul class="nav nav-tabs" id="tabs_api">
|
||||
<li><a href="#!api" id="menu_all">All</a></li>
|
||||
${tabopts}
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tab_api"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table table-hover table-condensed" style="overflow: auto;">
|
||||
<table class="table table-hover table-condensed" style="overflow: auto;">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Group</th>
|
||||
@ -28,9 +27,6 @@
|
||||
<td><input type="text" id="new_call_parentvalue" placeholder="parent value" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_call_name" placeholder="name" style="width: 140px;"></td>
|
||||
<td><input type="text" id="new_call_verify" placeholder="verify" style="width: 140px;"></td>
|
||||
</tr>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn-small btn-success" id="addcall">Add</button>
|
||||
</div><!-- /.modal -->
|
||||
</div>
|
||||
<button type="button" class="btn-small btn-success" id="addcall">Add</button>
|
||||
Loading…
x
Reference in New Issue
Block a user