[node-patches] Change in ovirt-node[master]: status page: Add confirmation dialog page for "reboot" and "...

hadong0720 at gmail.com hadong0720 at gmail.com
Fri May 31 11:32:35 UTC 2013


hadong has uploaded a new change for review.

Change subject: status page: Add confirmation dialog page for "reboot" and "Power off" buttons
......................................................................

status page: Add confirmation dialog page for "reboot" and
"Power off" buttons

Previously the status page missed confirmation dialog page for
"reboot" and " Power off" buttons.
Now this confirmation page has been added.

Change-Id: I56063e812d898e7e7d5490b15e5845115fe45be0
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=968886
Signed-off-by: hadong <hadong0720 at gmail.com>
---
M src/ovirt/node/setup/core/status_page.py
M src/ovirt/node/ui/__init__.py
2 files changed, 30 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/55/15255/1

diff --git a/src/ovirt/node/setup/core/status_page.py b/src/ovirt/node/setup/core/status_page.py
index d88a011..2e4092b 100644
--- a/src/ovirt/node/setup/core/status_page.py
+++ b/src/ovirt/node/setup/core/status_page.py
@@ -121,6 +121,7 @@
 
     def on_merge(self, changes):
         # Handle button presses
+	vmnumber="There are %s Virtual Machines running." % (virt.number_of_domains())
         if "action.lock" in changes:
             self.logger.info("Locking screen")
             self._lock_dialog = LockDialog()
@@ -141,13 +142,25 @@
             self.logger.info("Logging off")
             self.application.quit()
 
+
         elif "action.restart" in changes:
             self.logger.info("Restarting")
+            return ui.ConfirmationDialog("confirm.reboot", "Confirm System Restart",
+                                        vmnumber + "\nThis will restart the system, proceed?")
+
+        elif "confirm.reboot.yes" in changes:
+            self.logger.info("Confirm Restarting")
             self.dry_or(lambda: system.reboot())
 
         elif "action.poweroff" in changes:
             self.logger.info("Shutting down")
+            return ui.ConfirmationDialog("confirm.shutdown", "Confirm System Shutting down",
+                                        vmnumber + "\nThis will shut down the system, proceed?")
+
+        elif "confirm.shutdown.yes" in changes:
+            self.logger.info("Confirm Shutting down")
             self.dry_or(lambda: system.poweroff())
+
 
         elif "action.hostkey" in changes:
             self.logger.info("Showing hostkey")
@@ -219,3 +232,5 @@
                          ]
         self.buttons = [ui.Button("action.unlock", "Unlock")]
         self.escape_key = None
+
+
diff --git a/src/ovirt/node/ui/__init__.py b/src/ovirt/node/ui/__init__.py
index 680e623..4c6ded6 100644
--- a/src/ovirt/node/ui/__init__.py
+++ b/src/ovirt/node/ui/__init__.py
@@ -768,6 +768,21 @@
         self.buttons = [CloseButton("dialog.close")]
 
 
+class ConfirmationDialog(Dialog):
+    """A generic dialog showing a text and offering buttons
+    By default a OK and Close button will be shown.
+    """
+    def __init__(self, path, title, text, buttons=None):
+        super(ConfirmationDialog, self).__init__(path, title, [])
+        self.children = [Divider("divider[0]"),
+                         Label("label[0]", text)
+                         ]
+        if not buttons:
+            # Default: OK and Close
+            self.buttons = [Button(path + ".yes", "OK"),
+                            CloseButton("dialog.close")
+
+
 class TransactionProgressDialog(Dialog):
     """Display the progress of a transaction in a dialog
     """


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I56063e812d898e7e7d5490b15e5845115fe45be0
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: hadong <hadong0720 at gmail.com>



More information about the node-patches mailing list