api module update. Adding and deleting api calls is now possible via SAI Backend. further updates coming soon.

This commit is contained in:
messerbill 2014-06-04 03:41:24 +02:00
parent beaaf02efc
commit dc43d02250
9 changed files with 146 additions and 6 deletions

View File

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

View File

@ -0,0 +1,11 @@
<?php
namespace SYSTEM\DBD;
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;',
//mys
'DELETE FROM '.\SYSTEM\DBD\system_api::NAME_MYS.' WHERE `ID` = ?;'
);}}

View File

@ -70,7 +70,14 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
-- INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (500, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_config', 'action', NULL);
-- INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (600, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_api', 'action', NULL);
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (600, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_api', 'action', NULL);
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (601, 42, 2, 600, 'addcall', 'ID', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (602, 42, 2, 600, 'addcall', 'group', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (603, 42, 2, 600, 'addcall', 'type', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (604, 42, 2, 600, 'addcall', 'parentID', 'INT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (605, 42, 2, 600, 'addcall', 'parentValue', 'STRING');
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 (700, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_locale', 'action', NULL);

View File

@ -1,4 +1,4 @@
<tr class="${tr_class}">
<tr class="${tr_class} api_entries" id="${ID}" group="${group}" typ="${type}" parentID="${parentID}" parentValue="${parentValue}" name="${name}" verify="${verify}">
<td>${ID}</td>
<td>${group}</td>
<td>${type}</td>

View File

@ -0,0 +1,3 @@
p {
font-size: 90%;
}

View File

@ -1,3 +1,54 @@
function init__SYSTEM_SAI_saimod_sys_api() {
var currentID = '';
function init__SYSTEM_SAI_saimod_sys_api() {
$('tr.api_entries').click(function() {
currentID = $(this).attr("id");
$('#modaltitle').html("Call ID: "+currentID+'<hr>');
$('#modal_description').append('<div id="api_wrap"><b>Group:</b> '+$(this).attr("group")+'<br>');
$('#modal_description').append('<b>Type:</b> '+$(this).attr("typ")+'<br>');
$('#modal_description').append('<b>ParentID:</b> '+$(this).attr("parentID")+'<br>');
$('#modal_description').append('<b>ParentValue:</b> '+$(this).attr("parentValue")+'<br>');
$('#modal_description').append('<b>Name:</b> '+$(this).attr("name")+'<br>');
$('#modal_description').append('<b>Verify:</b> '+$(this).attr("verify")+'</div>');
$('#modal_api').modal('show');
});
$('#del_api').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");
$('#modal_api').modal('hide');
}
});
});
$('#addcall').click(function() {
console.log("bla");
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");
}
});});
$('#localetab a').click(function (e) {e.preventDefault(); $(this).tab('show');});
}

View File

@ -50,6 +50,18 @@ class saimod_sys_api extends \SYSTEM\SAI\SaiModule {
return $result;*/
}
public static function sai_mod__system_sai_saimod_sys_api_action_addcall($ID,$group,$type,$parentID,$parentValue,$name,$verify){
new \SYSTEM\LOG\WARNING("api call added");
$res = \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){
new \SYSTEM\LOG\WARNING("api call deleted");
$res = \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';
@ -74,7 +86,9 @@ class saimod_sys_api extends \SYSTEM\SAI\SaiModule {
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_api_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_api_flag_css(){
return \SYSTEM\LOG\JsonResult::toString(
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/saimod_sys_api.css')));}
public static function sai_mod__SYSTEM_SAI_saimod_sys_api_flag_js(){
return \SYSTEM\LOG\JsonResult::toString(
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_api/saimod_sys_api.js')));}

View File

@ -10,5 +10,5 @@
<th>Verify</th>
</tr>
${content}
</table>
</table>
</div>

View File

@ -7,4 +7,47 @@
<div class="tab-content">
${tabs}
</div>
</div>
</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>
<tr>
<td><input type="text" id="new_call_id" placeholder="new id" style="width: 140px;"></td>
<td><input type="text" id="new_call_group" placeholder="new group" style="width: 140px;"></td>
<td><input type="text" id="new_call_type" placeholder="new type" style="width: 140px;"></td>
<td><input type="text" id="new_call_parentid" placeholder="parent id" style="width: 140px;"></td>
<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>
</table>
<button type="button" class="btn-small btn-success" id="addcall">Add</button>
<div class="modal fade" id="modal_api" style="width: 700px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modaltitle"></h4>
<div id="modal_description"></div>
</div>
<div class="modal-body" id="modaltextarea" style="display: none;">
<input type="text" id="new_call_id" placeholder="new call id" name="content" style="width:100%" />
</div>
</div>
<div class="modal-footer">
<button type="button" id="del_api" class="btn-small btn-danger" style="float: left;">Delete</button>
<button type="button" class="btn-small" data-dismiss="modal" id="edit_close">Close</button>
<!-- <button type="button" class="btn-small btn-success" id="new_call">Add</button>-->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->