Author: justi9
Date: 2008-12-11 15:10:55 -0500 (Thu, 11 Dec 2008)
New Revision: 2983
Modified:
mgmt/trunk/cumin/python/cumin/broker.py
mgmt/trunk/cumin/python/cumin/broker.strings
Log:
Add a simple connection status indication to the broker view
Modified: mgmt/trunk/cumin/python/cumin/broker.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/broker.py 2008-12-11 20:03:58 UTC (rev 2982)
+++ mgmt/trunk/cumin/python/cumin/broker.py 2008-12-11 20:10:55 UTC (rev 2983)
@@ -192,8 +192,38 @@
self.add_mode(self.connections_close)
class BrokerStatus(CuminStatus):
- pass
+ def __init__(self, app, name):
+ super(BrokerStatus, self).__init__(app, name)
+ self.connected = self.ConnectedAttribute(app, "conn")
+ self.add_attribute(self.connected)
+
+ def render_status(self, session, reg):
+ if self.connected.get(session):
+ return "Connected"
+ else:
+ return "Disconnected"
+
+ def render_color(self, session, reg):
+ if self.connected.get(session):
+ return "green"
+ else:
+ return "yellow"
+
+ class ConnectedAttribute(Attribute):
+ def get_default(self, session):
+ reg = self.widget.frame.get_object(session)
+ connected = False
+
+ try:
+ mbroker = self.app.model.data.mintBrokersByUrl[reg.url]
+
+ connected = mbroker.connected
+ except KeyError:
+ pass
+
+ return connected
+
class BrokerView(CuminView):
"""
Despite the name, this is actually a view of two objects, usually
Modified: mgmt/trunk/cumin/python/cumin/broker.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/broker.strings 2008-12-11 20:03:58 UTC (rev 2982)
+++ mgmt/trunk/cumin/python/cumin/broker.strings 2008-12-11 20:10:55 UTC (rev 2983)
@@ -105,6 +105,13 @@
</tbody>
</table>
+[BrokerStatus.html]
+<div id="{id}" class="CuminStatus {color}">
+ <h2>Broker Status</h2>
+
+ {status}
+</div>
+
[BrokerStats.html]
<table class="twocol">
<tbody>