summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-16 11:39:29 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-16 11:39:29 +0000
commitdf2d967e519775ef67c7e004199fe52caea58f1d (patch)
tree1a78d3641a7f4874fa950bde06ad4c185d18efe7 /frontends/php/include
parent7aa815c71fb9382e11d5886e91fa36dfae80339d (diff)
- developed PopUp menu for overview (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3892 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/classes/ccolor.inc.php2
-rw-r--r--frontends/php/include/classes/ccombobox.inc.php4
-rw-r--r--frontends/php/include/classes/cpumenu.inc.php53
-rw-r--r--frontends/php/include/classes/ctag.inc.php15
-rw-r--r--frontends/php/include/classes/ctextbox.inc.php8
-rw-r--r--frontends/php/include/config.inc.php160
-rw-r--r--frontends/php/include/locales/en_gb.inc.php3
-rw-r--r--frontends/php/include/page_header.php1
-rw-r--r--frontends/php/include/triggers.inc.php83
9 files changed, 191 insertions, 138 deletions
diff --git a/frontends/php/include/classes/ccolor.inc.php b/frontends/php/include/classes/ccolor.inc.php
index 2e9d6ca9..3ebc2c28 100644
--- a/frontends/php/include/classes/ccolor.inc.php
+++ b/frontends/php/include/classes/ccolor.inc.php
@@ -209,7 +209,7 @@ else if (document.getElementById)
$txt = new CTextBox($name,$value,7);
$txt->AddOption('id', $name);
- $txt->AddOption('onChange', 'set_color_by_name(\''.$name.'\',this.value)');
+ $txt->AddAction('onChange', 'set_color_by_name(\''.$name.'\',this.value)');
$txt->AddOption('style', 'margin: 0px');
$this->AddItem(array($txt, $lbl));
diff --git a/frontends/php/include/classes/ccombobox.inc.php b/frontends/php/include/classes/ccombobox.inc.php
index d05020d7..79d50f3d 100644
--- a/frontends/php/include/classes/ccombobox.inc.php
+++ b/frontends/php/include/classes/ccombobox.inc.php
@@ -177,8 +177,8 @@
inseret_javascript_for_editable_combobox();
parent::CComboBox($name,$value,$action);
- parent::AddOption('onfocus','CEditableComboBoxInit(this);');
- parent::AddOption('onchange','CEditableComboBoxOnChange(this,'.$size.');');
+ parent::AddAction('onfocus','CEditableComboBoxInit(this);');
+ parent::AddAction('onchange','CEditableComboBoxOnChange(this,'.$size.');');
}
function AddItem($value, $caption='', $selected=NULL, $enabled='yes')
diff --git a/frontends/php/include/classes/cpumenu.inc.php b/frontends/php/include/classes/cpumenu.inc.php
new file mode 100644
index 00000000..1b697941
--- /dev/null
+++ b/frontends/php/include/classes/cpumenu.inc.php
@@ -0,0 +1,53 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ class CPUMenu
+ {
+/* private */
+ /*
+ var $items = array();
+ var $width;
+ */
+/* public */
+ function CPUMenu($items=array(), $width=null)
+ {
+ $this->InsertJavaScript();
+ $this->items = $items;
+ $this->width = $width;
+ }
+
+ function GetOnActionJS()
+ {
+ if(count($this->items) <= 0) return NULL;
+
+ return 'return show_popup_menu(event,'.zbx_jsvalue($this->items).','.zbx_jsvalue($this->width).');';
+ }
+
+ function InsertJavaScript()
+ {
+ if(defined('CPUMENU_INSERTJAVASCRIPT_INSERTED')) return;
+ define('CPUMENU_INSERTJAVASCRIPT_INSERTED', 1);
+?>
+<script language="JavaScript" type="text/javascript" src="js/menu.js"></script>
+<?php
+ }
+ }
+?>
diff --git a/frontends/php/include/classes/ctag.inc.php b/frontends/php/include/classes/ctag.inc.php
index 2b462617..df7d91ae 100644
--- a/frontends/php/include/classes/ctag.inc.php
+++ b/frontends/php/include/classes/ctag.inc.php
@@ -228,13 +228,21 @@
$code = "show_hint(this,event,'".$text."');";
}
- $this->AddOption('onMouseOver', $code);
- $this->AddOption('onMouseMove', $code);
+ $this->AddAction('onMouseOver', $code);
+ $this->AddAction('onMouseMove', $code);
}
function OnClick($handle_code)
{
- $this->AddOption('onClick', $handle_code);
+ $this->AddAction('onClick', $handle_code);
+ }
+
+ function AddAction($name, $value)
+ {
+ if(isset($value))
+ $this->options[$name] = str_replace("\n", '', strval($value));
+ else
+ unset($this->options[$name]);
}
function AddOption($name, $value)
@@ -244,6 +252,7 @@
else
unset($this->options[$name]);
}
+
function SetEnabled($value='yes')
{
if((is_string($value) && ($value == 'yes' || $value == 'enabled' || $value=='on') || $value=='1')
diff --git a/frontends/php/include/classes/ctextbox.inc.php b/frontends/php/include/classes/ctextbox.inc.php
index c1bd3134..a261f7dc 100644
--- a/frontends/php/include/classes/ctextbox.inc.php
+++ b/frontends/php/include/classes/ctextbox.inc.php
@@ -70,10 +70,10 @@
parent::CTextBox($name,$value,$size,$readonly);
$this->AddOption('MaxLength', $size);
$this->AddOption('Style', 'text-align: right;');
- $this->AddOption('OnKeyPress',
+ $this->AddAction('OnKeyPress',
' var c = (window.event) ? event.keyCode : event.which;'.
' if(event.ctrlKey || c <= 31 || (c >= 48 && c <= 57)) return true; else return false; ');
- $this->AddOption('OnChange',
+ $this->AddAction('OnChange',
($allowempty ? ' if(this.value.length==0 || this.value==null) this.value = \'\'; else ' : '').
' if(isNaN(parseInt(this.value))) this.value = 0; '.
' else this.value = parseInt(this.value);'
@@ -101,10 +101,10 @@
if($i != 3)
{
$this->ip_parts[$i]->tag_end = '';
- $this->ip_parts[$i]->AddOption('OnKeyDown',
+ $this->ip_parts[$i]->AddAction('OnKeyDown',
' this.maxlength = this.getAttribute("maxlength"); '.
' this.oldlength = this.value.length; ');
- $this->ip_parts[$i]->AddOption('OnKeyUp',
+ $this->ip_parts[$i]->AddAction('OnKeyUp',
' if(this.oldlength != this.value.length && this.value.length == this.maxlength) {'.
' var el = this.form.elements["'.$name.'['.($i+1).']'.'"];'.
' if(el) { el.focus(); el.select(); }}');
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index fd1ee764..367a0d71 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -58,6 +58,7 @@ function VDP($var, $msg=null) { echo "DEBUG DUMP: "; if(isset($msg)) echo '"'.$m
require_once("include/classes/cmap.inc.php");
require_once("include/classes/cflash.inc.php");
require_once("include/classes/ciframe.inc.php");
+ require_once("include/classes/cpumenu.inc.php");
require_once("include/classes/graph.inc.php");
// Include Tactical Overview modules
@@ -205,7 +206,41 @@ function VDP($var, $msg=null) { echo "DEBUG DUMP: "; if(isset($msg)) echo '"'.$m
*/
function zbx_jsstr($str)
{
- return htmlspecialchars(str_replace("\n", '\n', str_replace("\r", '', $str)));
+ return htmlspecialchars(str_replace("\n", '\n', str_replace("\r", '', $str)));
+ }
+
+ /* function:
+ * zbx_jsvalue
+ *
+ * description:
+ * convert PHP variable to string version
+ * of JavaScrip style
+ *
+ * author: Eugene Grigorjev
+ */
+ function zbx_jsvalue(&$value)
+ {
+ if(!is_array($value))
+ {
+ if(is_object($value)) return unpack_object($value);
+ if(is_string($value)) return '\''.str_replace('\'','\\\'',zbx_jsstr($value)).'\'';
+ if(is_null($value)) return 'null';
+ return strval($value);
+ }
+
+ if(count($value) == 0) return '[]';
+
+ foreach($value as $id => $v)
+ {
+ if(!isset($is_object) && is_string($id)) $is_object = true;
+
+ $value[$id] = (isset($is_object) ? '\''.$id.'\' : ' : '').zbx_jsvalue($v);
+ }
+
+ if(isset($is_object))
+ return '{'.implode(',',$value).'}';
+ else
+ return '['.implode(',',$value).']';
}
/* function:
@@ -1456,25 +1491,6 @@ function GetPos(obj)
var hint_box = null;
-function get_cursor_position(e)
-{
- e = e || window.event;
- var cursor = {x:0, y:0};
- if (e.pageX || e.pageY) {
- cursor.x = e.pageX;
- cursor.y = e.pageY;
- }
- else {
- var de = document.documentElement;
- var b = document.body;
- cursor.x = e.clientX +
- (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
- cursor.y = e.clientY +
- (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
- }
- return cursor;
-}
-
function hide_hint()
{
if(!hint_box) return;
@@ -1543,110 +1559,6 @@ else if (document.getElementById)
<?php
}
- function insert_confirm_javascript()
- {
-?>
-<script language="JavaScript" type="text/javascript">
-<!--
- function Redirect(url) {
- window.location = url;
- return false;
- }
-
- function create_var(form_name, var_name, var_val, submit)
- {
- var frmForm = document.forms[form_name];
-
- if(!frmForm) return false;
-
- var objVar = document.createElement('input');
-
- if(!objVar) return false;
-
- objVar.setAttribute('type', 'hidden');
- objVar.setAttribute('name', var_name);
- objVar.setAttribute('value', var_val);
-
- frmForm.appendChild(objVar);
- if(submit)
- frmForm.submit();
-
- return false;
- }
-
- function Confirm(msg)
- {
- if(confirm(msg,'title'))
- return true;
- else
- return false;
- }
- function PopUp(url,width,height,form_name)
- {
- if(!width) width = 600;
- if(!height) height = 450;
- if(!form_name) form_name = 'zbx_popup';
-
- var left = (screen.width-(width+150))/2;
- var top = (screen.height-(height+150))/2;
-
- var popup = window.open(url,form_name,'width=' + width +',height=' + height + ',top='+ top +',left='+ left +
- ',resizable=yes,scrollbars=yes,location=no,menubar=no');
-
- popup.focus();
-
- return false;
- }
-
- function CheckAll(form_name, chkMain, shkName)
- {
- var frmForm = document.forms[form_name];
- var value = frmForm.elements[chkMain].checked;
- for (var i=0; i < frmForm.length; i++)
- {
- name = frmForm.elements[i].name.split('[')[0];
- if(frmForm.elements[i].type != 'checkbox') continue;
- if(name == chkMain) continue;
- if(shkName && shkName != name) continue;
- if(frmForm.elements[i].disabled == true) continue;
- frmForm.elements[i].checked = value;
- }
- }
-
- function GetSelectedText(obj)
- {
- if (navigator.appName == "Microsoft Internet Explorer")
- {
- obj.focus();
- return document.selection.createRange().text;
- }
- else (obj.selectionStart)
- {
- if(obj.selectionStart != obj.selectionEnd) {
- var s = obj.selectionStart;
- var e = obj.selectionEnd;
- return obj.value.substring(s, e);
- }
- }
- return obj.value;
- }
-
- function ScaleChartToParenElement(obj_name)
- {
- var obj = document.getElementsByName(obj_name);
-
- if(obj.length <= 0) throw "Can't find objects with name [" + obj_name +"]";
-
- for(i = obj.length-1; i>=0; i--)
- {
- obj[i].src += "&width=" + (obj[i].parentNode.offsetWidth - obj[i].parentNode.offsetLeft - 10);
- }
- }
-//-->
-</script>
-<?php
- }
-
function Redirect($url)
{
zbx_flush_post_cookies();
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index 5245e24e..eab54baa 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -795,6 +795,9 @@
"S_OVERVIEW_BIG"=> "OVERVIEW",
"S_EXCL"=> "!",
"S_DATA"=> "Data",
+ "S_SHOW_GRAPH_OF_ITEM"=> "Show graph of item",
+ "S_SHOW_VALUES_OF_ITEM"=> "Show values of item",
+ "S_VALUES"=> "Values",
// queue.php
"S_QUEUE_BIG"=> "QUEUE",
diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php
index 2704f8a0..5428a3f4 100644
--- a/frontends/php/include/page_header.php
+++ b/frontends/php/include/page_header.php
@@ -340,6 +340,7 @@ COpt::profiling_start("page");
<?php } ?>
<link rel="stylesheet" href="css.css">
<meta name="Author" content="ZABBIX SIA">
+ <script type="text/javascript" src="js/common.js"></script>
</head>
<body onLoad="zbxCallPostScripts();">
<?php
diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php
index fffc4573..a2956927 100644
--- a/frontends/php/include/triggers.inc.php
+++ b/frontends/php/include/triggers.inc.php
@@ -1095,7 +1095,7 @@
$group_where = ' where';
}
- $result=DBselect('select distinct t.description,t.value,t.priority,t.lastchange,h.hostid,h.host'.
+ $result=DBselect('select distinct t.triggerid,t.description,t.value,t.priority,t.lastchange,h.hostid,h.host'.
' from hosts h,items i,triggers t, functions f '.$group_where.
' h.status='.HOST_STATUS_MONITORED.' and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid'.
' and h.hostid in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, null, null, $nodeid).') '.
@@ -1107,6 +1107,8 @@
{
$hosts[$row['host']] = $row['host'];
$triggers[$row['description']][$row['host']] = array(
+ 'hostid' => $row['hostid'],
+ 'triggerid' => $row['triggerid'],
'value' => $row['value'],
'lastchange' => $row['lastchange'],
'priority' => $row['priority']);
@@ -1130,6 +1132,7 @@
foreach($hosts as $hostname)
{
$style = NULL;
+ unset($tr_ov_menu);
if(isset($trhosts[$hostname]))
{
switch($trhosts[$hostname]['value'])
@@ -1143,10 +1146,82 @@
$style = 'unknown_trigger';
}
- if((time(NULL)-$trhosts[$hostname]['lastchange'])<300) $style .= '_blink1';
- elseif((time(NULL)-$trhosts[$hostname]['lastchange'])<900) $style .= '_blink2';
+ if((time(NULL)-$trhosts[$hostname]['lastchange'])<300)
+ $style_img = 'background-image: url(images/gradients/blink1.gif); '.
+ 'background-position: top left; '.
+ 'background-repeat: repeate;';
+ elseif((time(NULL)-$trhosts[$hostname]['lastchange'])<900)
+ $style_img = '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'))
+ );
+
+ $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'])
+ {
+ 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).'...';
+
+ $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']);
+ }
+
+ unset($item_menu);
+ }
+
+ $status_col = new CCol(SPACE,$style);
+ if(isset($style_img))
+ $status_col->AddOption('style', $style_img);
+
+ if(isset($tr_ov_menu))
+ {
+ $tr_ov_menu = new CPUMenu($tr_ov_menu,170);
+ $status_col->OnClick($tr_ov_menu->GetOnActionJS());
}
- array_push($table_row,new CCol(SPACE,$style));
+ array_push($table_row,$status_col);
}
$table->AddRow($table_row);
}