Refactor controller so that it only uses do_display to display panels
This commit is contained in:
parent
9567e6e327
commit
47514f6f28
@ -1,6 +1,6 @@
|
|||||||
package SrvMngr::Controller::Letsencrypt;
|
package SrvMngr::Controller::Letsencrypt;
|
||||||
#
|
#
|
||||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-27 16:15:50
|
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
# heading : Network
|
# heading : Network
|
||||||
@ -43,12 +43,6 @@ use esmith::HostsDB;
|
|||||||
use esmith::DomainsDB;
|
use esmith::DomainsDB;
|
||||||
|
|
||||||
|
|
||||||
#The most common ones
|
|
||||||
our $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
|
||||||
our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
|
||||||
our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
|
||||||
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
|
||||||
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
|
||||||
|
|
||||||
require '/usr/share/smanager/lib/SrvMngr/Controller/Letsencrypt-Custom.pm'; #The code that is to be added by the developer
|
require '/usr/share/smanager/lib/SrvMngr/Controller/Letsencrypt-Custom.pm'; #The code that is to be added by the developer
|
||||||
|
|
||||||
@ -67,6 +61,13 @@ sub main {
|
|||||||
my $c = shift;
|
my $c = shift;
|
||||||
$c->app->log->info( $c->log_req );
|
$c->app->log->info( $c->log_req );
|
||||||
|
|
||||||
|
#The most common ones
|
||||||
|
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||||
|
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||||
|
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||||
|
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||||
|
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||||
|
|
||||||
my %lets_data = ();
|
my %lets_data = ();
|
||||||
my $title = $c->l('lets_Letsencrypt_certificate');
|
my $title = $c->l('lets_Letsencrypt_certificate');
|
||||||
my $modul = '';
|
my $modul = '';
|
||||||
@ -78,25 +79,8 @@ sub main {
|
|||||||
my $db = $cdb; #pickup local or global db or Default to config
|
my $db = $cdb; #pickup local or global db or Default to config
|
||||||
|
|
||||||
|
|
||||||
#pickup any other contents needed and load them into hash shared with panel
|
$c->do_display($lets_data{'trt'});
|
||||||
my %returned_hash;
|
|
||||||
# subroutine returns a hash directly
|
|
||||||
%returned_hash = $c->get_data_for_panel_LIST();
|
|
||||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
|
||||||
while (my ($key, $value) = each %returned_hash) {
|
|
||||||
$lets_data{$key} = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
# and table control fields
|
|
||||||
$c->stash(DomainList=>$c->get_DomainList());
|
|
||||||
|
|
||||||
|
|
||||||
$c->stash(
|
|
||||||
title => $title,
|
|
||||||
modul => $modul,
|
|
||||||
lets_data => \%lets_data
|
|
||||||
);
|
|
||||||
$c->render( template => "letsencrypt" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Post request with params - submit from the form
|
# Post request with params - submit from the form
|
||||||
@ -129,6 +113,13 @@ sub do_update {
|
|||||||
$c->app->log->info($c->log_req);
|
$c->app->log->info($c->log_req);
|
||||||
my $modul = '';
|
my $modul = '';
|
||||||
|
|
||||||
|
#The most common ones - you might want to comment out any not used.
|
||||||
|
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||||
|
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||||
|
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||||
|
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||||
|
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||||
|
|
||||||
my %lets_data = ();
|
my %lets_data = ();
|
||||||
my $title = $c->l('lets_Letsencrypt_certificate');
|
my $title = $c->l('lets_Letsencrypt_certificate');
|
||||||
|
|
||||||
@ -182,14 +173,6 @@ sub do_update {
|
|||||||
|
|
||||||
|
|
||||||
if ($ret ne "ok"){
|
if ($ret ne "ok"){
|
||||||
# lets_data{'trt'} = $thispanel;
|
|
||||||
# $c->stash(error => $c->l($ret));
|
|
||||||
# $c->stash(
|
|
||||||
# title => $title,
|
|
||||||
# modul => $modul,
|
|
||||||
# lets_data => \%lets_data
|
|
||||||
# );
|
|
||||||
# $c->render( template => "letsencrypt" );
|
|
||||||
$c->do_display($thispanel);
|
$c->do_display($thispanel);
|
||||||
} else {
|
} else {
|
||||||
#Do whatever is needed, including writing values to the DB
|
#Do whatever is needed, including writing values to the DB
|
||||||
@ -287,12 +270,8 @@ sub do_update {
|
|||||||
} else {
|
} else {
|
||||||
$lets_data{'trt'} = 'none';
|
$lets_data{'trt'} = 'none';
|
||||||
}
|
}
|
||||||
$c->stash(
|
$c->do_display($lets_data{'trt'});
|
||||||
title => $title,
|
|
||||||
modul => $modul,
|
|
||||||
lets_data => \%lets_data
|
|
||||||
);
|
|
||||||
$c->render( template => "letsencrypt" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,6 +289,13 @@ sub do_display {
|
|||||||
|
|
||||||
my ($c,$trt) = @_;
|
my ($c,$trt) = @_;
|
||||||
$c->app->log->info($c->log_req);
|
$c->app->log->info($c->log_req);
|
||||||
|
|
||||||
|
#The most common ones - you might want to comment out any not used.
|
||||||
|
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||||
|
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||||
|
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||||
|
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||||
|
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||||
|
|
||||||
my %lets_data = ();
|
my %lets_data = ();
|
||||||
my $title = $c->l('lets_Letsencrypt_certificate');
|
my $title = $c->l('lets_Letsencrypt_certificate');
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-27 16:15:50
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||||
%#
|
%#
|
||||||
<div id="Letsencrypt-CHECKALLDOMAINS" class="partial Letsencrypt-CHECKALLDOMAINS">
|
<div id="Letsencrypt-CHECKALLDOMAINS" class="partial Letsencrypt-CHECKALLDOMAINS">
|
||||||
<script>
|
<script>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-27 16:15:50
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||||
%#
|
%#
|
||||||
<div id="Letsencrypt-CHECKALLENABLEDDOMAINS" class="partial Letsencrypt-CHECKALLENABLEDDOMAINS">
|
<div id="Letsencrypt-CHECKALLENABLEDDOMAINS" class="partial Letsencrypt-CHECKALLENABLEDDOMAINS">
|
||||||
<script>
|
<script>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-27 16:15:50
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||||
%#
|
%#
|
||||||
<div id="Letsencrypt-CHECKONEDOMAIN" class="partial Letsencrypt-CHECKONEDOMAIN">
|
<div id="Letsencrypt-CHECKONEDOMAIN" class="partial Letsencrypt-CHECKONEDOMAIN">
|
||||||
<script>
|
<script>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-27 16:15:50
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||||
%#
|
%#
|
||||||
<div id="Letsencrypt-LIST" class="partial Letsencrypt-LIST">
|
<div id="Letsencrypt-LIST" class="partial Letsencrypt-LIST">
|
||||||
<script>
|
<script>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-27 16:15:50
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||||
%#
|
%#
|
||||||
<div id="Letsencrypt-PARAMS" class="partial Letsencrypt-PARAMS">
|
<div id="Letsencrypt-PARAMS" class="partial Letsencrypt-PARAMS">
|
||||||
<script>
|
<script>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-27 16:15:50
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-29 13:00:55
|
||||||
%#
|
%#
|
||||||
% layout 'default', title => "Sme server 2 - Letsencrypt certificate", share_dir => './';
|
% layout 'default', title => "Sme server 2 - Letsencrypt certificate", share_dir => './';
|
||||||
%# css specific to this panel:
|
%# css specific to this panel:
|
||||||
|
@ -62,11 +62,11 @@ sub main {
|
|||||||
$c->app->log->info( $c->log_req );
|
$c->app->log->info( $c->log_req );
|
||||||
|
|
||||||
#The most common ones
|
#The most common ones
|
||||||
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||||
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||||
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||||
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||||
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||||
|
|
||||||
my %${prefix}_data = ();
|
my %${prefix}_data = ();
|
||||||
my $title = $c->l('${prefix}_${MenuDescription}');
|
my $title = $c->l('${prefix}_${MenuDescription}');
|
||||||
@ -81,25 +81,8 @@ sub main {
|
|||||||
$$${prefix}_data{'${dbfield}'} = $db->prop('${dbfield}') || ${dbdefault | ""} || "";
|
$$${prefix}_data{'${dbfield}'} = $db->prop('${dbfield}') || ${dbdefault | ""} || "";
|
||||||
</tal:block>
|
</tal:block>
|
||||||
|
|
||||||
#pickup any other contents needed and load them into hash shared with panel
|
$c->do_display($$${prefix}_data{'trt'});
|
||||||
my %returned_hash;
|
|
||||||
# subroutine returns a hash directly
|
|
||||||
%returned_hash = $c->get_data_for_panel_${firstPanel}();
|
|
||||||
# Copy each key-value pair from the returned hash to the prefix data hash
|
|
||||||
while (my ($key, $value) = each %returned_hash) {
|
|
||||||
$$${prefix}_data{$key} = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
# and table control fields
|
|
||||||
<tal:block tal:repeat="tablecontrol tablecontrols">$c->stash(${tablecontrol[0]}=>$c->get_${tablecontrol[0]}());
|
|
||||||
</tal:block>
|
|
||||||
|
|
||||||
$c->stash(
|
|
||||||
title => $title,
|
|
||||||
modul => $modul,
|
|
||||||
${prefix}_data => \%${prefix}_data
|
|
||||||
);
|
|
||||||
$c->render( template => "${lcPackageName}" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Post request with params - submit from the form
|
# Post request with params - submit from the form
|
||||||
@ -133,11 +116,11 @@ sub do_update {
|
|||||||
my $modul = '';
|
my $modul = '';
|
||||||
|
|
||||||
#The most common ones - you might want to comment out any not used.
|
#The most common ones - you might want to comment out any not used.
|
||||||
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||||
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||||
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||||
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||||
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||||
|
|
||||||
my %${prefix}_data = ();
|
my %${prefix}_data = ();
|
||||||
my $title = $c->l('${prefix}_${MenuDescription}');
|
my $title = $c->l('${prefix}_${MenuDescription}');
|
||||||
@ -168,14 +151,6 @@ sub do_update {
|
|||||||
</tal:block>
|
</tal:block>
|
||||||
|
|
||||||
if ($ret ne "ok"){
|
if ($ret ne "ok"){
|
||||||
# ${prefix}_data{'trt'} = $thispanel;
|
|
||||||
# $c->stash(error => $c->l($ret));
|
|
||||||
# $c->stash(
|
|
||||||
# title => $title,
|
|
||||||
# modul => $modul,
|
|
||||||
# ${prefix}_data => \%${prefix}_data
|
|
||||||
# );
|
|
||||||
# $c->render( template => "${lcPackageName}" );
|
|
||||||
$c->do_display($thispanel);
|
$c->do_display($thispanel);
|
||||||
} else {
|
} else {
|
||||||
#Do whatever is needed, including writing values to the DB
|
#Do whatever is needed, including writing values to the DB
|
||||||
@ -205,12 +180,8 @@ sub do_update {
|
|||||||
} else {
|
} else {
|
||||||
$$${prefix}_data{'trt'} = '${NextPanel | "none"}';
|
$$${prefix}_data{'trt'} = '${NextPanel | "none"}';
|
||||||
}
|
}
|
||||||
$c->stash(
|
$c->do_display($$${prefix}_data{'trt'});
|
||||||
title => $title,
|
|
||||||
modul => $modul,
|
|
||||||
${prefix}_data => \%${prefix}_data
|
|
||||||
);
|
|
||||||
$c->render( template => "${lcPackageName}" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,11 +201,11 @@ sub do_display {
|
|||||||
$c->app->log->info($c->log_req);
|
$c->app->log->info($c->log_req);
|
||||||
|
|
||||||
#The most common ones - you might want to comment out any not used.
|
#The most common ones - you might want to comment out any not used.
|
||||||
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||||
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
||||||
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
||||||
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||||
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||||
|
|
||||||
my %${prefix}_data = ();
|
my %${prefix}_data = ();
|
||||||
my $title = $c->l('${prefix}_${MenuDescription}');
|
my $title = $c->l('${prefix}_${MenuDescription}');
|
||||||
@ -256,7 +227,7 @@ sub do_display {
|
|||||||
|
|
||||||
# the value of trt will tell you which panel has returned
|
# the value of trt will tell you which panel has returned
|
||||||
if (! $trt){
|
if (! $trt){
|
||||||
my $trt = $c->param('trt') || '${firstPanel}'; #Indicates where to go now
|
$trt = $c->param('trt') || '${firstPanel}'; #Indicates where to go now
|
||||||
}
|
}
|
||||||
|
|
||||||
# Now add in the params from the selected row from the table
|
# Now add in the params from the selected row from the table
|
||||||
|
Loading…
Reference in New Issue
Block a user