added buttons and modal for refreshing / truncating table sys_log
This commit is contained in:
parent
137ebdefb9
commit
9bcf84be37
44
sai/modules/saimod_sys_error/sai_sys_error.js
Normal file
44
sai/modules/saimod_sys_error/sai_sys_error.js
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
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'},
|
||||||
|
success : function(data) {
|
||||||
|
if(data === true){
|
||||||
|
|
||||||
|
|
||||||
|
$('#truncate_modal').modal('hide');
|
||||||
|
//location.reload(true);
|
||||||
|
}else{
|
||||||
|
//location.reload(true);
|
||||||
|
$('#truncate_modal').modal('hide');
|
||||||
|
//you don't have the permission to truncate table
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('#refresh_error_table').click(function(){
|
||||||
|
|
||||||
|
$('img#loader').show();
|
||||||
|
|
||||||
|
|
||||||
|
setTimeout($('img#loader').hide(), 3000);
|
||||||
|
//TODO: reload error msgs....
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -2,7 +2,20 @@
|
|||||||
|
|
||||||
namespace SYSTEM\SAI;
|
namespace SYSTEM\SAI;
|
||||||
|
|
||||||
|
|
||||||
class saimod_sys_error extends \SYSTEM\SAI\SaiModule {
|
class saimod_sys_error extends \SYSTEM\SAI\SaiModule {
|
||||||
|
public static function truncate_sys_log(){
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function html_content(){
|
public static function html_content(){
|
||||||
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||||
$res = $con->query('SELECT * FROM system.sys_log ORDER BY time DESC LIMIT 100;');
|
$res = $con->query('SELECT * FROM system.sys_log ORDER BY time DESC LIMIT 100;');
|
||||||
@ -10,7 +23,26 @@ class saimod_sys_error extends \SYSTEM\SAI\SaiModule {
|
|||||||
|
|
||||||
$now = microtime(true);
|
$now = microtime(true);
|
||||||
|
|
||||||
$result = '<table class="table table-hover table-condensed" style="overflow: auto;">'.
|
$result = '<div id="truncate_modal" class="modal hide fade">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h3>Truncate table system.sys_log</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>This action will delete all error messages from databse. <br />
|
||||||
|
Are you sure?</p>
|
||||||
|
</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 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>';
|
'<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()){
|
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 .= '<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>';
|
||||||
@ -40,5 +72,6 @@ class saimod_sys_error extends \SYSTEM\SAI\SaiModule {
|
|||||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||||
|
|
||||||
public static function src_css(){}
|
public static function src_css(){}
|
||||||
public static function src_js(){}
|
public static function src_js(){return \SYSTEM\LOG\JsonResult::toString(
|
||||||
|
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_error/sai_sys_error.js')));}
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="project_navbar" style="width:150px;float:left;">
|
<div id="project_navbar" style="width:210px;float:left;">
|
||||||
<div class="navbar-inner">
|
<div class="navbar-inner">
|
||||||
<ul class="nav nav-list">
|
<ul class="nav nav-list">
|
||||||
${menu_proj}
|
${menu_proj}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user