diff --git a/Targets/Datetime/Datetime-Custom.pm b/Targets/Datetime/Datetime-Custom.pm new file mode 100644 index 0000000..20f570e --- /dev/null +++ b/Targets/Datetime/Datetime-Custom.pm @@ -0,0 +1,140 @@ +# +# 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; \ No newline at end of file diff --git a/Targets/Datetime/Datetime.pm b/Targets/Datetime/Datetime.pm new file mode 100644 index 0000000..fb39e69 --- /dev/null +++ b/Targets/Datetime/Datetime.pm @@ -0,0 +1,279 @@ +package SrvMngr::Controller::Datetime; +# +# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47 +# Remember that each route must be unique (else they just overwrite each other). +# you cannot have get and post on the same name and url. +# +#---------------------------------------------------------------------- +# heading : System +# description : Date and time +# navigation : 4000 300 +# +# name : datetime, method : get, url : /datetime, ctlact : Datetime#main +# name : datetimeu, method : post, url : /datetimeu, ctlact : Datetime#do_update +# name : datetimed, method : get, url : /datetimed, ctlact : Datetime#do_display +# +# routes : end +# +# Documentation: https://wiki.contribs.org/Datetime +#---------------------------------------------------------------------- + +# +# Scheme of things: +# +# TBA!! + +use strict; +use warnings; +use Mojo::Base 'Mojolicious::Controller'; + +use constant FALSE => 0; +use constant TRUE => 1; + +use Locale::gettext; +use SrvMngr::I18N; +use SrvMngr qw(theme_list init_session); + +use Data::Dumper; + +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: + +my $cdb; +my $adb; +my $ndb; +my $hdb; +my $ddb; + +my %dat_data; + +require '/usr/share/smanager/lib/SrvMngr/Controller/Datetime-Custom.pm'; #The code that is to be added by the developer + +sub main { +# +# Initial entry - route is "/" +# +#set initial panel +#for initial panel: + #Specifiy panel to enter + #load up _data hash with DB fields + #load up stash with pointer(s) to control fields hash(= get-)) + #and a pointer to the prefix_data hash +#render initial panel + + my $c = shift; + $c->app->log->info( $c->log_req ); + + #The most common ones - you might want to delete some of these if they are not used. + $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"); + + %dat_data = (); + my $title = $c->l('dat_Date_and_time'); + my $modul = ''; + + $dat_data{'trt'} = 'PARAMS'; + + #Load any DB entries into the _data area so as they are preset in the form + # which DB - this only really works if the initial panel is a PARAMS type panel and not a TABLE + my $db = $cdb; #pickup local or global db or Default to config + + + $c->do_display($dat_data{'trt'}); + +} + +# Post request with params - submit from the form +sub do_update { +# +# Return after submit pushed on panel (this is a post) - route is "/u" +# parameters in the params hash. +# +#load up all params into prefix_data hash: +#By panel (series of if statements - only one executed): + #call validate-PANEL() - return ret = ok or error message + +#if validation not ok: + #render back to current panel with error message in stash +#otherwise: + #By panel (series of if statements - only one executed): + #do whatever is required: call perform-PANEL() - return 'ok' or Error Message + #call signal-event for any global actions specified (check it exists - error and continue?) + #if action smeserver--update exists + #signal_event smeserver--update + #call signal-event for any specific actions for thids panel (check it exists first - error and continue) + #set success in stash + #if no "nextpanel" entry: + #set firstpanel + #else + #set nextpanel + #call render + + my $c = shift; + $c->app->log->info($c->log_req); + my $modul = ''; + + #The most common ones - you might want to delete some of these if they are not used. + $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"); + + my $title = $c->l('dat_Date_and_time'); + + # Accessing all POST/GET parameters + my $params = $c->req->params->to_hash; + + # Get number of POST parameters + #my $num_params = keys scaler %$params; + + #Params are available in the hash "params" - copy to the prefix_data hash + #while (my ($key, $value) = each %{$c->req->params->to_hash}) { + # $dat_data{$key} = $value; + #} + + # the value of trt will tell you which panel has returned + my $trt = $c->param('trt') || 'PARAMS'; #hidden control on every form. + my $ret = 'ok'; + + #Validate the parameters in a custom sub one for each panel (although only one of these will be executed) + my $thispanel; + + if ($trt eq 'PARAMS'){ + #Validate form parameters for panel PARAMS + $ret = $c->validate_PARAMS(\%dat_data); + $thispanel = 'PARAMS'; + } + + if ($ret ne 'ok'){ + $c->stash(error => $c->l($ret)); + $c->do_display($thispanel); + } else { + #Do whatever is needed, including writing values to the DB + + + if ($trt eq 'PARAMS'){ + #do whatever is required ... + $ret = $c->perform_PARAMS(\%dat_data); + if ($ret ne 'ok') { + # return to the panel with error message + $c->stash(error => $c->l($ret)); + $c->stash( + title => $title, + modul => $modul, + dat_data => \%dat_data + ); + $c->render(template => "datetime"); + } else { + $c->stash( success => $c->l('dat_PARAMS_panel_action_was_successful')); #A bit bland - edit it in the lex file + } + } + + # and call any signal-events needed + #TBD + # Setup shared data and call panel + if ('none' eq 'none') { + $dat_data{'trt'} = 'PARAMS'; + } else { + $dat_data{'trt'} = 'none'; + } + $c->do_display($dat_data{'trt'}); + } +} + +sub do_display { +# +# Return after link clicked in table (this is a get) - route is "/d" +# Expects ?trt=PANEL&selected="TableRowName" plus any other required +# +# OR it maybe a post from the main panel to add a new record +# +#load up all supplied params into prefix_data hash +#call get-selected-PANEL() - returns hash of all relevent parameters +#load up returned hash into prefix_data +#render - to called panel + + my ($c,$trt) = @_; + $c->app->log->info($c->log_req); + + #The most common ones - you might want to delete some of these if they are not used. + $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"); + + my $title = $c->l('dat_Date_and_time'); + my $modul = ''; + + # Accessing all parameters + my $params = $c->req->params->to_hash; + + # Get number of parameters + my $num_params = keys %$params; + + #Tag as Post or Get (ie. create new entry or edit existing one + my $is_new_record = ($c->req->method() eq 'POST'); + + #Params are available in the hash "params" - copy to the prefix_data hash + #while (my ($key, $value) = each %{$c->req->params->to_hash}) { + # $dat_data{$key} = $value; + #} + + # the value of trt will tell you which panel has returned + if (! $trt){ + $trt = $c->param('trt') || 'PARAMS'; #Indicates where to go now + } + + # Now add in the params from the selected row from the table + + my %selectedrow; + + if ($trt eq 'PARAMS'){ + #Validate Get selected row (if applicable) PARAMS + %selectedrow = $c->get_selected_PARAMS($dat_data{'Selected'},$is_new_record); + } + + + #Copy in the selected row params to the prefix_data hash to pass to the panel + while (my ($key, $value) = each %selectedrow){ + $dat_data{$key} = $value; + } + # Where to go now + $dat_data{'trt'} = $trt; + + # Set up other shared data according to the panel to go to + + if ($trt eq 'PARAMS'){ + # pickup any other contents needed and load them into hash shared with panel + my %returned_hash; + # subroutine returns a hash directly + %returned_hash = $c->get_data_for_panel_PARAMS(); + # Copy each key-value pair from the returned hash to the prefix data hash + while (my ($key, $value) = each %returned_hash) { + $dat_data{$key} = $value; + } + } + + + # and table control fields + + + # Data for panel + $c->stash( + title => $title, + modul => $modul, + dat_data => \%dat_data + ); + $c->render(template => "datetime"); +} +1; \ No newline at end of file diff --git a/Targets/Datetime/_dat_PARAMS.html.ep b/Targets/Datetime/_dat_PARAMS.html.ep new file mode 100644 index 0000000..23cb879 --- /dev/null +++ b/Targets/Datetime/_dat_PARAMS.html.ep @@ -0,0 +1,102 @@ +%# +%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47 +%# +
+%# + % if (config->{debug} == 1) { +
+			%= dumper $dat_data
+		
+ % } + % my $btn = l('dat_APPLY'); + + % $c->param(Selected => undef); #This may need deleting for a params panel - only needed for a table + + %= form_for "datetimeu" => (method => 'POST') => begin + % param 'trt' => $dat_data->{trt} unless param 'trt'; + %= hidden_field 'trt' => $dat_data->{trt} + %# Inputs etc in here. + +

