Add Table creation code
This commit is contained in:
@@ -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,
|
||||
|
@@ -44,7 +44,12 @@
|
||||
]]></Textinput>
|
||||
|
||||
<SubHeader><![CDATA[<h2>${value}</h2>]]></SubHeader>
|
||||
<Paragraph><![CDATA[<p>${value}</p>]]></Paragraph>
|
||||
|
||||
<Paragraph><![CDATA[
|
||||
<p>
|
||||
%= l('${prefix}_${value}')
|
||||
</p>
|
||||
]]></Paragraph>
|
||||
|
||||
<Submit><![CDATA[
|
||||
<span class='data'>
|
||||
@@ -92,8 +97,23 @@
|
||||
]]>
|
||||
</password>
|
||||
|
||||
<Extra6><![CDATA[
|
||||
<Table><![CDATA[
|
||||
<table class="sme-border TableSort">
|
||||
<thead>
|
||||
<tr><tal:block tal:repeat="ColHead TopHeadings">
|
||||
<td>${ColHead}</td></tal:block>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
% my $control_data = $self->stash('${Control}');
|
||||
% foreach my $row (@$control_data) {
|
||||
<tr><tal:block tal:repeat="ColContent Columns">
|
||||
<td><%=$row->${ColContent}%></td></tal:block>
|
||||
</tr>
|
||||
%}
|
||||
</tbody>
|
||||
</table>
|
||||
]]>
|
||||
</Extra6>
|
||||
</Table>
|
||||
|
||||
</root>
|
||||
|
Reference in New Issue
Block a user