mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-04-28 16:59:06 +00:00
add Finished UI² message
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
f9edca42a7
commit
a8fbe0ff55
@ -56,6 +56,11 @@ sub error {
|
||||
get_ui()->error($msg);
|
||||
}
|
||||
|
||||
sub finished {
|
||||
my ($success, $msg) = @_;
|
||||
get_ui()->finished(!!$success, $msg);
|
||||
}
|
||||
|
||||
sub prompt {
|
||||
my ($query) = @_;
|
||||
return get_ui()->prompt($query);
|
||||
|
@ -40,6 +40,12 @@ sub error {
|
||||
croak "implement me in sub-class";
|
||||
}
|
||||
|
||||
sub finished {
|
||||
my ($self, $success, $msg) = @_;
|
||||
|
||||
croak "implement me in sub-class";
|
||||
}
|
||||
|
||||
sub prompt {
|
||||
my ($self, $query) = @_;
|
||||
|
||||
|
@ -25,6 +25,11 @@ sub error {
|
||||
$dialog->destroy();
|
||||
}
|
||||
|
||||
sub finished {
|
||||
my ($self, $success, $msg) = @_;
|
||||
# handled manually in proxinstall at the moment
|
||||
}
|
||||
|
||||
sub prompt {
|
||||
my ($self, $query) = @_;
|
||||
|
||||
|
@ -5,6 +5,8 @@ use warnings;
|
||||
|
||||
use base qw(Proxmox::UI::Base);
|
||||
|
||||
use Proxmox::Log;
|
||||
|
||||
sub init {
|
||||
my ($self) = @_;
|
||||
|
||||
@ -19,10 +21,18 @@ sub message {
|
||||
|
||||
sub error {
|
||||
my ($self, $msg) = @_;
|
||||
|
||||
log_err("error: $msg\n");
|
||||
print STDOUT "error: $msg\n";
|
||||
}
|
||||
|
||||
sub finished {
|
||||
my ($self, $success, $msg) = @_;
|
||||
|
||||
my $state = $success ? 'ok' : 'err';
|
||||
log_info("finished: $state, $msg\n");
|
||||
print STDOUT "finished: $state, $msg\n";
|
||||
}
|
||||
|
||||
sub prompt {
|
||||
my ($self, $query) = @_;
|
||||
|
||||
|
@ -102,20 +102,18 @@ if ($cmd eq 'dump-env') {
|
||||
if (my $err = $@) {
|
||||
# suppress "empty" error as we got some case where the user choose to abort on a prompt,
|
||||
# there it doesn't make sense to show them an error again, they "caused" it after all.
|
||||
warn "installation failed - $err\n";
|
||||
log_error("installation failed: $err");
|
||||
Proxmox::UI::error($err) if $err ne "\n";
|
||||
if ($err ne "\n") {
|
||||
warn "installation failed - $err\n";
|
||||
log_error("installation failed: $err");
|
||||
Proxmox::UI::finished(0, $err);
|
||||
}
|
||||
} else {
|
||||
if (Proxmox::Install::Config::get_autoreboot()) {
|
||||
Proxmox::UI::message("Installation finished - auto-rebooting in ~ 5 seconds");
|
||||
for (my $i = 5; $i > 0; $i--) {
|
||||
sleep(1);
|
||||
exit(0)
|
||||
}
|
||||
Proxmox::UI::finished(1, "Installation finished - auto-rebooting in ~ 5 seconds");
|
||||
} else {
|
||||
while (!Proxmox::UI::prompt("Installation complete - reboot now?")) {}
|
||||
exit(0);
|
||||
Proxmox::UI::finished(1, "Installation complete - reboot now?");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
} elsif ($cmd eq 'start-session-test') {
|
||||
Proxmox::UI::init_stdio({}, $env);
|
||||
|
@ -746,16 +746,20 @@ fn install_progress_dialog(siv: &mut Cursive) -> InstallerView {
|
||||
progress_text.set_content(s);
|
||||
Ok(())
|
||||
}
|
||||
UiMessage::Finished(success, msg) => {
|
||||
counter.set(100);
|
||||
progress_text.set_content(msg.to_owned());
|
||||
cb_sink.send(Box::new(move |siv| {
|
||||
let title = if success { "Success" } else { "Failure" };
|
||||
siv.add_layer(
|
||||
Dialog::text(msg).title(title).button("Reboot", |s| s.quit()),
|
||||
);
|
||||
}))
|
||||
}
|
||||
}
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
cb_sink
|
||||
.send(Box::new(|siv| {
|
||||
siv.add_layer(Dialog::info("low-level install finished"));
|
||||
}))
|
||||
.unwrap();
|
||||
|
||||
Some(())
|
||||
};
|
||||
|
||||
@ -799,6 +803,7 @@ enum UiMessage {
|
||||
Info(String),
|
||||
Error(String),
|
||||
Prompt(String),
|
||||
Finished(bool, String),
|
||||
Progress(usize, String),
|
||||
}
|
||||
|
||||
@ -812,12 +817,16 @@ impl FromStr for UiMessage {
|
||||
"message" => Ok(UiMessage::Info(rest.to_owned())),
|
||||
"error" => Ok(UiMessage::Error(rest.to_owned())),
|
||||
"prompt" => Ok(UiMessage::Prompt(rest.to_owned())),
|
||||
"finished" => {
|
||||
let (state, rest) = rest.split_once(", ").ok_or("invalid message: no state")?;
|
||||
Ok(UiMessage::Finished(state == "ok", rest.to_owned()))
|
||||
}
|
||||
"progress" => {
|
||||
let (percent, rest) = rest.split_once(' ').ok_or("invalid progress message")?;
|
||||
Ok(UiMessage::Progress(
|
||||
percent
|
||||
.parse::<f64>()
|
||||
.map(|v| v.round() as usize)
|
||||
.map(|v| (v * 100.).floor() as usize)
|
||||
.map_err(|err| err.to_string())?,
|
||||
rest.to_owned(),
|
||||
))
|
||||
|
Loading…
Reference in New Issue
Block a user