[rhmessaging-commits] rhmessaging commits: r2686 - mgmt/trunk/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Oct 24 11:40:35 EDT 2008


Author: eallen
Date: 2008-10-24 11:40:35 -0400 (Fri, 24 Oct 2008)
New Revision: 2686

Modified:
   mgmt/trunk/cumin/python/cumin/scheduler.py
   mgmt/trunk/cumin/python/cumin/scheduler.strings
Log:
Rename status box to Scheduler Status
Implement ajax update of scheduler start/stop status

Modified: mgmt/trunk/cumin/python/cumin/scheduler.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/scheduler.py	2008-10-24 15:39:53 UTC (rev 2685)
+++ mgmt/trunk/cumin/python/cumin/scheduler.py	2008-10-24 15:40:35 UTC (rev 2686)
@@ -141,9 +141,22 @@
         data = "model.xml?class=scheduler;id=%i" % sched.id
         return "wooly.setIntervalUpdate('%s', updateScheduler, 3000)" % data
 
-class SchedulerStatus(CuminStatus):
-    pass
+class SchedulerStatus(CuminStatus, AjaxField):
+    def render_scheduler_status(self, session, scheduler):
+        return "<span id=\"%s\"></span>%s" % \
+            (self.name, self.render_script(session))
 
+    def render_color(self, session, scheduler):
+        return "transparent"
+        
+    def get_url(self, session):
+        scheduler = self.get_args(session)[0]
+        if scheduler:
+            return "call.xml?class=scheduler;id=%i;method=GetStarted" % scheduler.id
+
+    def got_fn(self, session):
+        return "startstop_status"
+
 class SchedulerStats(Widget):
     def __init__(self, app, name):
         super(SchedulerStats, self).__init__(app, name)

Modified: mgmt/trunk/cumin/python/cumin/scheduler.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/scheduler.strings	2008-10-24 15:39:53 UTC (rev 2685)
+++ mgmt/trunk/cumin/python/cumin/scheduler.strings	2008-10-24 15:40:35 UTC (rev 2686)
@@ -15,7 +15,7 @@
 {sql_limit}
 
 [SchedulerSet.count_sql]
-select count(*) from scheduler as s
+select count(1) from scheduler as s
 {sql_where}
 
 [SchedulerView.javascript]
@@ -99,3 +99,54 @@
 	<div>{hidden_inputs}</div>
 </form>
 
+[SchedulerStatus.css]
+#recTime {
+	display:none;
+}
+[SchedulerStatus.javascript]
+function got_startstop_status(obj, id) {
+    var elem = document.getElementById(id);
+    if (elem) {
+		var recTime = obj.rectime;
+		var confidence = obj.confidence;
+        var color = "clear";
+		var started = "Pending...";
+		var timeout;
+	    
+		var oRecTime = document.getElementById("recTime");
+		if (oRecTime) {
+			origRecTime = oRecTime.innerHTML;
+			oRecTime.innerHTML = recTime;
+			if (origRecTime == "") {
+				timeout = 1000;
+			} else if (recTime == origRecTime) {
+				fConfidence = parseFloat(confidence);
+				if (fConfidence < 75) { /* hasn't changed in approx 2.5 minutes */
+					color = "red";
+					started = "Stopped";
+					timeout = 10000;
+				}
+				else {
+					timeout = 1000;
+				}
+			} else {
+	        	color = "green";
+				started = "Started";
+				timeout = 0;
+			}
+	        elem.innerHTML = started;
+			elem.parentNode.className = "CuminStatus " + color;
+			if (timeout > 0) {
+				setTimeout("get_status()", 5000); 
+			}	
+		}
+    }
+}
+
+[SchedulerStatus.html]
+<div id="{id}" class="CuminStatus {color}">
+  <h2>Scheduler Status</h2>
+  {scheduler_status}
+  <div id="recTime"></div>
+</div>
+




More information about the rhmessaging-commits mailing list