From 9bcf84be3762b69c3b6adef69ac1c591c0ddb090 Mon Sep 17 00:00:00 2001 From: scholzDaSense Date: Fri, 24 May 2013 10:07:07 +0200 Subject: [PATCH] added buttons and modal for refreshing / truncating table sys_log --- sai/modules/saimod_sys_error/sai_sys_error.js | 44 +++++++++++++++++++ .../saimod_sys_error/saimod_sys_error.php | 37 +++++++++++++++- sai/page/default_page/sai.tpl | 2 +- 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 sai/modules/saimod_sys_error/sai_sys_error.js diff --git a/sai/modules/saimod_sys_error/sai_sys_error.js b/sai/modules/saimod_sys_error/sai_sys_error.js new file mode 100644 index 0000000..283eeab --- /dev/null +++ b/sai/modules/saimod_sys_error/sai_sys_error.js @@ -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.... + + + + + }) + + + + + +} \ No newline at end of file diff --git a/sai/modules/saimod_sys_error/saimod_sys_error.php b/sai/modules/saimod_sys_error/saimod_sys_error.php index b4b45ae..5a1e604 100644 --- a/sai/modules/saimod_sys_error/saimod_sys_error.php +++ b/sai/modules/saimod_sys_error/saimod_sys_error.php @@ -2,7 +2,20 @@ namespace SYSTEM\SAI; + 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(){ $con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo()); $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); - $result = ''. + $result = ' + + + +

'; + + $result .= '
'. ''.''.''.''.''.''.''.''.''.''; while($r = $res->next()){ $result .= ''.''.''.''.''.''.''.''.''.''; @@ -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 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')));} } \ No newline at end of file diff --git a/sai/page/default_page/sai.tpl b/sai/page/default_page/sai.tpl index 23edeef..c061f51 100644 --- a/sai/page/default_page/sai.tpl +++ b/sai/page/default_page/sai.tpl @@ -22,7 +22,7 @@ -
+
'.'time ago in sec'.''.'time'.''.'class'.''.'message'.''.'code'.''.'file'.''.'line'.''.'ip'.''.'querytime'.'
'.(int)($now - strtotime($r['time'])).''.$r['time'].''.$r['class'].''.$r['message'].''.$r['code'].''.$r['file'].''.$r['line'].''.$r['ip'].''.$r['querytime'].'