[rhmessaging-commits] rhmessaging commits: r1271 - in mgmt: cumin/python/wooly and 2 other directories.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Thu Nov 8 14:25:23 EST 2007


Author: justi9
Date: 2007-11-08 14:25:17 -0500 (Thu, 08 Nov 2007)
New Revision: 1271

Modified:
   mgmt/cumin/python/cumin/model.py
   mgmt/cumin/python/cumin/queue.strings
   mgmt/cumin/python/wooly/__init__.py
   mgmt/cumin/resources/wooly.js
   mgmt/notes/justin-todo.txt
Log:
Re-implements ajax updates for the new queue status box.  Improves the
javascript convenience api.



Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py	2007-11-08 18:48:57 UTC (rev 1270)
+++ mgmt/cumin/python/cumin/model.py	2007-11-08 19:25:17 UTC (rev 1271)
@@ -382,6 +382,10 @@
     def get_low(self):
         return self.__low
 
+    def write_xml(self, writer):
+        writer.write("<%s><v>%i</v><r>%i</r></%s>" % \
+                     (self.name, self.get_value(), self.get_rate(), self.name))
+
 class Queue(MeasuredModelObject):
     def __init__(self, model):
         super(Queue, self).__init__(model, model.queue)
@@ -598,6 +602,13 @@
 
         for binding in self.binding_items():
             binding.write_xml(writer)
+
+        writer.write("<measurements>")
+
+        for measure in self.measurements:
+            measure.write_xml(writer)
+
+        writer.write("</measurements>")
             
         writer.write("</queue>")
 

Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings	2007-11-08 18:48:57 UTC (rev 1270)
+++ mgmt/cumin/python/cumin/queue.strings	2007-11-08 19:25:17 UTC (rev 1271)
@@ -88,34 +88,57 @@
 }())
 </script>
 
-[QueueStatus.html]
-<script defer="defer">
-(function() {
-    var updateStatus = function(xml, elem) {
-        var ecount = xml.elems("error-count").next().text().get();
-        var errors = ecount + " " + (ecount == "1" && "error" || "errors");
+[QueueStatus.javascript]
+function updateQueueStatus(xml, elem) {
+    var ecount = xml.elems("error-count").next().text().get();
+    var errors = ecount + " " + (ecount == "1" && "error" || "errors");
 
-        var wcount = xml.elems("warning-count").next().text().get();
-        var warnings = wcount + " " + (wcount == "1" && "warning" || "warnings");
+    var wcount = xml.elems("warning-count").next().text().get();
+    var warnings = wcount + " " + (wcount == "1" && "warning" || "warnings");
 
-        if (ecount != "0") {
-            elem.node.className = "mstatus red";
-        } else if (wcount != "0") {
-            elem.node.className = "mstatus yellow";
-        } else {
-            elem.node.className = "mstatus green";
-        }
+    if (ecount != "0") {
+        elem.node.className = "mstatus red";
+    } else if (wcount != "0") {
+        elem.node.className = "mstatus yellow";
+    } else {
+        elem.node.className = "mstatus green";
+    }
 
-        var divs = elem.elems("div");
-        divs.next().set(errors + ", " + warnings);
+    var divs = elem.elems("div");
+    divs.next().set(errors + ", " + warnings);
 
-        // XXX
-        //wooly.doc().elem("{id}.menq").text().set("hmm")
-    }
+    var ms = xml.elems("measurements").next();
 
-    wooly.setIntervalUpdate("{id}", "{url}", updateStatus, 3000);
-}())
-</script>
+    var menq = ms.elem("msgtotalenqueues").elem("r").text().get();
+    var mdeq = ms.elem("msgtotaldequeues").elem("r").text().get();
+    var benq = ms.elem("bytetotalenqueues").elem("r").text().get();
+    var bdeq = ms.elem("bytetotaldequeues").elem("r").text().get();
+    var mdep = ms.elem("msgdepth").elem("v").text().get();
+    var bdep = ms.elem("bytedepth").elem("v").text().get();
+    var mdepacc = ms.elem("msgdepth").elem("r").text().get();
+    var bdepacc = ms.elem("bytedepth").elem("r").text().get();
+
+    var trs = elem.elem("table").elem("tbody").elems("tr", 1);
+    var tds = null;
+
+    tds = trs.next().elems("td");
+    tds.next().text().set(menq);
+    tds.next().text().set(mdeq);
+
+    tds = trs.next().elems("td");
+    tds.next().text().set(benq);
+    tds.next().text().set(bdeq);
+
+    tds = trs.next().elems("td");
+    tds.next().set(mdep);
+    tds.next().set(bdep);
+
+    tds = trs.next().elems("td");
+    tds.next().text().set(mdepacc);
+    tds.next().text().set(bdepacc);
+}
+
+[QueueStatus.html]
 <div id="{id}" class="{class}">
   <h2>Queue Status</h2>
 
