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

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue May 19 13:56:56 EDT 2009


Author: eallen
Date: 2009-05-19 13:56:56 -0400 (Tue, 19 May 2009)
New Revision: 3384

Modified:
   mgmt/trunk/cumin/python/cumin/__init__.py
   mgmt/trunk/cumin/python/cumin/action.py
   mgmt/trunk/cumin/python/cumin/action.strings
   mgmt/trunk/cumin/python/cumin/model.py
   mgmt/trunk/cumin/python/cumin/widgets.py
   mgmt/trunk/cumin/python/cumin/widgets.strings
Log:
1st cut at generic message/alert box. This version will show the actionInvocations.

Modified: mgmt/trunk/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/__init__.py	2009-05-19 17:55:07 UTC (rev 3383)
+++ mgmt/trunk/cumin/python/cumin/__init__.py	2009-05-19 17:56:56 UTC (rev 3384)
@@ -16,7 +16,6 @@
 from demo import DemoData
 from page import MainPage
 from stat import StatChartPage, StatStackedPage, SlotMapPage
-from action import ActionPage
 from user import LoginPage, UserSession, UserSessionExpireThread
 from datetime import timedelta
 from qpid.util import URL
@@ -50,7 +49,6 @@
         self.add_page(DevelPage(self, "devel.html"))
         self.add_page(ModelPage(self, "model.xml"))
         self.add_page(CallPage(self, "call.xml"))
-        self.add_page(ActionPage(self, "actions.html"))
         self.add_page(StatChartPage(self, "stats.png"))
         self.add_page(StatStackedPage(self, "stacked.png"))
         self.add_page(SlotMapPage(self, "slots.png"))

Modified: mgmt/trunk/cumin/python/cumin/action.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/action.py	2009-05-19 17:55:07 UTC (rev 3383)
+++ mgmt/trunk/cumin/python/cumin/action.py	2009-05-19 17:56:56 UTC (rev 3384)
@@ -8,81 +8,55 @@
 
 strings = StringCatalog(__file__)
 
-class ActionPage(HtmlPage):
+class ActionInvocationSet(ItemSet):
     def __init__(self, app, name):
-        super(ActionPage, self).__init__(app, name)
-
-        self.__actions = ActionInvocationSet(app, "actions")
-        self.add_child(self.__actions)
-
-    def render_title(self, session, *args):
-        return "Actions"
-
-class ActionInvocationSet(ItemTable):
-    def __init__(self, app, name):
         super(ActionInvocationSet, self).__init__(app, name)
 
-        col = self.DescriptionColumn(app, "desc")
-        self.add_column(col)
+        self.update_enabled = True
 
-        col = self.WhenColumn(app, "when")
-        self.add_column(col)
+    def get_item_count(self, session, *args):
+        items = self.do_get_items(session, *args)
+        return len(items)
 
-        col = self.StatusColumn(app, "status")
-        self.add_column(col)
+    def do_get_items(self, session, *args):
+        nsecs = secs(datetime.now())
+        return [x for x in reversed(sorted_by(self.app.model.invocations, "when")) if nsecs - secs(x.when) < 60]
 
-    class DescriptionColumn(ItemTableColumn):
-        def render_title(self, session, item):
-            return "Description"
+    def render_item_content(self, session, item):
+        delta = secs(datetime.now()) - secs(item.when)
+        if delta < 60:
+            return super(ActionInvocationSet, self).render_item_content(session, item)
 
-        def render_content(self, session, item):
-            return item.get_description(session)
+    def render_when(self, session, item):
+        delta = secs(datetime.now()) - secs(item.when)
+        duration = fmt_duration(delta)
+        if duration:
+            return "%s ago" % duration
+        else:
+            return ""
 
-    class WhenColumn(ItemTableColumn):
-        def render_title(self, session, item):
-            return "When"
+    def render_description(self, session, item):
+        return item.get_description(session)
 
-        def render_content(self, session, item):
-            delta = secs(datetime.now()) - secs(item.when)
-            duration = fmt_duration(delta)
-            if duration:
-                return "%s ago" % duration
-            else:
-                ""
+    def render_status_class(self, session, item):
+        text = "normal"
+        if item.status == "pending":
+            text = "warning"
+        else:
+            if item.exception:
+                text = "error"
 
-    class StatusColumn(ItemTableColumn):
-        def render_title(self, session, item):
-            return "Status"
+        return text
 
-        def render_content(self, session, item):
-            if item.status == "pending":
-                text = "Pending"
-            elif item.status == "OK":
-                text = "Completed"
+    def render_status(self, session, item):
+        if item.status == "pending":
+            text = "Pending"
+        elif item.status == "OK":
+            text = "Completed"
+        else:
+            if item.exception:
+                text = "Failed: " + str(item.exception)
             else:
-                if item.exception:
-                    text = "Failed: " + str(item.exception)
-                else:
-                    text = "Failed: " + item.status
+                text = "Failed: " + item.status
 
-            return text
-
-    def do_get_items(self, session, *args):
-        return reversed(sorted_by(self.app.model.invocations, "when"))
-
-class ActionInvocationStatus(Widget):
-    def __init__(self, app, name):
-        super(ActionInvocationStatus, self).__init__(app, name)
-
-        self.update_enabled = True
-
-    def render_pending_count(self, session):
-        return self.app.model.count_invocations("pending")
-
-    def render_completed_count(self, session):
-        return self.app.model.count_invocations("OK")
-
-    def render_failed_count(self, session):
-        pcount = self.app.model.count_invocations("pending")
-        ccount = self.app.model.count_invocations("OK")
-        return len(self.app.model.invocations) - pcount - ccount
+        return text

