diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-11-05 12:14:03 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-11-05 12:14:03 +0000 |
| commit | 4ca1f91b93ebdf892377410a0f1f64ca5db2c194 (patch) | |
| tree | 52b05b962227b640cc76e54e0b9a714c0e0427b1 /frontends/php/include | |
| parent | a15d9da563de55c96eb08f52dad5ac805f21e3d3 (diff) | |
| download | zabbix-4ca1f91b93ebdf892377410a0f1f64ca5db2c194.tar.gz zabbix-4ca1f91b93ebdf892377410a0f1f64ca5db2c194.tar.xz zabbix-4ca1f91b93ebdf892377410a0f1f64ca5db2c194.zip | |
- [DEV-60] added availability of setting hosts view style in overview & screens (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@4974 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/defines.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 9 | ||||
| -rw-r--r-- | frontends/php/include/items.inc.php | 170 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 9 | ||||
| -rw-r--r-- | frontends/php/include/screens.inc.php | 5 | ||||
| -rw-r--r-- | frontends/php/include/triggers.inc.php | 256 |
6 files changed, 259 insertions, 194 deletions
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 3c7658d1..063c8662 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -293,6 +293,10 @@ define('STYLE_HORISONTAL', 0); define('STYLE_VERTICAL', 1); +/* view style [OVERVIEW]*/ + define('STYLE_LEFT', 0); + define('STYLE_TOP', 1); + /* time module tipe */ define('TIME_TYPE_LOCAL', 0); define('TIME_TYPE_SERVER', 1); diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 221bd682..bdfaab0f 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -3894,7 +3894,14 @@ include_once 'include/discovery.inc.php'; $cmbStyle->AddItem(STYLE_VERTICAL, S_VERTICAL); $form->AddRow(S_STYLE, $cmbStyle); } - elseif($resourcetype == SCREEN_RESOURCE_CLOCK) + else if(in_array($resourcetype,array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW,SCREEN_RESOURCE_DATA_OVERVIEW))) + { + $cmbStyle = new CComboBox('style', $style); + $cmbStyle->AddItem(STYLE_TOP, S_TOP); + $cmbStyle->AddItem(STYLE_LEFT, S_LEFT); + $form->AddRow(S_HOSTS_LOCATION, $cmbStyle); + } + else if($resourcetype == SCREEN_RESOURCE_CLOCK) { $cmbStyle = new CComboBox("style", $style); $cmbStyle->AddItem(TIME_TYPE_LOCAL, S_LOCAL_TIME); diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index f44fa2cf..49b7dd16 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -840,10 +840,12 @@ * Comments: * */ - function get_items_data_overview($groupid) + function get_items_data_overview($groupid,$view_style=null) { global $USER_DETAILS; + if(is_null($view_style)) $view_style = get_profile('web.overview.view.style',STYLE_TOP); + $table = new CTableInfo(S_NO_ITEMS_DEFINED); if($groupid > 0) @@ -888,87 +890,113 @@ COpt::profiling_start('prepare data'); sort($hosts); COpt::profiling_stop('prepare data'); COpt::profiling_start('prepare table'); - $header=array(new CCol(S_ITEMS,'center')); - foreach($hosts as $hostname) - { - $header=array_merge($header,array(new CImg('vtext.php?text='.$hostname))); + + if($view_style == STYLE_TOP){ + $header=array(new CCol(S_ITEMS,'center')); + foreach($hosts as $hostname) + { + $header=array_merge($header,array(new CImg('vtext.php?text='.$hostname))); + } + $table->SetHeader($header,'vertical_header'); + $curr_rime = time(); + foreach($items as $descr => $ithosts) + { + $table_row = array(nbsp($descr)); + foreach($hosts as $hostname){ + $table_row = get_item_data_overview_cells($table_row,$ithosts,$hostname); + } + $table->AddRow($table_row); + } } - $table->SetHeader($header,'vertical_header'); - $curr_rime = time(); - foreach($items as $descr => $ithosts) - { - $table_row = array(nbsp($descr)); + else{ + $header=array(new CCol(S_ITEMS,'center')); + foreach($items as $descr => $ithosts) + { + $header=array_merge($header,array(new CImg('vtext.php?text='.$descr))); + } + $table->SetHeader($header,'vertical_header'); + $curr_rime = time(); + foreach($hosts as $hostname) { - $css_class = NULL; - unset($it_ov_menu); - - $value = '-'; - $ack = null; - if(isset($ithosts[$hostname])) + $table_row = array(nbsp($hostname)); + foreach($items as $descr => $ithosts) { - if($ithosts[$hostname]['tr_value'] == TRIGGER_VALUE_TRUE) - { - $css_class = get_severity_style($ithosts[$hostname]['severity']); - $ack = get_last_event_by_triggerid($ithosts[$hostname]['triggerid']); - if ( 1 == $ack['acknowledged'] ) - $ack = array(SPACE, new CImg('images/general/tick.png','ack')); - else - $ack = null; - } - - $value = format_lastvalue($ithosts[$hostname]); - - $it_ov_menu = array( - array(S_VALUES, null, null, - array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader'))), - array(S_500_LATEST_VALUES, 'history.php?action=showlatest&itemid='.$ithosts[$hostname]['itemid'], - array('tw'=>'_blank')) - ); - - switch($ithosts[$hostname]['value_type']) - { - case ITEM_VALUE_TYPE_UINT64: - case ITEM_VALUE_TYPE_FLOAT: - $it_ov_menu = array_merge(array( - /* name, url, (target [tw], statusbar [sb]), css, submenu */ - array(S_GRAPHS, null, null, - array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')) - ), - array(S_LAST_HOUR_GRAPH, 'history.php?period=3600&action=showgraph&itemid='. - $ithosts[$hostname]['itemid'], array('tw'=>'_blank')), - array(S_LAST_WEEK_GRAPH, 'history.php?period=604800&action=showgraph&itemid='. - $ithosts[$hostname]['itemid'], array('tw'=>'_blank')), - array(S_LAST_MONTH_GRAPH, 'history.php?period=2678400&action=showgraph&itemid='. - $ithosts[$hostname]['itemid'], array('tw'=>'_blank')) - ), $it_ov_menu); - break; - default: - break; - } + $table_row = get_item_data_overview_cells($table_row,$ithosts,$hostname); } + $table->AddRow($table_row); + } + } +COpt::profiling_stop('prepare table'); - if($value == '-') $css_class = 'center'; - $value_col = new CCol(array($value,$ack),$css_class); + return $table; + } + + function get_item_data_overview_cells(&$table_row,&$ithosts,$hostname){ + $css_class = NULL; + unset($it_ov_menu); - if(isset($it_ov_menu)) - { - $it_ov_menu = new CPUMenu($it_ov_menu,170); - $value_col->OnClick($it_ov_menu->GetOnActionJS()); - $value_col->AddOption('style', 'cursor: pointer;'); - $value_col->AddAction('onmouseover', - 'this.old_border=this.style.border; this.style.border=\'1px dotted #0C0CF0\''); - $value_col->AddAction('onmouseout', 'this.style.border=this.old_border;'); - unset($it_ov_menu); - } + $value = '-'; + $ack = null; + if(isset($ithosts[$hostname])) + { + if($ithosts[$hostname]['tr_value'] == TRIGGER_VALUE_TRUE) + { + $css_class = get_severity_style($ithosts[$hostname]['severity']); + $ack = get_last_event_by_triggerid($ithosts[$hostname]['triggerid']); + if ( 1 == $ack['acknowledged'] ) + $ack = array(SPACE, new CImg('images/general/tick.png','ack')); + else + $ack = null; + } + + $value = format_lastvalue($ithosts[$hostname]); + + $it_ov_menu = array( + array(S_VALUES, null, null, + array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader'))), + array(S_500_LATEST_VALUES, 'history.php?action=showlatest&itemid='.$ithosts[$hostname]['itemid'], + array('tw'=>'_blank')) + ); - array_push($table_row,$value_col); + switch($ithosts[$hostname]['value_type']) + { + case ITEM_VALUE_TYPE_UINT64: + case ITEM_VALUE_TYPE_FLOAT: + $it_ov_menu = array_merge(array( + /* name, url, (target [tw], statusbar [sb]), css, submenu */ + array(S_GRAPHS, null, null, + array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')) + ), + array(S_LAST_HOUR_GRAPH, 'history.php?period=3600&action=showgraph&itemid='. + $ithosts[$hostname]['itemid'], array('tw'=>'_blank')), + array(S_LAST_WEEK_GRAPH, 'history.php?period=604800&action=showgraph&itemid='. + $ithosts[$hostname]['itemid'], array('tw'=>'_blank')), + array(S_LAST_MONTH_GRAPH, 'history.php?period=2678400&action=showgraph&itemid='. + $ithosts[$hostname]['itemid'], array('tw'=>'_blank')) + ), $it_ov_menu); + break; + default: + break; } - $table->AddRow($table_row); } -COpt::profiling_stop('prepare table'); - return $table; + if($value == '-') $css_class = 'center'; + $value_col = new CCol(array($value,$ack),$css_class); + + if(isset($it_ov_menu)) + { + $it_ov_menu = new CPUMenu($it_ov_menu,170); + $value_col->OnClick($it_ov_menu->GetOnActionJS()); + $value_col->AddOption('style', 'cursor: pointer;'); + $value_col->AddAction('onmouseover', + 'this.old_border=this.style.border; this.style.border=\'1px dotted #0C0CF0\''); + $value_col->AddAction('onmouseout', 'this.style.border=this.old_border;'); + unset($it_ov_menu); + } + + array_push($table_row,$value_col); + return $table_row; } /****************************************************************************** diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 940e7a0b..f95678a0 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -903,6 +903,7 @@ 'S_SELECT_GROUP_DOT_DOT_DOT'=> 'Select group ...', 'S_OVERVIEW'=> 'Overview', 'S_OVERVIEW_BIG'=> 'OVERVIEW', + 'S_HOSTS_LOCATION'=> 'Hosts location', 'S_EXCL'=> '!', 'S_DATA'=> 'Data', 'S_SHOW_GRAPH_OF_ITEM'=> 'Show graph of item', @@ -1048,17 +1049,17 @@ 'S_SERVER_TIME'=> 'Server time', 'S_LOCAL_TIME'=> 'Local time', - 'S_STYLE'=> 'Style', + 'S_STYLE'=> 'Style', 'S_VERTICAL'=> 'Vertical', 'S_HORISONTAL'=> 'Horizontal', 'S_HORISONTAL_ALIGN'=> 'Horizontal align', - 'S_LEFT'=> 'Left', + 'S_LEFT'=> 'Left', 'S_CENTER'=> 'Center', - 'S_RIGHT'=> 'Right', + 'S_RIGHT'=> 'Right', 'S_VERTICAL_ALIGN'=> 'Vertical align', - 'S_TOP'=> 'Top', + 'S_TOP'=> 'Top', 'S_MIDDLE'=> 'Middle', 'S_BOTTOM'=> 'Bottom', diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php index 9831cf09..1553d53f 100644 --- a/frontends/php/include/screens.inc.php +++ b/frontends/php/include/screens.inc.php @@ -450,12 +450,12 @@ } elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_TRIGGERS_OVERVIEW) ) { - $item = array(get_triggers_overview($resourceid)); + $item = array(get_triggers_overview($resourceid,$style)); if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action)); } elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_DATA_OVERVIEW) ) { - $item = array(get_items_data_overview($resourceid)); + $item = array(get_items_data_overview($resourceid,$style)); if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action)); } elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_URL) ) @@ -598,5 +598,4 @@ ); } - ?> diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index c156ea5f..4676efeb 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -1782,10 +1782,12 @@ * Comments: !!! Don't forget sync code with C !!! * */ - function get_triggers_overview($groupid) + function get_triggers_overview($groupid,$view_style=null) { global $USER_DETAILS; + if(is_null($view_style)) $view_style = get_profile('web.overview.view.style',STYLE_TOP); + $table = new CTableInfo(S_NO_TRIGGERS_DEFINED); if($groupid > 0) { @@ -1820,135 +1822,159 @@ return $table; } sort($hosts); - - $header=array(new CCol(S_TRIGGERS,'center')); - foreach($hosts as $hostname) - { - $header=array_merge($header,array(new CImg('vtext.php?text='.$hostname))); - } - $table->SetHeader($header,'vertical_header'); - - foreach($triggers as $descr => $trhosts) - { - $table_row = array(nbsp($descr)); + if($view_style == STYLE_TOP){ + $header=array(new CCol(S_TRIGGERS,'center')); foreach($hosts as $hostname) { - $css_class = NULL; + $header=array_merge($header,array(new CImg('vtext.php?text='.$hostname))); + } + $table->SetHeader($header,'vertical_header'); - unset($tr_ov_menu); - $ack = null; - if(isset($trhosts[$hostname])) + foreach($triggers as $descr => $trhosts) + { + $table_row = array(nbsp($descr)); + foreach($hosts as $hostname) { - unset($ack_menu); - switch($trhosts[$hostname]['value']) - { - case TRIGGER_VALUE_TRUE: - $css_class = get_severity_style($trhosts[$hostname]['priority']); - if( ($ack = get_last_event_by_triggerid($trhosts[$hostname]['triggerid'])) ) - $ack_menu = array(S_ACKNOWLEDGE, 'acknow.php?eventid='.$ack['eventid'], array('tw'=>'_blank')); - - if ( 1 == $ack['acknowledged'] ) - $ack = new CImg('images/general/tick.png','ack'); - else - $ack = null; - - break; - case TRIGGER_VALUE_FALSE: - $css_class = 'normal'; - break; - default: - $css_class = 'unknown_trigger'; - } - - $style = 'cursor: pointer; '; - - if((time(NULL)-$trhosts[$hostname]['lastchange'])<300) - $style .= 'background-image: url(images/gradients/blink1.gif); '. - 'background-position: top left; '. - 'background-repeat: repeate;'; - elseif((time(NULL)-$trhosts[$hostname]['lastchange'])<900) - $style .= 'background-image: url(images/gradients/blink2.gif); '. - 'background-position: top left; '. - 'background-repeat: repeate;'; - - unset($item_menu); - $tr_ov_menu = array( - /* name, url, (target [tw], statusbar [sb]), css, submenu */ - array(S_TRIGGER, null, null, - array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')) - ), - array(S_EVENTS, 'tr_events.php?triggerid='.$trhosts[$hostname]['triggerid'], array('tw'=>'_blank')) - ); + $table_row=get_trigger_overview_cells($table_row,$trhosts,$hostname); + } + $table->AddRow($table_row); + } + } + else{ + $header=array(new CCol(S_TRIGGERS,'center')); + foreach($triggers as $descr => $trhosts) + { + $header=array_merge($header,array(new CImg('vtext.php?text='.$descr))); + } + $table->SetHeader($header,'vertical_header'); - if(isset($ack_menu)) $tr_ov_menu[] = $ack_menu; + foreach($hosts as $hostname){ + + $table_row = array(nbsp($hostname)); + + foreach($triggers as $descr => $trhosts){ + $table_row=get_trigger_overview_cells($table_row,$trhosts,$hostname); + } + $table->AddRow($table_row); + } + } + return $table; + } - $db_items = DBselect('select distinct i.itemid, i.description, i.key_, i.value_type '. - ' from items i, functions f '. - ' where f.itemid=i.itemid and f.triggerid='.$trhosts[$hostname]['triggerid']); + function get_trigger_overview_cells(&$table_row,&$trhosts,&$hostname){ + $css_class = NULL; - while($item_data = DBfetch($db_items)) - { - $description = item_description($item_data['description'], $item_data['key_']); - switch($item_data['value_type']) - { - case ITEM_VALUE_TYPE_UINT64: - case ITEM_VALUE_TYPE_FLOAT: - $action = 'showgraph'; - $status_bar = S_SHOW_GRAPH_OF_ITEM.' \''.$description.'\''; - break; - case ITEM_VALUE_TYPE_LOG: - case ITEM_VALUE_TYPE_STR: - case ITEM_VALUE_TYPE_TEXT: - default: - $action = 'showlatest'; - $status_bar = S_SHOW_VALUES_OF_ITEM.' \''.$description.'\''; - break; - } - - if(strlen($description) > 25) $description = substr($description,0,22).'...'; + unset($tr_ov_menu); + $ack = null; + if(isset($trhosts[$hostname])) + { + unset($ack_menu); + switch($trhosts[$hostname]['value']) + { + case TRIGGER_VALUE_TRUE: + $css_class = get_severity_style($trhosts[$hostname]['priority']); + if( ($ack = get_last_event_by_triggerid($trhosts[$hostname]['triggerid'])) ) + $ack_menu = array(S_ACKNOWLEDGE, 'acknow.php?eventid='.$ack['eventid'], array('tw'=>'_blank')); - $item_menu[$action][] = array( - $description, - 'history.php?action='.$action.'&itemid='.$item_data['itemid'].'&period=3600', - array('tw'=>'_blank', 'sb'=>$status_bar)); - } - if(isset($item_menu['showgraph'])) - { - $tr_ov_menu[] = array(S_GRAPHS, null, null, - array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')) - ); - $tr_ov_menu = array_merge($tr_ov_menu, $item_menu['showgraph']); - } - if(isset($item_menu['showlatest'])) - { - $tr_ov_menu[] = array(S_VALUES, null, null, - array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')) - ); - $tr_ov_menu = array_merge($tr_ov_menu, $item_menu['showlatest']); - } + if ( 1 == $ack['acknowledged'] ) + $ack = new CImg('images/general/tick.png','ack'); + else + $ack = null; - unset($item_menu); - } + break; + case TRIGGER_VALUE_FALSE: + $css_class = 'normal'; + break; + default: + $css_class = 'unknown_trigger'; + } - $status_col = new CCol(array(SPACE, $ack),$css_class); - if(isset($style)) + $style = 'cursor: pointer; '; + + if((time(NULL)-$trhosts[$hostname]['lastchange'])<300) + $style .= 'background-image: url(images/gradients/blink1.gif); '. + 'background-position: top left; '. + 'background-repeat: repeate;'; + elseif((time(NULL)-$trhosts[$hostname]['lastchange'])<900) + $style .= 'background-image: url(images/gradients/blink2.gif); '. + 'background-position: top left; '. + 'background-repeat: repeate;'; + + unset($item_menu); + $tr_ov_menu = array( + /* name, url, (target [tw], statusbar [sb]), css, submenu */ + array(S_TRIGGER, null, null, + array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')) + ), + array(S_EVENTS, 'tr_events.php?triggerid='.$trhosts[$hostname]['triggerid'], array('tw'=>'_blank')) + ); + + if(isset($ack_menu)) $tr_ov_menu[] = $ack_menu; + + $db_items = DBselect('select distinct i.itemid, i.description, i.key_, i.value_type '. + ' from items i, functions f '. + ' where f.itemid=i.itemid and f.triggerid='.$trhosts[$hostname]['triggerid']); + + while($item_data = DBfetch($db_items)) + { + $description = item_description($item_data['description'], $item_data['key_']); + switch($item_data['value_type']) { - $status_col->AddOption('style', $style); + case ITEM_VALUE_TYPE_UINT64: + case ITEM_VALUE_TYPE_FLOAT: + $action = 'showgraph'; + $status_bar = S_SHOW_GRAPH_OF_ITEM.' \''.$description.'\''; + break; + case ITEM_VALUE_TYPE_LOG: + case ITEM_VALUE_TYPE_STR: + case ITEM_VALUE_TYPE_TEXT: + default: + $action = 'showlatest'; + $status_bar = S_SHOW_VALUES_OF_ITEM.' \''.$description.'\''; + break; } + + if(strlen($description) > 25) $description = substr($description,0,22).'...'; - if(isset($tr_ov_menu)) - { - $tr_ov_menu = new CPUMenu($tr_ov_menu,170); - $status_col->OnClick($tr_ov_menu->GetOnActionJS()); - $status_col->AddAction('onmouseover', - 'this.old_border=this.style.border; this.style.border=\'1px dotted #0C0CF0\''); - $status_col->AddAction('onmouseout', 'this.style.border=this.old_border;'); - } - array_push($table_row,$status_col); + $item_menu[$action][] = array( + $description, + 'history.php?action='.$action.'&itemid='.$item_data['itemid'].'&period=3600', + array('tw'=>'_blank', 'sb'=>$status_bar)); + } + if(isset($item_menu['showgraph'])) + { + $tr_ov_menu[] = array(S_GRAPHS, null, null, + array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')) + ); + $tr_ov_menu = array_merge($tr_ov_menu, $item_menu['showgraph']); } - $table->AddRow($table_row); + if(isset($item_menu['showlatest'])) + { + $tr_ov_menu[] = array(S_VALUES, null, null, + array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')) + ); + $tr_ov_menu = array_merge($tr_ov_menu, $item_menu['showlatest']); + } + + unset($item_menu); } - return $table; + + $status_col = new CCol(array(SPACE, $ack),$css_class); + if(isset($style)) + { + $status_col->AddOption('style', $style); + } + + if(isset($tr_ov_menu)) + { + $tr_ov_menu = new CPUMenu($tr_ov_menu,170); + $status_col->OnClick($tr_ov_menu->GetOnActionJS()); + $status_col->AddAction('onmouseover', + 'this.old_border=this.style.border; this.style.border=\'1px dotted #0C0CF0\''); + $status_col->AddAction('onmouseout', 'this.style.border=this.old_border;'); + } + array_push($table_row,$status_col); + return $table_row; } function get_function_by_functionid($functionid) |
