More fixes to lexical scan

This commit is contained in:
2024-05-06 10:05:43 +01:00
parent 228a42ed60
commit a5f8e153a2
12 changed files with 152 additions and 105 deletions

View File

@@ -2,7 +2,7 @@
# Routines to be editted by the developer to provide validation for parameters
# and provison of the control data for table(s)
#
# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-04-27 10:35
# Generated by SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 08:40
#
use esmith::util;
@@ -23,14 +23,16 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
# Validation routines - parameters for each panel
sub validate_PARAMS {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
sub validate_TABLE {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
@@ -39,7 +41,7 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
sub get_ibays {
my $c = shift;
my @res;
my @ret = {};
my @ibays = $adb->ibays();
foreach my $i (@ibays){
# Taken pretty well verbatim from /usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/nfsshare.pm
@@ -59,7 +61,7 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
my $actionModify = ' ';
if ($modifiable eq 'yes'){
$actionModify .= "<a href='nfsshareu?trt=PARAMS&Selected=$ibayname'><button class='sme-modify-button' title=".$c->l("MODIFY").">".$c->l("MODIFY")."</button></a>"."&nbsp"
$actionModify .= "<a href='nfsshared?trt=PARAMS&Selected=$ibayname'><button class='sme-modify-button' title=".$c->l("MODIFY").">".$c->l("MODIFY")."</button></a>"."&nbsp"
}
my %hash = ('Name'=> $ibayname,
@@ -67,22 +69,27 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
'Flag' => $ibaynfs,
'Modify' => $actionModify
);
push(@res,\%hash);
push(@ret,\%hash);
}
return \@res
return \@ret
}
# Return hash with values from row in which link clicked on table
sub validate_get_selected_PARAMS {
$selected = shift; #Parameter is name of selected row.
%ret = {};
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 = {};
return $ret;
}
sub validate_get_selected_TABLE {
$selected = shift; #Parameter is name of selected row.
%ret = {};
sub get_selected_TABLE {
my $c = shift;
my $selected = shift; #Parameter is name of selected row.
my $is_new_record = shift; #Indicates new record required (defaults)
my %ret = {};
return $ret;
}
@@ -90,18 +97,27 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
#after sucessful modify or create or whatever and submit then perfom (if the params validate)
sub perform_PARAMS {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
sub perform_TABLE {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
sub create_link{
# WIP
my ($c,$route, $panel, $index) = shift;
my $link = "$route?trt=$panel&Selected=$index";
return $link;
}
1;

View File

@@ -2,7 +2,7 @@
# Routines to be editted by the developer to provide validation for parameters
# and provison of the control data for table(s)
#
# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-05 09:26
# Generated by SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 10:02
#
use esmith::util;
@@ -23,14 +23,16 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
# Validation routines - parameters for each panel
sub validate_PARAMS {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
sub validate_TABLE {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
@@ -39,22 +41,26 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
sub get_ibays {
my $c = shift;
@ret = {}
my @ret = {};
return \@ret
}
# Return hash with values from row in which link clicked on table
sub validate_get_selected_PARAMS {
$selected = shift; #Parameter is name of selected row.
%ret = {};
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 = {};
return $ret;
}
sub validate_get_selected_TABLE {
$selected = shift; #Parameter is name of selected row.
%ret = {};
sub get_selected_TABLE {
my $c = shift;
my $selected = shift; #Parameter is name of selected row.
my $is_new_record = shift; #Indicates new record required (defaults)
my %ret = {};
return $ret;
}
@@ -62,14 +68,16 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
#after sucessful modify or create or whatever and submit then perfom (if the params validate)
sub perform_PARAMS {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}
sub perform_TABLE {
$prefix_data = shift; #Data hash as parameter
$ret = 'ok';
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = 'ok';
return $ret;
}

View File

@@ -1,6 +1,6 @@
% layout 'default', title => "Sme server 2 - NFS data share", share_dir => './';
%#
%# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-05 09:26
%# Generated by SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 10:02
%#
% content_for 'module' => begin
<div id="module" class="module Nfsshare-panel">

View File

@@ -1,6 +1,6 @@
package SrvMngr::Controller::Nfsshare;
#
# Generated by version:SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-05 09:26
# Generated by version:SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 10:02
#
#----------------------------------------------------------------------
# heading : Network
@@ -10,6 +10,7 @@ package SrvMngr::Controller::Nfsshare;
# name : nfsshare, method : get, url : /nfsshare, ctlact : nfsshare#main
# name : nfsshareu, method : post, url : /nfsshareu, ctlact : nfsshare#do_update
# name : nfsshared, method : get, url : /nfsshared, ctlact : nfsshare#do_display
# name : nfssharee, method : post, url : /nfsshared, ctlact : nfsshare#do_display
#
# routes : end
#
@@ -67,7 +68,7 @@ sub main {
$c->app->log->info( $c->log_req );
my %nfs_data = ();
my $title = $c->l("nfs_NFS_data_share");
my $title = $c->l('nfs_NFS_data_share');
my $modul = '';
$nfs_data{'trt'} = 'TABLE';
@@ -89,7 +90,7 @@ sub main {
$c->render( template => "Nfsshare" );
}
# Post request with params - submit from a form
# 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"
@@ -119,7 +120,7 @@ sub do_update {
$c->app->log->info($c->log_req);
my %nfs_data = ();
my $title = $c->l("nfs_NFS_data_share");
my $title = $c->l('nfs_NFS_data_share');
# Accessing all POST parameters
my %params = $c->req->params->to_hash;
@@ -141,13 +142,13 @@ sub do_update {
if ($trt eq 'PARAMS'){
#Validate form parameters for panel PARAMS
$ret = validate_PARAMS(\%nfs_data);
$ret = validate_PARAMS($c,\%nfs_data);
$thispanel = 'PARAMS';
}
if ($trt eq 'TABLE'){
#Validate form parameters for panel TABLE
$ret = validate_TABLE(\%nfs_data);
$ret = validate_TABLE($c,\%nfs_data);
$thispanel = 'TABLE';
}
@@ -161,25 +162,25 @@ sub do_update {
if ($trt eq 'PARAMS'){
#do whatever is required ...
$ret = perform_PARAMS(\%nfs_data);
$ret = perform_PARAMS($c,\%nfs_data);
if ($ret ne "ok") {
# return to the panel with error message
$c->stash(error => $c->l($ret));
$c->render("Nfsshare");
} else {
$c->stash( success => $c->l("nfs_PARAMS_panel_action_was_successfull")); #A bit bland - edit it in the lex file
$c->stash( success => $c->l('nfs_PARAMS_panel_action_was_successfull')); #A bit bland - edit it in the lex file
}
}
if ($trt eq 'TABLE'){
#do whatever is required ...
$ret = perform_TABLE(\%nfs_data);
$ret = perform_TABLE($c,\%nfs_data);
if ($ret ne "ok") {
# return to the panel with error message
$c->stash(error => $c->l($ret));
$c->render("Nfsshare");
} else {
$c->stash( success => $c->l("nfs_TABLE_panel_action_was_successfull")); #A bit bland - edit it in the lex file
$c->stash( success => $c->l('nfs_TABLE_panel_action_was_successfull')); #A bit bland - edit it in the lex file
}
}
@@ -203,7 +204,9 @@ sub do_update {
sub do_display {
#
# Return after link clicked in table (this is a get) - route is "/<whatever>d"
# Expects ?trt=PANEL&selected="TableRownfs_Name" plus any other required
# 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
@@ -214,14 +217,17 @@ sub do_display {
$c->app->log->info($c->log_req);
my %nfs_data = ();
my $title = $c->l("nfs_NFS_data_share");
my $title = $c->l('nfs_NFS_data_share');
# Accessing all POST parameters
# Accessing all parameters
my %params = $c->req->params->to_hash;
# Get number of POST parameters
# 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}) {
$nfs_data{$key} = $value;
@@ -231,16 +237,17 @@ sub do_display {
my $trt = $c->param('trt') || 'TABLE'; #Indicates where to go now
# Now add in the params from the selected row from the table
my %selectedrow;
if ($trt eq 'PARAMS'){
#Validate form parameters for panel PARAMS
%selectedrow = selected_PARAMS($nfs_data{'Selected'});
%selectedrow = get_selected_PARAMS($c,$nfs_data{'Selected'},$is_new_record);
}
if ($trt eq 'TABLE'){
#Validate form parameters for panel TABLE
%selectedrow = selected_TABLE($nfs_data{'Selected'});
%selectedrow = get_selected_TABLE($c,$nfs_data{'Selected'},$is_new_record);
}

View File

@@ -1,5 +1,5 @@
%#
%# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-05 09:26
%# Generated by SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 10:02
%#
<div id="Nfsshare-PARAMS">
<script>
@@ -8,7 +8,7 @@
};
</script>
<h2>
%= l("nfs_Hello_PARAMS");
%= l('nfs_Hello_PARAMS');
</h2>
% my $btn = l('nfs_APPLY');
%= form_for "Nfsshared" => (method => 'POST') => begin
@@ -26,7 +26,7 @@
<p><span class=label>
%=l('nfs_Information_Bay_name'), class => 'label'
</span><span class=data>
%= stash("Ibaynfs_Name"), class => 'data'
%= stash("IbayName"), class => 'data'
</span></p>
<p><span class=label>

View File

@@ -1,5 +1,5 @@
%#
%# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-05 09:26
%# Generated by SME2Gen version:0.7 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-06 10:02
%#
<div id="Nfsshare-TABLE">
<script>
@@ -8,7 +8,7 @@
};
</script>
<h2>
%= l("nfs_Hello_TABLE");
%= l('nfs_Hello_TABLE');
</h2>
% my $btn = l('nfs_APPLY');
%= form_for "Nfsshared" => (method => 'POST') => begin
@@ -32,8 +32,8 @@
% my $control_data = $self->stash('ibays');
% foreach my $row (@$control_data) {
<tr>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{nfs_Name})%></td>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{nfs_Description})%></td>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{Name})%></td>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{Description})%></td>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{flag})%></td>
<td class='sme-border'><%=$c->render_to_string(inline=>$row->{Modify})%></td>
</tr>

View File

@@ -1,28 +1,28 @@
'nfs_PARAMS_panel_action_was_successfull' => 'PARAMS panel action was successfull',
'nfs_Information_Bay_name' => 'Information Bay name',
'nfs_Name' => 'Name',
'nfs_For_writing_permissions,allowing_the_root' => 'For writing permissions, Allowing the root user and using insecure ports, You must configure a list of one IP per line, Being part of the local network(s). ',
'nfs_Manage_NFS_Ibay_settings:' => 'Manage NFS Ibay settings:',
'nfs_NFS_data_share' => 'NFS data share',
'nfs_NFS_Client(s)_allowed' => 'NFS Client(s) allowed',
'nfs_Hello_TABLE' => 'Hello TABLE',
'nfs_Set_the_uid_and_gid' => 'Set the uid and gid if you want all requests appear to be from one user or one group, Otherwise leave blank',
'nfs_Write_(a)synchronously' => 'Write (a)synchronously',
'nfs_These_parameters_will_be_effective' => 'These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files',
'nfs_Set_the_UID.' => 'Set the UID. ',
'nfs_File_system_permissions' => 'File system permissions',
'nfs_Delays_the_disk_writing' => 'Delays the disk writing',
'nfs_Squash_the_power_of_users' => 'Squash the power of users',
'nfs_Information_Bay_name' => 'Information Bay name',
'nfs_Share_owner_Group' => 'Share owner Group',
'nfs_Save' => 'Save',
'nfs_APPLY' => 'Apply',
'nfs_Description' => 'Description',
'nfs_Hello_PARAMS' => 'Hello PARAMS',
'nfs_TABLE_panel_action_was_successfull' => 'TABLE panel action was successfull',
'nfs_Enable_the_NFS_Share' => 'Enable the NFS Share',
'nfs_EnableShare_on_local_network' => 'Enableshare on local network',
'nfs_Share_owner_Group' => 'Share owner Group',
'nfs_Browse_the_parent_folders' => 'Browse the parent folders',
'nfs_Hello_PARAMS' => 'Hello PARAMS',
'nfs_Delays_the_disk_writing' => 'Delays the disk writing',
'nfs_These_parameters_will_be_effective' => 'These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files',
'nfs_Hello_TABLE' => 'Hello TABLE',
'nfs_NFS_Client(s)_allowed' => 'NFS Client(s) allowed',
'nfs_File_system_permissions' => 'File system permissions',
'nfs_Description' => 'Description',
'nfs_PARAMS_panel_action_was_successfull' => 'PARAMS panel action was successfull',
'nfs_Set_the_GID.' => 'Set the GID. ',
'nfs_Action' => 'Action',
'nfs_NFS_data_share' => 'NFS data share',
'nfs_Manage_NFS_Ibay_settings:' => 'Manage NFS Ibay settings:',
'nfs_For_writing_permissions,allowing_the_root' => 'For writing permissions, Allowing the root user and using insecure ports, You must configure a list of one IP per line, Being part of the local network(s). ',
'nfs_Browse_the_parent_folders' => 'Browse the parent folders',
'Nfs_status' => 'Status',
'nfs_Requests_on_secure_ports' => 'Requests on secure ports',
'nfs_TABLE_panel_action_was_successfull' => 'TABLE panel action was successfull',
'nfs_Set_the_uid_and_gid' => 'Set the uid and gid if you want all requests appear to be from one user or one group, Otherwise leave blank',
'nfs_APPLY' => 'Apply',
'nfs_Set_the_UID.' => 'Set the UID. ',
'nfs_Name' => 'Name',
'nfs_Set_the_GID.' => 'Set the GID. ',
'nfs_Save' => 'Save',
'nfs_Write_(a)synchronously' => 'Write (a)synchronously',