diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-26 13:07:57 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-26 13:07:57 +0000 |
| commit | 3ad9ec2c7d4be13068a49fb19a1fb8f3781dd485 (patch) | |
| tree | aa2576f5266f28ddd94a7a22b15270802e1d8339 /frontends/php/include | |
| parent | 20dfeb5d1966879f9d76e69cab4872831119ba9f (diff) | |
| download | zabbix-3ad9ec2c7d4be13068a49fb19a1fb8f3781dd485.tar.gz zabbix-3ad9ec2c7d4be13068a49fb19a1fb8f3781dd485.tar.xz zabbix-3ad9ec2c7d4be13068a49fb19a1fb8f3781dd485.zip | |
- [DEV-57] added better "hosts info" selection in screens (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@4920 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/classes/chostsinfo.mod.php | 50 | ||||
| -rw-r--r-- | frontends/php/include/db.inc.php | 14 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 42 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 6 | ||||
| -rw-r--r-- | frontends/php/include/screens.inc.php | 2 |
5 files changed, 101 insertions, 13 deletions
diff --git a/frontends/php/include/classes/chostsinfo.mod.php b/frontends/php/include/classes/chostsinfo.mod.php index 00644ed8..44f5bec5 100644 --- a/frontends/php/include/classes/chostsinfo.mod.php +++ b/frontends/php/include/classes/chostsinfo.mod.php @@ -22,10 +22,12 @@ class CHostsInfo extends CTable { //var $style; - function CHostsInfo($style = STYLE_HORISONTAL) + function CHostsInfo($groupid=0, $style = STYLE_HORISONTAL) { + $this->nodeid = id2nodeid($groupid); + $this->groupid = $groupid; $this->style = null; - + parent::CTable(NULL,"hosts_info"); $this->SetOrientation($style); } @@ -40,21 +42,51 @@ function BodyToString() { + global $USER_DETAILS; $this->CleanItems(); - $db_host_cnt = DBselect("select count(*) as cnt from hosts where available=".HOST_AVAILABLE_TRUE); + $accessible_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY); + + $cond = (remove_nodes_from_id($this->groupid)>0)?(' AND hg.groupid='.zbx_dbstr($this->groupid)):(' AND '.DBin_node('hg.groupid', $this->nodeid)); + + $db_host_cnt = DBselect('SELECT COUNT(*) as cnt '. + ' FROM hosts h, hosts_groups hg'. + ' WHERE h.available='.HOST_AVAILABLE_TRUE. + ' AND hg.groupid IN ('.$accessible_groups.') '.$cond); + $host_cnt = DBfetch($db_host_cnt); - $avail = $host_cnt["cnt"]; + $avail = $host_cnt['cnt']; + + $db_host_cnt = DBselect('SELECT COUNT(*) as cnt '. + ' FROM hosts h, hosts_groups hg'. + ' WHERE h.available='.HOST_AVAILABLE_FALSE. + ' AND hg.groupid IN ('.$accessible_groups.') '.$cond); - $db_host_cnt = DBselect("select count(*) as cnt from hosts where available=".HOST_AVAILABLE_FALSE); $host_cnt = DBfetch($db_host_cnt); - $notav = $host_cnt["cnt"]; + $notav = $host_cnt['cnt']; + + $db_host_cnt = DBselect('SELECT COUNT(*) as cnt '. + ' FROM hosts h, hosts_groups hg'. + ' WHERE h.available='.HOST_AVAILABLE_UNKNOWN. + ' AND hg.groupid IN ('.$accessible_groups.') '.$cond); + - $db_host_cnt = DBselect("select count(*) as cnt from hosts where available=".HOST_AVAILABLE_UNKNOWN); $host_cnt = DBfetch($db_host_cnt); - $uncn = $host_cnt["cnt"]; + $uncn = $host_cnt['cnt']; - $header = new CCol(S_HOSTS_INFO,"header"); + $node = get_node_by_nodeid($this->nodeid); + $header_str = S_HOSTS_INFO.SPACE; + + if(remove_nodes_from_id($this->groupid)>0){ + $group = get_hostgroup_by_groupid($this->groupid); + $header_str.= S_FOR_GROUP_SMALL.SPACE.'"('.$node['name'].')'.SPACE.$group['name'].'"'; + } + else{ + $header_str.= S_FOR_NODE_SMALL.SPACE.'"('.$node['name'].')"'; + } + + + $header = new CCol($header_str,"header"); if($this->style == STYLE_HORISONTAL) $header->SetColspan(3); diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index c931b01f..ad6bb8b1 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -593,4 +593,18 @@ if(isset($DB_TYPE) && $DB_TYPE == "ORACLE") { return $ret2; } + + function create_id_by_nodeid($id,$nodeid=0){ + + global $ZBX_LOCALNODEID; + $nodeid = ($nodeid == 0)?get_current_nodeid(false):$nodeid; + + $id=remove_nodes_from_id($id); + $id=bcadd($id,bcadd(bcmul($nodeid,'100000000000000'),bcmul($ZBX_LOCALNODEID,'100000000000'))); + return $id; + } + + function remove_nodes_from_id($id){ + return bcmod($id,'100000000000'); + } ?> diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 5afa54dc..3127a1f3 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -3844,8 +3844,46 @@ include_once 'include/discovery.inc.php'; $form->AddRow(S_PARAMETER,array($textfield,SPACE,$selectbtn)); } - else // SCREEN_RESOURCE_HOSTS_INFO, SCREEN_RESOURCE_TRIGGERS_INFO, SCREEN_RESOURCE_CLOCK - { + else if($resourcetype == SCREEN_RESOURCE_HOSTS_INFO){ +// HOTS info + $caption = ''; + $id=0; + + if(remove_nodes_from_id($resourceid) > 0){ + $result=DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name '. + ' FROM hosts_groups hg, groups g '. + ' LEFT JOIN nodes n ON n.nodeid='.DBid2nodeid('g.groupid'). + ' WHERE g.groupid in ('.get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY).')'. + ' AND g.groupid='.$resourceid); + + while($row=DBfetch($result)){ + $row['node_name'] = isset($row['node_name']) ? '('.$row['node_name'].') ' : ''; + $caption = $row['node_name'].$row['name']; + $id = $resourceid; + } + } + else if(remove_nodes_from_id($resourceid)==0){ + $result=DBselect('SELECT DISTINCT n.name as node_name '. + ' FROM nodes n '. + ' WHERE n.nodeid='.id2nodeid($resourceid)); + + while($row=DBfetch($result)){ + $row['node_name'] = isset($row['node_name']) ? '('.$row['node_name'].') ' : ''; + $caption = $row['node_name'].S_MINUS_ALL_GROUPS_MINUS; + $id = $resourceid; + } + } + + $form->AddVar('resourceid',$id); + + $textfield = new Ctextbox('caption',$caption,60,'yes'); + $selectbtn = new Cbutton('select',S_SELECT,"javascript: return PopUp('popup.php?dstfrm=".$form->getName()."&dstfld1=resourceid&dstfld2=caption&srctbl=host_group_scr&srcfld1=groupid&srcfld2=name',480,450);"); + $selectbtn->AddOption('onmouseover','javascript: this.style.cursor = "pointer";'); + + $form->AddRow(S_GROUP,array($textfield,SPACE,$selectbtn)); + } + else{ +// SCREEN_RESOURCE_TRIGGERS_INFO, SCREEN_RESOURCE_CLOCK $form->AddVar("resourceid",0); } diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 085befd9..ec6d2952 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -473,7 +473,8 @@ 'S_LATEST_VALUES'=> 'Latest values', 'S_NO_PERMISSIONS'=> 'No permissions !', 'S_LATEST_DATA_BIG'=> 'LATEST DATA', - 'S_ALL_SMALL'=> 'all', + 'S_ALL_SMALL'=> 'all', + 'S_ALL_BIG'=> 'ALL', 'S_MINUS_ALL_MINUS'=> '- all -', 'S_MINUS_OTHER_MINUS'=> '- other -', 'S_DESCRIPTION_LARGE'=> 'DESCRIPTION', @@ -635,7 +636,10 @@ 'S_DELETED'=> 'Deleted', 'S_UNKNOWN'=> 'Unknown', 'S_GROUPS'=> 'Groups', + 'S_MINUS_ALL_GROUPS_MINUS'=> ' - all groups - ', 'S_NO_GROUPS_DEFINED'=> 'No groups defined', + 'S_FOR_GROUP_SMALL'=> 'for group', + 'S_FOR_NODE_SMALL'=> 'for node', 'S_NEW_GROUP'=> 'New group', 'S_DNS_NAME'=> 'DNS name', 'S_IP_ADDRESS'=> 'IP address', diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php index 0eb47b78..c5839c15 100644 --- a/frontends/php/include/screens.inc.php +++ b/frontends/php/include/screens.inc.php @@ -386,7 +386,7 @@ } elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_HOSTS_INFO) ) { - $item = array(new CHostsInfo($style)); + $item = array(new CHostsInfo($resourceid, $style)); if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action)); } elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_TRIGGERS_INFO) ) |