<%=l('Date_and_time_configuration')%>

+ +

<%=l('dat_Time_Configuration')%>

+ +

+ %=l('dat_Time_Setting_Mode:') + + % my @time_mode_options = [['NTP server' => 'dat_ntp_server'], ['Set manually' => 'dat_manually_set']]; + % param 'time_mode' => $dat_data->{time_mode} unless param 'time_mode'; + %= select_field 'time_mode' => @time_mode_options, class => 'input', id => 'time_mode_select' +

+ +

+ %=l('dat_The_server_is_periodically_synchronizing') +

+ +

+ %=l('dat_Set_Date_and_Time:') + + % param 'ntpserver' => $dat_data->{ntpserver} unless param 'ntpserver'; + %= text_field 'ntpserver', size => '50', class => 'textinput ntpserver' , pattern=>'.*' , placeholder=>'ntpserver', title =>'Pattern regex mismatch', id => 'ntpserver_text' +

+ +

+ %=l('dat_Choose_this_option_to_stop') +

+ +

+ %=l('dat_Year:') + + % my @year_options = [['2025' => '2025'], ['2026' => '2026'], ['2027' => '2027'], ['2028' => '2028'], ['2029' => '2029'], ['2030' => '2030'], ['2031' => '2031'], ['2032' => '2032'], ['2033' => '2033'], ['2034' => '2034'], ['2035' => '2035'], ['2036' => '2036'], ['2037' => '2037'], ['2038' => '2038'], ['2039' => '2039'], ['2040' => '2040'], ['2041' => '2041'], ['2042' => '2042'], ['2043' => '2043'], ['2044' => '2044'], ['2045' => '2045'], ['2046' => '2046'], ['2047' => '2047'], ['2048' => '2048'], ['2049' => '2049'], ['2050' => '2050'], ['2051' => '2051'], ['2052' => '2052'], ['2053' => '2053'], ['2054' => '2054'], ['2055' => '2055']]; + % param 'year' => $dat_data->{year} unless param 'year'; + %= select_field 'year' => @year_options, class => 'input', id => 'year_select' +

