error table controls
This commit is contained in:
parent
9bcf84be37
commit
e1427df405
@ -1,22 +1,18 @@
|
||||
function init__SYSTEM_SAI_saimod_sys_error() {
|
||||
|
||||
|
||||
$('#truncate_table').click(function(){
|
||||
|
||||
|
||||
$.ajax({
|
||||
type :'GET',
|
||||
//url : './system/sai/modules/saimod_sys_error/saimod_sys_error.php',
|
||||
data :{truncate : 'sys_log'},
|
||||
url : './?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_error&truncate=sys_log',
|
||||
success : function(data) {
|
||||
if(data === true){
|
||||
|
||||
|
||||
|
||||
if(data == 1){
|
||||
$('#info_box').html("deleting data...");
|
||||
$('#truncate_modal').modal('hide');
|
||||
//location.reload(true);
|
||||
$('#content-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_error');
|
||||
}else{
|
||||
//location.reload(true);
|
||||
$('#truncate_modal').modal('hide');
|
||||
//you don't have the permission to truncate table
|
||||
$('#info_box').html("You do not have the permission to truncate table!");
|
||||
}
|
||||
|
||||
}
|
||||
@ -24,21 +20,24 @@ function init__SYSTEM_SAI_saimod_sys_error() {
|
||||
});
|
||||
|
||||
|
||||
$('#refresh_error_table').click(function(){
|
||||
$('#refresh_error_table').live("click", (function(){
|
||||
|
||||
$('img#loader').show();
|
||||
|
||||
$('#content-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_error');
|
||||
|
||||
setTimeout($('img#loader').hide(), 3000);
|
||||
//TODO: reload error msgs....
|
||||
setTimeout("$('img#loader').hide()", 1300);
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
}));
|
||||
|
||||
|
||||
$("#filter-error button").live("click", (function(){
|
||||
|
||||
$(this).parents().children().removeClass('active');
|
||||
$(this).addClass('active');
|
||||
|
||||
|
||||
$('#table-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_error&filter_error='+$(this).attr('id'));
|
||||
}));
|
||||
|
||||
}
|
||||
18
sai/modules/saimod_sys_error/sai_sys_error_truncate.php
Normal file
18
sai/modules/saimod_sys_error/sai_sys_error_truncate.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
if( isset($_GET['truncate'])){
|
||||
if(\SYSTEM\SECURITY\Security::check(\SYSTEM::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI)){
|
||||
$con = new \SYSTEM\DB\Connection(\SYSTEM::getSystemDBInfo());
|
||||
$res = $con->query('TRUNCATE system.sys_log;');
|
||||
echo '1';
|
||||
return TRUE;
|
||||
}else{
|
||||
echo '0';
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -4,24 +4,57 @@ namespace SYSTEM\SAI;
|
||||
|
||||
|
||||
class saimod_sys_error extends \SYSTEM\SAI\SaiModule {
|
||||
public static function truncate_sys_log(){
|
||||
|
||||
private static function truncate_syslog(){
|
||||
if(\SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI)){
|
||||
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||
$res = $con->query('TRUNCATE system.sys_log;');
|
||||
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static function build_table($filter){
|
||||
|
||||
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||
$res = $con->query('SELECT * FROM system.sys_log ORDER BY time DESC LIMIT 100;');
|
||||
|
||||
$now = microtime(true);
|
||||
|
||||
$result = '<div id="table-wrapper"><table class="table table-hover table-condensed" style="overflow: auto;">'.
|
||||
'<tr>'.'<th>'.'time ago in sec'.'</th>'.'<th>'.'time'.'</th>'.'<th>'.'class'.'</th>'.'<th>'.'message'.'</th>'.'<th>'.'code'.'</th>'.'<th>'.'file'.'</th>'.'<th>'.'line'.'</th>'.'<th>'.'ip'.'</th>'.'<th>'.'querytime'.'</tr>';
|
||||
while($r = $res->next()){
|
||||
|
||||
if($filter !== NULL && $filter !== 'all'){
|
||||
if(self::tablerow_class($r['class']) === $filter){
|
||||
$result .= '<tr class="'.self::tablerow_class($r['class']).'">'.'<td>'.(int)($now - strtotime($r['time'])).'</td>'.'<td>'.$r['time'].'</td>'.'<td>'.$r['class'].'</td>'.'<td>'.$r['message'].'</td>'.'<td>'.$r['code'].'</td>'.'<td>'.$r['file'].'</td>'.'<td>'.$r['line'].'</td>'.'<td>'.$r['ip'].'</td>'.'<td>'.$r['querytime'].'</tr>';
|
||||
}
|
||||
}else{
|
||||
$result .= '<tr class="'.self::tablerow_class($r['class']).'">'.'<td>'.(int)($now - strtotime($r['time'])).'</td>'.'<td>'.$r['time'].'</td>'.'<td>'.$r['class'].'</td>'.'<td>'.$r['message'].'</td>'.'<td>'.$r['code'].'</td>'.'<td>'.$r['file'].'</td>'.'<td>'.$r['line'].'</td>'.'<td>'.$r['ip'].'</td>'.'<td>'.$r['querytime'].'</tr>';
|
||||
}
|
||||
}
|
||||
$result .= '</table></div>';
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function html_content(){
|
||||
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||
$res = $con->query('SELECT * FROM system.sys_log ORDER BY time DESC LIMIT 100;');
|
||||
|
||||
|
||||
$now = microtime(true);
|
||||
if( isset($_GET['truncate'])){
|
||||
return self::truncate_syslog();
|
||||
}
|
||||
|
||||
if( isset($_GET['filter_error'])){
|
||||
return self::build_table($_GET['filter_error']);
|
||||
}else{
|
||||
$filter = NULL;
|
||||
}
|
||||
|
||||
|
||||
$result = '<div id="truncate_modal" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
@ -31,23 +64,28 @@ class saimod_sys_error extends \SYSTEM\SAI\SaiModule {
|
||||
<div class="modal-body">
|
||||
<p>This action will delete all error messages from databse. <br />
|
||||
Are you sure?</p>
|
||||
<span id="info_box" />
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal">Cancel</a>
|
||||
<a href="#" class="btn btn-danger" id="truncate_table">Yes, delete all!</a>
|
||||
</div>
|
||||
</div>
|
||||
<button href="#refresh_error_table" class="btn" style="height: 32px; font-size: 13px;">Refresh</button>
|
||||
<button id="refresh_error_table" class="btn" style="height: 32px; font-size: 13px;">Refresh</button>
|
||||
<img id="loader" src="dasense/page/default_developer/img/ajax-loader.gif" style="margin-left: 10px; display: none;"/>
|
||||
<div id="filter-error" class="btn-group" style="left: 60px;">
|
||||
<button class="btn active" href="#" id="all">All</button>
|
||||
<button class="btn" href="#" id="error">Error</button>
|
||||
<button class="btn" href="#" id="warning">Warning</button>
|
||||
<button class="btn" href="#" id="success">Info</button>
|
||||
<button class="btn" href="#" id="info">Deprecated</button>
|
||||
</diV>
|
||||
<button data-toggle="modal" href="#truncate_modal" class="btn" style="height: 32px; font-size: 13px; float: right;">Truncate Table</button>
|
||||
<img id="loader" src="dasense/page/default_developer/img/ajax-loader.gif" style="margin-left: 10px;">
|
||||
<br /><br />';
|
||||
|
||||
$result .= '<table class="table table-hover table-condensed" style="overflow: auto;">'.
|
||||
'<tr>'.'<th>'.'time ago in sec'.'</th>'.'<th>'.'time'.'</th>'.'<th>'.'class'.'</th>'.'<th>'.'message'.'</th>'.'<th>'.'code'.'</th>'.'<th>'.'file'.'</th>'.'<th>'.'line'.'</th>'.'<th>'.'ip'.'</th>'.'<th>'.'querytime'.'</tr>';
|
||||
while($r = $res->next()){
|
||||
$result .= '<tr class="'.self::tablerow_class($r['class']).'">'.'<td>'.(int)($now - strtotime($r['time'])).'</td>'.'<td>'.$r['time'].'</td>'.'<td>'.$r['class'].'</td>'.'<td>'.$r['message'].'</td>'.'<td>'.$r['code'].'</td>'.'<td>'.$r['file'].'</td>'.'<td>'.$r['line'].'</td>'.'<td>'.$r['ip'].'</td>'.'<td>'.$r['querytime'].'</tr>';
|
||||
}
|
||||
$result .= '</table>';
|
||||
|
||||
$result .= self::build_table($filter);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
@ -5,10 +5,12 @@ namespace SYSTEM\SAI;
|
||||
class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
|
||||
public static function html_content(){
|
||||
|
||||
/*
|
||||
if( isset($_POST['username']) && isset($_POST['password']) &&
|
||||
\SYSTEM\SECURITY\Security::login(\SYSTEM\system::getSystemDBInfo(), $_POST['username'], sha1($_POST['password']), md5($_POST['password']))){
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/login_success.tpl'), array());}
|
||||
|
||||
*/
|
||||
|
||||
$vars = array();
|
||||
$vars['login'] = 'Login';
|
||||
$vars['logout'] = 'Logout';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user