system statesystem for todo and log

This commit is contained in:
Ulf Gebhardt 2015-04-10 03:29:27 +02:00
parent c19f9ad6c8
commit 36c76bb1b3
10 changed files with 69 additions and 113 deletions

View File

@ -47,21 +47,23 @@ SYSTEM.prototype.handle_call_pages_page = function (html,entry,id,forced,cached)
$.getScript(entry['js'][i])
.done(function(response, status, jqxhr) {
system.log_info('load js: '+status);
system.state_js[entry['js'][i]] = true;
if(loaded++ === entry['js'].length-1){
var fn = window[entry['func']];
if(call_func && typeof fn === 'function'){
call_func = false;
fn();
system.log_info('call func: '+entry['func']);
} else {
system.log_error('call func: '+entry['func']+' - fail');
if(call_func ){
if(typeof fn === 'function'){
call_func = false;
fn();
system.log_info('call func: '+entry['func']);
} else {
system.log_error('call func: '+entry['func']+' - fail');
}
}
}
})
.fail(function( jqxhr, settings, exception ) {
system.log_error( "Something went wrong"+exception );
});
this.state_js[entry['js'][i]] = true;
} else {
this.log_info('load js: '+entry['js'][i]+' - cached');
if(loaded++ === entry['js'].length-1){

View File

@ -5,7 +5,7 @@
<li class="active"><a href="#!log">Log</a></li>
<li><a href="#!log(stats)" id="menu_stats">Statistics</a></li>
<img id="loader" src="${PICPATH}ajax-loader.gif" style="margin-left: 10px; margin-top: 10px; display: none; float: left"/>
<button id="refresh_error_table" class="btn-success" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">Refresh</button>
<button onClick="system.load('log',true);" class="btn-success" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">Refresh</button>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_log"></div>

View File

@ -1,4 +1,4 @@
<tr class="sai_log_error ${class_row}" onClick="document.location = '#!log(error);error.${ID}';">
<tr class="sai_log_error ${class_row}" onClick="system.load('log(error);error.${ID}');">
<td>${time}</td>
<td>${class}</td>
<td style="word-break: break-all;">${message}</td>

View File

@ -1,46 +1,69 @@
function init_saimod_sys_todo() {
function init_saimod_sys_todo() {
$('#tabs_todo a').click(function (e) {
e.preventDefault();
$(this).tab('show');
load_todo_tab($(this).attr('action'));
$('#tabs_todo li').each(function(){
$(this).removeClass('active');});
$(this).parent().addClass('active');
});
load_todo_tab('todolist');
register_new();
if(system.cur_state() === 'todo(stats)'){
$('#tabs_todo li').each(function(){
$(this).removeClass('active');});
$('#menu_stats').parent().addClass('active');
}
if(system.cur_state() === 'todo(doto)'){
$('#tabs_todo li').each(function(){
$(this).removeClass('active');});
$('#menu_doto').parent().addClass('active');
}
$('#btn_close_all').click(function(){
if (confirm('Are you sure you want to delete all open entries in the todolist?')) {
$.ajax({ type :'GET',
url : './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=close_all',
success : function(data) {
if(data.status){
system.load('todo');
}else{
alert('Problem: '+data);}
}
});
}
})
};
function register_new(){
$('#btn_new').click(function(){
$('#img_loader').show();
$('#tab_todo').load('./sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=new', function(){
register_newform();
$('#btn_back').click(function(){
load_todo_tab('todolist');});
$('#img_loader').hide();
});
});
}
function register_edit(){
function init_saimod_sys_todo_todoopen(){
$('#btn_edit').click(function(){
$.ajax({ type : 'GET',
url : './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=edit&todo='+$(this).attr('todo')+'&message='+encodeURIComponent($('#ta_message').val()),
success : function(data) {
if(data.status){
load_todo_tab('todolist');
system.load('todo');
}
}
});
});
register_open();
}
function init_saimod_sys_todo_todoclose(){
$('#btn_edit').click(function(){
$.ajax({ type : 'GET',
url : './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=edit&todo='+$(this).attr('todo')+'&message='+encodeURIComponent($('#ta_message').val()),
success : function(data) {
if(data.status){
system.load('todo');
}
}
});
});
register_close();
}
function register_newform(){
function init_saimod_sys_todo_new(){
$('#btn_add').click(function(){
$.ajax({ type : 'GET',
url : './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=add&todo='+encodeURIComponent($('#input_message').val()),
success : function(data) {
if(data.status){
load_todo_tab('todolist');
system.load('todo');
}
}
});
@ -48,42 +71,6 @@ function register_newform(){
$('#input_message').focus();
}
function load_todo_tab(action){
$('#img_loader').show();
switch(action){
case 'todolist':
$('#tab_todo').load('./sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action='+action, function(){
register_todolist();
register_listclick(true);
$('#img_loader').hide();});
return;
case 'dotolist':
$('#tab_todo').load('./sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action='+action, function(){
register_doto();
register_listclick();
$('#img_loader').hide();});
return;
case 'stats':
$('#tab_todo').load('./sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action='+action, function(){
register_stats();
$('#img_loader').hide();});
return;
default:
$('#img_loader').hide();
}
}
function register_listclick(todo){
$('.sai_todo_element').click(function(){
$('#img_loader').show();
$('#tab_todo').load('./sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=todo&todo='+$(this).attr('todo'), function(){
register_edit();
$('#btn_back').click(function(){
if(todo){load_todo_tab('todolist');}else{load_todo_tab('dotolist');}});
if(todo){register_close();}else{register_open();}
$('#img_loader').hide();})});
}
function register_open(){
$('#btn_open').show();
$('#btn_open').click(function(){
@ -113,39 +100,3 @@ function register_close(){
});
});
}
function register_todolist(){
$('#btn_refresh').unbind('click');
$('#btn_refresh').click(function(){
load_todo_tab('todolist');});
$('#btn_close_all').unbind('click');
$('#btn_close_all').click(function(){
if (confirm('Are you sure you want to delete all open entries in the todolist?')) {
$.ajax({ type :'GET',
url : './sai.php?sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=close_all',
success : function(data) {
if(data.status){
load_todo_tab('todolist');
}else{
alert('Problem: '+data);}
}
});
}
})
}
function register_doto(){
$('#btn_refresh').unbind('click');
$('#btn_refresh').click(function(){
load_todo_tab('dotolist');});
$('#btn_close_all').unbind('click');
$('#btn_close_all').click(function(){
alert('operation not possible on this list');});
}
function register_stats(){
$('#btn_refresh').unbind('click');
$('#btn_refresh').click(function(){
load_todo_tab('stats');});
$('#btn_close_all').unbind('click');
$('#btn_close_all').click(function(){
alert('operation not possible on this list');});
}

View File

@ -49,6 +49,7 @@ class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
$row['state_btn'] = self::statebtn($row['count']);
$row['message'] = htmlspecialchars($row['message']);
$row['request_uri'] = htmlspecialchars($row['request_uri']);
$row['openclose'] = 'close';
if($row['type'] == \SYSTEM\DBD\system_todo::FIELD_TYPE_USER){
$row['message'] = str_replace("\r", '<br/>', $row['message']);
$result_user .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_todo/tpl/todo_user_list_element.tpl'), $row);
@ -67,6 +68,8 @@ class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
$row['time_elapsed'] = self::time_elapsed_string(strtotime($row['time']));
$row['state_string'] = self::state($row['count']);
$row['state_btn'] = self::statebtn($row['count']);
$row['request_uri'] = htmlspecialchars($row['request_uri']);
$row['openclose'] = 'open';
if($row['type'] == \SYSTEM\DBD\system_todo::FIELD_TYPE_USER){
$row['message'] = str_replace("\r", '<br/>', $row['message']);
$result_user .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_todo/tpl/todo_user_list_element.tpl'), $row);

View File

@ -2,13 +2,13 @@
<hr>
<div class="tabbable">
<ul class="nav nav-tabs" id="tabs_todo">
<li class="active"><a href="#tab_todo" action="todolist">ToDo</a></li>
<li><a href="#tab_todo" action="dotolist">DoTo</a></li>
<li><a href="#tab_todo" action="stats">Statistics</a></li>
<li class="active"><a href="#!todo" action="todolist">ToDo</a></li>
<li><a href="#!todo(doto)" id="menu_doto">DoTo</a></li>
<li><a href="#!todo(stats)" id="menu_stats">Statistics</a></li>
<img id="img_loader" src="${PICPATH}ajax-loader.gif" style="margin-left: 10px; margin-top: 10px; display: none; float: left"/>
<button id="btn_refresh" class="btn-primary" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">Refresh</button>
<button id="btn_refresh" class="btn-primary" onClick="system.load('todo',true);" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">Refresh</button>
<button id="btn_close_all" class="btn-danger" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">Close All</button>
<button id="btn_new" class="btn-success" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">Add</button>
<button id="btn_new" class="btn-success" onClick="system.load('todo(new)');" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">Add</button>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_todo"></div>

View File

@ -1,5 +1,5 @@
<table class="table table-hover table-condensed">
<tr><td>Message</td><td><textarea style="width: 80%; height: 400px;" id="input_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_back" class="btn-success" onClick="system.load('todo');" style="margin-right: 15px; height: 32px; font-size: 13px; float: left;">Back</button>
<button id="btn_add" class="btn-danger" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">Add</button>

View File

@ -21,6 +21,6 @@
<tr><td>thrown</td><td>${thrown}</td></tr>
<tr><td>message</td><td>${message}</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_back" onClick="system.load('todo');" class="btn-success" style="margin-right: 15px; height: 32px; font-size: 13px; float: left;">Back</button>
<button id="btn_close" class="btn-danger" style="display: none; margin-right: 15px; height: 32px; font-size: 13px; float: right;" todo="${ID}">Close</button>
<button id="btn_open" class="btn-danger" style="display: none; margin-right: 15px; height: 32px; font-size: 13px; float: right;" todo="${ID}">Open</button>

View File

@ -10,7 +10,7 @@
<tr><td>user</td><td>${username}</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_back" onClick="system.load('todo');" 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>
<button id="btn_close" class="btn-danger" style="display: none; margin-right: 15px; height: 32px; font-size: 13px; float: right;" todo="${ID}">Close</button>
<button id="btn_open" class="btn-danger" style="display: none; margin-right: 15px; height: 32px; font-size: 13px; float: right;" todo="${ID}">Open</button>

View File

@ -1,4 +1,4 @@
<tr class="sai_todo_element ${class_row}" todo="${ID}">
<tr class="sai_todo_element ${class_row}" onClick="system.load('todo(todo${openclose});todo.${ID}');">
<td>${time_elapsed}</td>
<td style="word-break: break-all;">${message}</td>
<td>${username}</td>