New page: Parameter classes administration.
authorarjen <arjen>
Sat, 4 Jun 2005 07:22:40 +0000 (07:22 +0000)
committerarjen <arjen>
Sat, 4 Jun 2005 07:22:40 +0000 (07:22 +0000)
src/web/classes.php [new file with mode: 0644]
src/web/menu.html

diff --git a/src/web/classes.php b/src/web/classes.php
new file mode 100644 (file)
index 0000000..d481649
--- /dev/null
@@ -0,0 +1,234 @@
+<?php 
+
+/**************************************************************************
+**  (c) Copyright 2003, Andromeda Technology & Automation
+** This is free software; you can redistribute it and/or modify it under the
+** terms of the GNU General Public License, see the file COPYING.
+***************************************************************************
+** MODULE INFORMATION *
+***********************
+**      FILE NAME      : classes.php
+**      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
+**      VERSION NUMBER : $Revision: 1.1 $
+**
+**  DESCRIPTION      :  Parameter classes Administration page.
+**                      Input parameters: action (POST) : empty, 'Create'
+**                            classname (POST) : short name of the class to create or remove
+**
+**  EXPORTED OBJECTS : 
+**  LOCAL    OBJECTS : 
+**  MODULES  USED    :
+***************************************************************************
+**  ADMINISTRATIVE INFORMATION *
+********************************
+**      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
+**      CREATION DATE   : Aug 04, 2003
+**      LAST UPDATE     : Aug 28, 2003
+**      MODIFICATIONS   : 
+**************************************************************************/
+
+/*****************************
+   $Log: classes.php,v $
+   Revision 1.1  2005-06-04 07:22:40  arjen
+   New page: Parameter classes administration.
+
+
+******************************/
+
+// RCSID = "$Id: classes.php,v 1.1 2005-06-04 07:22:40 arjen Exp $";
+
+ini_set('include_path', '.:./classes:../phpclasses');
+
+require_once('page.class.php');
+
+function clientscripts()
+{
+
+?>
+
+<script language='JavaScript'>
+
+function CheckCreate(f)
+{
+   if (f.classname.value == "")
+   {
+      alert("You must supply a class name");
+      return false;
+   }
+
+   if (f.propname.value == "")
+   {
+      alert("You must supply a property name");
+      return false;
+   }
+   return true;
+}
+
+function CheckRemove(f)
+{
+   var message = "Are you sure you want to remove property ";
+   message += f.propname.value;
+   message += " of class ";
+   message += f.classname.value;
+   message += " ?";
+
+   return confirm(message);
+}
+
+</script>
+
+<?php
+}
+
+class class_page extends page
+{
+
+   function Body()
+   {
+
+   clientscripts();
+
+   if (isset($_POST['action']) && $_POST['action'] == 'Create'
+       && !empty($_POST['classname']) && !empty($_POST['propname']))
+   {
+      pg_exec($this->database, "INSERT INTO parameter_class
+                       (name, property_name, property_type, notify) VALUES ('"
+                     . $_POST['classname'] . "','" . $_POST['propname'] . "','STATIC', 'true')");
+   }
+
+   if (isset($_POST['action']) && $_POST['action'] == 'Remove'
+       && !empty($_POST['classname']) && !empty($_POST['propname']))
+   {
+      pg_exec($this->database, "DELETE FROM parameter_class WHERE name='"
+                                . $_POST['classname'] . "' AND property_name='" . $_POST['propname'] . "'");
+   }
+
+   if (isset($_GET['classname']) && isset($_GET['propname']))
+   {
+      echo "<h1>Detailed information for property " . $_GET['propname']
+           . " of class " . $_GET['classname'] . "</h1><br>\n";
+
+      if (isset($_POST['action']) && $_POST['action'] == 'Save Changes')
+      {
+         $notify = 'f';
+         if (!empty($_POST['notify']) && $_POST['notify'] == 'on')
+         {
+            $notify='t';
+         }
+         $qry = "UPDATE parameter_class SET description='" . $_POST['description'] . "'";
+         $qry .= ", property_type='" . $_POST['proptype'] . "'";
+         $qry .= ", notify='" . $notify . "'";
+         if (isset($_POST['min']))
+         {
+            $qry .= ", min='" . $_POST['min'] . "'";
+         }
+         if (isset($_POST['max']))
+         {
+            $qry .= ", max='" . $_POST['max'] . "'";
+         }
+         $qry .= " WHERE name='" . $_GET['classname'] . "'";
+         $qry .= " AND property_name='" . $_GET['propname'] . "'";
+
+         echo $qry . "<br>";
+         pg_exec($this->database, $qry);
+         echo pg_errormessage($this->database) . "<br>";
+         print_r($_POST);
+      }
+
+      $res = pg_exec($this->database, "SELECT * FROM parameter_class
+                                       WHERE name='" . $_GET['classname']
+                                    . "' AND property_name='" . $_GET['propname'] . "'");
+      $cls = pg_fetch_object($res, 0);
+
+      echo "<form action='classes.php?classname=" . $cls->name . "&propname=" . $cls->property_name . "' method='POST'>";
+      echo "<table>";
+
+      echo "<tr><td>Description</td><td><input name='description' type='text' value='";
+      echo $cls->description . "'></td></tr>";
+
+      echo "<tr><td>Property type</td><td><input name='proptype' type='radio' value='STATIC'";
+      if ($cls->property_type == "STATIC")
+      {
+         echo " checked='true'";
+      }
+      echo ">STATIC<br><input name='proptype' type='radio' value='DYNAMIC'";
+      if ($cls->property_type == "DYNAMIC")
+      {
+         echo " checked='true'";
+      }
+      echo ">DYNAMIC</td></tr>";
+
+      echo "<tr><td>Notify Changes</td><td><input type='checkbox' name='notify'";
+      if ($cls->notify == 't')
+      {
+         echo " checked='true'";
+      }
+      echo "></td></tr>";
+      if ($cls->property_type == "DYNAMIC")
+      {
+         echo "<tr><td>Default minimum</td><td><input type='text' name='min' value='";
+         echo $cls->min;
+         echo "'></td></tr>";
+         echo "<tr><td>Default maximum</td><td><input type='text' name='max' value='";
+         echo $cls->max;
+         echo "'></td></tr>";
+      }
+      echo "</table>";
+      echo "<input type='submit' name='action' value='Save Changes'>";
+      echo "</form>";
+   }
+   else
+   {
+   echo "<h1>Parameter Classes Administration</h1><hr>";
+
+   $res = pg_exec($this->database, "SELECT name, property_name, description FROM parameter_class
+                                    ORDER BY name, property_name");
+
+   echo "<table>";
+   echo "<tr><th>Class</th><th>Property</th><th>Description</th><tr>";
+   $cls = 0;
+   while ($cls < pg_numrows($res))
+   {
+      $u = pg_fetch_object($res, $cls);
+      ?>
+      <tr><td align='center'><a href='classes.php?classname=<?php echo $u->name?>&propname=<?php echo $u->property_name ?>'><img src='change.png'></a><br>
+             <b><?php echo $u->name ?></b>
+      </td><td>
+         <?php echo $u->property_name ?>
+      </td><td>
+         <?php echo $u->description ?>
+      </td><td>
+          <form action='classes.php' method='post' onSubmit='return CheckRemove(this)'>
+              <input type='hidden' name='classname' value='<?php echo $u->name ?>'>
+              <input type='hidden' name='propname' value='<?php echo $u->property_name ?>'>
+              <input type='submit' name='action' value='Remove'>
+          </form>
+      </td></tr>
+      <?php
+      $cls++;
+   }
+   echo "</table>";
+
+?>
+
+<h2>Create new parameter class property:</h2>
+<p>
+
+<form action='classes.php' method='post' onSubmit='return CheckCreate(this)'>
+Class name: <input name='classname' type='text'>
+Property name: <input name='propname' type='text'>
+<br>
+<input type='submit' name='action' value='Create'>
+</form>
+</p>
+
+<?php
+   }
+   }
+}
+
+$page = new class_page("Gnucomo Parameter Classes Administration");
+
+$page->Showpage();
+
+?>
index 6b80d44..7443d80 100644 (file)
@@ -9,6 +9,7 @@
    <a href='objects.php' target='main'><img src='server.png' alt='Objects'></a>
    <a href='users.php' target='main'><img src='user.png' alt='Users'></a>
    <a href='services.php' target='main'><img src='service.png' alt='Services'></a>
+   <a href='classes.php' target='main'><img src='change.png' alt='Classes'></a>
    <a href='logout.php' target='main'><img src='exit.png' alt='Logout'></a>
    <hr>