Module: nagvis
Branch: master
Commit: 8f9860b34d978b7954c6c687169edeee379d7e83
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/commit/?id=8f9860b34d978b7954c6c687169edeee379d7e83

Author: Roman Kyrylych <[email protected]>
Date:   Tue Jul 21 16:57:17 2009 +0300

Flex UI: use list of Nagios objects received from server

Signed-off-by: Roman Kyrylych <[email protected]>

---

 share/netmap/amf-server.php               |    2 +
 uifx/src/modules/gmap/DialogLocation.mxml |   81 ++++++++++------------------
 uifx/src/modules/gmap/GMapModule.as       |    9 ++-
 3 files changed, 37 insertions(+), 55 deletions(-)

diff --git a/share/netmap/amf-server.php b/share/netmap/amf-server.php
index 2d06566..9965bd2 100644
--- a/share/netmap/amf-server.php
+++ b/share/netmap/amf-server.php
@@ -47,6 +47,8 @@ $server->setClassMap("Location", "Location");
 $server->setClassMap("Link", "Link");
 $server->setClassMap("Host", "Host");
 $server->setClassMap("Service", "Service");
+$server->setClassMap("HostGroup", "HostGroup");
+$server->setClassMap("ServiceGroup", "ServiceGroup");
 echo ($server->handle());
 
 ?>
diff --git a/uifx/src/modules/gmap/DialogLocation.mxml 
b/uifx/src/modules/gmap/DialogLocation.mxml
index 986efc0..2062e55 100644
--- a/uifx/src/modules/gmap/DialogLocation.mxml
+++ b/uifx/src/modules/gmap/DialogLocation.mxml
@@ -38,38 +38,15 @@
                        [Bindable]
                        public var locID : String;
 
-                       public var host : Array =
-                       [
-                               {name : "devel", ip: "172.27.76.33", notes: 
"Devel server"},
-                               {name : "beta", ip: "192.168.1.4", notes: "Beta 
system with automated rollout"},
-                               {name : "beta64", ip: "192.168.1.113", notes: 
"Beta 64 bit system  with automated rollaout"}
-                       ];
-                       
-                       public var service : Array =
-                       [
-                               {name: "ping", host: "devel"},
-                               {name: "ping", host: "beta"},
-                               {name: "ping", host: "beta64"},
-                       ];
-
-                       public var hostGroup : Array =
-                       [
-                               {name : "Goteburg Location", notes : "Goteburg 
Office"}, 
-                               {name : "Stockholm Location", notes : "Head 
Office"},
-                               {name : "Lviv Location", notes : "N-iX"}        
                
-                       ];
-
-                       public var serviceGroup : Array =
-                       [
-                               {name: "service group 1", notes: "lalala"},
-                               {name: "service group 2", notes: "tramtamtam"},
-                               {name: "service group 3", notes: "cool"},
-                       ];
+                       public var hosts         : ArrayCollection = new 
ArrayCollection()
+                       public var hostgroups    : ArrayCollection = new 
ArrayCollection()
+                       public var services      : ArrayCollection = new 
ArrayCollection();
+                       public var servicegroups : ArrayCollection = new 
ArrayCollection();
 
                        [Bindable]
-                       public var objects : ArrayCollection = new 
ArrayCollection(hostGroup);
+                       public var objects : ArrayCollection = hostgroups;
 
-                       private function init():void
+                       private function init() : void
                        {
                                locNObject.flowBox.setStyle("borderStyle", 
"solid");
                                locNObject.flowBox.setStyle("borderColor", 
"#000000");
@@ -97,8 +74,8 @@
                                        locDescription.text = "";
                                }
                        }
-                       
-                       private function objectItemClick( event:MenuEvent ):void
+
+                       private function objectItemClick(event : MenuEvent) : 
void
                        {
                                switch (String(event.it...@data))
                                {
@@ -107,58 +84,58 @@
                                                break;
                                }
                        }
-                       
-                       public function hostLabelFunction( item:Object ):String
+
+                       public function hostLabelFunction(item : Object) : 
String
                        {
-                               return item.name + ' ' + item.ip;
+                               return item.name + ' ' + item.address;
                        }
 
-                       public function serviceLabelFunction( item:Object 
):String
+                       public function serviceLabelFunction(item : Object) : 
String
                        {
-                               return item.name + ' ' + item.host;
+                               return item.description + ' ' + item.host;
                        }
 
-                       public function groupLabelFunction( item:Object ):String
+                       public function groupLabelFunction(item : Object) : 
String
                        {
-                               return item.name;
+                               return item.name + ' ' + item.alias;
                        }
-                       
-                       private function onObjectTypeChange():void
+
+                       private function onObjectTypeChange() : void
                        {
                                locNObject.removeAll();
-                               
+
                                switch(locNObjectType.selectedIndex)
                                {
                                        case 0:
-                                               objects.source = host;
-                                               locNObject.browserFields = 
["name", "ip", "notes"];
+                                               objects = hosts;
+                                               locNObject.browserFields = 
["name", "address"];
                                                locNObject.labelFunction = 
hostLabelFunction;
                                                break;
                                        case 1:
-                                               objects.source = service;
-                                               locNObject.browserFields = 
["name", "host"];
+                                               objects = services;
+                                               locNObject.browserFields = 
["description", "host"];
                                                locNObject.labelFunction = 
serviceLabelFunction;
                                                break;
                                        case 2:
-                                               objects.source = hostGroup;
-                                               locNObject.browserFields = 
["name", "notes"];
+                                               objects = hostgroups;
+                                               locNObject.browserFields = 
["name", "alias"];
                                                locNObject.labelFunction = 
groupLabelFunction;
                                                break;
                                        case 3:
-                                               objects.source = serviceGroup;
-                                               locNObject.browserFields = 
["name", "notes"];
+                                               objects = servicegroups;
+                                               locNObject.browserFields = 
["name", "alias"];
                                                locNObject.labelFunction = 
groupLabelFunction;
                                                break;
                                }
                        }
                ]]>
        </mx:Script>
