Discussion:
[pve-devel] [PATCH v4 installer] implement prev button and ack screen
Oguz Bektas
2018-12-10 11:13:30 UTC
Permalink
* adds a previous button
* adds an acknowledgement screen before the last install step
* modify the html files according to the new steps
* implements some structure into the script which will be later
used to make it more modular in the long run

Signed-off-by: Oguz Bektas <***@proxmox.com>
---
html-common/Makefile | 1 +
html-common/ack_template.htm | 88 ++++++++++++++++++++
html-common/ipconf.htm | 4 +-
proxinstall | 185 +++++++++++++++++++++++++++++++++++++++----
4 files changed, 262 insertions(+), 16 deletions(-)
create mode 100644 html-common/ack_template.htm

diff --git a/html-common/Makefile b/html-common/Makefile
index 1e041d1..4c90c6e 100644
--- a/html-common/Makefile
+++ b/html-common/Makefile
@@ -11,6 +11,7 @@ install:
install -D -m 644 ipconf.htm ${DESTDIR}/var/lib/pve-installer/html/ipconf.htm
install -D -m 644 nohds.htm ${DESTDIR}/var/lib/pve-installer/html/nohds.htm
install -D -m 644 nonics.htm ${DESTDIR}/var/lib/pve-installer/html/nonics.htm
+ install -D -m 644 ack_template.htm ${DESTDIR}/var/lib/pve-installer/html/ack_template.htm

.phony: clean
clean:
diff --git a/html-common/ack_template.htm b/html-common/ack_template.htm
new file mode 100644
index 0000000..af7f20a
--- /dev/null
+++ b/html-common/ack_template.htm
@@ -0,0 +1,88 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="pve-installer.css">
+</head>
+<body>
+<center>
+<table border="0" width="800">
+<tr><td>&nbsp;</td></tr>
+<tr>
+ <td colspan="4" align="center" width="800">
+ <b class="htext">Summary</b>
+ </td>
+</tr>
+<tr>
+ <td colspan="2" valign="top" width="400"><br><p>
+ <table>
+ <tbody><tr><td><b>Please verify</b>
+ the displayed informations.
+ <br><br>
+ Afterwards press the <b>Install</b> button. The installer will
+ begin to partition your drive and extract the required files.
+
+
+ </td></tr>
+ </tbody></table>
+</tr>
+
+<table border="0" width="800">
+
+<tr>
+ <th>Option</th>
+ <th>Value</th>
+</tr>
+
+<tr>
+ <td>Disk:</td>
+ <td>__target_hd__</td>
+</tr>
+
+<tr>
+ <td>Country:</td>
+ <td>__country__</td>
+</tr>
+<tr>
+ <td>Timezone:</td>
+ <td>__timezone__</td>
+</tr>
+<tr>
+ <td>Keymap:</td>
+ <td>__keymap__</td>
+</tr>
+<tr>
+ <td>E-Mail:</td>
+ <td>__mailto__</td>
+</tr>
+<tr>
+ <td>Interface:</td>
+ <td>__interface__</td>
+</tr>
+<tr>
+ <td>Hostname:</td>
+ <td>__hostname__</td>
+</tr>
+<tr>
+ <td>IP:</td>
+ <td>__ip__</td>
+</tr>
+<tr>
+ <td>Netmask:</td>
+ <td>__netmask__</td>
+</tr>
+<tr>
+ <td>Gateway:</td>
+ <td>__gateway__</td>
+</tr>
+<tr>
+ <td>DNS:</td>
+ <td>__dnsserver__</td>
+</tr>
+
+</tr>
+</table>
+
+
+</tbody></table>
+</center>
+</body></html>
diff --git a/html-common/ipconf.htm b/html-common/ipconf.htm
index ba699ed..2aefa90 100644
--- a/html-common/ipconf.htm
+++ b/html-common/ipconf.htm
@@ -19,8 +19,8 @@
the displayed network configuration. You will need a valid network
configuration to access the management interface after installation.
<br><br>
- Afterwards press the <b>Install</b> button to start the installation. The
- installer will then partition your hard disk and start copying packages.
+ Afterwards press the Next button. You will be displayed a list of the options
+ that you chose during the previous steps.
</td></tr>
</tbody></table>
</p></td>
diff --git a/proxinstall b/proxinstall
index 159c727..46112a3 100755
--- a/proxinstall
+++ b/proxinstall
@@ -190,9 +190,63 @@ my $ipv4_reverse_mask = [
'255.255.255.255',
];

