all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 7/7] low-level, tui: count down auto-reboot timeout
Date: Wed, 26 Jul 2023 16:04:01 +0200	[thread overview]
Message-ID: <20230726140406.1048552-8-c.heiss@proxmox.com> (raw)
In-Reply-To: <20230726140406.1048552-1-c.heiss@proxmox.com>

The GUI installer already has the same functionality, with this the TUI
installer gains the same. It is a nice touch anyway, primarily to
indicate to the user that the installer is not frozen or similar.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
 proxmox-low-level-installer                   | 25 +++++++++++--------
 .../src/views/install_progress.rs             | 12 +++++++--
 2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/proxmox-low-level-installer b/proxmox-low-level-installer
index 745402a..0141170 100755
--- a/proxmox-low-level-installer
+++ b/proxmox-low-level-installer
@@ -69,6 +69,19 @@ sub read_and_merge_config {
     log_info("got installation config: ". to_json(Proxmox::Install::Config::get(), { utf8 => 1, canonical => 1 }) ."\n");
 }
 
+sub send_reboot_ui_message {
+    if (Proxmox::Install::Config::get_autoreboot()) {
+	my $secs = 5;
+	while ($secs > 0) {
+	    Proxmox::UI::finished(1, "Installation finished - auto-rebooting in $secs seconds ..");
+	    sleep 1;
+	    $secs -= 1;
+	}
+    } else {
+	Proxmox::UI::finished(1, "Installation complete - reboot now?");
+    }
+}
+
 my $cmd = shift;
 if (!$cmd || $cmd eq 'help' || !exists($commands->{$cmd})) {
     usage($cmd // '');
@@ -115,11 +128,7 @@ if ($cmd eq 'dump-env') {
 	    Proxmox::UI::finished(0, $err);
 	}
     } else {
-	if (Proxmox::Install::Config::get_autoreboot()) {
-	    Proxmox::UI::finished(1, "Installation finished - auto-rebooting in ~ 5 seconds");
-	} else {
-	    Proxmox::UI::finished(1, "Installation complete - reboot now?");
-	}
+	send_reboot_ui_message();
     }
 } elsif ($cmd eq 'start-session-test') {
     Proxmox::UI::init_stdio({}, $env);
@@ -137,11 +146,7 @@ if ($cmd eq 'dump-env') {
 	}
     }
 
-    if (Proxmox::Install::Config::get_autoreboot()) {
-	Proxmox::UI::finished(1, "Installation finished - auto-rebooting in ~ 5 seconds");
-    } else {
-	Proxmox::UI::finished(1, "Installation complete - reboot now?");
-    }
+    send_reboot_ui_message();
 }
 
 exit(0);
diff --git a/proxmox-tui-installer/src/views/install_progress.rs b/proxmox-tui-installer/src/views/install_progress.rs
index 2025a4c..c8d9aab 100644
--- a/proxmox-tui-installer/src/views/install_progress.rs
+++ b/proxmox-tui-installer/src/views/install_progress.rs
@@ -9,7 +9,7 @@ use std::{
 
 use cursive::{
     utils::Counter,
-    view::{Resizable, ViewWrapper},
+    view::{Nameable, Resizable, ViewWrapper},
     views::{Dialog, DummyView, LinearLayout, PaddedView, ProgressBar, TextContent, TextView},
     CbSink, Cursive,
 };
@@ -102,13 +102,21 @@ fn show_prompt<W: Write + 'static>(siv: &mut Cursive, text: &str, writer: Arc<Mu
 }
 
 fn prepare_for_reboot(siv: &mut Cursive, success: bool, msg: &str) {
+    const DIALOG_ID: &str = "autoreboot-dialog";
     let title = if success { "Success" } else { "Failure" };
 
+    // If the dialog was previously created, just update its content and we're done.
+    if let Some(mut dialog) = siv.find_name::<Dialog>(DIALOG_ID) {
+        dialog.set_content(TextView::new(msg));
+        return;
+    }
+
     // For rebooting, we just need to quit the installer, our caller does the actual reboot.
     siv.add_layer(
         Dialog::text(msg)
             .title(title)
-            .button("Reboot now", Cursive::quit),
+            .button("Reboot now", Cursive::quit)
+            .with_name(DIALOG_ID),
     );
 
     let autoreboot = siv
-- 
2.41.0





      parent reply	other threads:[~2023-07-26 14:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-26 14:03 [pve-devel] [PATCH installer 0/7] refactor; improve installation progress Christoph Heiss
2023-07-26 14:03 ` [pve-devel] [PATCH installer 1/7] tui: move install progress dialog into own view module Christoph Heiss
2023-07-26 14:03 ` [pve-devel] [PATCH installer 2/7] tui: install progress: split out low-level installer spawing into own function Christoph Heiss
2023-07-26 14:03 ` [pve-devel] [PATCH installer 3/7] tui: install progress: split out reboot handling " Christoph Heiss
2023-07-26 14:03 ` [pve-devel] [PATCH installer 4/7] tui: install progress: split out prompt logic " Christoph Heiss
2023-07-26 14:03 ` [pve-devel] [PATCH installer 5/7] tui: install progress: handle errors in ui message loop more gracefully Christoph Heiss
2023-07-26 14:04 ` [pve-devel] [PATCH installer 6/7] low-level: avoid open-coding config reading, parsing and merging Christoph Heiss
2023-07-26 14:04 ` Christoph Heiss [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230726140406.1048552-8-c.heiss@proxmox.com \
    --to=c.heiss@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal