[node-patches] Change in ovirt-node[master]: Add ranking to pages

fabiand at fedoraproject.org fabiand at fedoraproject.org
Tue Dec 11 20:09:32 UTC 2012


Fabian Deutsch has uploaded a new change for review.

Change subject: Add ranking to pages
......................................................................

Add ranking to pages

Change-Id: I368473500fde0fee8d678c9be68f7b50a9ade2e0
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/plugins/__init__.py
M scripts/tui/src/ovirt/node/plugins/example.py
M scripts/tui/src/ovirt/node/plugins/features.py
M scripts/tui/src/ovirt/node/plugins/ping.py
M scripts/tui/src/ovirt/node/plugins/usage.py
M scripts/tui/src/ovirt/node/widgets.py
6 files changed, 19 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/71/9871/1

diff --git a/scripts/tui/src/ovirt/node/plugins/__init__.py b/scripts/tui/src/ovirt/node/plugins/__init__.py
index 00634af..337d38d 100644
--- a/scripts/tui/src/ovirt/node/plugins/__init__.py
+++ b/scripts/tui/src/ovirt/node/plugins/__init__.py
@@ -58,6 +58,11 @@
         """
         raise Exception("Not yet implemented.")
 
+    def rank(self):
+        """Is used to add a order in-between plugins 0<n<100
+        """
+        return 50
+
     def model(self):
         """Returns the model of the plugin.
         A model is just a dict (key-PatternObj) where each path (key) maps to a
diff --git a/scripts/tui/src/ovirt/node/plugins/example.py b/scripts/tui/src/ovirt/node/plugins/example.py
index ad43100..f2cac40 100644
--- a/scripts/tui/src/ovirt/node/plugins/example.py
+++ b/scripts/tui/src/ovirt/node/plugins/example.py
@@ -16,7 +16,7 @@
     _widgets = None
 
     def name(self):
-        return os.path.basename(__file__)
+        return "Example Page"
 
     def model(self):
         """Returns the model of this plugin
diff --git a/scripts/tui/src/ovirt/node/plugins/features.py b/scripts/tui/src/ovirt/node/plugins/features.py
index 2c7ee69..b34d12d 100644
--- a/scripts/tui/src/ovirt/node/plugins/features.py
+++ b/scripts/tui/src/ovirt/node/plugins/features.py
@@ -19,6 +19,8 @@
     def name(self):
         return "Features"
 
+    rank = lambda self: 10
+
     def ui_content(self):
         widgets = [
             ("features.info", ovirt.node.plugins.Label(features))
diff --git a/scripts/tui/src/ovirt/node/plugins/ping.py b/scripts/tui/src/ovirt/node/plugins/ping.py
index 51b1b75..4f2e004 100644
--- a/scripts/tui/src/ovirt/node/plugins/ping.py
+++ b/scripts/tui/src/ovirt/node/plugins/ping.py
@@ -18,6 +18,9 @@
     def name(self):
         return "Tools (ping)"
 
+    def rank(self):
+        return 70
+
     def model(self):
         """Returns the model of this plugin
         This is expected to parse files and all stuff to build up the model.
@@ -40,11 +43,6 @@
                 "ping.address": ovirt.node.valid.FQDNOrIPAddress(),
                 "ping.count": ovirt.node.valid.Number(min=1, max=20),
             }
-
-    def ui_metadata(self):
-        meta = super(Plugin, self).ui_metadata()
-#        meta.save_button = False
-        return meta
 
     def ui_content(self):
         """Describes the UI this plugin requires
diff --git a/scripts/tui/src/ovirt/node/plugins/usage.py b/scripts/tui/src/ovirt/node/plugins/usage.py
index 0131778..a7137a3 100644
--- a/scripts/tui/src/ovirt/node/plugins/usage.py
+++ b/scripts/tui/src/ovirt/node/plugins/usage.py
@@ -21,6 +21,8 @@
     def name(self):
         return "Usage"
 
+    rank = lambda self: 10
+
     def ui_content(self):
         widgets = [
             ("usage.info", ovirt.node.plugins.Label(usage))
diff --git a/scripts/tui/src/ovirt/node/widgets.py b/scripts/tui/src/ovirt/node/widgets.py
index c3b173b..1b492a2 100644
--- a/scripts/tui/src/ovirt/node/widgets.py
+++ b/scripts/tui/src/ovirt/node/widgets.py
@@ -50,12 +50,17 @@
 
     def __build_walker(self):
         items = []
-        for title, plugin in self.__pages.items():
+
+        plugins = self.__pages.items()
+        plugins = sorted(plugins, key=lambda two: two[1].rank())
+
+        for title, plugin in plugins:
             if plugin.has_ui():
                 item = PluginMenuEntry(title, plugin)
                 items.append(item)
             else:
                 LOGGER.warning("No UI page for plugin %s" % plugin)
+
         self.__walker = urwid.SimpleListWalker(items)
 
     def __build_list(self):


--
To view, visit http://gerrit.ovirt.org/9871
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I368473500fde0fee8d678c9be68f7b50a9ade2e0
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list