@@ -129,26 +152,29 @@
     </tr>
     <tr>
       <th>Enqueued</th>
-      <td id="{id}.menq" class="ralign">{messages_enqueued}</td>
-      <td id="{id}.benq" class="ralign">{bytes_enqueued}</td>
+      <td class="ralign">{messages_enqueued}</td>
+      <td class="ralign">{bytes_enqueued}</td>
     </tr>
     <tr>
       <th>Dequeued</th>
-      <td id="{id}.mdeq" class="ralign">{messages_dequeued}</td>
-      <td id="{id}.bdeq" class="ralign">{bytes_dequeued}</td>
+      <td class="ralign">{messages_dequeued}</td>
+      <td class="ralign">{bytes_dequeued}</td>
     </tr>
     <tr>
       <th>Depth</th>
-      <td id="{id}.mdep" class="ralign">{message_depth}</td>
-      <td id="{id}.bdep" class="ralign">{byte_depth}</td>
+      <td class="ralign">{message_depth}</td>
+      <td class="ralign">{byte_depth}</td>
     </tr>
     <tr>
       <th>Accel.</th>
-      <td id="{id}.mdepaccel" class="ralign">{message_depth_accel}</td>
-      <td id="{id}.bdepaccel" class="ralign">{byte_depth_accel}</td>
+      <td class="ralign">{message_depth_accel}</td>
+      <td class="ralign">{byte_depth_accel}</td>
     </tr>
   </table>
 </div>
+<script>
+  wooly.setIntervalUpdate("{id}", "{url}", updateQueueStatus, 3000);
+</script>
 
 [QueueView.html]
 {status}

Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py	2007-11-08 18:48:57 UTC (rev 1270)
+++ mgmt/cumin/python/wooly/__init__.py	2007-11-08 19:25:17 UTC (rev 1271)
@@ -468,6 +468,7 @@
 
     def clear_caches(self):
         self.cached_css = None
+        self.cached_javascript = None
 
 class Session(object):
     def __init__(self, app, trunk=None):

Modified: mgmt/cumin/resources/wooly.js
===================================================================
--- mgmt/cumin/resources/wooly.js	2007-11-08 18:48:57 UTC (rev 1270)
+++ mgmt/cumin/resources/wooly.js	2007-11-08 19:25:17 UTC (rev 1271)
@@ -174,12 +174,37 @@
             return this;
         }
 
-        this.elems = function(name) {
-            return new WoolyIterator(this.doc, WoolyElement,
-                                     this.node.childNodes,
-                                     1, name);
+        this.elems = function(name, start) {
+            if (start == null) {
+                start = 0;
+            }
+
+            var iter = new WoolyIterator(this.doc, WoolyElement,
+                                         this.node.childNodes,
+                                         1, name);
+
+            for (var i = 0; i < start; i++) {
+                iter.next();
+            }
+
+            return iter;
         }
 
+        this.elem = function(name, n) {
+            if (n == null) {
+                n = 0;
+            }
+
+            var elems = this.elems(name);
+            var elem = null;
+
+            for (var i = -1; i < n; i++) {
+                elem = elems.next();
+            }
+
+            return elem;
+        }
+
         this.text = function() {
             var children = this.node.childNodes;
 

Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt	2007-11-08 18:48:57 UTC (rev 1270)
+++ mgmt/notes/justin-todo.txt	2007-11-08 19:25:17 UTC (rev 1271)
@@ -6,10 +6,16 @@
 
  * Pagination and sort in tables
 
- * Ajaxify status boxes
+ * Exchange: ajaxify status
 
- * Ajaxify charts
+ * Exchange: ajaxify charts
 
+ * Client: ajaxify status
+
+ * Client: ajaxify status
+
+ * Queue: ajaxify status
+
 Deferred
 
  * Think about making css and jscript pages produce their document in




More information about the rhmessaging-commits mailing list