Add Table creation code

This commit is contained in:
2024-04-24 16:09:23 +01:00
parent 2d3fabcc5b
commit 9840d4171e
8 changed files with 174 additions and 73 deletions

View File

@@ -35,11 +35,11 @@ use esmith::DomainsDB;
#The most common ones
our $db = esmith::ConfigDB->open() || die("Couldn't open config db");
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");
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
sub main {
@@ -51,6 +51,13 @@ sub main {
my $modul = '';
$$${prefix}_data{trt} = '${firstPanel}';
#Load any DB entries into the <prefix>_data area so as they are preset in the form
# which DB
my $db = $$${db | 'cdb'}; #Default to config
<tal:block tal:repeat="dbentry dbentries">
$$${prefix}_data{${dbentry}} = $db->prop('${dbentry}') || ${dbdefault}
</tal:block>
$c->stash(
title => $title,
@@ -86,18 +93,22 @@ sub do_update {
#Validate the parameters accordingly
<tal:block tal:repeat="condition conditions">
if ($trt eq '${condition}'){
#Validate for panel ${condition}
# set $ret = $c->l('Error message') if invalid'
#Validate form parameters for panel ${condition}
# and set $ret = $c->l('Error message') if invalid'
# otherwise set $ret to "ok"
if ($ret ne "ok"){
$c->stash(error => $c->l($ret))
} else {
#Do whatever is needed, including writing values to the DB
my $db = $$${db | 'cdb'}; #Default to config
<tal:block tal:repeat="dbentry dbentries">
$db->set_prop('${dbentry}'=> param{'${dbentry}'}; #Copy back into db
$$${prefix}_data{${dbentry}} = $db->prop('${dbentry}'); #Copy out into stash
</tal:block>
} $c->stash( success => $c->l('ok message'))
}
</tal:block>
if ($ret ne "ok"){
$c->stash(error => $c->l($ret))
} else {
$c->stash( success => $c->l('ok message'))
}
if ($ret eq 'ok'){
#Do whatever
}
# set ${prefix}_data{trt} = <route>;
$c->stash(
title => $title,