summaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-06 15:34:26 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-06 15:34:26 +0000
commit07a5506c23fdad41781a7a9458c8bb5748f1619d (patch)
tree609701e4abe6020ef7d971d07a37a51bc5930d98 /frontends
parentfa076fa0fb007a382ab291a16a6645d4fb9e583c (diff)
downloadzabbix-07a5506c23fdad41781a7a9458c8bb5748f1619d.tar.gz
zabbix-07a5506c23fdad41781a7a9458c8bb5748f1619d.tar.xz
zabbix-07a5506c23fdad41781a7a9458c8bb5748f1619d.zip
added support of AND, OR, AND/OR calculation of action conditions [GUI] (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3876 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends')
-rw-r--r--frontends/php/actionconf.php5
-rw-r--r--frontends/php/css.css5
-rw-r--r--frontends/php/include/actions.inc.php10
-rw-r--r--frontends/php/include/defines.inc.php4
-rw-r--r--frontends/php/include/forms.inc.php71
-rw-r--r--frontends/php/include/locales/en_gb.inc.php6
6 files changed, 82 insertions, 19 deletions
diff --git a/frontends/php/actionconf.php b/frontends/php/actionconf.php
index 772b2b10..4e7395a0 100644
--- a/frontends/php/actionconf.php
+++ b/frontends/php/actionconf.php
@@ -49,6 +49,7 @@ include_once "include/page_header.php";
"scripts"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, '{actiontype}==1&&isset({save})'),
"repeat"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), 'isset({save})'),
"status"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), 'isset({save})'),
+ "evaltype"=> array(T_ZBX_INT, O_OPT, NULL, IN(ACTION_EVAL_TYPE_AND_OR.','.ACTION_EVAL_TYPE_AND.','.ACTION_EVAL_TYPE_OR), 'isset({save})'),
"maxrepeats"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'{repeat}==1&&isset({save})'),
"repeatdelay"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'{repeat}==1&&isset({save})'),
@@ -116,7 +117,7 @@ include_once "include/page_header.php";
$_REQUEST['actiontype'],$_REQUEST['userid'],
$_REQUEST["subject"], $_REQUEST["message"],$_REQUEST["recipient"],
$_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"],$_REQUEST["status"],
- $_REQUEST["scripts"]);
+ $_REQUEST["scripts"],$_REQUEST["evaltype"]);
show_messages($result,S_ACTION_UPDATED,S_CANNOT_UPDATE_ACTION);
} else {
@@ -127,7 +128,7 @@ include_once "include/page_header.php";
$_REQUEST['actiontype'],$_REQUEST['userid'],
$_REQUEST["subject"],$_REQUEST["message"],$_REQUEST["recipient"],
$_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"],$_REQUEST["status"],
- $_REQUEST["scripts"]);
+ $_REQUEST["scripts"],$_REQUEST["evaltype"]);
$result=$actionid;
show_messages($result,S_ACTION_ADDED,S_CANNOT_ADD_ACTION);
diff --git a/frontends/php/css.css b/frontends/php/css.css
index 322d4d57..940e2010 100644
--- a/frontends/php/css.css
+++ b/frontends/php/css.css
@@ -17,6 +17,11 @@ body
line-height:16px;
}
+table
+{
+ border-spacing: 0px; /* cellspacing */
+}
+
/**************** PAGE TABLE ****************/
/* header */
table.page_header
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php
index 7e5b70f4..68b8c84f 100644
--- a/frontends/php/include/actions.inc.php
+++ b/frontends/php/include/actions.inc.php
@@ -85,7 +85,7 @@
# Add Action
- function add_action($actiontype,$userid,$subject,$message,$recipient,$maxrepeats,$repeatdelay,$status,$scripts)
+ function add_action($actiontype,$userid,$subject,$message,$recipient,$maxrepeats,$repeatdelay,$status,$scripts,$evaltype)
{
// TODO check permission by new value.
@@ -102,8 +102,8 @@
}
$actionid=get_dbid("actions","actionid");
$sql="insert into actions (actionid,actiontype,userid,subject,message,recipient,".
- "maxrepeats,repeatdelay,status,scripts) values ($actionid,$actiontype,$userid,".zbx_dbstr($subject).",".
- zbx_dbstr($message).",$recipient,$maxrepeats,$repeatdelay,$status,".zbx_dbstr($scripts).")";
+ "maxrepeats,repeatdelay,status,scripts,evaltype) values ($actionid,$actiontype,$userid,".zbx_dbstr($subject).",".
+ zbx_dbstr($message).",$recipient,$maxrepeats,$repeatdelay,$status,".zbx_dbstr($scripts).",$evaltype)";
$result=DBexecute($sql);
if(!$result)
return $result;
@@ -112,7 +112,7 @@
# Update Action
- function update_action($actionid,$actiontype,$userid,$subject,$message,$recipient,$maxrepeats,$repeatdelay,$status,$scripts)
+ function update_action($actionid,$actiontype,$userid,$subject,$message,$recipient,$maxrepeats,$repeatdelay,$status,$scripts,$evaltype)
{
// TODO check permission by new value.
@@ -128,7 +128,7 @@
if(!check_commands($scripts)) return FALSE;
}
- $result=DBexecute("update actions set actiontype=$actiontype,userid=$userid,subject=".zbx_dbstr($subject).",message=".zbx_dbstr($message).",recipient=$recipient,maxrepeats=$maxrepeats, repeatdelay=$repeatdelay,status=$status,scripts=".zbx_dbstr($scripts)." where actionid=$actionid");
+ $result=DBexecute("update actions set actiontype=$actiontype,userid=$userid,subject=".zbx_dbstr($subject).",message=".zbx_dbstr($message).",recipient=$recipient,maxrepeats=$maxrepeats, repeatdelay=$repeatdelay,status=$status,scripts=".zbx_dbstr($scripts).",evaltype=$evaltype where actionid=$actionid");
return $result;
}
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index f576a745..76ab6bf0 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -195,6 +195,10 @@
define("ACTION_TYPE_MESSAGE",0);
define("ACTION_TYPE_COMMAND",1);
+ define("ACTION_EVAL_TYPE_AND_OR",0);
+ define("ACTION_EVAL_TYPE_AND",1);
+ define("ACTION_EVAL_TYPE_OR",2);
+
define("TRIGGER_STATUS_ENABLED",0);
define("TRIGGER_STATUS_DISABLED",1);
define("TRIGGER_STATUS_UNKNOWN",2);
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 963b88a2..8f002940 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -2542,6 +2542,7 @@
$repeatdelay = $action["repeatdelay"];
$status = $action["status"];
$scripts = $action["scripts"];
+ $evaltype = $action["evaltype"];
if(isset($_REQUEST["repeat"]))
{
@@ -2585,6 +2586,7 @@
$status = get_request("status",ACTION_STATUS_ENABLED);
$uid = get_request("userid",0);
$scripts = get_request("scripts","");
+ $evaltype = get_request("evaltype",ACTION_EVAL_TYPE_AND_OR);
}
@@ -2593,37 +2595,82 @@
$cmbActionType->AddItem(ACTION_TYPE_COMMAND,S_REMOTE_COMMAND);
$frmAction->AddRow(S_ACTION_TYPE, $cmbActionType);
+ $cmbSource = new CComboBox('source', $source);
+ $cmbSource->AddItem(0, S_TRIGGER);
+ $frmAction->AddRow(S_SOURCE, $cmbSource);
// prepare condition list
- $cond_el=array();
+ sort($conditions);
+
+ $grouped_conditions = array();
+ $cond_el = new CTable();
$i=0;
foreach($conditions as $val)
{
- array_push($cond_el,
- array(
+ $label = chr(65 + $i);
+ $cond_el->AddRow(array(
+ '('.$label.')',
new CCheckBox("rem_condition[]", 'no', null,$i),
get_condition_desc(
$val["type"],
$val["operator"],
$val["value"]
)
- ),
- BR);
+ ));
+
$frmAction->AddVar("conditions[$i][type]", $val["type"]);
$frmAction->AddVar("conditions[$i][operator]", $val["operator"]);
$frmAction->AddVar("conditions[$i][value]", $val["value"]);
+
+ if(!isset($grouped_conditions[$val["type"]]) || !is_array($grouped_conditions[$val["type"]]))
+ $grouped_conditions[$val["type"]] = array();
+
+ array_push($grouped_conditions[$val["type"]], $label);
+
$i++;
}
+ unset($conditions);
- if(count($cond_el)==0)
- array_push($cond_el, S_NO_CONDITIONS_DEFINED);
+ if($cond_el->ItemsCount() == 0)
+ $cond_el = S_NO_CONDITIONS_DEFINED;
else
- array_push($cond_el, new CButton('del_condition','delete selected'));
-// end of condition list preparation
+ {
+ if($cond_el->ItemsCount() > 1)
+ {
+ switch($evaltype)
+ {
+ case ACTION_EVAL_TYPE_AND:
+ $group_op = $glog_op = S_AND;
+ break;
+ case ACTION_EVAL_TYPE_OR:
+ $group_op = $glog_op = S_OR;
+ break;
+ default:
+ $group_op = S_OR;
+ $glog_op = S_AND;
+ }
- $cmbSource = new CComboBox('source', $source);
- $cmbSource->AddItem(0, S_TRIGGER);
- $frmAction->AddRow(S_SOURCE, $cmbSource);
+ foreach($grouped_conditions as $id => $val)
+ {
+ $grouped_conditions[$id] = '('.implode(' '.$group_op.' ', $val).')';
+ }
+ $grouped_conditions = implode(' '.$glog_op.' ', $grouped_conditions);
+
+ $cmb_calc_type = new CComboBox('evaltype', $evaltype, 'submit()');
+ $cmb_calc_type->AddItem(ACTION_EVAL_TYPE_AND_OR, S_AND_OR_BIG);
+ $cmb_calc_type->AddItem(ACTION_EVAL_TYPE_AND, S_AND_BIG);
+ $cmb_calc_type->AddItem(ACTION_EVAL_TYPE_OR, S_OR_BIG);
+ $frmAction->AddRow(S_TYPE_OF_CALCULATION, array($cmb_calc_type,new CTextBox('preview', $grouped_conditions, 60,'yes')));
+ }
+ else
+ {
+ $frmAction->AddVar('evaltype', ACTION_EVAL_TYPE_AND_OR);
+ }
+ $cond_el = array($cond_el, new CButton('del_condition','delete selected'));
+ }
+ unset($grouped_conditions);
+
+// end of condition list preparation
$frmAction->AddRow(S_CONDITIONS, $cond_el);
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index 0a4f251c..98cec786 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -207,6 +207,12 @@
"S_NO_REPEATS"=> "No repeats",
"S_NUMBER_OF_REPEATS"=> "Number of repeats",
"S_DELAY_BETWEEN_REPEATS"=> "Delay between repeats",
+ "S_AND_OR_BIG"=> "AND / OR",
+ "S_AND_BIG"=> "AND",
+ "S_AND"=> "and",
+ "S_OR_BIG"=> "OR",
+ "S_OR"=> "or",
+ "S_TYPE_OF_CALCULATION"=> "Type of calculation",
"S_CREATE_ACTION"=> "Create Action",
// alarms.php