+my $stack_number = 0; # Init number for global function list
+
+my @function_list = (
+
+ # Description: Global array list for functions
+
+ 'intro',
+ 'hdsel',
+ 'country',
+ 'password',
+ 'ipconf',
+ 'ack',
+ 'extract',
+);
+
+my $function_options = {
+
+ # Description: Custom options for functions
+
+ intro => {
+ html => 'license.htm',
+ button => 'I a_gree',
+ function => \&create_intro_view,
+ },
+ hdsel => {
+ html => 'page1.htm',
+ function => \&create_hdsel_view,
+ },
+ country => {
+ html => 'country.htm',
+ function => \&create_country_view,
+ },
+ password => {
+ html => 'passwd.htm',
+ function => \&create_password_view,
+ },
+ ipconf => {
+ html => 'ipconf.htm',
+ function => \&create_ipconf_view,
+ },
+ ack => {
+ html => 'ack.htm',
+ next_button => '_Install',
+ function => \&create_ack_view,
+ },
+ extract => {
+ next_button => '_Reboot',
+ function => \&create_extract_view,
+ },
+};
+
+# GUI global variables
my ($window, $cmdbox, $inbox, $htmlview);
+my $prev;
my ($next, $next_fctn, $target_hd);
my ($progress, $progress_status);
+
my ($ipversion, $ipaddress, $ipconf_entry_addr);
my ($netmask, $ipconf_entry_mask);
my ($gateway, $ipconf_entry_gw);
@@ -203,11 +257,37 @@ my $cmdline = file_read_firstline("/proc/cmdline");
my $ipconf;
my $country;
my $timezone = 'Europe/Vienna';
-my $password;
-my $mailto;
my $keymap = 'en-us';
+my $password;
+my $mailto = '***@example.invalid';
my $cmap;

+my $global_configuration = {
+
+ # Description: Hash to hold global configuration
+ # options for future use
+
+ # Format: screen/function name => settings for that screen
+
+ # TODO: add all the user-provided options during the install
+ # to be able to call them back if necessary
+
+ hdsel => {},
+ country => {
+ country => $country,
+ timezone => $timezone,
+ keymap => $keymap,
+ },
+ password => {
+ password => $password,
+ mailto => $mailto,
+ },
+ ipconf => {
+ hostname => $hostname,
+ domain => $domain,
+ },
+};
+
# parse command line args

my $config_options = {};
@@ -1682,11 +1762,28 @@ sub display_html {
$last_display_change = time();
}

