diff options
author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-05-08 06:56:46 +0000 |
---|---|---|
committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-05-08 06:56:46 +0000 |
commit | 86ada7d77c1ce15210d7894d0858bbafd3a3f0c6 (patch) | |
tree | 5624f1a872a7df3006c6dd90266d03a10d070731 /frontends/php | |
parent | 1f6bef28b8801d8f902ab23c520dfcf7430b1394 (diff) | |
download | zabbix-86ada7d77c1ce15210d7894d0858bbafd3a3f0c6.tar.gz zabbix-86ada7d77c1ce15210d7894d0858bbafd3a3f0c6.tar.xz zabbix-86ada7d77c1ce15210d7894d0858bbafd3a3f0c6.zip |
- [DEV-149] partial implementation {beta} (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5682 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r-- | frontends/php/include/blocks.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/include/classes/ccombobox.inc.php | 152 | ||||
-rw-r--r-- | frontends/php/include/forms.inc.php | 216 | ||||
-rw-r--r-- | frontends/php/include/hosts.inc.php | 14 | ||||
-rw-r--r-- | frontends/php/include/js.inc.php | 51 | ||||
-rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 1 | ||||
-rw-r--r-- | frontends/php/js/common.js | 20 |
7 files changed, 250 insertions, 206 deletions
diff --git a/frontends/php/include/blocks.inc.php b/frontends/php/include/blocks.inc.php index bf51d24c..fac98a0b 100644 --- a/frontends/php/include/blocks.inc.php +++ b/frontends/php/include/blocks.inc.php @@ -503,7 +503,7 @@ function make_latest_issues(){ global $USER_DETAILS; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); - $available_triggers = get_accessible_triggers(PERM_READ_LIST,PERM_RES_IDS_ARRAY); + $available_triggers = get_accessible_triggers(PERM_READ_ONLY,PERM_RES_IDS_ARRAY); $scripts_by_hosts = get_accessible_scripts_by_hosts($available_hosts); $config=select_config(); diff --git a/frontends/php/include/classes/ccombobox.inc.php b/frontends/php/include/classes/ccombobox.inc.php index 089038a9..30fa6d2d 100644 --- a/frontends/php/include/classes/ccombobox.inc.php +++ b/frontends/php/include/classes/ccombobox.inc.php @@ -68,10 +68,14 @@ { parent::CTag('select','yes'); $this->tag_end = ''; - $this->options['class'] = 'biginput'; + + $this->options['id'] = $name; $this->options['name'] = $name; - $this->value = $value; + + $this->options['class'] = 'biginput'; $this->options['size'] = 1; + + $this->value = $value; $this->SetAction($action); } function SetAction($value='submit()', $event='onchange') @@ -106,83 +110,23 @@ } } - class CListBox extends CComboBox - { + class CListBox extends CComboBox{ /* public */ - function CListBox($name='listbox',$value=NULL,$size=5,$action=NULL) - { + function CListBox($name='listbox',$value=NULL,$size=5,$action=NULL){ parent::CComboBox($name,NULL,$action); $this->options['multiple'] = 'multiple'; $this->options['size'] = $size; $this->SetValue($value); } + function SetSize($value) { $this->options['size'] = $value; } } - function inseret_javascript_for_editable_combobox() - { - if(defined('EDITABLE_COMBOBOX_SCRIPT_INSERTTED')) return; - - define('EDITABLE_COMBOBOX_SCRIPT_INSERTTED', 1); -?> -<script language="JavaScript" type="text/javascript"> -<!-- - function CEditableComboBoxInit(obj) - { - var opt = obj.options; - - if(obj.value) obj.oldValue = obj.value; - - for (var i = 0; i < opt.length; i++) - if (-1 == opt.item(i).value) - return; - - opt = document.createElement("option"); - opt.value = -1; - opt.text = "(other ...)"; - - if(!obj.options.add) - obj.insertBefore(opt, obj.options.item(0)); - else - obj.options.add(opt, 0); - - return; - } - - function CEditableComboBoxOnChange(obj,size) - { - if(-1 != obj.value) - { - obj.oldValue = obj.value; - } - else - { - var new_obj = document.createElement("input"); - new_obj.type = "text"; - new_obj.name = obj.name; - if(size && size > 0) - { - new_obj.size = size; - } - new_obj.className = obj.className; - if(obj.oldValue) new_obj.value = obj.oldValue; - obj.parentNode.replaceChild(new_obj, obj); - new_obj.focus(); - new_obj.select(); - } - } ---> -</script> -<?php - } - - class CEditableComboBox extends CComboBox - { - function CEditableComboBox($name='editablecombobox',$value=NULL,$size=0,$action=NULL) - { + class CEditableComboBox extends CComboBox{ + function CEditableComboBox($name='editablecombobox',$value=NULL,$size=0,$action=NULL){ inseret_javascript_for_editable_combobox(); parent::CComboBox($name,$value,$action); @@ -190,16 +134,13 @@ parent::AddAction('onchange','CEditableComboBoxOnChange(this,'.$size.');'); } - function AddItem($value, $caption='', $selected=NULL, $enabled='yes') - { - if(is_null($selected)) - { + function AddItem($value, $caption='', $selected=NULL, $enabled='yes'){ + if(is_null($selected)){ if(is_array($this->value)) { if(str_in_array($value,$this->value)) $this->value_exist = 1; } - else if(strcmp($value,$this->value) == 0) - { + else if(strcmp($value,$this->value) == 0){ $this->value_exist = 1; } } @@ -207,13 +148,68 @@ parent::AddItem($value,$caption,$selected,$enabled); } - function ToString($destroy=true) - { - if(!isset($this->value_exist) && !empty($this->value)) - { + function ToString($destroy=true){ + if(!isset($this->value_exist) && !empty($this->value)){ $this->AddItem($this->value, $this->value, 'yes'); } return parent::ToString($destroy); } } -?> + + class CTweenBox{ + function ctweenbox($name_l,$name_r,$size){ + $this->lbox = new ClistBox($name_l,null,$size); +// $this->lbox->AddOption('style','width: 140px;'); + + $this->rbox = new ClistBox($name_r,null,$size); +// $this->rbox->AddOption('style','width: 140px;'); + } + + function AddItem($expr, $value, $caption, $selected=NULL, $enabled='yes'){ + if($expr){ + $box = &$this->lbox; + } + else{ + $box = &$this->rbox; + } + + $box->AddItem($value,$caption,$selected,$enabled); + } + + function SetAction($expr, $value='submit()', $event='onchange'){ + if($expr){ + $box = &$this->lbox; + } + else{ + $box = &$this->rbox; + } + $box->AddOption($event,$value); + } + + function Get($caption_l=null,$caption_r=null){ + $grp_tab = new CTable(); + if(!is_null($caption_l) || !is_null($caption_r)){ + $grp_tab->AddRow(array(bold($caption_l),SPACE,bold($caption_r))); + } + + $id_l = $this->lbox->options['id']; + $id_r = $this->rbox->options['id']; + + $add_btn = new CButton('add',' « ');//S_ADD);// + $add_btn->SetType('button'); + $add_btn->SetAction('javascript: moveListBoxSelectedItem("'.$id_r.'","'.$id_l.'");'); + + $rmv_btn = new CButton('remove',' » ');//S_REMOVE);// + $rmv_btn->SetType('button'); + $rmv_btn->SetAction('javascript: moveListBoxSelectedItem("'.$id_l.'","'.$id_r.'");'); + + $grp_tab->AddRow(array($this->lbox,new CCol(array($add_btn,BR(),$rmv_btn),'top'),$this->rbox)); + return $grp_tab; + } + + function Show($caption_l=null,$caption_r=null){ + $tab = $this->Get($caption_l,$caption_r); + $tab->Show(); + } + } +?>
\ No newline at end of file diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 90c52c4c..081b6028 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -4091,94 +4091,89 @@ include_once 'include/discovery.inc.php'; $frmHouseKeep->Show(); } - function insert_host_form($show_only_tmp=0) - { + function insert_host_form($show_only_tmp=0){ global $USER_DETAILS; - global $_REQUEST; - $groups= get_request("groups",array()); - - $newgroup = get_request("newgroup",""); - - $host = get_request("host", ""); - $port = get_request("port", get_profile("HOST_PORT",10050)); - $status = get_request("status", HOST_STATUS_MONITORED); - $useip = get_request("useip", 0); - $dns = get_request("dns", ""); - $ip = get_request("ip", "0.0.0.0"); - $proxy_hostid = get_request("proxy_hostid",""); - - $useprofile = get_request("useprofile","no"); - - $devicetype = get_request("devicetype",""); - $name = get_request("name",""); - $os = get_request("os",""); - $serialno = get_request("serialno",""); - $tag = get_request("tag",""); - $macaddress = get_request("macaddress",""); - $hardware = get_request("hardware",""); - $software = get_request("software",""); - $contact = get_request("contact",""); - $location = get_request("location",""); - $notes = get_request("notes",""); - - $templates = get_request("templates",array()); + $groups= get_request('groups',array()); + + $newgroup = get_request('newgroup',''); + + $host = get_request('host', ''); + $port = get_request('port', get_profile('HOST_PORT',10050)); + $status = get_request('status', HOST_STATUS_MONITORED); + $useip = get_request('useip', 0); + $dns = get_request('dns', ''); + $ip = get_request('ip', '0.0.0.0'); + $proxy_hostid = get_request('proxy_hostid',''); + + $useprofile = get_request('useprofile','no'); + + $devicetype = get_request('devicetype',''); + $name = get_request('name',''); + $os = get_request('os',''); + $serialno = get_request('serialno',''); + $tag = get_request('tag',''); + $macaddress = get_request('macaddress',''); + $hardware = get_request('hardware',''); + $software = get_request('software',''); + $contact = get_request('contact',''); + $location = get_request('location',''); + $notes = get_request('notes',''); + + $templates = get_request('templates',array()); $clear_templates = get_request('clear_templates',array()); $frm_title = $show_only_tmp ? S_TEMPLATE : S_HOST; - if(isset($_REQUEST["hostid"])) - { - $db_host=get_host_by_hostid($_REQUEST["hostid"]); - $frm_title .= SPACE."\"".$db_host["host"]."\""; + if(isset($_REQUEST['hostid'])){ + $db_host=get_host_by_hostid($_REQUEST['hostid']); + $frm_title .= SPACE.'"'.$db_host['host'].'"'; - $original_templates = get_templates_by_hostid($_REQUEST["hostid"]); + $original_templates = get_templates_by_hostid($_REQUEST['hostid']); } - else - { + else{ $original_templates = array(); } - if(isset($_REQUEST["hostid"]) && !isset($_REQUEST["form_refresh"])) + if(isset($_REQUEST['hostid']) && !isset($_REQUEST['form_refresh'])) { - $proxy_hostid = $db_host["proxy_hostid"]; - $host = $db_host["host"]; - $port = $db_host["port"]; - $status = $db_host["status"]; - $useip = $db_host["useip"]; - $dns = $db_host["dns"]; - $ip = $db_host["ip"]; + $proxy_hostid = $db_host['proxy_hostid']; + $host = $db_host['host']; + $port = $db_host['port']; + $status = $db_host['status']; + $useip = $db_host['useip']; + $dns = $db_host['dns']; + $ip = $db_host['ip']; // add groups - $db_groups=DBselect("SELECT DISTINCT groupid FROM hosts_groups WHERE hostid=".$_REQUEST["hostid"]. - " AND groupid in (". - get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST). - ") "); + $db_groups=DBselect('SELECT DISTINCT groupid '. + ' FROM hosts_groups '. + ' WHERE hostid='.$_REQUEST['hostid']. + ' AND groupid in ('.get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST).') '); while($db_group=DBfetch($db_groups)){ - if(uint_in_array($db_group["groupid"],$groups)) continue; - array_push($groups, $db_group["groupid"]); + if(uint_in_array($db_group['groupid'],$groups)) continue; + array_push($groups, $db_group['groupid']); } // read profile - $db_profiles = DBselect("SELECT * FROM hosts_profiles WHERE hostid=".$_REQUEST["hostid"]); + $db_profiles = DBselect('SELECT * FROM hosts_profiles WHERE hostid='.$_REQUEST['hostid']); - $useprofile = "no"; + $useprofile = 'no'; $db_profile = DBfetch($db_profiles); - if($db_profile) - { - $useprofile = "yes"; - - - $devicetype = $db_profile["devicetype"]; - $name = $db_profile["name"]; - $os = $db_profile["os"]; - $serialno = $db_profile["serialno"]; - $tag = $db_profile["tag"]; - $macaddress = $db_profile["macaddress"]; - $hardware = $db_profile["hardware"]; - $software = $db_profile["software"]; - $contact = $db_profile["contact"]; - $location = $db_profile["location"]; - $notes = $db_profile["notes"]; + if($db_profile){ + $useprofile = 'yes'; + + + $devicetype = $db_profile['devicetype']; + $name = $db_profile['name']; + $os = $db_profile['os']; + $serialno = $db_profile['serialno']; + $tag = $db_profile['tag']; + $macaddress = $db_profile['macaddress']; + $hardware = $db_profile['hardware']; + $software = $db_profile['software']; + $contact = $db_profile['contact']; + $location = $db_profile['location']; + $notes = $db_profile['notes']; } $templates = $original_templates; } @@ -4187,57 +4182,45 @@ include_once 'include/discovery.inc.php'; $clear_templates = array_diff($clear_templates,array_keys($templates)); asort($templates); - $frmHost = new CFormTable($frm_title,"hosts.php"); - $frmHost->SetHelp("web.hosts.host.php"); - $frmHost->AddVar("config",get_request("config",0)); + $frmHost = new CFormTable($frm_title,'hosts.php'); + $frmHost->SetHelp('web.hosts.host.php'); + $frmHost->AddVar('config',get_request('config',0)); $frmHost->AddVar('clear_templates',$clear_templates); - if(isset($_REQUEST["hostid"])) $frmHost->AddVar("hostid",$_REQUEST["hostid"]); - if(isset($_REQUEST["groupid"])) $frmHost->AddVar("groupid",$_REQUEST["groupid"]); + if(isset($_REQUEST['hostid'])) $frmHost->AddVar('hostid',$_REQUEST['hostid']); + if(isset($_REQUEST['groupid'])) $frmHost->AddVar('groupid',$_REQUEST['groupid']); - $frmHost->AddRow(S_NAME,new CTextBox("host",$host,20)); + $frmHost->AddRow(S_NAME,new CTextBox('host',$host,20)); - $frm_row = array(); - - $db_groups=DBselect("SELECT DISTINCT groupid,name FROM groups ". - " WHERE groupid in (". - get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST). - ") order by name"); - while($db_group=DBfetch($db_groups)) - { - array_push($frm_row, - array( - new CCheckBox("groups[]", - uint_in_array($db_group["groupid"],$groups) ? 'yes' : 'no', - null, - $db_group["groupid"] - ), - get_node_name_by_elid($db_group["groupid"]).$db_group["name"] - ), - BR()); + $grp_tb = new CTweenBox('groups_in','groups_out',10); + + $db_groups=DBselect('SELECT DISTINCT groupid,name '. + ' FROM groups '. + ' WHERE groupid IN ('.get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST).') '. + ' ORDER BY name'); + + while($db_group=DBfetch($db_groups)){ + $grp_tb->AddItem(uint_in_array($db_group['groupid'],$groups),$db_group['groupid'],$db_group['name']); } - $frmHost->AddRow(S_GROUPS,$frm_row); + + $frmHost->AddRow(S_GROUPS,$grp_tb->Get(S_IN.SPACE.S_GROUPS,S_OTHER.SPACE.S_GROUPS)); - $frmHost->AddRow(S_NEW_GROUP,new CTextBox("newgroup",$newgroup),'new'); + $frmHost->AddRow(S_NEW_GROUP,new CTextBox('newgroup',$newgroup),'new'); // onchange does not work on some browsers: MacOS, KDE browser - if($show_only_tmp) - { - $frmHost->AddVar("useip",0); - $frmHost->AddVar("ip","0.0.0.0"); - $frmHost->AddVar("dns",""); + if($show_only_tmp){ + $frmHost->AddVar('useip',0); + $frmHost->AddVar('ip','0.0.0.0'); + $frmHost->AddVar('dns',''); } - else - { - $frmHost->AddRow(S_DNS_NAME,new CTextBox("dns",$dns,"40")); - if(defined('ZBX_HAVE_IPV6')) - { - $frmHost->AddRow(S_IP_ADDRESS,new CTextBox("ip",$ip,"39")); + else{ + $frmHost->AddRow(S_DNS_NAME,new CTextBox('dns',$dns,'40')); + if(defined('ZBX_HAVE_IPV6')){ + $frmHost->AddRow(S_IP_ADDRESS,new CTextBox('ip',$ip,'39')); } - else - { - $frmHost->AddRow(S_IP_ADDRESS,new CTextBox("ip",$ip,"15")); + else{ + $frmHost->AddRow(S_IP_ADDRESS,new CTextBox('ip',$ip,'15')); } $cmbConnectBy = new CComboBox('useip', $useip); @@ -4246,20 +4229,19 @@ include_once 'include/discovery.inc.php'; $frmHost->AddRow(S_CONNECT_TO,$cmbConnectBy); } - if($show_only_tmp) - { - $port = "10050"; + if($show_only_tmp){ + $port = '10050'; $status = HOST_STATUS_TEMPLATE; - $frmHost->AddVar("port",$port); - $frmHost->AddVar("status",$status); + $frmHost->AddVar('port',$port); + $frmHost->AddVar('status',$status); } else { - $frmHost->AddRow(S_PORT,new CNumericBox("port",$port,5)); + $frmHost->AddRow(S_PORT,new CNumericBox('port',$port,5)); //Proxy - $cmbProxy = new CComboBox("proxy_hostid", $proxy_hostid); + $cmbProxy = new CComboBox('proxy_hostid', $proxy_hostid); $cmbProxy->AddItem(0, S_NO_PROXY); $db_proxies = DBselect('SELECT hostid,host FROM hosts'. @@ -4270,7 +4252,7 @@ include_once 'include/discovery.inc.php'; $frmHost->AddRow(S_MONITORED_BY_PROXY,$cmbProxy); //---------- - $cmbStatus = new CComboBox("status",$status); + $cmbStatus = new CComboBox('status',$status); $cmbStatus->AddItem(HOST_STATUS_MONITORED, S_MONITORED); $cmbStatus->AddItem(HOST_STATUS_NOT_MONITORED, S_NOT_MONITORED); $frmHost->AddRow(S_STATUS,$cmbStatus); diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php index 40b39caa..5364953a 100644 --- a/frontends/php/include/hosts.inc.php +++ b/frontends/php/include/hosts.inc.php @@ -283,13 +283,13 @@ require_once "include/items.inc.php"; * Comments: * * NOTE: templates = array(id => name, id2 => name2, ...) - */ - function update_host($hostid,$host,$port,$status,$useip,$dns,$ip,$proxy_hostid,$templates,$newgroup,$groups) - { + */ + function update_host($hostid,$host,$port,$status,$useip,$dns,$ip,$proxy_hostid,$templates,$newgroup,$groups){ + $old_templates = get_templates_by_hostid($hostid); $unlinked_templates = array_diff($old_templates, $templates); - foreach($unlinked_templates as $id => $name) - { + + foreach($unlinked_templates as $id => $name){ unlink_template($hostid, $id); } @@ -302,11 +302,9 @@ require_once "include/items.inc.php"; return $result; update_host_groups($hostid, $groups); - add_group_to_host($hostid,$newgroup); - if(count($new_templates) > 0) - { + if(count($new_templates) > 0){ sync_host_with_templates($hostid,array_keys($new_templates)); } diff --git a/frontends/php/include/js.inc.php b/frontends/php/include/js.inc.php index 2dd8ae62..559c6e64 100644 --- a/frontends/php/include/js.inc.php +++ b/frontends/php/include/js.inc.php @@ -54,7 +54,7 @@ function zbx_add_post_js($script) } -function get_js_sizeable_graph($dom_graph_id,$url){ +function get_js_sizeable_graph($dom_graph_id,$url){ return new CScript(' <script language="JavaScript" type="text/javascript"> @@ -75,7 +75,7 @@ return new CScript(' } -function get_dynamic_chart($dom_graph_id,$img_src,$width=0){ +function get_dynamic_chart($dom_graph_id,$img_src,$width=0){ if(is_int($width) && $width > 0) $img_src.= url_param($width, false, 'width'); $result = new CScript(' <script language="JavaScript" type="text/javascript"> @@ -108,6 +108,53 @@ function get_dynamic_chart($dom_graph_id,$img_src,$width=0){ return $result; } +function inseret_javascript_for_editable_combobox(){ + if(defined('EDITABLE_COMBOBOX_SCRIPT_INSERTTED')) return; + define('EDITABLE_COMBOBOX_SCRIPT_INSERTTED', 1); + + $js = 'function CEditableComboBoxInit(obj){ + var opt = obj.options; + + if(obj.value) obj.oldValue = obj.value; + + for (var i = 0; i < opt.length; i++) + if (-1 == opt.item(i).value) + return; + + opt = document.createElement("option"); + opt.value = -1; + opt.text = "(other ...)"; + + if(!obj.options.add) + obj.insertBefore(opt, obj.options.item(0)); + else + obj.options.add(opt, 0); + + return; + } + + function CEditableComboBoxOnChange(obj,size){ + if(-1 != obj.value){ + obj.oldValue = obj.value; + } + else{ + var new_obj = document.createElement("input"); + new_obj.type = "text"; + new_obj.name = obj.name; + if(size && size > 0){ + new_obj.size = size; + } + new_obj.className = obj.className; + if(obj.oldValue) new_obj.value = obj.oldValue; + obj.parentNode.replaceChild(new_obj, obj); + new_obj.focus(); + new_obj.select(); + } + }'; + + insert_js($js); +} + function insert_showhint_javascript(){ global $page; if(defined('SHOW_HINT_SCRIPT_INSERTTED') || (PAGE_TYPE_HTML != $page['type'])) return; diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 3311347d..cca7ff9c 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -621,6 +621,7 @@ 'S_AS_BLUE'=> 'as Blue', // hosts.php + 'S_IN'=> 'In', 'S_APPLICATION'=> 'Application', 'S_APPLICATIONS'=> 'Applications', 'S_APPLICATIONS_BIG'=> 'APPLICATIONS', diff --git a/frontends/php/js/common.js b/frontends/php/js/common.js index 282ebd6f..34ea416a 100644 --- a/frontends/php/js/common.js +++ b/frontends/php/js/common.js @@ -585,4 +585,24 @@ function empty_form(id){ } return true; +} + +function moveListBoxSelectedItem(from,to){ + from = $(from); + to = $(to); + + for(i = 0; i < from.options.length; i++) { + if(from.options[i].selected == true) { + var temp = document.createElement('option'); + temp.setAttribute('value',from.options[i].value); + + var caption = IE?from.options[i].innerText:from.options[i].textContent; + temp.appendChild(document.createTextNode(caption)); + + from.removeChild(from.options[i]); + + to.appendChild(temp); + i--; + } + } }
\ No newline at end of file |