[rhmessaging-commits] rhmessaging commits: r3683 - in mgmt/trunk/cumin: python/cumin/inventory and 1 other directories.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Oct 23 10:55:28 EDT 2009


Author: eallen
Date: 2009-10-23 10:55:28 -0400 (Fri, 23 Oct 2009)
New Revision: 3683

Modified:
   mgmt/trunk/cumin/python/cumin/grid/pool.py
   mgmt/trunk/cumin/python/cumin/grid/pool.strings
   mgmt/trunk/cumin/python/cumin/grid/slot.py
   mgmt/trunk/cumin/python/cumin/grid/slot.strings
   mgmt/trunk/cumin/python/cumin/inventory/system.py
   mgmt/trunk/cumin/python/cumin/inventory/system.strings
   mgmt/trunk/cumin/resources/slots.swf
Log:
Added missing flash slot vis for Inventory-System-Statistics page.
Added javascript call from flash control to vis_loaded to signal that data was loaded so the control can be made visible.
Made sure popup tooltip for flash control does not draw off left side of control.

Modified: mgmt/trunk/cumin/python/cumin/grid/pool.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/pool.py	2009-10-22 16:50:27 UTC (rev 3682)
+++ mgmt/trunk/cumin/python/cumin/grid/pool.py	2009-10-23 14:55:28 UTC (rev 3683)
@@ -398,8 +398,6 @@
         self.group_by = self.GroupBySwitch(app, "group_by")
         self.add_child(self.group_by)
 
-        self.activities = SlotActivities(app, "activities_legend")
-        self.add_child(self.activities)
         self.fullpageable = True
 
     def render_slots_href(self, session):

Modified: mgmt/trunk/cumin/python/cumin/grid/pool.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/pool.strings	2009-10-22 16:50:27 UTC (rev 3682)
+++ mgmt/trunk/cumin/python/cumin/grid/pool.strings	2009-10-23 14:55:28 UTC (rev 3683)
@@ -36,7 +36,6 @@
   {grid_stats}
 </div>
 <div class="col2">
-  <h2>Slots</h2>
   <div id="flashSlotMap">{slot_map}</div>
   <div id="pngSlotMap">{slot_png}</div>
 </div>
@@ -50,8 +49,14 @@
 <div>{jobs_chart}</div>
 <div>{submit_chart}</div>
 
+[PoolSlotFlashVis.css]
+div#PoolSlotFlashVis {
+    visibility: hidden;
+}
+
 [PoolSlotFlashVis.html]
-<div>
+<div id="PoolSlotFlashVis">
+  <h2>Slots</h2>
     <div class="StatValueChart {fullpageable}" id="{id}">
       <h2>{title}</h2>
       <div class="duration">{group_by}</div>
@@ -75,6 +80,11 @@
             }
         }
     }