+ +

+ %=l('dat_Month:') + + % my @month_options = [['01' => '01'], ['02' => '02'], ['03' => '03'], ['04' => '04'], ['05' => '05'], ['06' => '06'], ['07' => '07'], ['08' => '08'], ['09' => '09'], ['10' => '10'], ['11' => '11'], ['12' => '12']]; + % param 'month' => $dat_data->{month} unless param 'month'; + %= select_field 'month' => @month_options, class => 'input', id => 'month_select' +

+ +

+ %=l('dat_Hour:') + + % param 'day' => $dat_data->{day} unless param 'day'; + %= text_field 'day', size => '50', class => 'textinput day' , pattern=>'.*' , placeholder=>'day', title =>'Pattern regex mismatch', id => 'day_text' +

+ +

+ %=l('dat_Hour:') + + % my @hour_options = [['00' => '00'], ['01' => '01'], ['02' => '02'], ['03' => '03'], ['04' => '04'], ['05' => '05'], ['06' => '06'], ['07' => '07'], ['08' => '08'], ['09' => '09'], ['10' => '10'], ['11' => '11'], ['12' => '12'], ['13' => '13'], ['14' => '14'], ['15' => '15'], ['16' => '16'], ['17' => '17'], ['18' => '18'], ['19' => '19'], ['20' => '20'], ['21' => '21'], ['22' => '22'], ['23' => '23']]; + % param 'hour' => $dat_data->{hour} unless param 'hour'; + %= select_field 'hour' => @hour_options, class => 'input', id => 'hour_select' +

