summaryrefslogtreecommitdiffstats
path: root/frontends/php/graphs.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-02-06 16:03:03 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-02-06 16:03:03 +0000
commitb6505a882597eee385998b6c0f07ab4512121b5e (patch)
tree88aef031e60598f93bd56727ee9c8e4d2dc00e20 /frontends/php/graphs.php
parent20e8946a7fe9ca6c7a615f20198e5e01fc4bd1c2 (diff)
downloadzabbix-b6505a882597eee385998b6c0f07ab4512121b5e.tar.gz
zabbix-b6505a882597eee385998b6c0f07ab4512121b5e.tar.xz
zabbix-b6505a882597eee385998b6c0f07ab4512121b5e.zip
- Frontend improvements (Eugene)
+ Configuration -> Graphs (finished) git-svn-id: svn://svn.zabbix.com/trunk@2612 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/graphs.php')
-rw-r--r--frontends/php/graphs.php284
1 files changed, 157 insertions, 127 deletions
diff --git a/frontends/php/graphs.php b/frontends/php/graphs.php
index aecac3c8..361b6b72 100644
--- a/frontends/php/graphs.php
+++ b/frontends/php/graphs.php
@@ -31,6 +31,31 @@
echo BR;
?>
<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "groupid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL),
+ "hostid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL),
+
+ "graphid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, '{form}=="update"'),
+ "name"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'),
+ "width"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535), 'isset({save})'),
+ "height"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535), 'isset({save})'),
+ "yaxistype"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), 'isset({save})'),
+ "yaxismin"=> array(T_ZBX_DBL, O_OPT, NULL, BETWEEN(-65535,65535), 'isset({save})'),
+ "yaxismax"=> array(T_ZBX_DBL, O_OPT, NULL, BETWEEN(-65535,65535), 'isset({save})'),
+
+/* actions */
+ "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+/* other */
+ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+ "form_refresh"=> array(T_ZBX_INT, O_OPT, NULL, NULL, NULL)
+ );
+
+ check_fields($fields);
+?>
+<?php
if(!check_anyright("Graph","U"))
{
show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
@@ -39,33 +64,25 @@
}
$_REQUEST["hostid"]=get_request("hostid",get_profile("web.latest.hostid",0));
+ $_REQUEST["groupid"]=get_request("groupid",get_profile("web.latest.groupid",0));
update_profile("web.latest.hostid",$_REQUEST["hostid"]);
+ update_profile("web.latest.groupid",$_REQUEST["groupid"]);
update_profile("web.menu.config.last",$page["file"]);
?>
<?php
- if(isset($_REQUEST["register"]))
+ if(isset($_REQUEST["save"]))
{
- if($_REQUEST["register"]=="add")
+ if(isset($_REQUEST["graphid"]))
{
- $result=add_graph($_REQUEST["name"],$_REQUEST["width"],$_REQUEST["height"],
+ update_graph_from_templates($_REQUEST["graphid"],
+ $_REQUEST["name"],$_REQUEST["width"],$_REQUEST["height"],
+ $_REQUEST["yaxistype"], $_REQUEST["yaxismin"],$_REQUEST["yaxismax"]);
+
+ $result=update_graph($_REQUEST["graphid"],
+ $_REQUEST["name"],$_REQUEST["width"],$_REQUEST["height"],
$_REQUEST["yaxistype"],$_REQUEST["yaxismin"],$_REQUEST["yaxismax"]);
- if($result)
- {
- add_audit(AUDIT_ACTION_ADD,AUDIT_RESOURCE_GRAPH,
- "Graph [".zbx_ads($_REQUEST["name"])."]");
- }
- show_messages($result, S_GRAPH_ADDED, S_CANNOT_ADD_GRAPH);
- }
- if($_REQUEST["register"]=="update")
- {
- update_graph_from_templates($_REQUEST["graphid"],$_REQUEST["name"],
- $_REQUEST["width"],$_REQUEST["height"],$_REQUEST["yaxistype"],
- $_REQUEST["yaxismin"],$_REQUEST["yaxismax"]);
- $result=update_graph($_REQUEST["graphid"],$_REQUEST["name"],$_REQUEST["width"],
- $_REQUEST["height"],$_REQUEST["yaxistype"],$_REQUEST["yaxismin"],
- $_REQUEST["yaxismax"]);
if($result)
{
add_audit(AUDIT_ACTION_ADD,AUDIT_RESOURCE_GRAPH,
@@ -74,140 +91,153 @@
}
show_messages($result, S_GRAPH_UPDATED, S_CANNOT_UPDATE_GRAPH);
}
- if($_REQUEST["register"]=="delete")
+ else
{
- delete_graph_from_templates($_REQUEST["graphid"]);
- $graph=get_graph_by_graphid($_REQUEST["graphid"]);
- $result=delete_graph($_REQUEST["graphid"]);
+ $result=add_graph($_REQUEST["name"],$_REQUEST["width"],$_REQUEST["height"],
+ $_REQUEST["yaxistype"],$_REQUEST["yaxismin"],$_REQUEST["yaxismax"]);
if($result)
{
- add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_GRAPH,
- "Graph [".zbx_ads($graph["name"])."]");
+ add_audit(AUDIT_ACTION_ADD,AUDIT_RESOURCE_GRAPH,
+ "Graph [".zbx_ads($_REQUEST["name"])."]");
}
- show_messages($result, S_GRAPH_DELETED, S_CANNOT_DELETE_GRAPH);
- unset($_REQUEST["graphid"]);
+ show_messages($result, S_GRAPH_ADDED, S_CANNOT_ADD_GRAPH);
+ }
+ if($result){
+ unset($_REQUEST["form"]);
}
}
-?>
-<?php
- if(isset($_REQUEST["groupid"])&&($_REQUEST["groupid"]==0))
- {
- unset($_REQUEST["groupid"]);
- }
-
- if(isset($_REQUEST["graphid"])&&($_REQUEST["graphid"]==0))
+ elseif(isset($_REQUEST["delete"])&&isset($_REQUEST["graphid"]))
{
- unset($_REQUEST["graphid"]);
+ delete_graph_from_templates($_REQUEST["graphid"]);
+ $graph=get_graph_by_graphid($_REQUEST["graphid"]);
+ $result=delete_graph($_REQUEST["graphid"]);
+ if($result)
+ {
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_GRAPH,
+ "Graph [".zbx_ads($graph["name"])."]");
+ unset($_REQUEST["form"]);
+ }
+ show_messages($result, S_GRAPH_DELETED, S_CANNOT_DELETE_GRAPH);
}
-
- if(isset($_REQUEST["graphid"]))
+?>
+<?php
+ if(isset($_REQUEST["form"]))
{
- $result=DBselect("select name from graphs where graphid=".$_REQUEST["graphid"]);
- $row=DBfetch($result);
- $graph=$row["name"];
- $h1=iif(isset($_REQUEST["fullscreen"]),
+ insert_graph_form();
+ } else {
+/* HEADER */
+ if(isset($_REQUEST["graphid"])&&($_REQUEST["graphid"]==0))
+ {
+ unset($_REQUEST["graphid"]);
+ }
+/*
+ if(isset($_REQUEST["graphid"]))
+ {
+ $result=DBselect("select name from graphs where graphid=".$_REQUEST["graphid"]);
+ $row=DBfetch($result);
+ $graph=$row["name"];
+ $h1=iif(isset($_REQUEST["fullscreen"]),
"<a href=\"charts.php?graphid=".$_REQUEST["graphid"]."\">".$graph."</a>",
"<a href=\"charts.php?graphid=".$_REQUEST["graphid"]."&fullscreen=1\">".$graph."</a>");
- }
- else
- {
- $h1=S_SELECT_GRAPH_TO_DISPLAY;
- }
-
- $h1=S_GRAPHS_BIG.nbsp(" / ").$h1;
+ }
+ else
+ {
+ $h1=S_SELECT_GRAPH_TO_DISPLAY;
+ }
- $h2=S_GROUP."&nbsp;";
- $h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
- $h2=$h2.form_select("groupid",0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups order by name");
- while($row=DBfetch($result))
- {
-// Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg".
- " where h.hostid=i.hostid and hg.groupid=".$row["groupid"].
- " and hg.hostid=h.hostid and h.status not in (".HOST_STATUS_DELETED.")".
- " group by h.hostid,h.host order by h.host");
- $cnt=0;
- while($row2=DBfetch($result2))
+ $h1=S_GRAPHS_BIG.nbsp(" / ").$h1;
+*/
+ $form = new CForm();
+ $form->AddItem(S_GROUP.SPACE);
+ $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
+ $cmbGroup->AddItem(0,S_ALL_SMALL);
+ $result=DBselect("select groupid,name from groups order by name");
+ while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row2["hostid"]))
+ // Check if at least one host with read permission exists for this group
+ $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg".
+ " where h.hostid=i.hostid and hg.groupid=".$row["groupid"].
+ " and hg.hostid=h.hostid and h.status not in (".HOST_STATUS_DELETED.")".
+ " group by h.hostid,h.host order by h.host");
+ while($row2=DBfetch($result2))
{
- continue;
+ if(!check_right("Host","R",$row2["hostid"]))
+ continue;
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
+ break;
}
- $cnt=1; break;
}
- if($cnt!=0)
+ $form->AddItem($cmbGroup);
+
+ $form->AddItem(SPACE.S_HOST.SPACE);
+
+ $cmbHosts = new CComboBox("hostid", $_REQUEST["hostid"], "submit()");
+ $cmbHosts->AddItem(0,S_ALL_SMALL);
+ if(isset($_REQUEST["groupid"]) && $_REQUEST["groupid"] > 0)
{
- $h2=$h2.form_select("groupid",$row["groupid"],$row["name"]);
+ $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg".
+ " where h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"].
+ " and hg.hostid=h.hostid"." and h.status not in (".HOST_STATUS_DELETED.")".
+ " group by h.hostid,h.host order by h.host";
}
- }
- $h2=$h2."</select>";
+ else
+ {
+ $sql="select h.hostid,h.host from hosts h,items i where h.hostid=i.hostid".
+ " and h.status not in (".HOST_STATUS_DELETED.") group by h.hostid,h.host".
+ " order by h.host";
+ }
+ $result=DBselect($sql);
+ while($row=DBfetch($result))
+ {
+ if(!check_right("Host","R",$row["hostid"])) continue;
+ $cmbHosts->AddItem($row["hostid"],$row["host"]);
+ }
+ $form->AddItem($cmbHosts);
- $h2=$h2."&nbsp;".S_HOST."&nbsp;";
- $h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
- $h2=$h2.form_select("hostid",0,S_SELECT_HOST_DOT_DOT_DOT);
+ $form->AddItem(SPACE."|".SPACE);
+ $form->AddItem(new CButton("form",S_CREATE_GRAPH));
- if(isset($_REQUEST["groupid"]))
- {
- $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg".
- " where h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid".
- " and h.status not in (".HOST_STATUS_DELETED.") group by h.hostid,h.host order by h.host";
- }
- else
- {
- $sql="select h.hostid,h.host from hosts h,items i where h.hostid=i.hostid".
- " and h.status not in (".HOST_STATUS_DELETED.") group by h.hostid,h.host order by h.host";
- }
+ show_header2(S_GRAPHS_BIG, $form);
- $result=DBselect($sql);
- while($row=DBfetch($result))
- {
- if(!check_right("Host","R",$row["hostid"])) continue;
- $h2=$h2.form_select("hostid",$row["hostid"],$row["host"]);
- }
- $h2=$h2."</select>";
+/* TABLE */
+ $table = new CTableInfo(S_NO_GRAPHS_DEFINED);
+ $table->setHeader(array(S_ID,S_NAME,S_WIDTH,S_HEIGHT,S_GRAPH));
- show_header2($h1,$h2,"<form name=\"form2\" method=\"get\" action=\"graphs.php\">","</form>");
-?>
-<?php
- $table = new CTableInfo(S_NO_GRAPHS_DEFINED);
- $table->setHeader(array(S_ID,S_NAME,S_WIDTH,S_HEIGHT,S_ACTIONS));
-
- if(isset($_REQUEST["hostid"])&&($_REQUEST["hostid"]!=0))
- {
- $result=DBselect("select distinct g.graphid,g.name,g.width,g.height from graphs g,items i".
- ",graphs_items gi where gi.itemid=i.itemid and g.graphid=gi.graphid".
- " and i.hostid=".$_REQUEST["hostid"]." order by g.name");
- }
- else
- {
- $result=DBselect("select distinct g.graphid,g.name,g.width,g.height".
- " from graphs g order by g.name");
- }
- while($row=DBfetch($result))
- {
- if(!check_right("Graph","U",$row["graphid"])) continue;
-
- if(!isset($_REQUEST["hostid"]))
+ if(isset($_REQUEST["hostid"])&&($_REQUEST["hostid"]!=0))
+ {
+ $result=DBselect("select distinct g.graphid,g.name,g.width,g.height from graphs g,items i".
+ ",graphs_items gi where gi.itemid=i.itemid and g.graphid=gi.graphid".
+ " and i.hostid=".$_REQUEST["hostid"]." order by g.name");
+ }
+ else
{
- $sql="select * from graphs_items where graphid=".$row["graphid"];
- $result2=DBselect($sql);
- if(DBnum_rows($result2)>0) continue;
+ $result=DBselect("select distinct g.graphid,g.name,g.width,g.height".
+ " from graphs g order by g.name");
}
-
- $table->addRow(array(
- $row["graphid"],
- new CLink($row["name"],"graph.php?graphid=".$row["graphid"]),
- $row["width"],
- $row["height"],
- new CLink("Change","graphs.php?graphid=".$row["graphid"])
- ));
+ while($row=DBfetch($result))
+ {
+ if(!check_right("Graph","U",$row["graphid"])) continue;
+
+ if(!isset($_REQUEST["hostid"]))
+ {
+ $sql="select * from graphs_items where graphid=".$row["graphid"];
+ $result2=DBselect($sql);
+ if(DBnum_rows($result2)>0) continue;
+ }
+
+ $table->AddRow(array(
+ $row["graphid"],
+ new CLink($row["name"],
+ "graphs.php?graphid=".$row["graphid"]."&form=update".
+ url_param("groupid").url_param("hostid"),'action'),
+ $row["width"],
+ $row["height"],
+ new CLink("Edit",
+ "graph.php?graphid=".$row["graphid"])
+ ));
+ }
+ $table->show();
}
- $table->show();
-?>
-<?php
- echo BR;
- insert_graph_form();
?>
<?php