+    function vis_loaded(data) {
+        if (data == "1") {
+            $('PoolSlotFlashVis').style.visibility = "visible";
+        }
+    }
     function vis_ready(vis) {
         if (vis == "slots") {
             var chart = cumin.getFlashChart("{id}");
@@ -132,9 +142,6 @@
  			fsm.style.display = "block";
 
 		var params = {menu: "false", scale: "noScale", allowFullscreen: "true", allowScriptAccess: "always", bgcolor: "#FFFFFF"};
- 		//var BackgroundGlass = document.getElementById('BackgroundGlass');
- 		//alert(BackgroundGlass);
- 		
         swfobject.embedSWF("resource?name=slots.swf", "{id}_chart", "{slot_chart_width}", "{slot_chart_height}", "9.0.0", "", {vis:"slots"}, params);
         swfobject.embedSWF("resource?name=slots.swf", "{id}ctrl_chart", "{slot_chart_width}", "{slot_ctrl_height}", "9.0.0", "", {vis:"ctrl"}, params);
 

Modified: mgmt/trunk/cumin/python/cumin/grid/slot.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/slot.py	2009-10-22 16:50:27 UTC (rev 3682)
+++ mgmt/trunk/cumin/python/cumin/grid/slot.py	2009-10-23 14:55:28 UTC (rev 3683)
@@ -257,26 +257,28 @@
         root.slots = slot_count
         root.vis = self.json.get(session)
         root.activity_colors = self.interiors
-        root.tree = self.treeify(records, range(slot_count), groups, 0)
+        leaves = True
+        if self.json.get(session) == "slots":
+            if slot_count > 1000:
+                leaves = False
+
+        root.tree = self.treeify(records, range(slot_count), groups, 0, leaves)
         return "[%s]" % root.create()
 
-    def treeify(self, records, plist, groups, level):
+    def treeify(self, records, plist, groups, level, leaves):
         level_list = list()
         # leaf
         if level == len(groups):
-            el = Element()
-            el.name = "Slot"
-            interiors = self.interiors.copy()
-            interiors[None] = interiors["Unknown"]
-            for i in sorted(plist, key=lambda x:records[x]["name"]):
-                el = Element()
-                el.job_id = records[i]["job_id"] and records[i]["job_id"] or ""
-                el.activity = records[i]["activity"] and records[i]["activity"] or "Unknown"
-                el.state = records[i]["state"] and records[i]["state"] or "Unknown"
-                el.value = records[i]["name"] and records[i]["name"] or ""
-                el.load_avg = records[i]["load_avg"] and round(records[i]["load_avg"], 2) or 0
-                el.name = "slot"
-                level_list.append(el)
+            if leaves:
+                for i in sorted(plist, key=lambda x:records[x]["name"]):
+                    el = Element()
+                    el.job_id = records[i]["job_id"] and records[i]["job_id"] or ""
+                    el.activity = records[i]["activity"] and records[i]["activity"] or "Unknown"
+                    el.state = records[i]["state"] and records[i]["state"] or "Unknown"
+                    el.value = records[i]["name"] and records[i]["name"] or ""
+                    el.load_avg = records[i]["load_avg"] and round(records[i]["load_avg"], 2) or 0
+                    el.name = "slot"
+                    level_list.append(el)
             return level_list
 
         # not a leaf
@@ -289,8 +291,9 @@
             el.slots = len(level_dict[key])
             el.level = level
             if level < len(groups):
-                el.tree = self.treeify(records, level_dict[key], groups, level + 1)
+                el.tree = self.treeify(records, level_dict[key], groups, level + 1, leaves)
             level_list.append(el)
+            
         return level_list
 
     def get_cached(self, session, zl):

Modified: mgmt/trunk/cumin/python/cumin/grid/slot.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/slot.strings	2009-10-22 16:50:27 UTC (rev 3682)
+++ mgmt/trunk/cumin/python/cumin/grid/slot.strings	2009-10-23 14:55:28 UTC (rev 3683)
@@ -1070,7 +1070,7 @@
 
 [SlotMap.html]
 <div id="slot_visualization" class="fullpageable">
-  <h2>{title}</h2>
+  <h2>Slots</h2>
   <div id="slot_controls">
     <div id="zoom_text">Zoom</div><div id="zoom_levels"><div id="zoom_pos"></div></div><div style="clear:left;"><!-- --></div>
   </div>

Modified: mgmt/trunk/cumin/python/cumin/inventory/system.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/inventory/system.py	2009-10-22 16:50:27 UTC (rev 3682)
+++ mgmt/trunk/cumin/python/cumin/inventory/system.py	2009-10-23 14:55:28 UTC (rev 3683)
@@ -9,6 +9,7 @@
 from cumin.grid.slot import SlotFrame, SlotMap, SlotMapPage
 
 from wooly import Session
+import main
 
 strings = StringCatalog(__file__)
 
@@ -142,6 +143,9 @@
         slots = SystemSlotMap(app, "system_slot_map", system)
         self.add_child(slots)
 
+        slot_vis = SystemSlotFlashVis(app, "system_slot_flash", system)
+        self.add_child(slot_vis)
+
     def render_title(self, session):
         return "Statistics"
 
@@ -149,6 +153,55 @@
         job = Identifiable("XXX")
         return self.page.main.grid.pool.job.get_href(session, job, None)
 
+class SystemSlotMap(SlotMap):
+    def __init__(self, app, name, system):
+        super(SystemSlotMap, self).__init__(app, name)
+
+        self.system = system
+        self.slot_clip_size = 240
+
+    def do_process(self, session):
+        super(SystemSlotMap, self).do_process(session)
+
+        system = self.system.get(session)
+
+        self.slots.add_where_expr(session, "s.system = '%s'", system.nodeName)
+
+    def render_image_href(self, session):
+        system = self.system.get(session)
+
+        import main # XXX
+
+        page = main.module.system_slots_page
+        sess = Session(page)
+
+        page.system.set(sess, system)
+
+        return sess.marshal()
+
+    def get_scheduler_select(self, session):
+        system = self.system.get(session)
+        return "system='%s'" % system.nodeName
+
+class SystemSlotFlashVis(SystemSlotMap):
+    def render_slots_href(self, session):
+        system = self.system.get(session)
+
+        page = main.module.system_slots_page
+        sess = Session(page)
+
+        page.system.set(sess, system)
+        page.json.set(sess, "slots")
+        page.groups.set(sess, [])
+
+        return sess.marshal()
+
+    def render_slot_chart_width(self, session):
+        return 300
+
+    def render_slot_chart_height(self, session):
+        return 200
+
 class SystemView(CuminView):
     def __init__(self, app, name, system):
         super(SystemView, self).__init__(app, name, system)
@@ -272,36 +325,6 @@
         else:
             return "Daemon"
 
-class SystemSlotMap(SlotMap):
-    def __init__(self, app, name, system):
-        super(SystemSlotMap, self).__init__(app, name)
-
-        self.system = system
-        self.slot_clip_size = 240
-
-    def do_process(self, session):
-        super(SystemSlotMap, self).do_process(session)
-
-        system = self.system.get(session)
-
-        self.slots.add_where_expr(session, "s.system = '%s'", system.nodeName)
-
-    def render_image_href(self, session):
-        system = self.system.get(session)
-
-        import main # XXX
-
-        page = main.module.system_slots_page
-        sess = Session(page)
-
-        page.system.set(sess, system)
-
-        return sess.marshal()
-
-    def get_scheduler_select(self, session):
-        system = self.system.get(session)
-        return "system='%s'" % system.nodeName
-
 class SystemSlotMapPage(SlotMapPage):
     def __init__(self, app, name):
         self.system = SystemParameter(app, "id")

Modified: mgmt/trunk/cumin/python/cumin/inventory/system.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/inventory/system.strings	2009-10-22 16:50:27 UTC (rev 3682)
+++ mgmt/trunk/cumin/python/cumin/inventory/system.strings	2009-10-23 14:55:28 UTC (rev 3683)
@@ -54,8 +54,8 @@
         <h2>Memory/Load</h2>
         {stats}
         <br/>
-        <h2>Grid Slots</h2>
 	{system_slot_map}
+	{system_slot_flash}
       </td>
       <td>
 	{freemem}
@@ -78,3 +78,57 @@
 
 [SystemServices.item_html]
 <tr><th>{item_type}</th><td>{item_content}</td></tr>
+
+[SystemSlotFlashVis.css]
+div#SystemSlotFlashVis {
+    visibility: hidden;
+}
+
+[SystemSlotFlashVis.html]
+<div id="SystemSlotFlashVis">
+  <h2>Slots</h2>
+    <div class="StatValueChart" id="{id}">
+      <div id="{id}_chart"></div>
+    </div>
+</div>
+<script type="text/javascript">
+//<![CDATA[
+    function updateSystemSlotVis(id, loadType) {
+        var chart = cumin.getFlashChart(id);
+        if ((chart != null)  && (typeof chart.src != "undefined")) {
+            if (typeof loadType != "undefined") {
+                if (typeof chart.reload != "undefined")
+                    chart.reload(chart.src, false);
+            } else {
+                if (typeof chart.load != "undefined")
+                    chart.load(chart.src, false);
+                else
+                    wooly.log("load not definded for " + id);
+            }
+        }
+    }
+    function vis_loaded(data) {
+        if (data == "1") {
+            $('SystemSlotFlashVis').style.visibility = "visible";
+        }
+    }
+    function vis_ready(vis) {
+        if (vis == "slots") {
+            var chart = cumin.getFlashChart("{id}");
+            chart.src = "{slots_href}";
+            updateSystemSlotVis('{id}');
+        }
+    }
+    var flashversion = swfobject.getFlashPlayerVersion();
+    if (flashversion.major >= 9) {
+        var fsm = document.getElementById('flashSlotMap');
+        if (fsm)
+            fsm.style.display = "block";
+
+        var params = {menu: "false", scale: "noScale", allowFullscreen: "true", allowScriptAccess: "always", bgcolor: "#FFFFFF"};
+        swfobject.embedSWF("resource?name=slots.swf", "{id}_chart", "{slot_chart_width}", "{slot_chart_height}", "9.0.0", "", {vis:"slots"}, params);
+
+        wooly.addPageUpdateListener(function () { updateSystemSlotVis('{id}', "reload"); });
+    }
+//]]>
+</script>

Modified: mgmt/trunk/cumin/resources/slots.swf
===================================================================
(Binary files differ)



More information about the rhmessaging-commits mailing list