+ +

+ %=l('dat_Second:') + + % param 'minute' => $dat_data->{minute} unless param 'minute'; + %= text_field 'minute', size => '50', class => 'textinput minute' , pattern=>'.*' , placeholder=>'minute', title =>'Pattern regex mismatch', id => 'minute_text' +

+ +

+ %=l('dat_second') + + % param 'second' => $dat_data->{second} unless param 'second'; + %= text_field 'second', size => '50', class => 'textinput second' , pattern=>'.*' , placeholder=>'second', title =>'Pattern regex mismatch', id => 'second_text' +

+ + + %= submit_button l('dat_Save'), class => 'action subm9' + + + %# Probably finally by a submit. + %end +
\ No newline at end of file diff --git a/Targets/Datetime/datetime.css b/Targets/Datetime/datetime.css new file mode 100644 index 0000000..987868c --- /dev/null +++ b/Targets/Datetime/datetime.css @@ -0,0 +1,19 @@ +/* +Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47 +*/ +.Datetime-panel {} +.name {} +.rout {} +.head {} +.subh {} +.sele1 {} +.para1 {} +.text2 {} +.para2 {} +.sele3 {} +.sele4 {} +.text5 {} +.sele6 {} +.text7 {} +.text8 {} +.subm9 {} diff --git a/Targets/Datetime/datetime.html.ep b/Targets/Datetime/datetime.html.ep new file mode 100644 index 0000000..71b1149 --- /dev/null +++ b/Targets/Datetime/datetime.html.ep @@ -0,0 +1,56 @@ +%# +%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47 +%# +% layout 'default', title => "Sme server 2 - Date and time", share_dir => './'; +%# css specific to this panel: +% content_for 'module' => begin +%= stylesheet '/css/datetime.css' +%= javascript '/js/datetime.js' +
+ + % if (config->{debug} == 1) { +
+		%= dumper $c->current_route
+		%= dumper $dat_data->{trt}
+	
+ % } + +

<%=$title%>

