Skip to content

Commit

Permalink
webmin: Split up index page into three tabs, GitHub #1761
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmark committed Nov 24, 2024
1 parent 63ea66e commit fd86b1d
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 178 deletions.
2 changes: 1 addition & 1 deletion contrib/webmin_module/delete_atalk.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ eval {
}
}

redirect("show_atalk.cgi");
redirect("index.cgi");
};
if($@) {
# in case the block above has been exited through "die": output error message
Expand Down
2 changes: 1 addition & 1 deletion contrib/webmin_module/edit_atalk.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ if ($in{action} =~ /edit/) {
}
print &ui_form_end([[undef, $text{'save_button_title'}]]);

&ui_print_footer("show_atalk.cgi", $text{'index_atalk'});
&ui_print_footer("index.cgi", $text{'edit_return'});
Binary file removed contrib/webmin_module/images/ifcs.gif
Binary file not shown.
228 changes: 138 additions & 90 deletions contrib/webmin_module/index.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
require 'netatalk-lib.pl';
use File::Basename;

my @tabs = ( [ 'global', $text{'index_tab_global'} ],
[ 'ddp', $text{'index_tab_ddp'} ],
[ 'fileserver', $text{'index_tab_fileserver'} ]
);

ui_print_header(&text('index_version', version()), $text{'index_title'}, "", "configs", 1, 1);

# check if netatalk daemon's path is configured correctly, if not: print error then exit
Expand All @@ -40,40 +45,8 @@ if($@) {
exit;
}

# Volumes
print "<h3>$text{index_volumes}</h3>\n";
my @volume_links = ( "<a href=\"edit_vol_section.cgi?action=new_volume\">$text{'index_create_volume_link_name'}</a>" );
if(@{$$afpconf{volumeSections}}) {
unshift @volume_links, (
&select_all_link('section_index', $current_formindex),
&select_invert_link('section_index', $current_formindex)
) if(@{$$afpconf{volumeSections}} > 1);
print &ui_form_start('delete_sections.cgi', 'post', undef, "id='volumes'");
print &ui_columns_start( [
'',
$text{'index_col_title_vol_name'},
$text{'index_col_title_path'},
$text{'index_col_title_uses_preset'}
], undef, 0, undef, undef
);
foreach $volumeSection (@{$$afpconf{volumeSections}}) {
print &ui_columns_row( [
&ui_checkbox('section_index', $$volumeSection{'index'}),
"<a href=\"edit_vol_section.cgi?action=edit_volume&index=$$volumeSection{'index'}\"><b>$$volumeSection{name}</b></a>",
$$volumeSection{parameters}{'path'}{value},
$$volumeSection{parameters}{'vol preset'}{value}
], [ "width='20'" ]);
}
print &ui_columns_end();
print &ui_links_row(\@volume_links);
print &ui_form_end([[undef, $text{'index_delete_volumes_button_title'}, 0, undef]]);
$current_formindex += 1;
} else {
print "<b>$text{'index_no_volumes'}</b>\n";
print "<p>\n";
print &ui_links_row(\@volume_links);
}
print &ui_hr();
print &ui_tabs_start(\@tabs, 'mode', 'fileserver');
print &ui_tabs_start_tab('mode', 'global');

# Volume presets
print "<h3>$text{index_volume_presets}</h3>\n";
Expand Down Expand Up @@ -135,33 +108,159 @@ if($$afpconf{sectionsByName}{'Homes'}) {
print "<p>\n";
print &ui_links_row( ["<a href=\"edit_vol_section.cgi?action=new_homes\">$text{'index_create_homes_link_name'}</a>"] );
}
print &ui_hr();

print"<h3>$text{index_global}</h3>\n";

my @links = (
"edit_global_section.cgi",
"show_atalk.cgi",
"edit_print.cgi",
"show_users.cgi",
"server_status.cgi"
);
my @titles = (
$text{'index_icon_text_server'},
$text{'index_icon_text_atalk'},
$text{'index_icon_text_print'},
$text{'index_icon_text_users'},
$text{'index_icon_text_capabilities'}
);
my @icons = (
"images/server.gif",
"images/ifcs.gif",
"images/printer.gif",
"images/users.gif",
"images/inspect.gif"
);
icons_table(\@links, \@titles, \@icons, 5);

print &ui_tabs_end_tab('mode', 'global');

print &ui_tabs_start_tab('mode', 'ddp');

my @atalk_ifs = getAtalkIfs();

print "<h3>$text{index_show_atalk_title}</h3>\n";
print "<p>$text{'show_atalk_notice'}</p>";
my @atalk_links = ( "<a href=\"edit_atalk.cgi?action=create\">$text{'index_create_atalk'}</a>" );

if (@atalk_ifs) {
unshift @atalk_links, (
&select_all_link('section_index', 1),
&select_invert_link('section_index', 1)
);
print &ui_form_start('delete_atalk.cgi', 'POST');
print &ui_columns_start([
'',
$text{'show_atalk_iface'},
$text{'show_atalk_routing'},
$text{'show_atalk_phase'},
$text{'show_atalk_net'},
$text{'show_atalk_addr'},
$text{'show_atalk_zone'}
], undef, 0, undef, undef);
my $index = 0;
foreach $if (@atalk_ifs) {
print &ui_columns_row([
&ui_checkbox('section_index', $if->{atalk_iface}),
"<a href=\"edit_atalk.cgi?action=edit&index=".$index."\">"
.$if->{atalk_iface}."</a>",
$if->{atalk_routing} ? $if->{atalk_routing} : $text{'index_value_not_set'},
$if->{atalk_phase} ? $if->{atalk_phase} : $text{'index_value_not_set'},
$if->{atalk_net} ? $if->{atalk_net} : $text{'index_value_not_set'},
$if->{atalk_addr} ? $if->{atalk_addr} : $text{'index_value_not_set'},
$if->{atalk_zone} ? $if->{atalk_zone} : $text{'index_value_not_set'}
], [ "width='20'" ]);
$index++;
}
print &ui_columns_end();
print &ui_links_row(\@atalk_links);
print &ui_form_end([[undef, $text{'index_delete_atalk_ifs'}, 0, undef]]);
} else {
print "<p><b>$text{'index_no_atalk_ifs'}</b></p>\n";
print &ui_links_row(\@atalk_links);
}

my @daemons = (
{basename($config{atalkd_d}) => $text{index_process_atalkd}},
{basename($config{papd_d}) => $text{index_process_papd}},
{basename($config{timelord_d}) => $text{index_process_timelord}},
{basename($config{a2boot_d}) => $text{index_process_a2boot}}
);

print "<h3>$text{'index_appletalk_services'}</h3>\n";
print "<p>$text{'index_appletalk_services_notice'}</p>";

foreach my $daemon (@daemons) {
foreach my $d (keys %$daemon) {
if (-x $config{$d.'_d'}) {
if (&find_byname($config{$d.'_d'})) {
print "<h3>".&text('index_running_service', $daemon->{$d})."</h3>\n";
print &ui_buttons_start();
print &ui_buttons_row(
'control.cgi?action=restart&daemon='.$d,
&text('running_restart_daemon', $daemon->{$d}),
&text('index_process_control_restart_daemon', $d)
);
print &ui_buttons_row(
'control.cgi?action=stop&daemon='.$d,
&text('running_stop_daemon', $daemon->{$d}),
&text('index_process_control_stop_daemon', $d)
);
print &ui_buttons_end();
$current_formindex += 2;
} else {
print "<h3>".&text('index_not_running', $daemon->{$d})."</h3>\n";
print &ui_buttons_start();
print &ui_buttons_row(
'control.cgi?action=start&daemon='.$d,
&text('running_start_daemon', $daemon->{$d}),
&text('index_process_control_start_daemon', $d)
);
print &ui_buttons_end();
$current_formindex += 1;
}
}
else {
print "<p>".&text('index_daemon_not_found', $d)."</p>";
}
}
}

print &ui_tabs_end_tab('mode', 'ddp');

print &ui_tabs_start_tab('mode', 'fileserver');

# Volumes
print "<h3>$text{index_volumes}</h3>\n";
my @volume_links = ( "<a href=\"edit_vol_section.cgi?action=new_volume\">$text{'index_create_volume_link_name'}</a>" );
if(@{$$afpconf{volumeSections}}) {
unshift @volume_links, (
&select_all_link('section_index', $current_formindex),
&select_invert_link('section_index', $current_formindex)
) if(@{$$afpconf{volumeSections}} > 1);
print &ui_form_start('delete_sections.cgi', 'post', undef, "id='volumes'");
print &ui_columns_start( [
'',
$text{'index_col_title_vol_name'},
$text{'index_col_title_path'},
$text{'index_col_title_uses_preset'}
], undef, 0, undef, undef
);
foreach $volumeSection (@{$$afpconf{volumeSections}}) {
print &ui_columns_row( [
&ui_checkbox('section_index', $$volumeSection{'index'}),
"<a href=\"edit_vol_section.cgi?action=edit_volume&index=$$volumeSection{'index'}\"><b>$$volumeSection{name}</b></a>",
$$volumeSection{parameters}{'path'}{value},
$$volumeSection{parameters}{'vol preset'}{value}
], [ "width='20'" ]);
}
print &ui_columns_end();
print &ui_links_row(\@volume_links);
print &ui_form_end([[undef, $text{'index_delete_volumes_button_title'}, 0, undef]]);
$current_formindex += 1;
} else {
print "<b>$text{'index_no_volumes'}</b>\n";
print "<p>\n";
print &ui_links_row(\@volume_links);
}
print &ui_hr();

# since we are using a different number of forms, depending on the status of the service,
Expand Down Expand Up @@ -196,55 +295,4 @@ if(&find_byname($config{'netatalk_d'})) {
$current_formindex += 1;
}

print &ui_hr();

# Show process control buttons for AppleTalk services
# only if atalkd init commands are defined.
if ($config{'start_atalkd'} && $config{'stop_atalkd'} && $config{'restart_atalkd'}) {

my @daemons = (
{basename($config{atalkd_d}) => $text{index_process_atalkd}},
{basename($config{papd_d}) => $text{index_process_papd}},
{basename($config{timelord_d}) => $text{index_process_timelord}},
{basename($config{a2boot_d}) => $text{index_process_a2boot}}
);

print "<h3>$text{'index_appletalk_services'}</h3>\n";
print "<p>$text{'index_appletalk_services_notice'}</p>";

foreach my $daemon (@daemons) {
foreach my $d (keys %$daemon) {
if (-x $config{$d.'_d'}) {
if (&find_byname($config{$d.'_d'})) {
print "<h3>".&text('index_running_service', $daemon->{$d})."</h3>\n";
print &ui_buttons_start();
print &ui_buttons_row(
'control.cgi?action=restart&daemon='.$d,
&text('running_restart_daemon', $daemon->{$d}),
&text('index_process_control_restart_daemon', $d)
);
print &ui_buttons_row(
'control.cgi?action=stop&daemon='.$d,
&text('running_stop_daemon', $daemon->{$d}),
&text('index_process_control_stop_daemon', $d)
);
print &ui_buttons_end();
$current_formindex += 2;
} else {
print "<h3>".&text('index_not_running', $daemon->{$d})."</h3>\n";
print &ui_buttons_start();
print &ui_buttons_row(
'control.cgi?action=start&daemon='.$d,
&text('running_start_daemon', $daemon->{$d}),
&text('index_process_control_start_daemon', $d)
);
print &ui_buttons_end();
$current_formindex += 1;
}
}
else {
print "<p>".&text('index_daemon_not_found', $d)."</p>";
}
}
}
}
print &ui_tabs_end_tab('mode', 'fileserver');
38 changes: 19 additions & 19 deletions contrib/webmin_module/lang/en
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@ index_version=Version $1
index_ever=The $1 program was not found on your system. Either Netatalk is not installed, or your <a href='$2'> module configuration</a> is incorrect.

init_failed=Command "$1" failed

delete_failed=Could not delete file
not_valid_path=Not Valid Path
no_path=No Path

index_filesharing_services=File Sharing Services
index_appletalk_services=AppleTalk Services
index_appletalk_services_notice=<em>Note:</em> Start <strong>AppleTalk Network Manager</strong> first if you want the other services made available over AppleTalk, including the AFP File Server.
index_tab_global=Global Settings
index_tab_ddp=DDP Services
index_tab_fileserver=File Sharing Services

index_filesharing_services=File Sharing Service Control
index_appletalk_services=DDP Service Control
index_appletalk_services_notice=<em>Note:</em> Start <strong>Network Manager</strong> before any other services, including <code>netatalk</code>.
index_daemon_not_found=<code>$1</code> not found. Have you configured the daemon path correctly?
index_process_control_restart_daemon=Restarts the <code>$1</code> daemon
index_process_control_start_daemon=Starts the <code>$1</code> daemon
index_process_control_stop_daemon=Stops the <code>$1</code> daemon

index_process_atalkd=AppleTalk Network Manager
index_process_atalkd=Network Manager
index_process_papd=Print Server
index_process_timelord=Time Server
index_process_a2boot=Apple II Netboot Server
index_process_a2boot=A2 Netboot Server

running_restart=Restart AFP File Server
running_start=Start AFP File Server
Expand Down Expand Up @@ -69,9 +72,7 @@ index_col_title_home_name=Home volume name
index_value_not_set=<i>not set</i>

index_icon_text_server=Edit Server Options
index_atalk=Manage AppleTalk Interfaces
index_print=Manage Print Server
index_icon_text_atalk=Edit AppleTalk Interfaces
index_icon_text_print=Edit Print Server Configuration
index_icon_text_users=Manage Connected Users
index_icon_text_capabilities=Show Server Status
Expand Down Expand Up @@ -271,7 +272,6 @@ edit_groups=Groups
edit_undefined=Leave undefined
edit_default=default

show_atalk_title=AppleTalk Interfaces
show_atalk_notice=<em>Note:</em> When <code>atalkd</code> starts up, it attempts to autodetect available interfaces and may rewrite these settings.
show_atalk_iface=Interface
show_atalk_addr=Address
Expand All @@ -281,25 +281,25 @@ show_atalk_phase=Phase
show_atalk_zone=Zone

index_delete_atalk_ifs=Delete selected interfaces
index_no_atalk_ifs=No AppleTalk interfaces configured
index_show_atalk_title=Manage AppleTalk network interfaces
index_no_atalk_ifs=No network interfaces configured
index_show_atalk_title=Manage network interfaces
index_create_atalk=Create new interface

edit_atalk_title=Edit AppleTalk Interface
edit_atalk_new_title=Create new AppleTalk Interface
edit_atalk_table_heading=AppleTalk options
edit_atalk_title=Edit DDP Interface
edit_atalk_new_title=Create new Interface
edit_atalk_table_heading=DDP options
edit_atalk_iface=Network interface
edit_atalk_iface_help=Confirm available Network Interfaces (new tab)
edit_atalk_addr=AppleTalk address
edit_atalk_addr=DDP address
edit_atalk_addr_help=example: 77.7
edit_atalk_net=AppleTalk net range
edit_atalk_net=DDP net range
edit_atalk_net_help=example: 9461-9471
edit_atalk_routing=AppleTalk routing
edit_atalk_routing=Routing
edit_atalk_routing_dontroute=disabled (dontroute)
edit_atalk_routing_route=single interface (route)
edit_atalk_routing_seed=multiple interfaces (seed)
edit_atalk_phase=AppleTalk phase
edit_atalk_zone=AppleTalk zone
edit_atalk_phase=Phase
edit_atalk_zone=Zone

manual_title=Edit Directives
manual_file=Edit File:
Expand Down
1 change: 0 additions & 1 deletion contrib/webmin_module/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ webmin_files = [
'save_print.cgi',
'save_vol_section.cgi',
'server_status.cgi',
'show_atalk.cgi',
'show_users.cgi',
]

Expand Down
2 changes: 1 addition & 1 deletion contrib/webmin_module/save_atalk.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ if ($atalkLine ne 0) {
addLineToFile($filetoedit, $atalkLine, $lineNumber, $totalLines);
}

redirect("show_atalk.cgi");
redirect("index.cgi");
Loading

0 comments on commit fd86b1d

Please sign in to comment.