Modified: mgmt/trunk/cumin/python/cumin/action.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/action.strings	2009-05-19 17:55:07 UTC (rev 3383)
+++ mgmt/trunk/cumin/python/cumin/action.strings	2009-05-19 17:56:56 UTC (rev 3384)
@@ -1,30 +1,30 @@
-[ActionPage.css]
-body {
-    margin: 1em;
-}
-
 [ActionInvocationSet.html]
-<table class="mobjects">
-  <thead>
-    <tr>{headers}</tr>
-  </thead>
-  <tbody>{items}</tbody>
-</table>
+<div id="{id}" class="actionInvocation">{items}</div>
 
-[ActionInvocationStatus.javascript]
+[ActionInvocationSet.item_html]
+<div class="action">
+<span class="description">{description}</span> <span class="{status_class}">{status}</span>
+</div>
+
+[ActionInvocationSet.javascript]
 (function() {
-    cumin.popupActions = function() {
-        window.open("actions.html", "actions",
-                    "width=640,height=480,scrollbars=yes");
+    var old_action_count = 0;
+    cumin.hideActions = function () {
+        $("messages").dissolve();
     }
+    cumin.showActions = function () {
+        $("messages").reveal();
+    }
+
+    wooly.addPageUpdateListener( function () {
+        var actions = $$('div#messages div.action');
+        if (actions.length > old_action_count) {
+            cumin.showActions();
+        }
+        if (actions.length == 0) {
+            cumin.hideActions();
+        }
+        old_action_count = actions.length;
+    } );
+
 }())
-
-[ActionInvocationStatus.html]
-<span id="{id}">
-  Actions:
-  <a href="javascript:cumin.popupActions()">
-    <span>{pending_count}</span> pending,
-    <span>{completed_count}</span> completed,
-    <span>{failed_count}</span> failed
-  </a>
-</span>

Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py	2009-05-19 17:55:07 UTC (rev 3383)
+++ mgmt/trunk/cumin/python/cumin/model.py	2009-05-19 17:56:56 UTC (rev 3384)
@@ -873,8 +873,11 @@
 #        return super(CuminBroker, self).show_object(session, reg)
 
     def get_object_name(self, broker):
-        host, port = broker.system.nodeName, broker.port
-        return "%s:%i" % (host, port)
+        try:
+            host, port = broker.system.nodeName, broker.port
+            return "%s:%i" % (host, port)
+        except:
+            return broker.name
 
     class StatusStat(CuminStat):
         def value_text(self, broker):

Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py	2009-05-19 17:55:07 UTC (rev 3383)
+++ mgmt/trunk/cumin/python/cumin/widgets.py	2009-05-19 17:56:56 UTC (rev 3384)
@@ -7,6 +7,7 @@
 from wooly.tables import *
 from mint.schema import *
 
+from action import *
 from parameters import *
 from charts import *
 from formats import *
@@ -50,8 +51,8 @@
 
         self.__frame_tmpl = Template(self, "frame_html")
 
-        #self.actions = ActionInvocationStatus(app, "actions")
-        #self.add_child(self.actions)
+        self.actions = ActionInvocationSet(app, "actions")
+        self.add_child(self.actions)
 
     def show_child(self, session, child):
         super(CuminMainView, self).show_child(session, child)
@@ -65,6 +66,9 @@
         if hasattr(session, "user_session"):
             return session.user_session.subject.name
 
+    def render_action_display(self, session):
+        return self.actions.get_item_count(session) > 0 and "block" or "none"
+
     def render_logout_href(self, session):
         page = self.app.login_page
 

Modified: mgmt/trunk/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.strings	2009-05-19 17:55:07 UTC (rev 3383)
+++ mgmt/trunk/cumin/python/cumin/widgets.strings	2009-05-19 17:56:56 UTC (rev 3384)
@@ -79,7 +79,35 @@
   z-index: 1;
   min-height: 20em;
 }
+#messages {
+    -moz-border-radius: 0.35em;
+    border: 1px solid #886;
+    background-color: #ffd;
+    display: none;
+    font-size: 0.8em;
+    font-weight: normal;
+    padding: 6px 8px;
+    position: relative;
+    z-index: 1;
+    width: 96%;
+    margin-top: 0.25em;
+    margin-bottom: 0.25em;
+    margin-left: 2%;
+}
 
+#messages p {
+    width: 1em;
+    height: 0.8em;
+    cursor: pointer;
+    float: right;
+    font-weight: bold;
+    font-size: 1.2em;
+    margin: 0;
+    padding: 0 0.25em 0.25em 0.25em;
+    position: relative;
+    top: -2px;
+}
+
 [CuminMainView.html]
 <div id="head">
   <div id="user">
@@ -92,9 +120,12 @@
 
   <ul id="tabs">{tabs}</ul>
 </div>
+<div id="body">
 
-<div id="body">{content}</div>
+<div id="messages" style="display: {action_display};"><p title="close" onclick="cumin.hideActions()">x</p>{actions}</div>
 
+{content}</div>
+
 <div id="foot"/>
 
 [CuminMainView.frame_html]
@@ -231,6 +262,7 @@
     margin: 0.5em 0;
     padding: 0.5em 0.75em;
     width: 15em;
+    display: none;
 }
 
 div.CuminStatus h2 {




More information about the rhmessaging-commits mailing list