+ + % if ( stash('modul')) { + %= $c->render_to_string(inline => stash('modul') ); + % } + + %if ($c->stash('first')) { +

+ %=$c->render_to_string(inline =>$c->l($c->stash('first'))) +

+ + %} elsif ($c->stash('success')) { +
+

+ %= $c->l($c->stash('success')); +

+
+
+ + %} elsif ($c->stash('error')) { +
+

+ %= $c->l($c->stash('error')); +

+
+
+ %} + + %#Routing to partials according to trt parameter. + %#This ought to be cascading if/then/elsif, but is easier to just stack the if/then's rather like a case statement' + + % if ($dat_data->{trt} eq "PARAMS") { + %= include 'partials/_dat_PARAMS' + %} + + + +
+%end \ No newline at end of file diff --git a/Targets/Datetime/datetime.js b/Targets/Datetime/datetime.js new file mode 100644 index 0000000..59eca20 --- /dev/null +++ b/Targets/Datetime/datetime.js @@ -0,0 +1,5 @@ +// +//Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47 +// +$(document).ready(function() { +}); diff --git a/Targets/Datetime/datetime_en.lex b/Targets/Datetime/datetime_en.lex new file mode 100644 index 0000000..8c75132 --- /dev/null +++ b/Targets/Datetime/datetime_en.lex @@ -0,0 +1,18 @@ +# +# Generated by SM2Gen version: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-06-15 12:45:47 +# +'dat_second' => 'Second', +'dat_Year:' => 'years', +'dat_Hour:' => 'hours', +'dat_Date_and_time' => 'Date and time', +'dat_Choose_this_option_to_stop' => 'Choose this option to stop synchronizing the system clock to the NTP server When the NTP service is disabled You can set the system date and time manually from this page', +'dat_Month:' => 'months', +'dat_Set_Date_and_Time:' => 'Set Date and time', +'dat_Save' => 'Save', +'dat_Second:' => 'second', +'dat_Time_Setting_Mode:' => 'Time Setting model', +'dat_Time_Configuration' => 'Time Configuration', +'dat_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful', +'dat_The_server_is_periodically_synchronizing' => 'The server is periodically synchronizing the system clock to the network time protocol (NTP) server specified below To synchronize to a different NTP server Enter a different hostage or IP address in the field below', +'Date_and_time_configuration' => 'And time configuration', +'dat_APPLY' => 'Apply', diff --git a/Templates/controller.pm.tem b/Templates/controller.pm.tem index d3825f2..b1f7658 100644 --- a/Templates/controller.pm.tem +++ b/Templates/controller.pm.tem @@ -38,11 +38,11 @@ use Data::Dumper; use esmith::util; use esmith::util::network; -use esmith::ConfigDB; +use esmith::ConfigDB::UTF8; use esmith::AccountsDB; -use esmith::NetworksDB; +use esmith::NetworksDB::UTF8; use esmith::HostsDB; -use esmith::DomainsDB; +use esmith::DomainsDB::UTF8; my $cdb; my $adb; @@ -69,12 +69,12 @@ sub main { my $c = shift; $c->app->log->info( $c->log_req ); - #The most common ones - $cdb = esmith::ConfigDB->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->open() || die('Couldn't open Hosts db'); - $ddb = esmith::DomainsDB->open() || die('Couldn't open Domains db'); + #The most common ones - you might want to delete some of these if they are not used. + $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"); %${prefix}_data = (); my $title = $c->l('${prefix}_${MenuDescription}'); @@ -123,12 +123,12 @@ sub do_update { $c->app->log->info($c->log_req); my $modul = ''; - #The most common ones - you might want to comment out any not used. - $cdb = esmith::ConfigDB->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->open() || die('Couldn't open Hosts db'); - $ddb = esmith::DomainsDB->open() || die('Couldn't open Domains db'); + #The most common ones - you might want to delete some of these if they are not used. + $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"); my $title = $c->l('${prefix}_${MenuDescription}'); @@ -207,12 +207,12 @@ sub do_display { my ($c,$trt) = @_; $c->app->log->info($c->log_req); - #The most common ones - you might want to comment out any not used. - $cdb = esmith::ConfigDB->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->open() || die('Couldn't open Hosts db'); - $ddb = esmith::DomainsDB->open() || die('Couldn't open Domains db'); + #The most common ones - you might want to delete some of these if they are not used. + $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"); my $title = $c->l('${prefix}_${MenuDescription}'); my $modul = ''; diff --git a/Templates/custom.pm.tem b/Templates/custom.pm.tem index f204fd2..63b5f1c 100644 --- a/Templates/custom.pm.tem +++ b/Templates/custom.pm.tem @@ -7,11 +7,11 @@ # use esmith::util; use esmith::util::network; -use esmith::ConfigDB; -use esmith::HostsDB; +use esmith::ConfigDB::UTF8; use esmith::AccountsDB; -use esmith::NetworksDB; -use esmith::DomainsDB; +use esmith::NetworksDB::UTF8; +use esmith::HostsDB; +use esmith::DomainsDB::UTF8; use constant FALSE => 0; use constant TRUE => 1; @@ -24,6 +24,14 @@ 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_${panel} { diff --git a/html/Datetime.html b/html/Datetime.html new file mode 100644 index 0000000..3a7bf24 --- /dev/null +++ b/html/Datetime.html @@ -0,0 +1,75 @@ +
+ + +

