Discussion:
[pve-devel] [PATCH installer] implement previous button
Oguz Bektas
2018-11-29 11:38:40 UTC
Permalink
Signed-off-by: Oguz Bektas <***@proxmox.com>
---
proxinstall | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)

diff --git a/proxinstall b/proxinstall
index 9945dd1..43da7be 100755
--- a/proxinstall
+++ b/proxinstall
@@ -190,8 +190,19 @@ my $ipv4_reverse_mask = [
'255.255.255.255',
];

+my $stack_number = 0; # init number for function stack
+
+my %function_stack = ( # global function stack
+ 1 => \&create_intro_view,
+ 2 => \&create_hdsel_view,
+ 3 => \&create_country_view,
+ 4 => \&create_password_view,
+ 5 => \&create_ipconf_view,
+);
+
my ($window, $cmdbox, $inbox, $htmlview);
my ($next, $next_fctn, $target_hd);
+my $prev;
my ($progress, $progress_status);
my ($ipversion, $ipaddress, $ipconf_entry_addr);
my ($netmask, $ipconf_entry_mask);
@@ -1682,6 +1693,20 @@ sub display_html {
$last_display_change = time();
}

+sub prev_fctn {
+
+ my ($text, $fctn) = @_;
+
+ $stack_number = $stack_number - 1;
+ $fctn = $stack_number if !$fctn;
+ $text = "_Previous" if !$text;
+ $prev->set_label ($text);
+
+ $function_stack{lc $stack_number}();
+
+ $prev->grab_focus ();
+}
+
sub set_next {
my ($text, $fctn) = @_;

@@ -1721,6 +1746,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_fctn (); });
+ $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);
@@ -1899,6 +1931,8 @@ my $ipconf_first_view = 1;

sub create_ipconf_view {

+ $stack_number = 5;
+
cleanup_view ();
display_html ("ipconf.htm");

@@ -2165,6 +2199,9 @@ sub update_zonelist {

sub create_password_view {

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

my $vbox2 = Gtk3::VBox->new (0, 0);
@@ -2254,6 +2291,9 @@ sub create_password_view {

sub create_country_view {

+ $stack_number = 3;
+ $prev->set_sensitive (0);
+
cleanup_view ();

my $countryhash = $cmap->{countryhash};
@@ -2886,6 +2926,9 @@ sub get_btrfs_raid_setup {

sub create_hdsel_view {

+ $stack_number = 2;
+ $prev->set_sensitive (0);
+
cleanup_view ();

my $vbox = Gtk3::VBox->new (0, 0);
@@ -2997,6 +3040,9 @@ sub create_extract_view {

sub create_intro_view {

+ $stack_number = 1;
+ $prev->set_sensitive (0);
+
cleanup_view ();

if ($setup->{product} eq 'pve') {
--
2.11.0
Oguz Bektas
2018-12-03 10:57:50 UTC
Permalink
* adds an additional installation step before extracting the filesystem,
showing the user the options that were chosen during the installation.

* adapt the html file accordingly

Signed-off-by: Oguz Bektas <***@proxmox.com>
---
html-common/ipconf.htm | 4 +--
proxinstall | 85 ++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 74 insertions(+), 15 deletions(-)

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 9970bf9..0631490 100755
--- a/proxinstall
+++ b/proxinstall
@@ -14,6 +14,7 @@ use IO::Select;
use Cwd 'abs_path';
use Gtk3 '-init';
use Gtk3::WebKit;
+use Gtk3::SimpleList;
use Encode;
use String::ShellQuote;
use Data::Dumper;
@@ -192,12 +193,16 @@ my $ipv4_reverse_mask = [

my $stack_number = 0; # init number for function stack

-my %function_stack = ( # global function stack
+my %function_stack = (
+
+ # Description: Hash for global function stack
+
1 => \&create_intro_view,
2 => \&create_hdsel_view,
3 => \&create_country_view,
4 => \&create_password_view,
5 => \&create_ipconf_view,
+ 6 => \&create_ack_view,
);

my ($window, $cmdbox, $inbox, $htmlview);
@@ -1697,7 +1702,7 @@ sub prev_fctn {

my ($text, $fctn) = @_;

- $stack_number = $stack_number - 1;
+ $stack_number--;
$fctn = $stack_number if !$fctn;
$text = "_Previous" if !$text;
$prev->set_label ($text);
@@ -1707,11 +1712,6 @@ sub prev_fctn {
$prev->grab_focus ();
}

-sub prev_available {
- $prev->set_sensitive (1);
- $prev->set_sensitive (0) if $stack_number <= 3;
-}
-
sub set_next {
my ($text, $fctn) = @_;

@@ -2030,7 +2030,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

@@ -2116,12 +2116,73 @@ sub create_ipconf_view {

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

- create_extract_view ();
+ 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
+
+ $stack_number = 6;
+
+ cleanup_view ();
+
+ display_info ();
+
+ #display_html ('install.htm'); # TODO: show fitting html file
+
+ my $grid = Gtk3::Grid->new();
+ $grid->set_visible(1);
+ $grid->set_column_spacing(10);
+ $grid->set_row_spacing(10);
+ $grid->set_hexpand(1);
+
+ $grid->set_margin_start(7);
+ $grid->set_margin_end(7);
+ $grid->set_margin_top(7);
+ $grid->set_margin_bottom(7);
+
+
+ # acknowledge the following configs:
+ # a. target disk
+ # b. network configuration
+ # c. timezone/keyboard layout
+ # d. email
+
+ my $ack_list = Gtk3::SimpleList->new (
+ 'Option' => 'text',
+ 'Value' => 'text',
+ );
+
+ @{$ack_list->{data}} = (
+ [ 'disk', $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 ],
+ );
+
+ $grid->add($ack_list);
+
+ $inbox->pack_start($grid, 1, 0, 0);
+ $inbox->show_all ();
+
+ set_next ('_Install', sub {
+ create_extract_view ();
+ });
+
+}
+
sub get_device_desc {
my ($devname, $size, $model) = @_;

@@ -2205,7 +2266,6 @@ sub update_zonelist {
sub create_password_view {

$stack_number = 4;
- $prev->set_sensitive (1); # enable previous button at this point

cleanup_view ();

@@ -2297,7 +2357,6 @@ sub create_password_view {
sub create_country_view {

$stack_number = 3;
- $prev->set_sensitive (0);

cleanup_view ();

@@ -2932,7 +2991,7 @@ sub get_btrfs_raid_setup {
sub create_hdsel_view {

$stack_number = 2;
- $prev->set_sensitive (0);
+ $prev->set_sensitive (1); # enable previous button at this point

cleanup_view ();

@@ -3021,7 +3080,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;
--
2.11.0
Loading...