Add in UTF8 changes

This commit is contained in:
Brian Read 2025-06-15 12:54:11 +01:00
parent ae2ba92597
commit 7f02b4f109
11 changed files with 1087 additions and 25 deletions

View File

@ -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;

View File

@ -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 "/<whatever>"
#
#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 <prefix>_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 "/<whatever>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-<whatever>-update exists
#signal_event smeserver-<whatever>-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 "/<whatever>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;

View File

@ -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
%#
<div id="Datetime-PARAMS" class="partial Datetime-PARAMS">
%# <script>
%# window.onload = function() {
%# SelectInput();
%# };
%# </script>
% if (config->{debug} == 1) {
<pre>
%= dumper $dat_data
</pre>
% }
% 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.
<h1 class='head'><%=l('Date_and_time_configuration')%></h1>
<h2 class='subh'><%=l('dat_Time_Configuration')%></h2>
<p><span class=label>
%=l('dat_Time_Setting_Mode:')
</span><span class=data>
% 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'
<br></span> </p>
<p class='paragraph para1'>
%=l('dat_The_server_is_periodically_synchronizing')
</p>
<p><span class=label>
%=l('dat_Set_Date_and_Time:')
</span><span class=data>
% 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'
<br></span></p>
<p class='paragraph para2'>
%=l('dat_Choose_this_option_to_stop')
</p>
<p><span class=label>
%=l('dat_Year:')
</span><span class=data>
% 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'
<br></span> </p>
<p><span class=label>
%=l('dat_Month:')
</span><span class=data>
% 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'
<br></span> </p>
<p><span class=label>
%=l('dat_Hour:')
</span><span class=data>
% 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'
<br></span></p>
<p><span class=label>
%=l('dat_Hour:')
</span><span class=data>
% 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'
<br></span> </p>
<p><span class=label>
%=l('dat_Second:')
</span><span class=data>
% 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'
<br></span></p>
<p><span class=label>
%=l('dat_second')
</span><span class=data>
% 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'
<br></span></p>
<span class='data'>
%= submit_button l('dat_Save'), class => 'action subm9'
</span>
%# Probably finally by a submit.
%end
</div>

View File

@ -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 {}

View File

@ -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'
<div id="module" class="module Datetime-panel">
% if (config->{debug} == 1) {
<pre>
%= dumper $c->current_route
%= dumper $dat_data->{trt}
</pre>
% }
<h1><%=$title%></h1>
% if ( stash('modul')) {
%= $c->render_to_string(inline => stash('modul') );
% }
%if ($c->stash('first')) {
<br><p>
%=$c->render_to_string(inline =>$c->l($c->stash('first')))
</p>
%} elsif ($c->stash('success')) {
<div class='success '>
<p>
%= $c->l($c->stash('success'));
</p>
</div>
<br />
%} elsif ($c->stash('error')) {
<div class='sme-error'>
<p>
%= $c->l($c->stash('error'));
</p>
</div>
<br />
%}
%#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'
%}
</div>
%end

View File

@ -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() {
});

View File

@ -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',

View File

@ -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 = '';

View File

@ -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
<tal:block tal:repeat="panel panels">
sub validate_${panel} {

75
html/Datetime.html Normal file
View File

@ -0,0 +1,75 @@
<div id='module' class='module datetime-panel'>
<h1>Date and time configuration</h1><br>
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.
<p>
<input name="Old_ntpstatus" type="hidden" value="enabled">
<h2>Time Configuration</h2>
<form action="smanager/save_time_config" method="post">
<span class=label>
<label for="time_mode">Time Setting Mode:</label>
</span><span class=data2>
<select id="time_mode_select" name="time_mode"><option value="dat_ntp_server">NTP server</option><option value="dat_manually_set">Set manually</option></select>
</span>
<div id='ntp_section'>
<p>
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.
</p>
<span class=label>
<label for="ntpserver">NTP Server URL:</label>
</span><span class=data2>
<input id="ntpserver" name="ntpserver" pattern="^([a-zA-Z0-9][a-zA-Z0-9\.\-]{0,253}[a-zA-Z0-9]|(\d{1,3}\.){3}\d{1,3})$" placeholder="e.g. smeserver.pool.ntp.org" title="Enter a valid hostname or IPv4 address" type="text" value="smeserver.pool.ntp.org">
</span>
</div>
<div id='manual_section'>
<p>
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.
</p>
<div class='datetime-config-row'>
<div class='datetime-label-col'>
<span class='datetime-label'>
<label for="datetime_manual">Set Date and Time:</label>
</span>
</div>
<div class='datetime-fields-col' id='datetime_manual'>
<fieldset>
<legend>Date</legend>
<label for="year">Year:</label>
<select id="year" name="year" required="required"><option selected value="2025">2025</option><option value="2026">2026</option><option value="2027">2027</option><option value="2028">2028</option><option value="2029">2029</option><option value="2030">2030</option><option value="2031">2031</option><option value="2032">2032</option><option value="2033">2033</option><option value="2034">2034</option><option value="2035">2035</option><option value="2036">2036</option><option value="2037">2037</option><option value="2038">2038</option><option value="2039">2039</option><option value="2040">2040</option><option value="2041">2041</option><option value="2042">2042</option><option value="2043">2043</option><option value="2044">2044</option><option value="2045">2045</option><option value="2046">2046</option><option value="2047">2047</option><option value="2048">2048</option><option value="2049">2049</option><option value="2050">2050</option><option value="2051">2051</option><option value="2052">2052</option><option value="2053">2053</option><option value="2054">2054</option><option value="2055">2055</option></select>
&nbsp;
<label for="month">Month:</label>
<select id="month" name="month" required="required"><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option></select>
&nbsp;
<label for="day">Day:</label>
<input autocomplete="off" id="day" inputmode="numeric" maxlength="2" name="day" pattern="^(0[1-9]|[12][0-9]|3[01])$" placeholder="DD" required="required" size="2" title="Day (01-31)" type="text" value="15">
</fieldset>
<fieldset>
<legend>Time</legend>
<label for="hour">Hour:</label>
<select id="hour" name="hour" required="required"><option value="00">00</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option selected value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option></select>
&nbsp;
<label for="minute">Minute:</label>
<input autocomplete="off" id="minute" inputmode="numeric" maxlength="2" name="minute" pattern="^[0-5][0-9]$" placeholder="MM" required="required" size="2" title="Minute (00-59)" type="text" value="42">
&nbsp;
<label for="second">Second:</label>
<input autocomplete="off" id="second" inputmode="numeric" maxlength="2" name="second" pattern="^[0-5][0-9]$" placeholder="SS" required="required" size="2" title="Second (00-59)" type="text" value="47">
</fieldset>
</div>
</div>
</div>
<input type="submit" value="Save">
</form> </div>

360
json5/Datetime.json5 Normal file
View File

@ -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
}
}
]
}