summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-02-25 15:20:55 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-02-25 15:20:55 +0000
commit8b818f2fa041df344af3cfde1fec132bf3ae2927 (patch)
tree43c86a894fe6ceb8225adc933cc486de05ebdf6d /frontends/php
parentd215a0cc8d018303992833528c36455480cfb10b (diff)
downloadzabbix-8b818f2fa041df344af3cfde1fec132bf3ae2927.tar.gz
zabbix-8b818f2fa041df344af3cfde1fec132bf3ae2927.tar.xz
zabbix-8b818f2fa041df344af3cfde1fec132bf3ae2927.zip
- [DEV-118] added refresh options to dashboard screen {still beta} (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5394 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/dashboard.php102
-rw-r--r--frontends/php/include/blocks.inc.php37
-rw-r--r--frontends/php/include/locales/en_gb.inc.php4
-rw-r--r--frontends/php/js/dashboard.js83
-rw-r--r--frontends/php/styles/popupmenu.css14
5 files changed, 219 insertions, 21 deletions
diff --git a/frontends/php/dashboard.php b/frontends/php/dashboard.php
index 34dc8d8a..63f44a1a 100644
--- a/frontends/php/dashboard.php
+++ b/frontends/php/dashboard.php
@@ -64,10 +64,44 @@ include_once "include/page_header.php";
// ACTION /////////////////////////////////////////////////////////////////////////////
if(isset($_REQUEST['favobj'])){
- if($_REQUEST['favobj'] == 'hat'){
+ if('hat' == $_REQUEST['favobj']){
// echo 'alert("'.$_REQUEST['favid'].' : '.$_REQUEST['state'].'");';
update_profile('web.dashboard.hats.'.$_REQUEST['favid'].'.state',$_REQUEST['state']);
}
+ if('refresh' == $_REQUEST['favobj']){
+// echo 'alert("'.$_REQUEST['favid'].' : '.$_REQUEST['state'].'");';
+ switch($_REQUEST['favid']){
+ case 'hat_syssum':
+ $syssum = make_system_summary($available_hosts);
+ $syssum->show();
+ break;
+ case 'hat_stszbx':
+ $stszbx = make_status_of_zbx();
+ $stszbx->Show();
+ break;
+ case 'hat_lastiss':
+ $lastiss = make_latest_issues($available_hosts);
+ $lastiss->Show();
+ break;
+ case 'hat_webovr':
+ $webovr = make_webmon_overview();
+ $webovr->Show();
+ break;
+ }
+ }
+ if('set_rf_rate' == $_REQUEST['favobj']){
+ if(in_array($_REQUEST['favid'],array('hat_syssum','hat_stszbx','hat_lastiss','hat_webovr'))){
+ update_profile('web.dahsboard.rf_rate.'.$_REQUEST['favid'],$_REQUEST['favcnt']);
+ echo get_refresh_obj_script($_REQUEST['favid'],$_REQUEST['favcnt']);
+
+ $menu = array();
+ $submenu = array();
+
+ make_refresh_menu('hat_syssum',$_REQUEST['favcnt'],$menu,$submenu);
+
+ echo 'dashboard_menu["menu_'.$_REQUEST['favid'].'"] = '.zbx_jsvalue($menu['menu_'.$_REQUEST['favid']]).';';
+ }
+ }
//SDI()
if(in_array($_REQUEST['favobj'],array('simple_graph','graphs'))){
$result = false;
@@ -216,7 +250,9 @@ include_once "include/page_header.php";
}
// validate_group(PERM_READ_ONLY,array("allow_all_hosts","monitored_hosts","with_monitored_items"));
- show_table_header(SPACE.S_DASHBOARD_BIG.SPACE.date("[H:i:s]",time()),SPACE);
+// $time = new CSpan(date("[H:i:s]",time()));
+// $time->AddOption('id','refreshed');
+ show_table_header(array(S_DASHBOARD_BIG,SPACE),SPACE);
$left_tab = new CTable();
$left_tab->SetCellPadding(5);
@@ -232,6 +268,11 @@ include_once "include/page_header.php";
make_sysmap_menu($menu,$submenu);
make_screen_menu($menu,$submenu);
+ make_refresh_menu('hat_syssum',get_profile('web.dahsboard.rf_rate.hat_syssum',120),$menu,$submenu);
+ make_refresh_menu('hat_stszbx',get_profile('web.dahsboard.rf_rate.hat_stszbx',120),$menu,$submenu);
+ make_refresh_menu('hat_lastiss',get_profile('web.dahsboard.rf_rate.hat_lastiss',60),$menu,$submenu);
+ make_refresh_menu('hat_webovr',get_profile('web.dahsboard.rf_rate.hat_webovr',60),$menu,$submenu);
+
insert_js('var dashboard_menu='.zbx_jsvalue($menu)."\n".
'var dashboard_submenu='.zbx_jsvalue($submenu)."\n"
);
@@ -246,7 +287,7 @@ include_once "include/page_header.php";
make_favorite_graphs($available_hosts),
array($graph_menu),
'hat_favgrph',
- get_profile('web.dashboard.hats.hat_favgrph.state')
+ get_profile('web.dashboard.hats.hat_favgrph.state',1)
));
$sysmap_menu = new CDiv(SPACE,'menuplus');
@@ -257,7 +298,7 @@ include_once "include/page_header.php";
make_favorite_maps(),
array($sysmap_menu),
'hat_favmap',
- get_profile('web.dashboard.hats.hat_favmap.state')
+ get_profile('web.dashboard.hats.hat_favmap.state',1)
));
$screen_menu = new CDiv(SPACE,'menuplus');
@@ -268,7 +309,7 @@ include_once "include/page_header.php";
make_favorite_screens(),
array($screen_menu),
'hat_favscr',
- get_profile('web.dashboard.hats.hat_favscr.state')
+ get_profile('web.dashboard.hats.hat_favscr.state',1)
));
$left_tab->AddRow(SPACE);
@@ -278,35 +319,58 @@ include_once "include/page_header.php";
$right_tab->AddOption('border',0);
-// $right_td_l = new CCol();
-// $right_td_l->Addoption('valign','top');
+// Refresh tab
+
+ $refresh_tab = array(
+ 'hat_syssum' => get_profile('web.dahsboard.rf_rate.hat_syssum',120),
+ 'hat_stszbx' => get_profile('web.dahsboard.rf_rate.hat_stszbx',120),
+ 'hat_lastiss' => get_profile('web.dahsboard.rf_rate.hat_lastiss',60),
+ 'hat_webovr' => get_profile('web.dahsboard.rf_rate.hat_webovr',60)
+ );
+ add_refresh_objects($refresh_tab);
+
+ $refresh_menu = new CDiv(SPACE,'menuplus');
+ $refresh_menu->AddAction('onclick','javascript: create_menu(event,"hat_syssum");');
$right_tab->AddRow(create_hat(
S_SYSTEM_STATUS,
- make_system_summary($available_hosts),
- null,
+ null,//make_system_summary($available_hosts),
+ array($refresh_menu),
'hat_syssum',
- get_profile('web.dashboard.hats.hat_syssum.state')
+ get_profile('web.dashboard.hats.hat_syssum.state',1)
));
+
+ $refresh_menu = new CDiv(SPACE,'menuplus');
+ $refresh_menu->AddAction('onclick','javascript: create_menu(event,"hat_stszbx");');
+
+
$right_tab->AddRow(create_hat(
S_STATUS_OF_ZABBIX,
- make_status_of_zbx(),
- null,
+ null,//make_status_of_zbx(),
+ array($refresh_menu),
'hat_stszbx',
- get_profile('web.dashboard.hats.hat_stszbx.state')
+ get_profile('web.dashboard.hats.hat_stszbx.state',1)
));
+
+ $refresh_menu = new CDiv(SPACE,'menuplus');
+ $refresh_menu->AddAction('onclick','javascript: create_menu(event,"hat_lastiss");');
+
$right_tab->AddRow(create_hat(S_LATEST_ISSUES,
- make_latest_issues($available_hosts),
- null,
+ null,//make_latest_issues($available_hosts),
+ array($refresh_menu),
'hat_lastiss',
- get_profile('web.dashboard.hats.hat_lastiss.state')
+ get_profile('web.dashboard.hats.hat_lastiss.state',1)
));
+
+ $refresh_menu = new CDiv(SPACE,'menuplus');
+ $refresh_menu->AddAction('onclick','javascript: create_menu(event,"hat_webovr");');
+
$right_tab->AddRow(create_hat(
S_WEB_MONITORING,
- make_webmon_overview(),
- null,
+ null,//make_webmon_overview(),
+ array($refresh_menu),
'hat_webovr',
- get_profile('web.dashboard.hats.hat_webovr.state')
+ get_profile('web.dashboard.hats.hat_webovr.state',1)
));
$td_l = new CCol($left_tab);
diff --git a/frontends/php/include/blocks.inc.php b/frontends/php/include/blocks.inc.php
index 6272cc3b..0f97ea4a 100644
--- a/frontends/php/include/blocks.inc.php
+++ b/frontends/php/include/blocks.inc.php
@@ -92,6 +92,7 @@ function make_system_summary($available_hosts=false){
}
$table->AddRow($group_row);
}
+ $table->SetFooter(new CCol(S_REFRESHED.': '.date("[H:i:s]",time())));
return $table;
}
@@ -152,7 +153,7 @@ function make_status_of_zbx(){
}
$table->AddRow(array(S_NUMBER_OF_USERS,$usr_cnt,new CSpan($online_cnt,'green')));
-
+ $table->SetFooter(new CCol(S_REFRESHED.': '.date("[H:i:s]",time())));
return $table;
}
@@ -295,7 +296,7 @@ function make_latest_issues($available_hosts=false){
' AND h.hostid in ('.$available_hosts.') '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND t.value='.TRIGGER_VALUE_TRUE.
- 'ORDER BY t.lastchange DESC';
+ ' ORDER BY t.lastchange DESC';
$result = DBselect($sql);
while($row=DBfetch($result)){
@@ -354,6 +355,7 @@ function make_latest_issues($available_hosts=false){
}
unset($row,$description, $actions);
}
+ $table->SetFooter(new CCol(S_REFRESHED.': '.date("[H:i:s]",time())));
return $table;
}
@@ -430,6 +432,7 @@ function make_webmon_overview($available_hosts=false){
new CSpan($apps[HTTPTEST_STATE_UNKNOWN],'unknown')
));
}
+ $table->SetFooter(new CCol(S_REFRESHED.': '.date("[H:i:s]",time())));
return $table;
}
@@ -716,4 +719,34 @@ function make_screen_submenu(){
return $screenids;
}
+
+function add_refresh_objects($ref_tab){
+ $min = PHP_INT_MAX;
+ foreach($ref_tab as $id => $interval){
+ $min = ($min < $interval)?$min:$interval;
+ zbx_add_post_js(get_refresh_obj_script($id,$interval));
+ }
+ zbx_add_post_js('updater.interval = 10; updater.check4Update();');
+}
+
+function get_refresh_obj_script($id,$interval){
+ return 'updater.setObj4Update("'.$id.'","dashboard.php?output=html",{"favobj": "refresh", "favid": "'.$id.'"}, '.$interval.');';
+}
+
+function make_refresh_menu($id,$cur_interval,&$menu,&$submenu){
+
+ $menu['menu_'.$id][] = array(S_REFRESH, null, null, array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')));
+ $intervals = array('10','30','60', '120','600','900');
+
+ foreach($intervals as $key => $value){
+ $menu['menu_'.$id][] = array(
+ S_EVERY.SPACE.$value.SPACE.S_SECONDS_SMALL,
+ 'javascript: setRefreshRate("'.$id.'",'.$value.');'.
+ 'void(0);',
+ null,
+ array('outer' => ($value == $cur_interval)?'pum_b_submenu':'pum_o_submenu', 'inner'=>array('pum_i_submenu')
+ ));
+ }
+ $submenu['menu_'.$id][] = array();
+}
?> \ No newline at end of file
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index b8614521..a2444c29 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -937,6 +937,8 @@
'S_SYSTEM_STATUS'=> 'System status',
'S_LATEST_ISSUES'=> 'Latest issues',
'S_FAVORITE'=> 'Favorite',
+ 'S_EVERY'=> 'Every',
+ 'S_REFRESHED'=> 'Refreshed',
// overview.php
'S_SELECT_GROUP_DOT_DOT_DOT'=> 'Select group ...',
@@ -958,6 +960,8 @@
'S_THE_QUEUE_IS_EMPTY'=> 'The queue is empty',
'S_TOTAL'=> 'Total',
'S_COUNT'=> 'Count',
+ 'S_SECONDS_SMALL'=> 'seconds',
+ 'S_MINUTES_SMALL'=> 'minutes',
'S_5_SECONDS'=> '5 seconds',
'S_10_SECONDS'=> '10 seconds',
'S_30_SECONDS'=> '30 seconds',
diff --git a/frontends/php/js/dashboard.js b/frontends/php/js/dashboard.js
index 997d3a5a..7702f388 100644
--- a/frontends/php/js/dashboard.js
+++ b/frontends/php/js/dashboard.js
@@ -1,4 +1,21 @@
// JavaScript Document
+function setRefreshRate(id,interval){
+ var params = {
+ 'favobj': 'set_rf_rate',
+ 'favid': id,
+ 'favcnt': interval
+ }
+
+ new Ajax.Request("dashboard.php?output=ajax",
+ {
+ 'method': 'post',
+ 'parameters':params,
+ 'onSuccess': function(resp){ },//alert(resp.responseText);
+ 'onFailure': function(){ document.location = 'dashboard.php?'+Object.toQueryString(params); }
+ }
+ );
+
+}
function add2favorites(){
@@ -93,6 +110,7 @@ function create_menu(e,id){
var dbrd_menu = new Array();
//to create a copy of array, but not references!!!!
+//alert(id+' : '+dashboard_menu[id]);
for(var i=0; i < dashboard_menu[id].length; i++){
if(isset(dashboard_menu[id][i]) && !empty(dashboard_menu[id][i]))
dbrd_menu[i] = dashboard_menu[id][i].clone();
@@ -107,4 +125,69 @@ function create_menu(e,id){
}
//alert(dashboard_menu[id]);
show_popup_menu(e,dbrd_menu,280);// JavaScript Document
+}
+
+
+// DOM obj update class
+// Author: Aly
+var updater = {
+objlist: new Array(), // list of objects
+optlist : new Array(), // object params, list
+interval: 10, // update interval in sec
+
+setObj4Update: function(id,url,params,frequency){
+ var obj = document.getElementById(id);
+ if(!isset(obj)) return false;
+
+ var obj4update = {
+ 'id': id,
+ 'url': url,
+ 'params': params,
+ 'interval': frequency,
+ 'lastupdate': 0
+ }
+
+ if(!isset(this.optlist[id])){
+ this.objlist.push(id);
+ }
+ this.optlist[id] = obj4update;
+},
+
+check4Update: function(){
+ if(this.objlist.length > 0){
+ var dt = new Date();
+ var now = parseInt(dt.getTime()/1000);
+
+ for(var i=0; i < this.objlist.length; i++){
+ if(isset(this.optlist[this.objlist[i]]) && !empty(this.optlist[this.objlist[i]])){
+// alert(Math.abs(now - this.optlist[this.objlist[i]].lastupdate));
+ if(this.optlist[this.objlist[i]].interval <= Math.abs(now - this.optlist[this.objlist[i]].lastupdate)){
+ this.update(this.optlist[this.objlist[i]],now);
+ }
+ }
+ }
+ }
+ setTimeout('updater.check4Update();',(this.interval*1000));
+},
+
+update: function(obj4update,time){
+ new Ajax.Updater(obj4update.id, obj4update.url,
+ {
+ method: 'post',
+ 'parameters': obj4update.params,
+ 'onSuccess': function(resp){ obj4update.lastupdate = time;},
+ 'onFailure': function(){ document.location = 'dashboard.php?'+Object.toQueryString(obj4update.params); }
+ });
+}
+}
+
+function getTimeFormated(timestamp){
+ var dt = new Date();
+
+ var hours = dt.getHours();
+ var minutes = dt.getMinutes();
+ var seconds = dt.getSeconds();
+ var str = '['+hours+':'+minutes+':'+seconds+']';
+
+return str;
} \ No newline at end of file
diff --git a/frontends/php/styles/popupmenu.css b/frontends/php/styles/popupmenu.css
index 7e8e2dde..34b46ad6 100644
--- a/frontends/php/styles/popupmenu.css
+++ b/frontends/php/styles/popupmenu.css
@@ -21,6 +21,20 @@
}
/* menu menu item with submenu */
+.pum_b_submenu{
+ font-family: sans-serif, Tahoma, Verdana, Geneva, Arial, Helvetica;
+ font-size: 12px;
+ text-decoration: none;
+ font-weight: bold;
+ background: #ECECFF;
+ border: black 1px solid;
+ margin: 0px;
+}
+.pum_b_submenu:hover {
+ text-decoration: none;
+ background-color: #FDFDFF;
+}
+
.pum_o_submenu{
font-family: sans-serif, Tahoma, Verdana, Geneva, Arial, Helvetica;
font-size: 12px;