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