summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2003-08-15 14:08:47 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2003-08-15 14:08:47 +0000
commit345f9a1860e018a1395d5b52bef54437148039e2 (patch)
treee91be9fa4e4dc503b4ec882f41394d5a70002d34
parent0dd6639c30456074235350b28d0577add6fbdb43 (diff)
downloadzabbix-345f9a1860e018a1395d5b52bef54437148039e2.tar.gz
zabbix-345f9a1860e018a1395d5b52bef54437148039e2.tar.xz
zabbix-345f9a1860e018a1395d5b52bef54437148039e2.zip
Major rewrite of screen handling code.
git-svn-id: svn://svn.zabbix.com/trunk@918 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--ChangeLog4
-rw-r--r--TODO5
-rw-r--r--create/mysql/schema.sql18
-rw-r--r--create/postgresql/schema.sql18
-rw-r--r--frontends/php/include/config.inc.php4
-rw-r--r--frontends/php/screenedit.php78
-rw-r--r--frontends/php/screens.php28
-rw-r--r--upgrades/dbpatches/1.0beta9_to_1.0beta10/mysql/patch.sql18
-rw-r--r--upgrades/dbpatches/1.0beta9_to_1.0beta10/postgresql/patch.sql21
9 files changed, 55 insertions, 139 deletions
diff --git a/ChangeLog b/ChangeLog
index e83efeba..7a89be7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
Changes for 1.0beta10:
+ - removed column graphid from table screens_items (Alexei)
+ - added columns resource and resourceid to table screens_items
+ (Alexei)
- non breakable space in PHP forms (Alexei)
- new draw type for graphs: Dot (Alexei)
- improved media maintenance form (Alexei)
@@ -44,7 +47,6 @@ Changes for 1.0beta10:
- added check for kstat library for ./configure (Alexei)
- added support for zabbix[queue] (Alexei)
- added basic support for simple graphs in screens (Alexei)
- - added table screens_graphs (Alexei)
- dynamic form hosts.php (Alexei)
- fixed 'make clean' under Solaris (rm -fv -> rm -f) (Alexei)
- link map's connector to a trigger
diff --git a/TODO b/TODO
index 7cf74c81..66f89b6d 100644
--- a/TODO
+++ b/TODO
@@ -1,10 +1,9 @@
1.0beta10:
- - add &nbsp; to forms and other places
- - fix evaluation of trigger expressions
+ - test screenedit
+ - fix form 'edit actions'
- fix pinger
- finish src/zabbix_snmptrapper
- - fix PostgreSQL schema
- improve screens (add maps, all in one table, etc)
- links to Zabbix frontend in alert emails
diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql
index 5c224dcd..d2635c25 100644
--- a/create/mysql/schema.sql
+++ b/create/mysql/schema.sql
@@ -490,7 +490,8 @@ CREATE TABLE screens (
CREATE TABLE screens_items (
screenitemid int(4) NOT NULL auto_increment,
screenid int(4) DEFAULT '0' NOT NULL,
- graphid int(4) DEFAULT '0' NOT NULL,
+ resource int(4) DEFAULT '0' NOT NULL,
+ resourceid int(4) DEFAULT '0' NOT NULL,
width int(4) DEFAULT '320' NOT NULL,
height int(4) DEFAULT '200' NOT NULL,
x int(4) DEFAULT '0' NOT NULL,
@@ -499,21 +500,6 @@ CREATE TABLE screens_items (
) TYPE=InnoDB;
--
--- Table structure for table 'screens_graphs'
---
-
-CREATE TABLE screens_graphs (
- screengraphid int(4) NOT NULL auto_increment,
- screenid int(4) DEFAULT '0' NOT NULL,
- itemid int(4) DEFAULT '0' NOT NULL,
- width int(4) DEFAULT '320' NOT NULL,
- height int(4) DEFAULT '200' NOT NULL,
- x int(4) DEFAULT '0' NOT NULL,
- y int(4) DEFAULT '0' NOT NULL,
- PRIMARY KEY (screengraphid)
-) TYPE=InnoDB;
-
---
-- Table structure for table 'stats'
--
diff --git a/create/postgresql/schema.sql b/create/postgresql/schema.sql
index dcd40c6e..96273b11 100644
--- a/create/postgresql/schema.sql
+++ b/create/postgresql/schema.sql
@@ -501,7 +501,8 @@ CREATE TABLE screens (
CREATE TABLE screens_items (
screenitemid serial,
screenid int4 DEFAULT '0' NOT NULL,
- graphid int4 DEFAULT '0' NOT NULL,
+ resource int4 DEFAULT '0' NOT NULL,
+ resourceid int4 DEFAULT '0' NOT NULL,
width int4 DEFAULT '320' NOT NULL,
height int4 DEFAULT '200' NOT NULL,
x int4 DEFAULT '0' NOT NULL,
@@ -510,21 +511,6 @@ CREATE TABLE screens_items (
);
--
--- Table structure for table 'screens_graphs'
---
-
-CREATE TABLE screens_graphs (
- screengraphid serial,
- screenid int4 DEFAULT '0' NOT NULL,
- itemid int4 DEFAULT '0' NOT NULL,
- width int4 DEFAULT '320' NOT NULL,
- height int4 DEFAULT '200' NOT NULL,
- x int4 DEFAULT '0' NOT NULL,
- y int4 DEFAULT '0' NOT NULL,
- PRIMARY KEY (screengraphid)
-);
-
---
-- Table structure for table 'stats'
--
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index a4809b67..3e018b4d 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -4310,11 +4310,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
return DBexecute($sql);
}
- function add_screen_item($screenid,$x,$y,$graphid,$width,$height)
+ function add_screen_item($resource,$screenid,$x,$y,$resourceid,$width,$height)
{
$sql="delete from screens_items where screenid=$screenid and x=$x and y=$y";
DBexecute($sql);
- $sql="insert into screens_items (screenid,x,y,graphid,width,height) values ($screenid,$x,$y,$graphid,$width,$height)";
+ $sql="insert into screens_items (resource,screenid,x,y,resourceid,width,height) values ($resource,$screenid,$x,$y,$resourceid,$width,$height)";
return DBexecute($sql);
}
diff --git a/frontends/php/screenedit.php b/frontends/php/screenedit.php
index 1e314c4c..18493884 100644
--- a/frontends/php/screenedit.php
+++ b/frontends/php/screenedit.php
@@ -49,14 +49,7 @@
// delete_screen_item($HTTP_GET_VARS["screenitemid"]);
// unset($HTTP_GET_VARS["screenitemid"]);
// }
- if($HTTP_GET_VARS["resource"]==0)
- {
- $result=add_screen_graph($HTTP_GET_VARS["screenid"],$HTTP_GET_VARS["x"],$HTTP_GET_VARS["y"],$HTTP_GET_VARS["itemid"],$HTTP_GET_VARS["width"],$HTTP_GET_VARS["height"]);
- }
- if($HTTP_GET_VARS["resource"]==1)
- {
- $result=add_screen_item($HTTP_GET_VARS["screenid"],$HTTP_GET_VARS["x"],$HTTP_GET_VARS["y"],$HTTP_GET_VARS["graphid"],$HTTP_GET_VARS["width"],$HTTP_GET_VARS["height"]);
- }
+ $result=add_screen_item($HTTP_GET_VARS["resource"],$HTTP_GET_VARS["screenid"],$HTTP_GET_VARS["x"],$HTTP_GET_VARS["y"],$HTTP_GET_VARS["resourceid"],$HTTP_GET_VARS["width"],$HTTP_GET_VARS["height"]);
unset($HTTP_GET_VARS["x"]);
show_messages($result,"Item added","Cannot add item");
}
@@ -97,10 +90,8 @@
{
$screenitemid=0;
- $screengraphid=0;
- $graphid=0;
- $sysmapid=0;
- $itemid=0;
+ $resource=0;
+ $resourceid=0;
$width=500;
$height=100;
$resource=@iif(isset($HTTP_GET_VARS["resource"]),$HTTP_GET_VARS["resource"],0);
@@ -109,26 +100,15 @@
$iresult=DBSelect("select * from screens_items where screenid=$screenid and x=$c and y=$r");
if(DBnum_rows($iresult)>0)
{
- $resource=1;
$irow=DBfetch($iresult);
$screenitemid=$irow["screenitemid"];
- $graphid=$irow["graphid"];
+ $resource=$irow["resource"];
+ $resourceid=$irow["resourceid"];
$width=$irow["width"];
$height=$irow["height"];
$found=1;
}
- $iresult=DBSelect("select * from screens_graphs where screenid=$screenid and x=$c and y=$r");
- if(DBnum_rows($iresult)>0)
- {
- $resource=0;
- $irow=DBfetch($iresult);
- $screengraphid=$irow["screengraphid"];
- $itemid=$irow["itemid"];
- $width=$irow["width"];
- $height=$irow["height"];
- }
-
if(isset($HTTP_GET_VARS["x"])&&($HTTP_GET_VARS["x"]==$c)&&($HTTP_GET_VARS["y"]==$r))
{
show_table2_header_begin();
@@ -137,63 +117,51 @@
echo "<input name=\"screenid\" type=\"hidden\" value=$screenid>";
echo "<input name=\"x\" type=\"hidden\" value=$c>";
echo "<input name=\"y\" type=\"hidden\" value=$r>";
- echo "<input name=\"screenitemid\" type=\"hidden\" value=$screenitemid>";
- echo "<input name=\"screengraphid\" type=\"hidden\" value=$screengraphid>";
- echo "<input name=\"resource\" type=\"hidden\" value=$resource>";
+// echo "<input name=\"resourceid\" type=\"hidden\" value=$resourceid>";
+// echo "<input name=\"resource\" type=\"hidden\" value='$resource'>";
show_table2_v_delimiter();
echo "Resource";
show_table2_h_delimiter();
echo "<select name=\"resource\" size=1 onChange=\"submit()\">";
- echo "<OPTION VALUE='0' ".iif($resource==0,"selected","").">Simple graph";
- echo "<OPTION VALUE='1' ".iif($resource==1,"selected","").">Graph";
-// echo "<OPTION VALUE='2' ".iif($resource==2,"selected","").">Network map";
+ echo "<OPTION VALUE='1' ".iif($resource==1,"selected","").">Simple graph";
+ echo "<OPTION VALUE='0' ".iif($resource==0,"selected","").">Graph";
echo "</SELECT>";
- if($resource == 0)
+ if($resource == 1)
{
show_table2_v_delimiter();
echo nbsp("Graph name");
show_table2_h_delimiter();
$result=DBselect("select h.host,i.description,i.itemid from hosts h,items i where h.hostid=i.hostid and h.status in (0,2) and i.status=0 order by h.host,i.description");
- echo "<select name=\"itemid\" size=1>";
+ echo "<select name=\"resourceid\" size=1>";
echo "<OPTION VALUE='0'>(none)";
for($i=0;$i<DBnum_rows($result);$i++)
{
$host_=DBget_field($result,$i,0);
$description_=DBget_field($result,$i,1);
$itemid_=DBget_field($result,$i,2);
- echo "<OPTION VALUE='$itemid_' ".iif($itemid==$itemid_,"selected","")."'>$host_: $description_";
+ echo "<OPTION VALUE='$itemid_' ".iif($resourceid==$itemid_,"selected","")."'>$host_: $description_";
}
echo "</SELECT>";
}
- else
- {
- echo "<input class=\"biginput\" name=\"itemid\" type=\"hidden\" size=1 value=\"$itemid\">";
- }
-
- if($resource == 1)
+ else if($resource == 0)
{
show_table2_v_delimiter();
echo nbsp("Graph name");
show_table2_h_delimiter();
$result=DBselect("select graphid,name from graphs order by name");
- echo "<select name=\"graphid\" size=1>";
+ echo "<select name=\"resourceid\" size=1>";
echo "<OPTION VALUE='0'>(none)";
for($i=0;$i<DBnum_rows($result);$i++)
{
$name_=DBget_field($result,$i,1);
$graphid_=DBget_field($result,$i,0);
- echo "<OPTION VALUE='$graphid_' ".iif($graphid==$graphid_,"selected","").">$name_";
+ echo "<OPTION VALUE='$graphid_' ".iif($resourceid==$graphid_,"selected","").">$name_";
}
echo "</SELECT>";
}
- else
- {
- echo "<input class=\"biginput\" name=\"graphid\" type=\"hidden\" size=1 value=\"$graphid\">";
- }
-
- if($resource == 2)
+ else if($resource == 2)
{
show_table2_v_delimiter();
echo "Map";
@@ -205,13 +173,13 @@
{
$name_=DBget_field($result,$i,1);
$sysmapid_=DBget_field($result,$i,0);
- echo "<OPTION VALUE='$sysmapid_' ".iif($sysmapid==$sysmapid_,"selected","").">$name_";
+ echo "<OPTION VALUE='$sysmapid_' ".iif($resourceid==$sysmapid_,"selected","").">$name_";
}
echo "</SELECT>";
}
else
{
- echo "<input class=\"biginput\" name=\"sysmapid\" type=\"hidden\" size=1 value=\"$sysmapid\">";
+ echo "<input class=\"biginput\" name=\"resourceid\" type=\"hidden\" size=1 value=\"$resourceid\">";
}
if($resource!=2)
@@ -233,7 +201,7 @@
show_table2_v_delimiter2();
echo "<input type=\"submit\" name=\"register\" value=\"add\">";
- if(($screenitemid!=0)||($screengraphid!=0))
+ if($resourceid!=0)
{
echo "<input type=\"submit\" name=\"register\" value=\"update\">";
}
@@ -241,13 +209,13 @@
show_table2_header_end();
}
- else if($graphid!=0)
+ else if( ($screenitemid!=0) && ($resource==0) )
{
- echo "<a href=screenedit.php?register=edit&screenid=$screenid&x=$c&y=$r><img src='chart2.php?graphid=$graphid&width=$width&height=$height&period=3600' border=0></a>";
+ echo "<a href=screenedit.php?register=edit&screenid=$screenid&x=$c&y=$r><img src='chart2.php?graphid=$resourceid&width=$width&height=$height&period=3600' border=0></a>";
}
- else if($itemid!=0)
+ else if( ($screenitemid!=0) && ($resource==1) )
{
- echo "<a href=screenedit.php?register=edit&screenid=$screenid&x=$c&y=$r><img src='chart.php?itemid=$itemid&width=$width&height=$height&period=3600' border=0></a>";
+ echo "<a href=screenedit.php?register=edit&screenid=$screenid&x=$c&y=$r><img src='chart.php?itemid=$resourceid&width=$width&height=$height&period=3600' border=0></a>";
}
else
{
diff --git a/frontends/php/screens.php b/frontends/php/screens.php
index 38605b64..d7063ab6 100644
--- a/frontends/php/screens.php
+++ b/frontends/php/screens.php
@@ -119,28 +119,22 @@
{
$irow=DBfetch($iresult);
$screenitemid=$irow["screenitemid"];
- $graphid=$irow["graphid"];
- $width=$irow["width"];
- $height=$irow["height"];
- }
- $sql="select * from screens_graphs where screenid=$screenid and x=$c and y=$r";
- $iresult=DBSelect($sql);
- if(DBnum_rows($iresult)>0)
- {
- $irow=DBfetch($iresult);
- $screengraphid=$irow["screengraphid"];
- $itemid=$irow["itemid"];
+ $resource=$irow["resource"];
+ $resourceid=$irow["resourceid"];
$width=$irow["width"];
$height=$irow["height"];
}
- if($graphid!=0)
+ if($resourceid!=0)
{
- echo "<a href=charts.php?graphid=$graphid><img src='chart2.php?graphid=$graphid&width=$width&height=$height&period=3600&noborder=1' border=0></a>";
- }
- if($itemid!=0)
- {
- echo "<a href=history.php?action=showhistory&itemid=$itemid><img src='chart.php?itemid=$itemid&width=$width&height=$height&period=3600&noborder=1' border=0></a>";
+ if($resource == 0)
+ {
+ echo "<a href=charts.php?graphid=$resourceid><img src='chart2.php?graphid=$resourceid&width=$width&height=$height&period=3600&noborder=1' border=0></a>";
+ }
+ else if($resource == 1)
+ {
+ echo "<a href=history.php?action=showhistory&itemid=$resourceid><img src='chart.php?itemid=$resourceid&width=$width&height=$height&period=3600&noborder=1' border=0></a>";
+ }
}
echo "</form>\n";
echo "</TD>";
diff --git a/upgrades/dbpatches/1.0beta9_to_1.0beta10/mysql/patch.sql b/upgrades/dbpatches/1.0beta9_to_1.0beta10/mysql/patch.sql
index 57f0baf4..73bc1de9 100644
--- a/upgrades/dbpatches/1.0beta9_to_1.0beta10/mysql/patch.sql
+++ b/upgrades/dbpatches/1.0beta9_to_1.0beta10/mysql/patch.sql
@@ -28,18 +28,8 @@ CREATE TABLE stats (
PRIMARY KEY (itemid,year,month,day,hour)
) type=InnoDB;
---
--- Table structure for table 'screens_graphs'
---
-
-CREATE TABLE screens_graphs (
- screengraphid int(4) NOT NULL auto_increment,
- screenid int(4) DEFAULT '0' NOT NULL,
- itemid int(4) DEFAULT '0' NOT NULL,
- width int(4) DEFAULT '320' NOT NULL,
- height int(4) DEFAULT '200' NOT NULL,
- x int(4) DEFAULT '0' NOT NULL,
- y int(4) DEFAULT '0' NOT NULL,
- PRIMARY KEY (screengraphid)
-) TYPE=InnoDB;
+alter table screens_items add resource int(4) DEFAULT '0' NOT NULL;
+alter table screens_items add resourceid int(4) DEFAULT '0' NOT NULL;
+update screens_items set resourceid=graphid, resource=0;
+alter table screens_items drop graphid;
diff --git a/upgrades/dbpatches/1.0beta9_to_1.0beta10/postgresql/patch.sql b/upgrades/dbpatches/1.0beta9_to_1.0beta10/postgresql/patch.sql
index 01b8a130..e69a487a 100644
--- a/upgrades/dbpatches/1.0beta9_to_1.0beta10/postgresql/patch.sql
+++ b/upgrades/dbpatches/1.0beta9_to_1.0beta10/postgresql/patch.sql
@@ -34,18 +34,9 @@ CREATE TABLE stats (
PRIMARY KEY (itemid,year,month,day,hour)
);
---
--- Table structure for table 'screens_graphs'
---
-
-CREATE TABLE screens_graphs (
- screengraphid serial,
- screenid int4 DEFAULT '0' NOT NULL,
- itemid int4 DEFAULT '0' NOT NULL,
- width int4 DEFAULT '320' NOT NULL,
- height int4 DEFAULT '200' NOT NULL,
- x int4 DEFAULT '0' NOT NULL,
- y int4 DEFAULT '0' NOT NULL,
- PRIMARY KEY (screengraphid)
-);
-
+alter table screens_items add resourceid int4;
+alter table screens_items alter resourceid set default '0';
+alter table screens_items add resource int4;
+alter table screens_items alter resource set default '0';
+update screens_items set resourceid=graphid, resource=0;
+alter table screens_items drop graphid;