[rhmessaging-commits] rhmessaging commits: r1832 - mgmt/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Wed Apr 2 14:24:24 EDT 2008


Author: justi9
Date: 2008-04-02 14:24:24 -0400 (Wed, 02 Apr 2008)
New Revision: 1832

Modified:
   mgmt/cumin/python/cumin/model.py
   mgmt/cumin/python/cumin/system.py
   mgmt/cumin/python/cumin/system.strings
   mgmt/cumin/python/cumin/widgets.py
   mgmt/cumin/python/cumin/widgets.strings
Log:
Introduce an object summary that works from the ui metadata.  This is
to replace all the custom object props and actions html.

As a first deployment, change the system ui to use it.

Add summary=False attrs to props, actions, and stats, to control
whether they are shown as part of the summary or only in the larger
property and action displays.



Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py	2008-04-02 18:20:33 UTC (rev 1831)
+++ mgmt/cumin/python/cumin/model.py	2008-04-02 18:24:24 UTC (rev 1832)
@@ -85,6 +85,7 @@
         self.name = name
         self.title = None
         self.categories = ()
+        self.summary = False
 
         self.cumin_class.add_property(self)
 
@@ -111,9 +112,16 @@
         self.cumin_class = cls
         self.name = name
         self.title = None
-
+        self.summary = False
+        
         self.cumin_class.add_action(self)
 
+    def get_title(self, session):
+        if self.title:
+            return self.title
+        else:
+            return self.name
+
     def invoke(self, object, args={}):
         invoc = CuminActionInvocation(self, object)
 
@@ -173,6 +181,7 @@
         self.unit = None
         self.title = None
         self.categories = ()
+        self.summary = False
 
         self.link_cb = None
         self.highlow = False
@@ -353,6 +362,7 @@
         prop = CuminProperty(self, "recTime")
         prop.title = "Last Updated"
         prop.categories = ("basic",)
+        prop.summary = True
 
 class LocalClass(CuminClass):
     def __init__(self, model, name, mint_class):
@@ -413,6 +423,7 @@
         
         prop = CuminProperty(self, "nodeName")
         prop.title = "Address"
+        prop.summary = True
 
         prop = CuminProperty(self, "osName")
         prop.title = "Kernel"
@@ -426,6 +437,10 @@
         prop = CuminProperty(self, "machine")
         prop.title = "Architecture"
 
+        action = CuminAction(self, "ping")
+        action.title = "Send Ping"
+        action.summary = True
+
 class CuminBroker(RemoteClass):
     def __init__(self, model):
         super(CuminBroker, self).__init__(model, "broker", Broker, BrokerStats)

Modified: mgmt/cumin/python/cumin/system.py
===================================================================
--- mgmt/cumin/python/cumin/system.py	2008-04-02 18:20:33 UTC (rev 1831)
+++ mgmt/cumin/python/cumin/system.py	2008-04-02 18:24:24 UTC (rev 1832)
@@ -61,6 +61,9 @@
     def __init__(self, app, name):
         super(SystemView, self).__init__(app, name)
 
+        self.summary = CuminSummary(app, "summary")
+        self.add_child(self.summary)
+
         self.status = SystemStatus(app, "status")
         self.add_child(self.status)
 

Modified: mgmt/cumin/python/cumin/system.strings
===================================================================
--- mgmt/cumin/python/cumin/system.strings	2008-04-02 18:20:33 UTC (rev 1831)
+++ mgmt/cumin/python/cumin/system.strings	2008-04-02 18:24:24 UTC (rev 1832)
@@ -27,13 +27,6 @@
 [SystemView.html]
 <h1><img src="resource?name=system-36.png"/>{title}</h1>
 
-<table class="props">
-  <tr><th>Address</th><td>{address}</td></tr>
-  <tr><th>Kernel</th><td>{kernel} {kernel_release}<br/>{kernel_version}</td></tr>
-  <tr><th>Architecture</th><td>{architecture}</td></tr>
-  <tr><th>Updated</th><td>{updated}</td></tr>
-  <tr><th>Created &ndash; Deleted</th><td>{created_deleted}</td></tr>
-  <tr><th>Updated</th><td>{updated}</td></tr>
-</table>
+{summary}
 
 {tabs}

Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py	2008-04-02 18:20:33 UTC (rev 1831)
+++ mgmt/cumin/python/cumin/widgets.py	2008-04-02 18:24:24 UTC (rev 1832)
@@ -261,7 +261,29 @@
 
     def render_title(self, session):
         return "Details"
-    
+
+class CuminSummary(Widget):
+    def __init__(self, app, name):
+        super(CuminSummary, self).__init__(app, name)
+
+        props = self.SummaryProperties(app, "properties")
+        self.add_child(props)
+
+        actions = self.SummaryActions(app, "actions")
+        self.add_child(actions)
+
+    class SummaryProperties(CuminProperties):
+        def do_get_items(self, session, object):
+            cls = self.app.model.get_class_by_object(object)
+            return [(x.get_title(session), x.value(object))
+                    for x in cls.properties if x.summary]
+
+    class SummaryActions(CuminActions):
+        def do_get_items(self, session, object):
+            cls = self.app.model.get_class_by_object(object)
+            return [("", x.get_title(session))
+                    for x in cls.actions if x.summary]
+
 class StateSwitch(ItemSet):
     def __init__(self, app, name):
         super(StateSwitch, self).__init__(app, name)

Modified: mgmt/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/cumin/python/cumin/widgets.strings	2008-04-02 18:20:33 UTC (rev 1831)
+++ mgmt/cumin/python/cumin/widgets.strings	2008-04-02 18:24:24 UTC (rev 1832)
@@ -121,6 +121,7 @@
 [CuminDetails.css]
 table.CuminDetails {
   width: 100%;
+  border-collapse: collapse;
 }
 
 table.CuminDetails td {
@@ -140,6 +141,72 @@
   </tr>
 </table>
 
+[CuminSummary.css]
+table.CuminSummary {
+  width: 36em;
+  font-size: 0.9em;
+  margin: 0 0 1em 0;
+  border-collapse: collapse;
+}
+
+table.CuminSummary td.properties {
+  width: 50%;
+  padding: 0.5em;
+  border-top: 1px dotted #ccc;
+  border-right: 1px dotted #ccc;
+}
+
+table.CuminSummary td.actions {
+  width: 50%;
+  padding: 0.5em;
+  border-top: 1px dotted #ccc;
+}
+
+table.CuminSummary table.PropertySet {
+  margin: 0.5em 0;
+}
+
+table.CuminSummary ul.ActionSet {
+  margin: 0.5em 0;
+}
+
+table.CuminSummary ul.ActionSet li {
+  list-style-type: square;
+}
+
+[CuminSummary.html]
+<table class="CuminSummary">
+  <tr>
+    <td class="properties">
+      {properties}
+    </td>
+    <td class="actions">
+      <div>Act on this object:</div>
+      {actions}
+    </td>
+  </tr>
+</table>
+
+[SummaryProperties.css]
+dl.SummaryProperties {
+  margin: 0 0 0.5em 0;
+}
+
+dl.SummaryProperties dt {
+  font-size: 0.9em;
+  font-weight: bold;
+}
+
+dl.SummaryProperties dt {
+  font-size: 0.9em;
+}
+
+[SummaryProperties.html]
+<dl class="SummaryProperties">{items}</dl>
+
+[SummaryProperties.property_html]
+<dt>{title}</dt><dd>{value}</dd>
+
 [StateSwitch.html]
 <ul class="radiotabs">
   {items}




More information about the rhmessaging-commits mailing list