-           <mx:XML format="e4x" id="autoCompleteMenu">
+       <mx:XML format="e4x" id="autoCompleteMenu">
                <root>
                        <menuitem data="browse" label="Browse..."/>
                </root>
        </mx:XML>
-       <flexlib:HAccordion selectedIndex="2" left="10" right="20" top="40" 
bottom="40" styleName="accordion" creationPolicy="all">
+       <flexlib:HAccordion selectedIndex="0" left="10" right="20" top="40" 
bottom="40" styleName="accordion" creationPolicy="all">
                <mx:Canvas label="General" width="100%" height="100%">
                        <flexlib:PromptingTextInput id="locName" prompt="Name"
                                left="10" right="10" top="0"
@@ -209,7 +186,7 @@
                                                dataProvider="{objects}" 
selectedItemStyleName="underline" labelFunction="groupLabelFunction"
                                                matchType="anyPart" 
allowMultipleSelection="false"
                                                
actionsMenuDataProvider="{autoCompleteMenu}" itemClick="objectItemClick(event)"
-                                               browserFields="{['name', 
'notes']}"
+                                               browserFields="{['name', 
'alias']}"
                                        />
                                        <mx:Spacer/>
                                </mx:HBox>
diff --git a/uifx/src/modules/gmap/GMapModule.as 
b/uifx/src/modules/gmap/GMapModule.as
index a40be65..72fcfbe 100644
--- a/uifx/src/modules/gmap/GMapModule.as
+++ b/uifx/src/modules/gmap/GMapModule.as
@@ -84,6 +84,8 @@ private function onMapReady(event : Event) : void
 
        rDatabase.getHosts();
        rDatabase.getServices();
+       rDatabase.getHostGroups();
+       rDatabase.getServiceGroups();
        rViewpoints.getAll();
        rLocations.getAll();
        // Note: rLinks.getAll() is called at the end of getLocations_handler
@@ -218,7 +220,7 @@ private function getHosts_handler(event : ResultEvent) : 
void
        for each (var host : Host in result)
                hosts.addItem(host);
 
-       //locationBox.locHosts.dataProvider = hosts;
+       locationBox.hosts = hosts;
 }
 
 private function getServices_handler(event : ResultEvent) : void
@@ -229,6 +231,7 @@ private function getServices_handler(event : ResultEvent) : 
void
        for each (var service : Service in result)
                services.addItem(service);
 
+       locationBox.services = services;
        //linksBox.services.dataProvider = services;
 }
 
@@ -240,7 +243,7 @@ private function getHostGroups_handler(event : ResultEvent) 
: void
        for each (var hostgroup : HostGroup in result)
                hostgroups.addItem(hostgroup);
 
-       //locationBox.locHosts.dataProvider = hosts;
+       locationBox.hostgroups = hostgroups;
 }
 
 private function getServiceGroups_handler(event : ResultEvent) : void
@@ -251,7 +254,7 @@ private function getServiceGroups_handler(event : 
ResultEvent) : void
        for each (var servicegroup : ServiceGroup in result)
                servicegroups.addItem(servicegroup);
 
-       //linksBox.services.dataProvider = services;
+       locationBox.servicegroups = servicegroups;
 }
 
 /*********************************************/


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to