statesystem endpoint caching, system.js hashchange function, todo edit field size fixed,todo stats table classes, siastart layout fix
This commit is contained in:
parent
55326931b3
commit
962ee35de7
@ -1,7 +1,7 @@
|
||||
var system = null;
|
||||
|
||||
//mother object
|
||||
function SYSTEM(endpoint, group,start_state){
|
||||
function SYSTEM(endpoint, group,start_state,hashchange){
|
||||
system = this;
|
||||
|
||||
this.LOG_START = 0;
|
||||
@ -12,21 +12,29 @@ function SYSTEM(endpoint, group,start_state){
|
||||
this.group = group;
|
||||
this.pages = null;
|
||||
this.state = {};
|
||||
this.state_info = {};
|
||||
this.start_state = start_state;
|
||||
this.go_state(start_state);
|
||||
|
||||
$(window).bind('hashchange', function( event ) {
|
||||
system.go_state();});
|
||||
system.go_state();
|
||||
//user callback
|
||||
if(hashchange){
|
||||
hashchange(system.cur_state());}
|
||||
});
|
||||
}
|
||||
//internal function to handle pagestate results
|
||||
SYSTEM.prototype.handle_call_pages = function (data,id,forced) {
|
||||
SYSTEM.prototype.handle_call_pages = function (data,id,forced,cached) {
|
||||
if(data['status']){
|
||||
system.log_info('load pages: endpoint '+system.endpoint+' group:'+system.group+' state:'+id+' - success');
|
||||
system.log_info('load pages: endpoint '+system.endpoint+' group:'+system.group+' state:'+id+' - '+(cached ? 'cached ' : 'success'));
|
||||
//state not found?
|
||||
if(data['result'].length === 0){
|
||||
system.log_error('load pages: endpoint '+system.endpoint+' group:'+system.group+' state:'+id+' - state not found - redirecting to start state: '+system.start_state);
|
||||
system.load(system.start_state);
|
||||
return;}
|
||||
//cache state info data
|
||||
system.state_info[id] = data;
|
||||
//update history?
|
||||
if(id !== system.cur_state()){
|
||||
window.history.pushState(null, "", '#!'+id);}
|
||||
data['result'].forEach(function(entry) {
|
||||
@ -109,20 +117,14 @@ SYSTEM.prototype.log_info = function(msg){
|
||||
this.log(this.LOG_INFO,msg);}
|
||||
SYSTEM.prototype.log_error = function(msg){
|
||||
this.log(this.LOG_ERROR,msg);}
|
||||
//get the pages and save em
|
||||
SYSTEM.prototype.load_page = function(){
|
||||
result = false;
|
||||
newps = this.pages;
|
||||
if(!this.pages){
|
||||
this.call('call=pages&group='+this.group,this.handle_call_pages,{},"json",false);
|
||||
} else { result = true;}
|
||||
this.pages = newps;
|
||||
return result;
|
||||
};
|
||||
//load a pagestatewith given id
|
||||
SYSTEM.prototype.load = function(id,forced){
|
||||
system.log(system.LOG_START,'load page '+id);
|
||||
this.call('call=pages&group='+this.group+'&state='+id,function(data){system.handle_call_pages(data,id,forced);},{},"json",false);};
|
||||
this.log(system.LOG_START,'load page: '+id+(forced ? ' - forced' : ''));
|
||||
if(!forced && this.state_info[id]){
|
||||
this.handle_call_pages(this.state_info[id],id,forced,true);
|
||||
}else {
|
||||
this.call('call=pages&group='+this.group+'&state='+id,function(data){system.handle_call_pages(data,id,forced,false);},{},"json",false);}
|
||||
};
|
||||
|
||||
SYSTEM.prototype.load_css = function loadCSS(csssrc) {
|
||||
var snode = document.createElement('link');
|
||||
|
||||
@ -91,7 +91,7 @@ class saimod_sys_api extends \SYSTEM\SAI\SaiModule {
|
||||
}
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#!api">API</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a id="menu_api" href="#!api">API</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);}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ class saimod_sys_cache extends \SYSTEM\SAI\SaiModule {
|
||||
return 'success';
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#!cache">Cache</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a id="menu_cache" href="#!cache">Cache</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ class saimod_sys_config extends \SYSTEM\SAI\SaiModule {
|
||||
|
||||
return $result;
|
||||
}
|
||||
public static function html_li_menu(){return '<li><a href="#!config">Config</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a id="menu_config" href="#!config">Config</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ class saimod_sys_cron extends \SYSTEM\SAI\SaiModule {
|
||||
\SYSTEM\DBD\SYS_SAIMOD_CRON_DEL::QI(array($cls));
|
||||
return \SYSTEM\LOG\JsonResult::ok();}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#!cron">Cron</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a id="menu_cron" href="#!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_CRON);}
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ class saimod_sys_docu extends \SYSTEM\SAI\SaiModule {
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_docu/tpl/tabs.tpl'), $vars);
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#!docu">Docu</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a id="menu_docu" href="#!docu">Docu</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ class saimod_sys_files extends \SYSTEM\SAI\SaiModule {
|
||||
$result .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_files/tpl/saimod_sys_files_tableentry.tpl'), array('i' => $i++, 'cat' => $name, 'name' => $file, 'extension' => substr($file,-3,3), 'url' => 'api.php?call=files&cat='.$name.'&id='.$file));}
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_files/tpl/saimod_sys_files_tabfull.tpl'), array('cat' => $name, 'content' => $result));}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#!files">Files</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a id="menu_files" href="#!files">Files</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_FILES);}
|
||||
|
||||
|
||||
@ -342,7 +342,7 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
||||
}
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#!log">Log</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a id="menu_log" href="#!log">Log</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
|
||||
\SYSTEM\locale::getStrings(\SYSTEM\DBD\system_locale_string::VALUE_CATEGORY_BASIC));
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/tpl/register.tpl'), $vars);}
|
||||
|
||||
public static function html_li_menu(){return '</ul><ul class="nav pull-right"><li><a href="#!login" id="sai_login_loginmenuli">'.(\SYSTEM\SECURITY\Security::isLoggedIn() ? 'Logout' : 'Login').'</a></li>';}
|
||||
public static function html_li_menu(){return '</ul><ul class="nav pull-right"><li><a id="menu_login" href="#!login">'.(\SYSTEM\SECURITY\Security::isLoggedIn() ? 'Logout' : 'Login').'</a></li>';}
|
||||
public static function right_public(){return true;}
|
||||
public static function right_right(){return true;}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ class saimod_sys_mod extends \SYSTEM\SAI\SaiModule {
|
||||
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#!mod">SAI Mods</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a id="menu_mod" href="#!mod">SAI Mods</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -174,7 +174,7 @@ class saimod_sys_security extends \SYSTEM\SAI\SaiModule {
|
||||
}
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#!security">Security</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a id="menu_security" href="#!security">Security</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_SECURITY);}
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ class saimod_sys_text extends \SYSTEM\SAI\SaiModule {
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_text_action_delete($id){
|
||||
return \SYSTEM\DBD\SYS_SAIMOD_LOCALE_DEL::QI(array($id)) ? \SYSTEM\LOG\JsonResult::ok() : \SYSTEM\LOG\JsonResult::error(new \SYSTEM\LOG\WARNING("could not delete the permitted data"));}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#!text">Text</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a id="menu_text" href="#!text">Text</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_LOCALE);}
|
||||
|
||||
|
||||
@ -171,7 +171,7 @@ class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
|
||||
\SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_todo/tpl/saimod_sys_todo_todo_user.tpl'), $vars) :
|
||||
\SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_todo/tpl/saimod_sys_todo_todo.tpl'), $vars);}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#!todo">ToDo</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a id="menu_todo" href="#!todo">ToDo</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<tr><td>http_referer</td><td>${http_referer}</td></tr>
|
||||
<tr><td>http_user_agent</td><td>${http_user_agent}</td></tr>
|
||||
<tr><td>user</td><td>${username}</td></tr>
|
||||
<tr><td>message</td><td><textarea id="ta_message">${message}</textarea></td></tr>
|
||||
<tr><td>message</td><td><textarea id="ta_message" style="width: 80%; height: 400px;">${message}</textarea></td></tr>
|
||||
</table>
|
||||
<button id="btn_back" class="btn-success" style="margin-right: 15px; height: 32px; font-size: 13px; float: left;">Back</button>
|
||||
<button id="btn_edit" class="btn-danger" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;" todo="${ID}">Edit</button>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<table class="sai_table" style="width: 100%">
|
||||
<table class="table table-hover table-condensed sai_table" style="width: 100%">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Count</th>
|
||||
|
||||
@ -1,21 +1,25 @@
|
||||
#content_saistart {
|
||||
width: 1250px;
|
||||
}
|
||||
|
||||
#container_top .well{
|
||||
height: 220px;
|
||||
width: 21%;
|
||||
min-width: 250px;
|
||||
}
|
||||
#project {
|
||||
float: left;
|
||||
}
|
||||
#analytics {
|
||||
margin-left: 10px;
|
||||
margin-left: 20px;
|
||||
float: left;
|
||||
}
|
||||
#git {
|
||||
margin-left: 10px;
|
||||
margin-left: 20px;
|
||||
float: left;
|
||||
}
|
||||
#logout {
|
||||
margin-left: 10px;
|
||||
float: right;
|
||||
margin-left: 20px;
|
||||
float: left;
|
||||
}
|
||||
#todo {
|
||||
clear: both;
|
||||
|
||||
@ -8,7 +8,7 @@ class saistart_sys_sai extends \SYSTEM\SAI\SaiModule {
|
||||
\SYSTEM\locale::getStrings(\SYSTEM\DBD\system_locale_string::VALUE_CATEGORY_SYSTEM_SAI),
|
||||
\SYSTEM\locale::getStrings(\SYSTEM\DBD\system_locale_string::VALUE_CATEGORY_SYSTEM_SAI_ERROR));
|
||||
return \SYSTEM\PAGE\replace::replaceFile( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saistart_sys_sai/tpl/saistart.tpl'),$vars);}
|
||||
public static function html_li_menu(){return '<li class="active"><a href="#!start">'.\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_TITLE).'</a></li>';}
|
||||
public static function html_li_menu(){return '<li class="active"><a id="menu_start" href="#!start">'.\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_TITLE).'</a></li>';}
|
||||
public static function right_public(){return true;}
|
||||
public static function right_right(){return true;}
|
||||
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
<div id="content_saistart" style="float:left; width: auto;">${content}</div>
|
||||
<!--<div style="clear:both;"></div>-->
|
||||
<div id="content_saistart">
|
||||
${content}
|
||||
</div>
|
||||
@ -1,5 +1,5 @@
|
||||
$(document).ready(function() {
|
||||
new SYSTEM('./sai.php',42,'start');
|
||||
new SYSTEM('./sai.php',42,'start',sys_hashchange);
|
||||
|
||||
$('#sai_navbar ul li a, #project_navbar ul li a').click(function () {
|
||||
$('#sai_navbar li, #project_navbar li').each(function(){
|
||||
@ -8,11 +8,13 @@ $(document).ready(function() {
|
||||
system.reload($(this).attr('href'));
|
||||
});
|
||||
|
||||
$('#sai_navbar li, #project_navbar li').each(function(){
|
||||
$(this).removeClass('active');});
|
||||
$("a[href='"+location.hash+"']").parent().addClass('active');
|
||||
|
||||
$('.brand').click(function(){
|
||||
location.reload();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function sys_hashchange(state){
|
||||
$('#sai_navbar li, #project_navbar li').each(function(){
|
||||
$(this).removeClass('active');});
|
||||
$('#menu_'+state).parent().addClass('active');
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user