140 lines
4.7 KiB
Perl
140 lines
4.7 KiB
Perl
#
|
|
# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47
|
|
#
|
|
#
|
|
# Routines to be edited by the developer to provide content and validation for parameters
|
|
# and provison of the control data for table(s)
|
|
#
|
|
use esmith::util;
|
|
use esmith::util::network;
|
|
use esmith::ConfigDB::UTF8;
|
|
use esmith::AccountsDB;
|
|
use esmith::NetworksDB::UTF8;
|
|
use esmith::HostsDB;
|
|
use esmith::DomainsDB::UTF8:
|
|
|
|
use constant FALSE => 0;
|
|
use constant TRUE => 1;
|
|
|
|
|
|
#The most common ones - open DB when required.
|
|
my $cdb;
|
|
my $adb;
|
|
my $ndb;
|
|
my $hdb;
|
|
my $ddb;
|
|
|
|
#The most common ones - you might want to use these if you need to make sure that the DB is refreshed.
|
|
#$cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
|
|
#$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
|
|
#$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
|
#$hdb = esmith::HostsDB::UTF8->open() || die("Couldn't open Hosts db");
|
|
#$ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
|
|
|
|
|
|
# Validation routines - parameters for each panel
|
|
|
|
sub validate_PARAMS {
|
|
my $c = shift;
|
|
my $dat_data = shift; #Data hash as parameter
|
|
# Validation for each field
|
|
my $ret = '';
|
|
|
|
if (! TRUE) #validate $c->param('time_mode')
|
|
{$ret .= 'Validation for time_mode failed';}
|
|
if (! TRUE) #validate $c->param('ntpserver')
|
|
{$ret .= 'Validation for ntpserver failed';}
|
|
if (! TRUE) #validate $c->param('year')
|
|
{$ret .= 'Validation for year failed';}
|
|
if (! TRUE) #validate $c->param('month')
|
|
{$ret .= 'Validation for month failed';}
|
|
if (! TRUE) #validate $c->param('day')
|
|
{$ret .= 'Validation for day failed';}
|
|
if (! TRUE) #validate $c->param('hour')
|
|
{$ret .= 'Validation for hour failed';}
|
|
if (! TRUE) #validate $c->param('minute')
|
|
{$ret .= 'Validation for minute failed';}
|
|
if (! TRUE) #validate $c->param('second')
|
|
{$ret .= 'Validation for second failed';}
|
|
if ($ret eq '') {$ret = 'ok';}
|
|
return $ret;
|
|
}
|
|
|
|
|
|
# Get singleton data for each panel
|
|
|
|
sub get_data_for_panel_PARAMS {
|
|
# Return a hash with the fields required which will be loaded into the shared data
|
|
my $c = shift;
|
|
my %ret = (
|
|
'Data1'=>'Data for PARAMS', #Example
|
|
# fields from Inputs in PARAMS $fields['PARAMS']
|
|
'time_mode'=>'time_mode contents',
|
|
'ntpserver'=>'ntpserver contents',
|
|
'year'=>'year contents',
|
|
'month'=>'month contents',
|
|
'day'=>'day contents',
|
|
'hour'=>'hour contents',
|
|
'minute'=>'minute contents',
|
|
'second'=>'second contents',
|
|
|
|
);
|
|
return %ret;
|
|
}
|
|
|
|
|
|
|
|
# Get control data for table(s)
|
|
|
|
|
|
|
|
# Return hash with values from row in which link clicked on table
|
|
|
|
sub get_selected_PARAMS {
|
|
my $c = shift;
|
|
my $selected = shift; #Parameter is name of selected row.
|
|
my $is_new_record = shift; #Indicates new record required (defaults)
|
|
my %ret = ();
|
|
#gather the values here
|
|
return %ret;
|
|
}
|
|
|
|
|
|
#after sucessful modify or create or whatever and submit then perfom (if the params validate)
|
|
|
|
sub perform_PARAMS {
|
|
my $c = shift;
|
|
my $dat_data = shift; #Data hash as parameter
|
|
my $ret = '';
|
|
my $db = $cdb; #maybe one of the others
|
|
my $dbkey = 'ChangeThis';
|
|
# To make it write to DB as comment, delete this (regex) string in each if statement "TRUE\) \#copy or perform with value: .* e.g."
|
|
|
|
if (! TRUE) #copy or perform with value: time_mode e.g. $db->set_prop($dbkey,'time_mode',$c->param('time_mode'),type=>'service'))
|
|
{$ret .= 'Perform/save failed for time_mode';}
|
|
if (! TRUE) #copy or perform with value: ntpserver e.g. $db->set_prop($dbkey,'ntpserver',$c->param('ntpserver'),type=>'service'))
|
|
{$ret .= 'Perform/save failed for ntpserver';}
|
|
if (! TRUE) #copy or perform with value: year e.g. $db->set_prop($dbkey,'year',$c->param('year'),type=>'service'))
|
|
{$ret .= 'Perform/save failed for year';}
|
|
if (! TRUE) #copy or perform with value: month e.g. $db->set_prop($dbkey,'month',$c->param('month'),type=>'service'))
|
|
{$ret .= 'Perform/save failed for month';}
|
|
if (! TRUE) #copy or perform with value: day e.g. $db->set_prop($dbkey,'day',$c->param('day'),type=>'service'))
|
|
{$ret .= 'Perform/save failed for day';}
|
|
if (! TRUE) #copy or perform with value: hour e.g. $db->set_prop($dbkey,'hour',$c->param('hour'),type=>'service'))
|
|
{$ret .= 'Perform/save failed for hour';}
|
|
if (! TRUE) #copy or perform with value: minute e.g. $db->set_prop($dbkey,'minute',$c->param('minute'),type=>'service'))
|
|
{$ret .= 'Perform/save failed for minute';}
|
|
if (! TRUE) #copy or perform with value: second e.g. $db->set_prop($dbkey,'second',$c->param('second'),type=>'service'))
|
|
{$ret .= 'Perform/save failed for second';}
|
|
if ($ret eq '') {$ret = 'ok';}
|
|
return $ret;
|
|
}
|
|
|
|
|
|
sub create_link{
|
|
# WIP
|
|
my ($c,$route, $panel, $index) = @_;
|
|
my $link = "$route?trt=$panel&Selected=$index";
|
|
return $link;
|
|
}
|
|
1; |