+sub prev_function {
+
+ # Description: Calls the last function
+
+ my ($text, $fctn) = @_;
+
+ $fctn = $stack_number if !$fctn;
+ $text = "_Previous" if !$text;
+ $prev->set_label ($text);
+
+ $stack_number--;
+ $function_options->{$function_list[$stack_number]}->{function}();
+
+ $prev->grab_focus ();
+}
+
sub set_next {
my ($text, $fctn) = @_;

$next_fctn = $fctn;
- $text = "_Next" if !$text;
+ my $step = $function_list[$stack_number];
+ $text //= $function_options->{$step}->{next_button} // '_Next';
$next->set_label ($text);

$next->grab_focus ();
@@ -1721,6 +1818,13 @@ sub create_main_window {
$next = Gtk3::Button->new ('_Next');
$next->signal_connect (clicked => sub { $last_display_change = 0; &$next_fctn (); });
$cmdbox->pack_end ($next, 0, 0, 10);
+
+
+ $prev = Gtk3::Button->new ('_Previous');
+ $prev->signal_connect (clicked => sub { $last_display_change = 0; &prev_function (); });
+ $cmdbox->pack_end ($prev, 0, 0, 10);
+
+
my $abort = Gtk3::Button->new ('_Abort');
$abort->set_can_focus (0);
$cmdbox->pack_start ($abort, 0, 0, 10);
@@ -1900,7 +2004,7 @@ my $ipconf_first_view = 1;
sub create_ipconf_view {

cleanup_view ();
- display_html ("ipconf.htm");
+ display_html ($function_options->{ipconf}->{html});

my $vbox = Gtk3::VBox->new (0, 0);
$inbox->pack_start ($vbox, 1, 0, 0);
@@ -1991,7 +2095,7 @@ sub create_ipconf_view {
$vbox2->pack_start ($dnsbox, 0, 0, 0);

$inbox->show_all;
- set_next ('_Install', sub {
+ set_next (undef, sub {

# verify hostname

@@ -2077,12 +2181,53 @@ sub create_ipconf_view {

#print "TEST $ipaddress $netmask $gateway $dnsserver\n";

- create_extract_view ();
+ $stack_number++;
+ create_ack_view ();
});

$hostentry->grab_focus();
}

+sub create_ack_view {
+
+ # Description: Function for showing the user a list of
+ # the previously chosen options during install
+
+ cleanup_view ();
+
+ my $ack_template = "${proxmox_libdir}/html/ack_template.htm";
+ my $ack_html = "${proxmox_libdir}/html/$function_options->{ack}->{html}";
+ my $html_data = file_get_contents($ack_template);
+
+ my %config_values = (
+ __target_hd__ => $target_hd,
+ __country__ => $country,
+ __timezone__ => $timezone,
+ __keymap__ => $keymap,
+ __mailto__ => $mailto,
+ __interface__ => $ipconf->{ifaces}->{$ipconf->{selected}}->{name},
+ __hostname__ => $hostname,
+ __ip__ => $ipaddress,
+ __netmask__ => $netmask,
+ __gateway__ => $gateway,
+ __dnsserver__ => $dnsserver,
+ );
+
+ while ( my ($k, $v) = each %config_values) {
+ $html_data =~ s/$k/$v/g;
+ }
+
+ write_config($html_data, "$ack_html");
+
+ display_html ($function_options->{ack}->{html});
+
+ set_next (undef, sub {
+ $stack_number++;
+ create_extract_view ();
+ });
+
+}
+
sub get_device_desc {
my ($devname, $size, $model) = @_;

@@ -2179,6 +2324,7 @@ sub create_password_view {
$hbox1->pack_start ($label, 0, 0, 10);
my $pwe1 = Gtk3::Entry->new ();
$pwe1->set_visibility (0);
+ $pwe1->set_text($password) if $password;
$pwe1->set_size_request (200, -1);
$hbox1->pack_start ($pwe1, 0, 0, 0);

@@ -2189,6 +2335,7 @@ sub create_password_view {
$hbox2->pack_start ($label, 0, 0, 10);
my $pwe2 = Gtk3::Entry->new ();
$pwe2->set_visibility (0);
+ $pwe2->set_text($password) if $password;
$pwe2->set_size_request (200, -1);
$hbox2->pack_start ($pwe2, 0, 0, 0);

@@ -2199,7 +2346,7 @@ sub create_password_view {
$hbox3->pack_start ($label, 0, 0, 10);
my $eme = Gtk3::Entry->new ();
$eme->set_size_request (200, -1);
- $eme->set_text('***@example.invalid');
+ $eme->set_text($mailto);
$hbox3->pack_start ($eme, 0, 0, 0);


@@ -2209,7 +2356,7 @@ sub create_password_view {

$inbox->show_all;

- display_html ("passwd.htm");
+ display_html ($function_options->{password}->{html});

set_next (undef, sub {

@@ -2245,6 +2392,7 @@ sub create_password_view {
$password = $t1;
$mailto = $t3;

+ $stack_number++;
create_ipconf_view();
});

@@ -2389,13 +2537,14 @@ sub create_country_view {

$inbox->show_all;

- display_html ("country.htm");
+ display_html ($function_options->{country}->{html});
set_next (undef, sub {

my $text = $w->get_text;

if (my $cc = $countryhash->{lc($text)}) {
$country = $cc;
+ $stack_number++;
create_password_view();
return;
} else {
@@ -2888,6 +3037,8 @@ sub get_btrfs_raid_setup {

sub create_hdsel_view {

+ $prev->set_sensitive(1); # enable previous button at this point
+
cleanup_view ();

my $vbox = Gtk3::VBox->new (0, 0);
@@ -2924,7 +3075,7 @@ sub create_hdsel_view {

$inbox->show_all;

- display_html ("page1.htm");
+ display_html($function_options->{hdsel}->{html});

set_next (undef, sub {

@@ -2934,6 +3085,7 @@ sub create_hdsel_view {
display_message ("Warning: $err\n" .
"Please fix ZFS setup first.");
} else {
+ $stack_number++;
create_country_view();
}
} elsif ($config_options->{filesys} =~ m/btrfs/) {
@@ -2942,9 +3094,11 @@ sub create_hdsel_view {
display_message ("Warning: $err\n" .
"Please fix BTRFS setup first.");
} else {
+ $stack_number++;
create_country_view();
}
} else {
+ $stack_number++;
create_country_view();
}
});
@@ -2956,7 +3110,7 @@ sub create_extract_view {

display_info();

- $next->set_sensitive (0);
+ $next->set_sensitive(0);

my $vbox = Gtk3::VBox->new (0, 0);
$inbox->pack_start ($vbox, 1, 0, 0);
@@ -2975,7 +3129,7 @@ sub create_extract_view {

$vbox2->pack_start ($progress, 0, 0, 0);

- $inbox->show_all;
+ $inbox->show_all();

my $tdir = $opt_testmode ? "target" : "/target";
mkdir $tdir;
@@ -2984,7 +3138,7 @@ sub create_extract_view {
eval { extract_data ($base, $tdir); };
my $err = $@;

- $next->set_sensitive (1);
+ $next->set_sensitive(1);

set_next ("_Reboot", sub { exit (0); } );

@@ -2999,6 +3153,8 @@ sub create_extract_view {

sub create_intro_view {

+ $prev->set_sensitive(0);
+
cleanup_view ();

if ($setup->{product} eq 'pve') {
@@ -3011,8 +3167,9 @@ sub create_intro_view {
};
}

- display_html ("license.htm");
+ display_html ($function_options->{intro}->{html});

+ $stack_number++;
set_next ("I a_gree", \&create_hdsel_view);
}
--
2.11.0
Loading...