Date and time configuration


+ This is where you configure the date and time of this server. You may use an existing network time server or +manually set the date and time for your time zone. + +

+ + +

Time Configuration

+
+ + + + + + + +
+

+ The server is periodically synchronizing the system clock to the network time protocol (NTP) server specified below. To synchronize to a different NTP server, enter a different hostname or IP address in the field below. +

+ + + + + +
+ +
+

+ Choose this option to stop syncronizing the system clock to the NTP +server.When the NTP service is disabled, you can set the system date and time manually from this page. +

+
+
+ + + +
+
+
+ Date + + +   + + + +   + + + +
+ +
+ Time + + +   + + + +   + + + +
+
+
+
+ + +
\ No newline at end of file diff --git a/json5/Datetime.json5 b/json5/Datetime.json5 new file mode 100644 index 0000000..5450ea0 --- /dev/null +++ b/json5/Datetime.json5 @@ -0,0 +1,360 @@ +// +// Generated by sm1-html-2-json5 version:0.5 Chameleon version:3.8.1 On Python:3.12.3 at 2025-06-15 10:49:09 +// +{ + 'PackageName': 'Datetime', + 'prefix': 'dat', + 'MenuHeading': 'System', + 'MenuDescription': 'Date and time', + 'MenuNavigation': '4000 300', + 'firstPanel': 'PARAMS', + 'signalEvent': 'smeserver-datetime-update', + 'html': [ + { + 'Name': 'params', + 'route': 'PARAMS', + 'Header': 'Date and time configuration', + 'SubHeader': 'Time Configuration', + 'Input1': { + 'Type': 'Select', + 'Value': '', + 'Name': 'time_mode', + 'Label': 'Time Setting Mode:', + 'Options': [ + { + 'Value': 'dat_ntp_server', + 'Text': 'NTP server' + }, + { + 'Value': 'dat_manually_set', + 'Text': 'Set manually' + } + ] + }, + 'Paragraph1': 'The server is periodically synchronizing the system clock to the network time protocol (NTP) server specified below. To synchronize to a different NTP server, enter a different hostname or IP address in the field below.', + 'Input2': { + 'Type': 'Text', + 'Value': 'smeserver.pool.ntp.org', + 'Name': 'ntpserver', + 'Label': 'Set Date and Time:' + }, + 'Paragraph2': 'Choose this option to stop syncronizing the system clock to the NTP server.When the NTP service is disabled, you can set the system date and time manually from this page.', + 'Input3': { + 'Type': 'Select', + 'Value': '', + 'Name': 'year', + 'Label': 'Year:', + 'Options': [ + { + 'Value': '2025', + 'Text': '2025' + }, + { + 'Value': '2026', + 'Text': '2026' + }, + { + 'Value': '2027', + 'Text': '2027' + }, + { + 'Value': '2028', + 'Text': '2028' + }, + { + 'Value': '2029', + 'Text': '2029' + }, + { + 'Value': '2030', + 'Text': '2030' + }, + { + 'Value': '2031', + 'Text': '2031' + }, + { + 'Value': '2032', + 'Text': '2032' + }, + { + 'Value': '2033', + 'Text': '2033' + }, + { + 'Value': '2034', + 'Text': '2034' + }, + { + 'Value': '2035', + 'Text': '2035' + }, + { + 'Value': '2036', + 'Text': '2036' + }, + { + 'Value': '2037', + 'Text': '2037' + }, + { + 'Value': '2038', + 'Text': '2038' + }, + { + 'Value': '2039', + 'Text': '2039' + }, + { + 'Value': '2040', + 'Text': '2040' + }, + { + 'Value': '2041', + 'Text': '2041' + }, + { + 'Value': '2042', + 'Text': '2042' + }, + { + 'Value': '2043', + 'Text': '2043' + }, + { + 'Value': '2044', + 'Text': '2044' + }, + { + 'Value': '2045', + 'Text': '2045' + }, + { + 'Value': '2046', + 'Text': '2046' + }, + { + 'Value': '2047', + 'Text': '2047' + }, + { + 'Value': '2048', + 'Text': '2048' + }, + { + 'Value': '2049', + 'Text': '2049' + }, + { + 'Value': '2050', + 'Text': '2050' + }, + { + 'Value': '2051', + 'Text': '2051' + }, + { + 'Value': '2052', + 'Text': '2052' + }, + { + 'Value': '2053', + 'Text': '2053' + }, + { + 'Value': '2054', + 'Text': '2054' + }, + { + 'Value': '2055', + 'Text': '2055' + } + ] + }, + 'Input4': { + 'Type': 'Select', + 'Value': '', + 'Name': 'month', + 'Label': 'Month:', + 'Options': [ + { + 'Value': '01', + 'Text': '01' + }, + { + 'Value': '02', + 'Text': '02' + }, + { + 'Value': '03', + 'Text': '03' + }, + { + 'Value': '04', + 'Text': '04' + }, + { + 'Value': '05', + 'Text': '05' + }, + { + 'Value': '06', + 'Text': '06' + }, + { + 'Value': '07', + 'Text': '07' + }, + { + 'Value': '08', + 'Text': '08' + }, + { + 'Value': '09', + 'Text': '09' + }, + { + 'Value': '10', + 'Text': '10' + }, + { + 'Value': '11', + 'Text': '11' + }, + { + 'Value': '12', + 'Text': '12' + } + ] + }, + 'Input5': { + 'Type': 'Text', + 'Value': '15', + 'Name': 'day', + 'Label': 'Hour:' + }, + 'Input6': { + 'Type': 'Select', + 'Value': '', + 'Name': 'hour', + 'Label': 'Hour:', + 'Options': [ + { + 'Value': '00', + 'Text': '00' + }, + { + 'Value': '01', + 'Text': '01' + }, + { + 'Value': '02', + 'Text': '02' + }, + { + 'Value': '03', + 'Text': '03' + }, + { + 'Value': '04', + 'Text': '04' + }, + { + 'Value': '05', + 'Text': '05' + }, + { + 'Value': '06', + 'Text': '06' + }, + { + 'Value': '07', + 'Text': '07' + }, + { + 'Value': '08', + 'Text': '08' + }, + { + 'Value': '09', + 'Text': '09' + }, + { + 'Value': '10', + 'Text': '10' + }, + { + 'Value': '11', + 'Text': '11' + }, + { + 'Value': '12', + 'Text': '12' + }, + { + 'Value': '13', + 'Text': '13' + }, + { + 'Value': '14', + 'Text': '14' + }, + { + 'Value': '15', + 'Text': '15' + }, + { + 'Value': '16', + 'Text': '16' + }, + { + 'Value': '17', + 'Text': '17' + }, + { + 'Value': '18', + 'Text': '18' + }, + { + 'Value': '19', + 'Text': '19' + }, + { + 'Value': '20', + 'Text': '20' + }, + { + 'Value': '21', + 'Text': '21' + }, + { + 'Value': '22', + 'Text': '22' + }, + { + 'Value': '23', + 'Text': '23' + } + ] + }, + 'Input7': { + 'Type': 'Text', + 'Value': '42', + 'Name': 'minute', + 'Label': 'Second:' + }, + 'Input8': { + 'Type': 'Text', + 'Value': '47', + 'Name': 'second', + 'Label': 'second' + }, + 'Input9': { + 'Type': 'Submit', + 'Value': 'Save', + 'Name': null, + 'Label': null + } + } + ] +} \ No newline at end of file