From 588081417b1833eb39e161716fb1cf52bd537c1c Mon Sep 17 00:00:00 2001 From: Brian Read Date: Wed, 21 May 2025 11:06:32 +0100 Subject: [PATCH] Add in shares contrib also fix comment out script in partial add fix json5 python --- Targets/Shares/Shares-Custom.pm | 546 +++++++++++++++++++++++++ Targets/Shares/Shares.pm | 398 ++++++++++++++++++ Targets/Shares/_sf_LIST.html.ep | 69 ++++ Targets/Shares/_sf_MODIFY.html.ep | 113 +++++ Targets/Shares/_sf_PERMISSIONS.html.ep | 365 +++++++++++++++++ Targets/Shares/_sf_REMOVE.html.ep | 50 +++ Targets/Shares/shares.css | 86 ++++ Targets/Shares/shares.html.ep | 68 +++ Targets/Shares/shares.js | 5 + Targets/Shares/shares_en.lex | 46 +++ Templates/partial.html.ep.tem | 10 +- html/shared-folders_list.html | 57 +++ html/shared-folders_modify.html | 129 ++++++ html/shared-folders_perms.html | 136 ++++++ html/shared-folders_remove.html | 55 +++ json5/Shares.json5 | 504 +++++++++++++++++++++++ json5/shared-folders_list.json5 | 56 +++ json5/shared-folders_modify.json5 | 198 +++++++++ json5/shared-folders_perms.json5 | 271 ++++++++++++ json5/shared-folders_remove.json5 | 35 ++ json5_fix_format.py | 96 +++++ 21 files changed, 3288 insertions(+), 5 deletions(-) create mode 100644 Targets/Shares/Shares-Custom.pm create mode 100644 Targets/Shares/Shares.pm create mode 100644 Targets/Shares/_sf_LIST.html.ep create mode 100644 Targets/Shares/_sf_MODIFY.html.ep create mode 100644 Targets/Shares/_sf_PERMISSIONS.html.ep create mode 100644 Targets/Shares/_sf_REMOVE.html.ep create mode 100644 Targets/Shares/shares.css create mode 100644 Targets/Shares/shares.html.ep create mode 100644 Targets/Shares/shares.js create mode 100644 Targets/Shares/shares_en.lex create mode 100644 html/shared-folders_list.html create mode 100644 html/shared-folders_modify.html create mode 100644 html/shared-folders_perms.html create mode 100644 html/shared-folders_remove.html create mode 100644 json5/Shares.json5 create mode 100644 json5/shared-folders_list.json5 create mode 100644 json5/shared-folders_modify.json5 create mode 100644 json5/shared-folders_perms.json5 create mode 100644 json5/shared-folders_remove.json5 create mode 100644 json5_fix_format.py diff --git a/Targets/Shares/Shares-Custom.pm b/Targets/Shares/Shares-Custom.pm new file mode 100644 index 0000000..57b7fe2 --- /dev/null +++ b/Targets/Shares/Shares-Custom.pm @@ -0,0 +1,546 @@ +# +# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-21 08:46:42 +# +# +# 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; +use esmith::HostsDB; +use esmith::AccountsDB; +use esmith::NetworksDB; +use esmith::DomainsDB; + +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; + +# Validation routines - parameters for each panel + + sub validate_LIST { + my $c = shift; + my $sf_data = shift; #Data hash as parameter + # Validation for each field + my $ret = ""; + + if ($ret eq "") {$ret = 'ok';} + return $ret; + } + + sub validate_MODIFY { + my $c = shift; + my $sf_data = shift; #Data hash as parameter + # Validation for each field + my $ret = ""; + + if (! TRUE) #validate $c->param('description') + {$ret .= 'Validation for description failed';} + if (! TRUE) #validate $c->param('smbaccess') + {$ret .= 'Validation for smbaccess failed';} + if (! TRUE) #validate $c->param('recyclebin') + {$ret .= 'Validation for recyclebin failed';} + if (! TRUE) #validate $c->param('retention') + {$ret .= 'Validation for retention failed';} + if (! TRUE) #validate $c->param('httpaccess') + {$ret .= 'Validation for httpaccess failed';} + if (! TRUE) #validate $c->param('webdav') + {$ret .= 'Validation for webdav failed';} + if (! TRUE) #validate $c->param('requireSSL') + {$ret .= 'Validation for requireSSL failed';} + if (! TRUE) #validate $c->param('indexes') + {$ret .= 'Validation for indexes failed';} + if (! TRUE) #validate $c->param('dynamic') + {$ret .= 'Validation for dynamic failed';} + if ($ret eq "") {$ret = 'ok';} + return $ret; + } + + sub validate_PERMISSIONS { + my $c = shift; + my $sf_data = shift; #Data hash as parameter + # Validation for each field + my $ret = ""; + + if (! TRUE) #validate $c->param('writegroup') + {$ret .= 'Validation for writegroup failed';} + if (! TRUE) #validate $c->param('readgroup') + {$ret .= 'Validation for readgroup failed';} + if (! TRUE) #validate $c->param('writegroup') + {$ret .= 'Validation for writegroup failed';} + if (! TRUE) #validate $c->param('readgroup') + {$ret .= 'Validation for readgroup failed';} + if (! TRUE) #validate $c->param('writegroup') + {$ret .= 'Validation for writegroup failed';} + if (! TRUE) #validate $c->param('readgroup') + {$ret .= 'Validation for readgroup failed';} + if (! TRUE) #validate $c->param('writegroup') + {$ret .= 'Validation for writegroup failed';} + if (! TRUE) #validate $c->param('readgroup') + {$ret .= 'Validation for readgroup failed';} + if (! TRUE) #validate $c->param('writegroup') + {$ret .= 'Validation for writegroup failed';} + if (! TRUE) #validate $c->param('readgroup') + {$ret .= 'Validation for readgroup failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if (! TRUE) #validate $c->param('writeuser') + {$ret .= 'Validation for writeuser failed';} + if (! TRUE) #validate $c->param('readuser') + {$ret .= 'Validation for readuser failed';} + if ($ret eq "") {$ret = 'ok';} + return $ret; + } + + sub validate_REMOVE { + my $c = shift; + my $sf_data = shift; #Data hash as parameter + # Validation for each field + my $ret = ""; + + if ($ret eq "") {$ret = 'ok';} + return $ret; + } + + +# Get singleton data for each panel + + sub get_data_for_panel_LIST { + # Return a hash with the fields required which will be loaded into the shared data + my $c = shift; + my %ret = ( + 'Data1'=>'Data for LIST', #Example + # fields from Inputs in LIST $fields['LIST'] + + ); + return %ret; + } + + sub get_data_for_panel_MODIFY { + # Return a hash with the fields required which will be loaded into the shared data + my $c = shift; + my %ret = ( + 'Data1'=>'Data for MODIFY', #Example + # fields from Inputs in MODIFY $fields['MODIFY'] + 'description'=>'description contents', + 'smbaccess'=>'smbaccess contents', + 'recyclebin'=>'recyclebin contents', + 'retention'=>'retention contents', + 'httpaccess'=>'httpaccess contents', + 'webdav'=>'webdav contents', + 'requireSSL'=>'requireSSL contents', + 'indexes'=>'indexes contents', + 'dynamic'=>'dynamic contents', + + ); + return %ret; + } + + sub get_data_for_panel_PERMISSIONS { + # Return a hash with the fields required which will be loaded into the shared data + my $c = shift; + my %ret = ( + 'Data1'=>'Data for PERMISSIONS', #Example + # fields from Inputs in PERMISSIONS $fields['PERMISSIONS'] + 'writegroup'=>'writegroup contents', + 'readgroup'=>'readgroup contents', + 'writegroup'=>'writegroup contents', + 'readgroup'=>'readgroup contents', + 'writegroup'=>'writegroup contents', + 'readgroup'=>'readgroup contents', + 'writegroup'=>'writegroup contents', + 'readgroup'=>'readgroup contents', + 'writegroup'=>'writegroup contents', + 'readgroup'=>'readgroup contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + 'writeuser'=>'writeuser contents', + 'readuser'=>'readuser contents', + + ); + return %ret; + } + + sub get_data_for_panel_REMOVE { + # Return a hash with the fields required which will be loaded into the shared data + my $c = shift; + my %ret = ( + 'Data1'=>'Data for REMOVE', #Example + # fields from Inputs in REMOVE $fields['REMOVE'] + + ); + return %ret; + } + + + +# Get control data for table(s) + + # Define a constant hash for field name mapping + use constant Table1_FIELD_MAPPING => ( + 'Table1-Name' => 'Table1-Name', + 'Table1-Description' => 'Table1-Description', + 'Table1-Actionp' => 'Table1-Actionp', + 'Table1-Actionm' => 'Table1-Actionm', + 'Table1-Actionr' => 'Table1-Actionr', + ); + +sub actual_Table1 { + my $c = shift; + my @ret = (); + # Actual code for extracting Table1 + $adb = esmith::AccountsDB::open() | die("Unable to open accounts DB"); + my @shares = $adb->get_all_by_prop(type => 'share'); + foreach my $share (@shares) { + my $sharename = $share->key(); + my $sharedesc = $share->prop('Name'); + next if (($share->prop('Hide') || 'no') eq 'yes'); + my $removable = $share->prop('Removable') || 'yes'; + my $actionModify = ''.$c->l('sf_Permisssions').'>'; + my $actionRemove = ($removable ne 'no') ?'set_prop($dbkey,'description',$c->param('description'),type=>'service')) + {$ret .= 'Perform/save failed for description';} + if (! TRUE) #copy or perform with value: smbaccess e.g. $db->set_prop($dbkey,'smbaccess',$c->param('smbaccess'),type=>'service')) + {$ret .= 'Perform/save failed for smbaccess';} + if (! TRUE) #copy or perform with value: recyclebin e.g. $db->set_prop($dbkey,'recyclebin',$c->param('recyclebin'),type=>'service')) + {$ret .= 'Perform/save failed for recyclebin';} + if (! TRUE) #copy or perform with value: retention e.g. $db->set_prop($dbkey,'retention',$c->param('retention'),type=>'service')) + {$ret .= 'Perform/save failed for retention';} + if (! TRUE) #copy or perform with value: httpaccess e.g. $db->set_prop($dbkey,'httpaccess',$c->param('httpaccess'),type=>'service')) + {$ret .= 'Perform/save failed for httpaccess';} + if (! TRUE) #copy or perform with value: webdav e.g. $db->set_prop($dbkey,'webdav',$c->param('webdav'),type=>'service')) + {$ret .= 'Perform/save failed for webdav';} + if (! TRUE) #copy or perform with value: requireSSL e.g. $db->set_prop($dbkey,'requireSSL',$c->param('requireSSL'),type=>'service')) + {$ret .= 'Perform/save failed for requireSSL';} + if (! TRUE) #copy or perform with value: indexes e.g. $db->set_prop($dbkey,'indexes',$c->param('indexes'),type=>'service')) + {$ret .= 'Perform/save failed for indexes';} + if (! TRUE) #copy or perform with value: dynamic e.g. $db->set_prop($dbkey,'dynamic',$c->param('dynamic'),type=>'service')) + {$ret .= 'Perform/save failed for dynamic';} + if ($ret eq "") {$ret = 'ok';} + return $ret; + } + + sub perform_PERMISSIONS { + my $c = shift; + my $sf_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: writegroup e.g. $db->set_prop($dbkey,'writegroup',$c->param('writegroup'),type=>'service')) + {$ret .= 'Perform/save failed for writegroup';} + if (! TRUE) #copy or perform with value: readgroup e.g. $db->set_prop($dbkey,'readgroup',$c->param('readgroup'),type=>'service')) + {$ret .= 'Perform/save failed for readgroup';} + if (! TRUE) #copy or perform with value: writegroup e.g. $db->set_prop($dbkey,'writegroup',$c->param('writegroup'),type=>'service')) + {$ret .= 'Perform/save failed for writegroup';} + if (! TRUE) #copy or perform with value: readgroup e.g. $db->set_prop($dbkey,'readgroup',$c->param('readgroup'),type=>'service')) + {$ret .= 'Perform/save failed for readgroup';} + if (! TRUE) #copy or perform with value: writegroup e.g. $db->set_prop($dbkey,'writegroup',$c->param('writegroup'),type=>'service')) + {$ret .= 'Perform/save failed for writegroup';} + if (! TRUE) #copy or perform with value: readgroup e.g. $db->set_prop($dbkey,'readgroup',$c->param('readgroup'),type=>'service')) + {$ret .= 'Perform/save failed for readgroup';} + if (! TRUE) #copy or perform with value: writegroup e.g. $db->set_prop($dbkey,'writegroup',$c->param('writegroup'),type=>'service')) + {$ret .= 'Perform/save failed for writegroup';} + if (! TRUE) #copy or perform with value: readgroup e.g. $db->set_prop($dbkey,'readgroup',$c->param('readgroup'),type=>'service')) + {$ret .= 'Perform/save failed for readgroup';} + if (! TRUE) #copy or perform with value: writegroup e.g. $db->set_prop($dbkey,'writegroup',$c->param('writegroup'),type=>'service')) + {$ret .= 'Perform/save failed for writegroup';} + if (! TRUE) #copy or perform with value: readgroup e.g. $db->set_prop($dbkey,'readgroup',$c->param('readgroup'),type=>'service')) + {$ret .= 'Perform/save failed for readgroup';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if (! TRUE) #copy or perform with value: writeuser e.g. $db->set_prop($dbkey,'writeuser',$c->param('writeuser'),type=>'service')) + {$ret .= 'Perform/save failed for writeuser';} + if (! TRUE) #copy or perform with value: readuser e.g. $db->set_prop($dbkey,'readuser',$c->param('readuser'),type=>'service')) + {$ret .= 'Perform/save failed for readuser';} + if ($ret eq "") {$ret = 'ok';} + return $ret; + } + + sub perform_REMOVE { + my $c = shift; + my $sf_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 ($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/Shares/Shares.pm b/Targets/Shares/Shares.pm new file mode 100644 index 0000000..d538199 --- /dev/null +++ b/Targets/Shares/Shares.pm @@ -0,0 +1,398 @@ +package SrvMngr::Controller::Shares; +# +# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-21 08:46:42 +# 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 : Network +# description : Shared Folders +# navigation : 7000 400 +# +# name : shares, method : get, url : /shares, ctlact : Shares#main +# name : sharesu, method : post, url : /sharesu, ctlact : Shares#do_update +# name : sharesd, method : get, url : /sharesd, ctlact : Shares#do_display +# +# routes : end +# +# Documentation: https://wiki.contribs.org/Shares +#---------------------------------------------------------------------- + +# +# 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; +use esmith::AccountsDB; +use esmith::NetworksDB; +use esmith::HostsDB; +use esmith::DomainsDB; + +my $cdb; +my $adb; +my $ndb; +my $hdb; +my $ddb; + +my %sf_data; + +require '/usr/share/smanager/lib/SrvMngr/Controller/Shares-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 + $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"); + + %sf_data = (); + my $title = $c->l('sf_Shared_Folders'); + my $modul = ''; + + $sf_data{'trt'} = 'LIST'; + + #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($sf_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 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"); + + my $title = $c->l('sf_Shared_Folders'); + + # 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}) { + # $sf_data{$key} = $value; + #} + + # the value of trt will tell you which panel has returned + my $trt = $c->param('trt') || 'LIST'; #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 'LIST'){ + #Validate form parameters for panel LIST + $ret = $c->validate_LIST(\%sf_data); + $thispanel = 'LIST'; + } + + if ($trt eq 'MODIFY'){ + #Validate form parameters for panel MODIFY + $ret = $c->validate_MODIFY(\%sf_data); + $thispanel = 'MODIFY'; + } + + if ($trt eq 'PERMISSIONS'){ + #Validate form parameters for panel PERMISSIONS + $ret = $c->validate_PERMISSIONS(\%sf_data); + $thispanel = 'PERMISSIONS'; + } + + if ($trt eq 'REMOVE'){ + #Validate form parameters for panel REMOVE + $ret = $c->validate_REMOVE(\%sf_data); + $thispanel = 'REMOVE'; + } + + 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 'LIST'){ + #do whatever is required ... + $ret = $c->perform_LIST(\%sf_data); + if ($ret ne "ok") { + # return to the panel with error message + $c->stash(error => $c->l($ret)); + $c->stash( + title => $title, + modul => $modul, + sf_data => \%sf_data + ); + $c->render(template => "shares"); + } else { + $c->stash( success => $c->l('sf_LIST_panel_action_was_successful')); #A bit bland - edit it in the lex file + } + } + + if ($trt eq 'MODIFY'){ + #do whatever is required ... + $ret = $c->perform_MODIFY(\%sf_data); + if ($ret ne "ok") { + # return to the panel with error message + $c->stash(error => $c->l($ret)); + $c->stash( + title => $title, + modul => $modul, + sf_data => \%sf_data + ); + $c->render(template => "shares"); + } else { + $c->stash( success => $c->l('sf_MODIFY_panel_action_was_successful')); #A bit bland - edit it in the lex file + } + } + + if ($trt eq 'PERMISSIONS'){ + #do whatever is required ... + $ret = $c->perform_PERMISSIONS(\%sf_data); + if ($ret ne "ok") { + # return to the panel with error message + $c->stash(error => $c->l($ret)); + $c->stash( + title => $title, + modul => $modul, + sf_data => \%sf_data + ); + $c->render(template => "shares"); + } else { + $c->stash( success => $c->l('sf_PERMISSIONS_panel_action_was_successful')); #A bit bland - edit it in the lex file + } + } + + if ($trt eq 'REMOVE'){ + #do whatever is required ... + $ret = $c->perform_REMOVE(\%sf_data); + if ($ret ne "ok") { + # return to the panel with error message + $c->stash(error => $c->l($ret)); + $c->stash( + title => $title, + modul => $modul, + sf_data => \%sf_data + ); + $c->render(template => "shares"); + } else { + $c->stash( success => $c->l('sf_REMOVE_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') { + $sf_data{'trt'} = 'LIST'; + } else { + $sf_data{'trt'} = 'none'; + } + $c->do_display($sf_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 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"); + + my $title = $c->l('sf_Shared_Folders'); + 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}) { + # $sf_data{$key} = $value; + #} + + # the value of trt will tell you which panel has returned + if (! $trt){ + $trt = $c->param('trt') || 'LIST'; #Indicates where to go now + } + + # Now add in the params from the selected row from the table + + my %selectedrow; + + if ($trt eq 'LIST'){ + #Validate Get selected row (if applicable) LIST + %selectedrow = $c->get_selected_LIST($sf_data{'Selected'},$is_new_record); + } + + if ($trt eq 'MODIFY'){ + #Validate Get selected row (if applicable) MODIFY + %selectedrow = $c->get_selected_MODIFY($sf_data{'Selected'},$is_new_record); + } + + if ($trt eq 'PERMISSIONS'){ + #Validate Get selected row (if applicable) PERMISSIONS + %selectedrow = $c->get_selected_PERMISSIONS($sf_data{'Selected'},$is_new_record); + } + + if ($trt eq 'REMOVE'){ + #Validate Get selected row (if applicable) REMOVE + %selectedrow = $c->get_selected_REMOVE($sf_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){ + $sf_data{$key} = $value; + } + # Where to go now + $sf_data{'trt'} = $trt; + + # Set up other shared data according to the panel to go to + + if ($trt eq 'LIST'){ + # 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_LIST(); + # Copy each key-value pair from the returned hash to the prefix data hash + while (my ($key, $value) = each %returned_hash) { + $sf_data{$key} = $value; + } + } + + if ($trt eq 'MODIFY'){ + # 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_MODIFY(); + # Copy each key-value pair from the returned hash to the prefix data hash + while (my ($key, $value) = each %returned_hash) { + $sf_data{$key} = $value; + } + } + + if ($trt eq 'PERMISSIONS'){ + # 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_PERMISSIONS(); + # Copy each key-value pair from the returned hash to the prefix data hash + while (my ($key, $value) = each %returned_hash) { + $sf_data{$key} = $value; + } + } + + if ($trt eq 'REMOVE'){ + # 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_REMOVE(); + # Copy each key-value pair from the returned hash to the prefix data hash + while (my ($key, $value) = each %returned_hash) { + $sf_data{$key} = $value; + } + } + + + # and table control fields + $c->stash(Table1=>$c->get_Table1()); + $c->stash(Table2=>$c->get_Table2()); + + + # Data for panel + $c->stash( + title => $title, + modul => $modul, + sf_data => \%sf_data + ); + $c->render(template => "shares"); +} +1; \ No newline at end of file diff --git a/Targets/Shares/_sf_LIST.html.ep b/Targets/Shares/_sf_LIST.html.ep new file mode 100644 index 0000000..d29603b --- /dev/null +++ b/Targets/Shares/_sf_LIST.html.ep @@ -0,0 +1,69 @@ +%# +%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-21 08:46:42 +%# +
+# + % if (config->{debug} == 1) { +
+			%= dumper $sf_data
+		
+ % } + % my $btn = l('sf_APPLY'); + + % $c->param(Selected => undef); #This may need deleting for a params panel - only needed for a table + + %= form_for "sharesu" => (method => 'POST') => begin + % param 'trt' => $sf_data->{trt} unless param 'trt'; + %= hidden_field 'trt' => $sf_data->{trt} + %# Inputs etc in here. + +

<%=l('sf_Create,_modify,_or_remove_shared')%>

+ +

<%=l('sf_Manage_shared-folders_settings:')%>

+ +

+ %=l('sf_You_can_remove_any_shared') +

+ +

+ %=l('sf_Create_a_new_shared_folder') +

+ +
+ %= l('sf_Create_a_new_shared_folder') + + %#= link_to l('sf_Create_a_new_shared_folder'), 'shared-folderu?trt=MODIFY' , class=>'link link1' + + +
+ + + + + + + + + + + % my $control_data = $c->stash('Table1'); + % foreach my $row (@$control_data) { + + + + + + + + %} + +
<%=l('sf_Name')%><%=l('sf_Description')%><%=l('sf_Actionp')%><%=l('sf_Actionm')%><%=l('sf_Actionr')%>
<%=$c->render_to_string(inline=>$row->{'Table1-Name'})%><%=$c->render_to_string(inline=>$row->{'Table1-Description'})%><%=$c->render_to_string(inline=>$row->{'Table1-Actionp'})%><%=$c->render_to_string(inline=>$row->{'Table1-Actionm'})%><%=$c->render_to_string(inline=>$row->{'Table1-Actionr'})%>
+ + + %# Probably finally by a submit. + %end +
\ No newline at end of file diff --git a/Targets/Shares/_sf_MODIFY.html.ep b/Targets/Shares/_sf_MODIFY.html.ep new file mode 100644 index 0000000..02f4db9 --- /dev/null +++ b/Targets/Shares/_sf_MODIFY.html.ep @@ -0,0 +1,113 @@ +%# +%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-21 08:46:42 +%# +
+# + % if (config->{debug} == 1) { +
+			%= dumper $sf_data
+		
+ % } + % my $btn = l('sf_APPLY'); + + % $c->param(Selected => undef); #This may need deleting for a params panel - only needed for a table + + %= form_for "sharesu" => (method => 'POST') => begin + % param 'trt' => $sf_data->{trt} unless param 'trt'; + %= hidden_field 'trt' => $sf_data->{trt} + %# Inputs etc in here. + +

<%=l('sf_Create,_modify,_or_remove_shared')%>

+ +

<%=l('sf_Create_or_modify_a_shared')%>

+ +

+ %=l('sf_description') + + % param 'description' => $sf_data->{description} unless param 'description'; + %= text_field 'description', size => '50', class => 'textinput description' , pattern=>'.*' , placeholder=>'description', title =>'Pattern regex mismatch', id => 'description_text' +

+ +

+ %=l('sf_The_following_settings_control_the') +

+ +

+ %=l('sf_smbaccess') + + % my @smbaccess_options = [['Enabled, browseable' => 'browseable'], ['Enabled, hidden' => 'non-browseable'], ['No access' => 'none']]; + % param 'smbaccess' => $sf_data->{smbaccess} unless param 'smbaccess'; + %= select_field 'smbaccess' => @smbaccess_options, class => 'input', id => 'smbaccess_select' +

+ +

+ %=l('sf_recyclebin') + + % my @recyclebin_options = [['disabled' => 'disabled'], ['Enabled, keep only the latest version' => 'enabled'], ['Enabled, keep a copy of all versions' => 'keep-versions']]; + % param 'recyclebin' => $sf_data->{recyclebin} unless param 'recyclebin'; + %= select_field 'recyclebin' => @recyclebin_options, class => 'input', id => 'recyclebin_select' +

+ +

+ %=l('sf_retention') + + % my @retention_options = [['one month' => '30'], ['one week' => '7'], ['one year' => '365'], ['six months' => '180'], ['unlimited' => 'unlimited']]; + % param 'retention' => $sf_data->{retention} unless param 'retention'; + %= select_field 'retention' => @retention_options, class => 'input', id => 'retention_select' +

+ +

+ %=l('sf_The_following_settings_control_the') +

+ +

+ %=l('sf_httpaccess') + + % my @httpaccess_options = [['Entire Internet (no password required)' => 'global'], ['Entire Internet (password required)' => 'global-pw'], ['Entire Internet (password required outside local network)' => 'global-pw-remote'], ['Local network (no password required)' => 'local'], ['Local network (password required)' => 'local-pw'], ['No access' => 'none']]; + % param 'httpaccess' => $sf_data->{httpaccess} unless param 'httpaccess'; + %= select_field 'httpaccess' => @httpaccess_options, class => 'input', id => 'httpaccess_select' +

+ +

+ %=l('sf_webdav') + + % my @webdav_options = [['disabled' => 'disabled'], ['enabled' => 'enabled']]; + % param 'webdav' => $sf_data->{webdav} unless param 'webdav'; + %= select_field 'webdav' => @webdav_options, class => 'input', id => 'webdav_select' +

+ +

+ %=l('sf_requireSSL') + + % my @requireSSL_options = [['disabled' => 'disabled'], ['enabled' => 'enabled']]; + % param 'requireSSL' => $sf_data->{requireSSL} unless param 'requireSSL'; + %= select_field 'requireSSL' => @requireSSL_options, class => 'input', id => 'requireSSL_select' +

+ +

+ %=l('sf_indexes') + + % my @indexes_options = [['disabled' => 'disabled'], ['enabled' => 'enabled']]; + % param 'indexes' => $sf_data->{indexes} unless param 'indexes'; + %= select_field 'indexes' => @indexes_options, class => 'input', id => 'indexes_select' +

+ +

+ %=l('sf_dynamic') + + % my @dynamic_options = [['disabled' => 'disabled'], ['enabled' => 'enabled']]; + % param 'dynamic' => $sf_data->{dynamic} unless param 'dynamic'; + %= select_field 'dynamic' => @dynamic_options, class => 'input', id => 'dynamic_select' +

+ + + %= submit_button l('sf_Save'), class => 'action subm109' + + + %# Probably finally by a submit. + %end +
\ No newline at end of file diff --git a/Targets/Shares/_sf_PERMISSIONS.html.ep b/Targets/Shares/_sf_PERMISSIONS.html.ep new file mode 100644 index 0000000..9a50594 --- /dev/null +++ b/Targets/Shares/_sf_PERMISSIONS.html.ep @@ -0,0 +1,365 @@ +%# +%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-21 08:46:42 +%# +
+# + % if (config->{debug} == 1) { +
+			%= dumper $sf_data
+		
+ % } + % my $btn = l('sf_APPLY'); + + % $c->param(Selected => undef); #This may need deleting for a params panel - only needed for a table + + %= form_for "sharesu" => (method => 'POST') => begin + % param 'trt' => $sf_data->{trt} unless param 'trt'; + %= hidden_field 'trt' => $sf_data->{trt} + %# Inputs etc in here. + +

<%=l('sf_Create,_modify,_or_remove_shared')%>

+ +

<%=l('sf_Access_right_management')%>

+ +

+ %=l('sf_You_can_use_this_matrix') +

+ +
+ + + + + + + + + + % my $control_data = $c->stash('Table2'); + % foreach my $row (@$control_data) { + + + + + + + %} + +
<%=l('sf_Groups')%><%=l('sf_Description')%><%=l('sf_Read_/_Write')%><%=l('sf_Read_Only')%>
<%=$c->render_to_string(inline=>$row->{'Table2-Groups'})%><%=$c->render_to_string(inline=>$row->{'Table2-Description'})%><%=$c->render_to_string(inline=>$row->{'Table2-Read / Write'})%><%=$c->render_to_string(inline=>$row->{'Table2-Read Only'})%>
+ + +

+ %=l('sf_writegroup') + + % param 'writegroup' => $sf_data->{writegroup} unless param 'writegroup'; + %=checkbox_field 'writegroup', class => 'chec110' +

+ + +

+ %=l('sf_readgroup') + + % param 'readgroup' => $sf_data->{readgroup} unless param 'readgroup'; + %=checkbox_field 'readgroup', class => 'chec111' +

+ + +

+ %=l('sf_writegroup') + + % param 'writegroup' => $sf_data->{writegroup} unless param 'writegroup'; + %=checkbox_field 'writegroup', class => 'chec112' +

+ + +

+ %=l('sf_readgroup') + + % param 'readgroup' => $sf_data->{readgroup} unless param 'readgroup'; + %=checkbox_field 'readgroup', class => 'chec113' +

+ + +

+ %=l('sf_writegroup') + + % param 'writegroup' => $sf_data->{writegroup} unless param 'writegroup'; + %=checkbox_field 'writegroup', class => 'chec114' +

+ + +

+ %=l('sf_readgroup') + + % param 'readgroup' => $sf_data->{readgroup} unless param 'readgroup'; + %=checkbox_field 'readgroup', class => 'chec115' +

+ + +

+ %=l('sf_writegroup') + + % param 'writegroup' => $sf_data->{writegroup} unless param 'writegroup'; + %=checkbox_field 'writegroup', class => 'chec116' +

+ + +

+ %=l('sf_readgroup') + + % param 'readgroup' => $sf_data->{readgroup} unless param 'readgroup'; + %=checkbox_field 'readgroup', class => 'chec117' +

+ + +

+ %=l('sf_writegroup') + + % param 'writegroup' => $sf_data->{writegroup} unless param 'writegroup'; + %=checkbox_field 'writegroup', class => 'chec118' +

+ + +

+ %=l('sf_readgroup') + + % param 'readgroup' => $sf_data->{readgroup} unless param 'readgroup'; + %=checkbox_field 'readgroup', class => 'chec119' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec120' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec121' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec122' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec123' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec124' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec125' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec126' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec127' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec128' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec129' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec130' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec131' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec132' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec133' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec134' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec135' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec136' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec137' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec138' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec139' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec140' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec141' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec142' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec143' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec144' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec145' +

+ + +

+ %=l('sf_writeuser') + + % param 'writeuser' => $sf_data->{writeuser} unless param 'writeuser'; + %=checkbox_field 'writeuser', class => 'chec146' +

+ + +

+ %=l('sf_readuser') + + % param 'readuser' => $sf_data->{readuser} unless param 'readuser'; + %=checkbox_field 'readuser', class => 'chec147' +

+ + + + %= submit_button l('sf_Save'), class => 'action subm148' + + + %# Probably finally by a submit. + %end +
\ No newline at end of file diff --git a/Targets/Shares/_sf_REMOVE.html.ep b/Targets/Shares/_sf_REMOVE.html.ep new file mode 100644 index 0000000..29ea094 --- /dev/null +++ b/Targets/Shares/_sf_REMOVE.html.ep @@ -0,0 +1,50 @@ +%# +%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-21 08:46:42 +%# +
+# + % if (config->{debug} == 1) { +
+			%= dumper $sf_data
+		
+ % } + % my $btn = l('sf_APPLY'); + + % $c->param(Selected => undef); #This may need deleting for a params panel - only needed for a table + + %= form_for "sharesu" => (method => 'POST') => begin + % param 'trt' => $sf_data->{trt} unless param 'trt'; + %= hidden_field 'trt' => $sf_data->{trt} + %# Inputs etc in here. + +

<%=l('sf_Create,_modify,_or_remove_shared')%>

+ +

<%=l('sf_Remove_shared_folder')%>

+ +

+ %=l('sf_You_are_about_to_remove') +

+ +

+ %=l('sf_All_files_belonging_to_this') +

+ +

+ %=l('sf_Are_you_sure_you_wish') +

+ + + %= submit_button l('sf_Cancel'), class => 'action subm149' + + + + %= submit_button l('sf_Remove'), class => 'action subm150' + + + %# Probably finally by a submit. + %end +
\ No newline at end of file diff --git a/Targets/Shares/shares.css b/Targets/Shares/shares.css new file mode 100644 index 0000000..8e45ebb --- /dev/null +++ b/Targets/Shares/shares.css @@ -0,0 +1,86 @@ +/* +Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-21 08:46:42 +*/ +.Shares-panel {} +.name {} +.rout {} +.head {} +.subh {} +.para1 {} +.para2 {} +.link1 {} +.tabl1 {} +thead .tabl1 {} +tbody .tabl1 {} +.name {} +.rout {} +.head {} +.subh {} +.text100 {} +.para14 {} +.sele101 {} +.sele102 {} +.sele103 {} +.para2 {} +.sele104 {} +.sele105 {} +.sele106 {} +.sele107 {} +.sele108 {} +.subm109 {} +.name {} +.rout {} +.head {} +.subh {} +.para10 {} +.tabl2 {} +thead .tabl2 {} +tbody .tabl2 {} +.chec110 {} +.chec111 {} +.chec112 {} +.chec113 {} +.chec114 {} +.chec115 {} +.chec116 {} +.chec117 {} +.chec118 {} +.chec119 {} +.chec120 {} +.chec121 {} +.chec122 {} +.chec123 {} +.chec124 {} +.chec125 {} +.chec126 {} +.chec127 {} +.chec128 {} +.chec129 {} +.chec130 {} +.chec131 {} +.chec132 {} +.chec133 {} +.chec134 {} +.chec135 {} +.chec136 {} +.chec137 {} +.chec138 {} +.chec139 {} +.chec140 {} +.chec141 {} +.chec142 {} +.chec143 {} +.chec144 {} +.chec145 {} +.chec146 {} +.chec147 {} +.subm148 {} +.name {} +.rout {} +.head {} +.subh {} +.para11 {} +.para21 {} +.para31 {} +.subm149 {} +.subm150 {} diff --git a/Targets/Shares/shares.html.ep b/Targets/Shares/shares.html.ep new file mode 100644 index 0000000..68aa0f3 --- /dev/null +++ b/Targets/Shares/shares.html.ep @@ -0,0 +1,68 @@ +%# +%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-21 08:46:42 +%# +% layout 'default', title => "Sme server 2 - Shared Folders", share_dir => './'; +%# css specific to this panel: +% content_for 'module' => begin +%= stylesheet '/css/shares.css' +%= javascript '/js/shares.js' +
+ + % if (config->{debug} == 1) { +
+		%= dumper $c->current_route
+		%= dumper $sf_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 ($sf_data->{trt} eq "LIST") { + %= include 'partials/_sf_LIST' + %} + + % if ($sf_data->{trt} eq "MODIFY") { + %= include 'partials/_sf_MODIFY' + %} + + % if ($sf_data->{trt} eq "PERMISSIONS") { + %= include 'partials/_sf_PERMISSIONS' + %} + + % if ($sf_data->{trt} eq "REMOVE") { + %= include 'partials/_sf_REMOVE' + %} + + + +
+%end \ No newline at end of file diff --git a/Targets/Shares/shares.js b/Targets/Shares/shares.js new file mode 100644 index 0000000..2f3c6e2 --- /dev/null +++ b/Targets/Shares/shares.js @@ -0,0 +1,5 @@ +// +//Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-21 08:46:42 +// +$(document).ready(function() { +}); diff --git a/Targets/Shares/shares_en.lex b/Targets/Shares/shares_en.lex new file mode 100644 index 0000000..a8caa70 --- /dev/null +++ b/Targets/Shares/shares_en.lex @@ -0,0 +1,46 @@ +# +# Generated by SM2Gen version: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-21 08:46:42 +# +'sf_readgroup' => 'regroup', +'sf_Description' => 'Description', +'sf_dynamic' => 'Dynamic', +'sf_description' => 'Description', +'sf_The_following_settings_control_the' => 'The following settings control the access of this shared folder using the HTTP/HTTPS protocol', +'sf_Create,_modify,_or_remove_shared' => 'create modify Or remove shared folders', +'sf_Remove' => 'Remove', +'sf_httpaccess' => 'Httpaccess', +'sf_readuser' => 'reader', +'sf_Cancel' => 'Cancel', +'sf_All_files_belonging_to_this' => 'All files belonging to this shared folder will be deleted', +'sf_smbaccess' => 'Smbaccess', +'sf_You_can_use_this_matrix' => 'You can use this matrix to define groups and users access permissions', +'sf_webdav' => 'Webdav', +'sf_Create_a_new_shared_folder' => 'Create a new shared folder', +'sf_REMOVE_panel_action_was_successful' => 'REMOVE panel action was successful', +'sf_Actionr' => 'action', +'sf_You_are_about_to_remove' => 'You are about to remove the following shared folder', +'sf_Shared_Folders' => 'Shared Folders', +'sf_MODIFY_panel_action_was_successful' => 'MODIFY panel action was successful', +'sf_indexes' => 'Indexes', +'sf_Are_you_sure_you_wish' => 'Are you sure you wish to remove it ?', +'sf_Actionm' => 'action', +'sf_writeuser' => 'Writeuser', +'sf_LIST_panel_action_was_successful' => 'LIST panel action was successful', +'sf_Remove_shared_folder' => 'Remove shared folder', +'sf_PERMISSIONS_panel_action_was_successful' => 'PERMISSIONS panel action was successful', +'sf_Manage_shared-folders_settings:' => 'Manage shared-folders settings', +'sf_You_can_remove_any_shared' => 'You can remove any shared folder by clicking on the corresponding command next to the shared folder', +'sf_APPLY' => 'Apply', +'sf_requireSSL' => 'requires', +'sf_Groups' => 'Groups', +'sf_Save' => 'Save', +'sf_Actionp' => 'action', +'sf_writegroup' => 'Writegroup', +'sf_Name' => 'Name', +'sf_Read_Only' => 'Read Only', +'sf_retention' => 'Retention', +'sf_Access_right_management' => 'Access right management', +'sf_Read_/_Write' => 'Read / Write', +'sf_Create_or_modify_a_shared' => 'Create or modify a shared folder', +'sf_The_following_settings_control_the' => 'The following settings control the access of this shared folder from the local network Using the SMB/CIFS protocol', +'sf_recyclebin' => 'Recyclebin', diff --git a/Templates/partial.html.ep.tem b/Templates/partial.html.ep.tem index 635f336..0044ef7 100644 --- a/Templates/partial.html.ep.tem +++ b/Templates/partial.html.ep.tem @@ -2,11 +2,11 @@ %# Generated by ${version} %#
-# +%# % if (config->{debug} == 1) {
 			%= dumper $$${prefix}_data
diff --git a/html/shared-folders_list.html b/html/shared-folders_list.html
new file mode 100644
index 0000000..2a9d1ad
--- /dev/null
+++ b/html/shared-folders_list.html
@@ -0,0 +1,57 @@
+
+
+
+
+
+SME Server mailserver.bjsystems.co.uk
+  
+
+  
+  
+  
+  
+
+
+
+

Create, modify, or remove shared folders

+
+ + + + + + + + + +

You can remove any shared folder by clicking on the corresponding command next to the shared folder.

+

Create a new shared folder

+ + + + + + + + + +
NameDescriptionAction
africa2023New onePermissions Modify Remove 
+ + +
+ +
+ + SME Server 10.1
Copyright 1999-2006 Mitel Corporation
All rights reserved. + +
Copyright (c) 2013 - 2021 Koozali Foundation Inc.
+
+ + + \ No newline at end of file diff --git a/html/shared-folders_modify.html b/html/shared-folders_modify.html new file mode 100644 index 0000000..f896482 --- /dev/null +++ b/html/shared-folders_modify.html @@ -0,0 +1,129 @@ + + + + + +SME Server mailserver.bjsystems.co.uk + + + + + + + + + +

Create, modify, or remove shared folders

+

Create or modify a shared folder

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
The share name should contain only lower-case letters, numbers, periods, hyphens and underscores, and should start with a lower-case letter. For example "johnson", "intra", and "cust3.prj12" are all valid names, but "3associates", "John Smith" and "Bus!Partner" are not. The name is limited to 12 characters.
Shared folder nameafrica2023 + + +
Description +
+
+

The following settings control the access of this shared folder from the local network, using the SMB/CIFS protocol.

SMB Access +
Recycle bin +
Retention time +
+
+

The following settings control the access of this shared folder using the HTTP/HTTPS protocol.

Web Access +
WebDav support +
Force secure connections +
Indexes +
Dynamic content execution (PHP, CGI, SSI) +
+
+ +
+ +
+ + SME Server 10.1
Copyright 1999-2006 Mitel Corporation
All rights reserved. + +
Copyright (c) 2013 - 2021 Koozali Foundation Inc.
+
+ + + \ No newline at end of file diff --git a/html/shared-folders_perms.html b/html/shared-folders_perms.html new file mode 100644 index 0000000..0b1acaa --- /dev/null +++ b/html/shared-folders_perms.html @@ -0,0 +1,136 @@ + + + + + +SME Server mailserver.bjsystems.co.uk + + + + + + + + + +

Create, modify, or remove shared folders

+

Access right management

+
+ + + + + + + + + + + + +

You can use this matrix to define groups and users access permissions.

Shared folder nameafrica2023
DescriptionNew one
Permissions + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GroupsDescriptionRead / WriteRead Only
sharedEveryone
changeofkeyGroup for emails
domainadminsDomain Admins
ecmw2023grpecmw 2023
miwgrpGroup for MIW payments
UsersDescriptionRead / WriteRead Only
brianrBrian Read
cok1Clare Park
cok2Frank Park
dmarcDmarc Dmarc
ecmw2025ecmw 2025
englishcountrymusicweekendEnglish Music Weekend
guestGuest Guest
katyKaty Read
moreMore 4AllianceForFoodPurity
nikkiNicola Escott
philPhil Fermor
sheilaSheila Read
smeserversme server
zara.healyZara Healy
+
+ +
+ +
+ + SME Server 10.1
Copyright 1999-2006 Mitel Corporation
All rights reserved. + +
Copyright (c) 2013 - 2021 Koozali Foundation Inc.
+
+ + + \ No newline at end of file diff --git a/html/shared-folders_remove.html b/html/shared-folders_remove.html new file mode 100644 index 0000000..9b33614 --- /dev/null +++ b/html/shared-folders_remove.html @@ -0,0 +1,55 @@ + + + + + +SME Server mailserver.bjsystems.co.uk + + + + + + + + + +

Create, modify, or remove shared folders

+

Remove shared folder

+
+ + + + + + + + + +

+ You are about to remove the following shared folder +

+

+ All files belonging to this shared folder will be deleted. +

+

+ Are you sure you wish to remove it ? +

Name africa2023
Description New one
+ + +
+ +
+ + SME Server 10.1
Copyright 1999-2006 Mitel Corporation
All rights reserved. + +
Copyright (c) 2013 - 2021 Koozali Foundation Inc.
+
+ + + \ No newline at end of file diff --git a/json5/Shares.json5 b/json5/Shares.json5 new file mode 100644 index 0000000..73892ce --- /dev/null +++ b/json5/Shares.json5 @@ -0,0 +1,504 @@ +{ + PackageName: 'Shares', + prefix: 'sf', + MenuHeading: 'Network', + MenuDescription: 'Shared Folders', + MenuNavigation: '7000 400', + firstPanel: 'LIST', + signalEvent: 'smeserver-shared-folders-update', + html: [ + { + Name: 'list', + route: 'LIST', + Header: 'Create, modify, or remove shared folders', + SubHeader: 'Manage shared-folders settings:', + Paragraph1: 'You can remove any shared folder by clicking on the corresponding command next to the shared folder.', + Paragraph2: 'Create a new shared folder', + Link1: { + Type: 'Link', + href: 'shared-folderu?trt=MODIFY', + title: 'Create a new shared folder' + }, + Table1: { + Type: 'Table', + TableControl: 'Table1', + TopHeadings: [ + 'Name', + 'Description', + 'Actionp', + 'Actionm', + 'Actionr' + ], + Columns: [ + 'Table1-Name', + 'Table1-Description', + 'Table1-Actionp', + 'Table1-Actionm', + 'Table1-Actionr' + ] + } + }, + { + Name: 'modify', + route: 'MODIFY', + Header: 'Create, modify, or remove shared folders', + SubHeader: 'Create or modify a shared folder', + Input100: { + Type: 'Text', + Value: 'New one', + Name: 'description', + Label: 'description' + }, + Paragraph14: 'The following settings control the access of this shared folder from the local network, using the SMB/CIFS protocol.', + Input101: { + Type: 'Select', + Value: '', + Name: 'smbaccess', + Label: 'smbaccess', + Options: [ + { + Value: 'browseable', + Text: 'Enabled, browseable' + }, + { + Value: 'non-browseable', + Text: 'Enabled, hidden' + }, + { + Value: 'none', + Text: 'No access' + } + ] + }, + Input102: { + Type: 'Select', + Value: '', + Name: 'recyclebin', + Label: 'recyclebin', + Options: [ + { + Value: 'disabled', + Text: 'disabled' + }, + { + Value: 'enabled', + Text: 'Enabled, keep only the latest version' + }, + { + Value: 'keep-versions', + Text: 'Enabled, keep a copy of all versions' + } + ] + }, + Input103: { + Type: 'Select', + Value: '', + Name: 'retention', + Label: 'retention', + Options: [ + { + Value: '30', + Text: 'one month' + }, + { + Value: '7', + Text: 'one week' + }, + { + Value: '365', + Text: 'one year' + }, + { + Value: '180', + Text: 'six months' + }, + { + Value: 'unlimited', + Text: 'unlimited' + } + ] + }, + Paragraph2: 'The following settings control the access of this shared folder using the HTTP/HTTPS protocol.', + Input104: { + Type: 'Select', + Value: '', + Name: 'httpaccess', + Label: 'httpaccess', + Options: [ + { + Value: 'global', + Text: 'Entire Internet (no password required)' + }, + { + Value: 'global-pw', + Text: 'Entire Internet (password required)' + }, + { + Value: 'global-pw-remote', + Text: 'Entire Internet (password required outside local network)' + }, + { + Value: 'local', + Text: 'Local network (no password required)' + }, + { + Value: 'local-pw', + Text: 'Local network (password required)' + }, + { + Value: 'none', + Text: 'No access' + } + ] + }, + Input105: { + Type: 'Select', + Value: '', + Name: 'webdav', + Label: 'webdav', + Options: [ + { + Value: 'disabled', + Text: 'disabled' + }, + { + Value: 'enabled', + Text: 'enabled' + } + ] + }, + Input106: { + Type: 'Select', + Value: '', + Name: 'requireSSL', + Label: 'requireSSL', + Options: [ + { + Value: 'disabled', + Text: 'disabled' + }, + { + Value: 'enabled', + Text: 'enabled' + } + ] + }, + Input107: { + Type: 'Select', + Value: '', + Name: 'indexes', + Label: 'indexes', + Options: [ + { + Value: 'disabled', + Text: 'disabled' + }, + { + Value: 'enabled', + Text: 'enabled' + } + ] + }, + Input108: { + Type: 'Select', + Value: '', + Name: 'dynamic', + Label: 'dynamic', + Options: [ + { + Value: 'disabled', + Text: 'disabled' + }, + { + Value: 'enabled', + Text: 'enabled' + } + ] + }, + Input109: { + Type: 'Submit', + Value: 'Save', + Name: 'Next', + Label: 'Next' + } + }, + { + Name: 'permissions', + route: 'PERMISSIONS', + Header: 'Create, modify, or remove shared folders', + SubHeader: 'Access right management', + Paragraph10: 'You can use this matrix to define groups and users access permissions.', + Table2: { + Type: 'Table', + TableControl: 'Table2', + TopHeadings: [ + 'Groups', + 'Description', + 'Read / Write', + 'Read Only' + ], + Columns: [ + 'Table2-Groups', + 'Table2-Description', + 'Table2-Read / Write', + 'Table2-Read Only' + ] + }, + Input110: { + Type: 'Checkbox', + Value: 'shared', + Name: 'writegroup', + Label: 'writegroup' + }, + Input111: { + Type: 'Checkbox', + Value: 'shared', + Name: 'readgroup', + Label: 'readgroup' + }, + Input112: { + Type: 'Checkbox', + Value: 'changeofkey', + Name: 'writegroup', + Label: 'writegroup' + }, + Input113: { + Type: 'Checkbox', + Value: 'changeofkey', + Name: 'readgroup', + Label: 'readgroup' + }, + Input114: { + Type: 'Checkbox', + Value: 'domainadmins', + Name: 'writegroup', + Label: 'writegroup' + }, + Input115: { + Type: 'Checkbox', + Value: 'domainadmins', + Name: 'readgroup', + Label: 'readgroup' + }, + Input116: { + Type: 'Checkbox', + Value: 'ecmw2023grp', + Name: 'writegroup', + Label: 'writegroup' + }, + Input117: { + Type: 'Checkbox', + Value: 'ecmw2023grp', + Name: 'readgroup', + Label: 'readgroup' + }, + Input118: { + Type: 'Checkbox', + Value: 'miwgrp', + Name: 'writegroup', + Label: 'writegroup' + }, + Input119: { + Type: 'Checkbox', + Value: 'miwgrp', + Name: 'readgroup', + Label: 'readgroup' + }, + Input120: { + Type: 'Checkbox', + Value: 'brianr', + Name: 'writeuser', + Label: 'writeuser' + }, + Input121: { + Type: 'Checkbox', + Value: 'brianr', + Name: 'readuser', + Label: 'readuser' + }, + Input122: { + Type: 'Checkbox', + Value: 'cok1', + Name: 'writeuser', + Label: 'writeuser' + }, + Input123: { + Type: 'Checkbox', + Value: 'cok1', + Name: 'readuser', + Label: 'readuser' + }, + Input124: { + Type: 'Checkbox', + Value: 'cok2', + Name: 'writeuser', + Label: 'writeuser' + }, + Input125: { + Type: 'Checkbox', + Value: 'cok2', + Name: 'readuser', + Label: 'readuser' + }, + Input126: { + Type: 'Checkbox', + Value: 'dmarc', + Name: 'writeuser', + Label: 'writeuser' + }, + Input127: { + Type: 'Checkbox', + Value: 'dmarc', + Name: 'readuser', + Label: 'readuser' + }, + Input128: { + Type: 'Checkbox', + Value: 'ecmw2025', + Name: 'writeuser', + Label: 'writeuser' + }, + Input129: { + Type: 'Checkbox', + Value: 'ecmw2025', + Name: 'readuser', + Label: 'readuser' + }, + Input130: { + Type: 'Checkbox', + Value: 'englishcountrymusicweekend', + Name: 'writeuser', + Label: 'writeuser' + }, + Input131: { + Type: 'Checkbox', + Value: 'englishcountrymusicweekend', + Name: 'readuser', + Label: 'readuser' + }, + Input132: { + Type: 'Checkbox', + Value: 'guest', + Name: 'writeuser', + Label: 'writeuser' + }, + Input133: { + Type: 'Checkbox', + Value: 'guest', + Name: 'readuser', + Label: 'readuser' + }, + Input134: { + Type: 'Checkbox', + Value: 'katy', + Name: 'writeuser', + Label: 'writeuser' + }, + Input135: { + Type: 'Checkbox', + Value: 'katy', + Name: 'readuser', + Label: 'readuser' + }, + Input136: { + Type: 'Checkbox', + Value: 'more', + Name: 'writeuser', + Label: 'writeuser' + }, + Input137: { + Type: 'Checkbox', + Value: 'more', + Name: 'readuser', + Label: 'readuser' + }, + Input138: { + Type: 'Checkbox', + Value: 'nikki', + Name: 'writeuser', + Label: 'writeuser' + }, + Input139: { + Type: 'Checkbox', + Value: 'nikki', + Name: 'readuser', + Label: 'readuser' + }, + Input140: { + Type: 'Checkbox', + Value: 'phil', + Name: 'writeuser', + Label: 'writeuser' + }, + Input141: { + Type: 'Checkbox', + Value: 'phil', + Name: 'readuser', + Label: 'readuser' + }, + Input142: { + Type: 'Checkbox', + Value: 'sheila', + Name: 'writeuser', + Label: 'writeuser' + }, + Input143: { + Type: 'Checkbox', + Value: 'sheila', + Name: 'readuser', + Label: 'readuser' + }, + Input144: { + Type: 'Checkbox', + Value: 'smeserver', + Name: 'writeuser', + Label: 'writeuser' + }, + Input145: { + Type: 'Checkbox', + Value: 'smeserver', + Name: 'readuser', + Label: 'readuser' + }, + Input146: { + Type: 'Checkbox', + Value: 'zara.healy', + Name: 'writeuser', + Label: 'writeuser' + }, + Input147: { + Type: 'Checkbox', + Value: 'zara.healy', + Name: 'readuser', + Label: 'readuser' + }, + Input148: { + Type: 'Submit', + Value: 'Save', + Name: 'Next', + Label: 'Next' + } + }, + { + Name: 'remove', + route: 'REMOVE', + Header: 'Create, modify, or remove shared folders', + SubHeader: 'Remove shared folder', + Paragraph11: 'You are about to remove the following shared folder', + Paragraph21: 'All files belonging to this shared folder will be deleted.', + Paragraph31: 'Are you sure you wish to remove it ?', + Input149: { + Type: 'Submit', + Value: 'Cancel', + Name: 'cancel', + Label: 'cancel' + }, + Input150: { + Type: 'Submit', + Value: 'Remove', + Name: 'remove', + Label: 'remove' + } + } + ] +} \ No newline at end of file diff --git a/json5/shared-folders_list.json5 b/json5/shared-folders_list.json5 new file mode 100644 index 0000000..32f7b84 --- /dev/null +++ b/json5/shared-folders_list.json5 @@ -0,0 +1,56 @@ +// +// Generated by sm1-html-2-json5 version:0.5 Chameleon version:3.8.1 On Python:3.12.3 at 2025-05-20 15:40:23 +// +{ + 'PackageName': 'shared-folders_list', + 'prefix': '', + 'MenuHeading': 'Miscellaneous', + 'MenuDescription': 'shared-folders_list', + 'MenuNavigation': '2000 400', + 'firstPanel': 'PARAMS', + 'signalEvent': 'smeserver-shared-folders_list-update', + 'html': [ + { + 'Name': 'params', + 'route': 'PARAMS', + 'Header': 'Create, modify, or remove shared folders', + 'SubHeader': 'Manage shared-folders_list settings:', + 'Paragraph1': 'You can remove any shared folder by clicking on the corresponding command next to the shared folder.', + 'Paragraph2': 'Create a new shared folder', + 'Link1': { + 'Type': 'Link', + 'href': 'shares?page=0&page_stack=&Next=Next&wherenext=CreateModify', + 'title': 'Create a new shared folder' + }, + 'Table1': { + 'Type': 'Table', + 'TableControl': 'Table1', + 'TopHeadings': [ + 'Name', + 'Description', + 'Action' + ], + 'Columns': [ + 'Table1-Name', + 'Table1-Description', + 'Table1-Action' + ] + }, + 'Link2': { + 'Type': 'Link', + 'href': 'shares?page=;page_stack=;wherenext=Permissions&name=africa2023', + 'title': 'Permissions' + }, + 'Link3': { + 'Type': 'Link', + 'href': 'shares?page=;page_stack=;wherenext=CreateModify&action=modify&name=africa2023', + 'title': 'Modify' + }, + 'Link4': { + 'Type': 'Link', + 'href': 'shares?page=;page_stack=;wherenext=Remove&name=africa2023&description=New one', + 'title': 'Remove' + } + } + ] +} \ No newline at end of file diff --git a/json5/shared-folders_modify.json5 b/json5/shared-folders_modify.json5 new file mode 100644 index 0000000..fbfc1cc --- /dev/null +++ b/json5/shared-folders_modify.json5 @@ -0,0 +1,198 @@ +// +// Generated by sm1-html-2-json5 version:0.5 Chameleon version:3.8.1 On Python:3.12.3 at 2025-05-20 15:40:34 +// +{ + 'PackageName': 'shared-folders_modify', + 'prefix': '', + 'MenuHeading': 'Miscellaneous', + 'MenuDescription': 'shared-folders_modify', + 'MenuNavigation': '2000 400', + 'firstPanel': 'PARAMS', + 'signalEvent': 'smeserver-shared-folders_modify-update', + 'html': [ + { + 'Name': 'params', + 'route': 'PARAMS', + 'Header': 'Create, modify, or remove shared folders', + 'SubHeader': 'Create or modify a shared folder', + 'Input1': { + 'Type': 'Text', + 'Value': 'New one', + 'Name': 'description', + 'Label': 'description' + }, + 'Paragraph1': 'The following settings control the access of this shared folder from the local network, using the SMB/CIFS protocol.', + 'Input2': { + 'Type': 'Select', + 'Value': '', + 'Name': 'smbaccess', + 'Label': 'smbaccess', + 'Options': [ + { + 'Value': 'browseable', + 'Text': 'Enabled, browseable' + }, + { + 'Value': 'non-browseable', + 'Text': 'Enabled, hidden' + }, + { + 'Value': 'none', + 'Text': 'No access' + } + ] + }, + 'Input3': { + 'Type': 'Select', + 'Value': '', + 'Name': 'recyclebin', + 'Label': 'recyclebin', + 'Options': [ + { + 'Value': 'disabled', + 'Text': 'disabled' + }, + { + 'Value': 'enabled', + 'Text': 'Enabled, keep only the latest version' + }, + { + 'Value': 'keep-versions', + 'Text': 'Enabled, keep a copy of all versions' + } + ] + }, + 'Input4': { + 'Type': 'Select', + 'Value': '', + 'Name': 'retention', + 'Label': 'retention', + 'Options': [ + { + 'Value': '30', + 'Text': 'one month' + }, + { + 'Value': '7', + 'Text': 'one week' + }, + { + 'Value': '365', + 'Text': 'one year' + }, + { + 'Value': '180', + 'Text': 'six months' + }, + { + 'Value': 'unlimited', + 'Text': 'unlimited' + } + ] + }, + 'Paragraph2': 'The following settings control the access of this shared folder using the HTTP/HTTPS protocol.', + 'Input5': { + 'Type': 'Select', + 'Value': '', + 'Name': 'httpaccess', + 'Label': 'httpaccess', + 'Options': [ + { + 'Value': 'global', + 'Text': 'Entire Internet (no password required)' + }, + { + 'Value': 'global-pw', + 'Text': 'Entire Internet (password required)' + }, + { + 'Value': 'global-pw-remote', + 'Text': 'Entire Internet (password required outside local network)' + }, + { + 'Value': 'local', + 'Text': 'Local network (no password required)' + }, + { + 'Value': 'local-pw', + 'Text': 'Local network (password required)' + }, + { + 'Value': 'none', + 'Text': 'No access' + } + ] + }, + 'Input6': { + 'Type': 'Select', + 'Value': '', + 'Name': 'webdav', + 'Label': 'webdav', + 'Options': [ + { + 'Value': 'disabled', + 'Text': 'disabled' + }, + { + 'Value': 'enabled', + 'Text': 'enabled' + } + ] + }, + 'Input7': { + 'Type': 'Select', + 'Value': '', + 'Name': 'requireSSL', + 'Label': 'requireSSL', + 'Options': [ + { + 'Value': 'disabled', + 'Text': 'disabled' + }, + { + 'Value': 'enabled', + 'Text': 'enabled' + } + ] + }, + 'Input8': { + 'Type': 'Select', + 'Value': '', + 'Name': 'indexes', + 'Label': 'indexes', + 'Options': [ + { + 'Value': 'disabled', + 'Text': 'disabled' + }, + { + 'Value': 'enabled', + 'Text': 'enabled' + } + ] + }, + 'Input9': { + 'Type': 'Select', + 'Value': '', + 'Name': 'dynamic', + 'Label': 'dynamic', + 'Options': [ + { + 'Value': 'disabled', + 'Text': 'disabled' + }, + { + 'Value': 'enabled', + 'Text': 'enabled' + } + ] + }, + 'Input10': { + 'Type': 'Submit', + 'Value': 'Save', + 'Name': 'Next', + 'Label': 'Next' + } + } + ] +} \ No newline at end of file diff --git a/json5/shared-folders_perms.json5 b/json5/shared-folders_perms.json5 new file mode 100644 index 0000000..4815453 --- /dev/null +++ b/json5/shared-folders_perms.json5 @@ -0,0 +1,271 @@ +// +// Generated by sm1-html-2-json5 version:0.5 Chameleon version:3.8.1 On Python:3.12.3 at 2025-05-20 15:41:06 +// +{ + 'PackageName': 'shared-folders_perms', + 'prefix': '', + 'MenuHeading': 'Miscellaneous', + 'MenuDescription': 'shared-folders_perms', + 'MenuNavigation': '2000 400', + 'firstPanel': 'PARAMS', + 'signalEvent': 'smeserver-shared-folders_perms-update', + 'html': [ + { + 'Name': 'params', + 'route': 'PARAMS', + 'Header': 'Create, modify, or remove shared folders', + 'SubHeader': 'Access right management', + 'Paragraph1': 'You can use this matrix to define groups and users access permissions.', + 'Table1': { + 'Type': 'Table', + 'TableControl': 'Table1', + 'TopHeadings': [ + 'Groups', + 'Description', + 'Read / Write', + 'Read Only' + ], + 'Columns': [ + 'Table1-Groups', + 'Table1-Description', + 'Table1-Read / Write', + 'Table1-Read Only' + ] + }, + 'Input1': { + 'Type': 'Checkbox', + 'Value': 'shared', + 'Name': 'writegroup', + 'Label': 'writegroup' + }, + 'Input2': { + 'Type': 'Checkbox', + 'Value': 'shared', + 'Name': 'readgroup', + 'Label': 'readgroup' + }, + 'Input3': { + 'Type': 'Checkbox', + 'Value': 'changeofkey', + 'Name': 'writegroup', + 'Label': 'writegroup' + }, + 'Input4': { + 'Type': 'Checkbox', + 'Value': 'changeofkey', + 'Name': 'readgroup', + 'Label': 'readgroup' + }, + 'Input5': { + 'Type': 'Checkbox', + 'Value': 'domainadmins', + 'Name': 'writegroup', + 'Label': 'writegroup' + }, + 'Input6': { + 'Type': 'Checkbox', + 'Value': 'domainadmins', + 'Name': 'readgroup', + 'Label': 'readgroup' + }, + 'Input7': { + 'Type': 'Checkbox', + 'Value': 'ecmw2023grp', + 'Name': 'writegroup', + 'Label': 'writegroup' + }, + 'Input8': { + 'Type': 'Checkbox', + 'Value': 'ecmw2023grp', + 'Name': 'readgroup', + 'Label': 'readgroup' + }, + 'Input9': { + 'Type': 'Checkbox', + 'Value': 'miwgrp', + 'Name': 'writegroup', + 'Label': 'writegroup' + }, + 'Input10': { + 'Type': 'Checkbox', + 'Value': 'miwgrp', + 'Name': 'readgroup', + 'Label': 'readgroup' + }, + 'Input11': { + 'Type': 'Checkbox', + 'Value': 'brianr', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input12': { + 'Type': 'Checkbox', + 'Value': 'brianr', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input13': { + 'Type': 'Checkbox', + 'Value': 'cok1', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input14': { + 'Type': 'Checkbox', + 'Value': 'cok1', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input15': { + 'Type': 'Checkbox', + 'Value': 'cok2', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input16': { + 'Type': 'Checkbox', + 'Value': 'cok2', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input17': { + 'Type': 'Checkbox', + 'Value': 'dmarc', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input18': { + 'Type': 'Checkbox', + 'Value': 'dmarc', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input19': { + 'Type': 'Checkbox', + 'Value': 'ecmw2025', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input20': { + 'Type': 'Checkbox', + 'Value': 'ecmw2025', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input21': { + 'Type': 'Checkbox', + 'Value': 'englishcountrymusicweekend', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input22': { + 'Type': 'Checkbox', + 'Value': 'englishcountrymusicweekend', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input23': { + 'Type': 'Checkbox', + 'Value': 'guest', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input24': { + 'Type': 'Checkbox', + 'Value': 'guest', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input25': { + 'Type': 'Checkbox', + 'Value': 'katy', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input26': { + 'Type': 'Checkbox', + 'Value': 'katy', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input27': { + 'Type': 'Checkbox', + 'Value': 'more', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input28': { + 'Type': 'Checkbox', + 'Value': 'more', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input29': { + 'Type': 'Checkbox', + 'Value': 'nikki', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input30': { + 'Type': 'Checkbox', + 'Value': 'nikki', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input31': { + 'Type': 'Checkbox', + 'Value': 'phil', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input32': { + 'Type': 'Checkbox', + 'Value': 'phil', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input33': { + 'Type': 'Checkbox', + 'Value': 'sheila', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input34': { + 'Type': 'Checkbox', + 'Value': 'sheila', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input35': { + 'Type': 'Checkbox', + 'Value': 'smeserver', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input36': { + 'Type': 'Checkbox', + 'Value': 'smeserver', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input37': { + 'Type': 'Checkbox', + 'Value': 'zara.healy', + 'Name': 'writeuser', + 'Label': 'writeuser' + }, + 'Input38': { + 'Type': 'Checkbox', + 'Value': 'zara.healy', + 'Name': 'readuser', + 'Label': 'readuser' + }, + 'Input39': { + 'Type': 'Submit', + 'Value': 'Save', + 'Name': 'Next', + 'Label': 'Next' + } + } + ] +} \ No newline at end of file diff --git a/json5/shared-folders_remove.json5 b/json5/shared-folders_remove.json5 new file mode 100644 index 0000000..1ae9679 --- /dev/null +++ b/json5/shared-folders_remove.json5 @@ -0,0 +1,35 @@ +// +// Generated by sm1-html-2-json5 version:0.5 Chameleon version:3.8.1 On Python:3.12.3 at 2025-05-20 15:41:15 +// +{ + 'PackageName': 'shared-folders_remove', + 'prefix': '', + 'MenuHeading': 'Miscellaneous', + 'MenuDescription': 'shared-folders_remove', + 'MenuNavigation': '2000 400', + 'firstPanel': 'PARAMS', + 'signalEvent': 'smeserver-shared-folders_remove-update', + 'html': [ + { + 'Name': 'params', + 'route': 'PARAMS', + 'Header': 'Create, modify, or remove shared folders', + 'SubHeader': 'Remove shared folder', + 'Paragraph1': 'You are about to remove the following shared folder', + 'Paragraph2': 'All files belonging to this shared folder will be deleted.', + 'Paragraph3': 'Are you sure you wish to remove it ?', + 'Input1': { + 'Type': 'Submit', + 'Value': 'Cancel', + 'Name': 'cancel', + 'Label': 'cancel' + }, + 'Input2': { + 'Type': 'Submit', + 'Value': 'Remove', + 'Name': 'remove', + 'Label': 'remove' + } + } + ] +} \ No newline at end of file diff --git a/json5_fix_format.py b/json5_fix_format.py new file mode 100644 index 0000000..bdebd04 --- /dev/null +++ b/json5_fix_format.py @@ -0,0 +1,96 @@ +import re +import json5 + +def fix_json5_syntax(text): + # Remove comments + text = re.sub(r'//.*', '', text) + text = re.sub(r'/\*.*?\*/', '', text, flags=re.DOTALL) + # Replace single quotes with double quotes + text = re.sub(r"'", '"', text) + # Add missing commas between objects in arrays (naive) + text = re.sub(r'(\})(\s*\{)', r'\1,\2', text) + # Remove trailing commas before closing } or ] + text = re.sub(r',(\s*[}\]])', r'\1', text) + return text + +def renumber_inputs(obj, start=100): + """ + Recursively renumber InputN keys to Input{start}, Input{start+1}, ... + Returns the new object and the next available number. + """ + if isinstance(obj, dict): + new_obj = {} + for k, v in obj.items(): + m = re.match(r'Input(\d+)', k) + if m: + new_key = f"Input{start}" + start += 1 + else: + new_key = k + new_obj[new_key], start = renumber_inputs(v, start) + return new_obj, start + elif isinstance(obj, list): + new_list = [] + for item in obj: + new_item, start = renumber_inputs(item, start) + new_list.append(new_item) + return new_list, start + else: + return obj, start + +def dict_to_json5(obj, indent=0): + """Convert a dict to JSON5-like text with unquoted field names.""" + IND = ' ' + if isinstance(obj, dict): + items = [] + for k, v in obj.items(): + # Only quote keys if necessary (not a valid identifier) + if re.match(r'^[A-Za-z_]\w*$', k): + key = k + else: + key = f'"{k}"' + items.append(f"{IND* (indent+1)}{key}: {dict_to_json5(v, indent+1)}") + return '{\n' + ',\n'.join(items) + f'\n{IND*indent}' + '}' + elif isinstance(obj, list): + items = [f"{IND*(indent+1)}{dict_to_json5(v, indent+1)}" for v in obj] + return '[\n' + ',\n'.join(items) + f'\n{IND*indent}' + ']' + elif isinstance(obj, str): + # Always single-quote strings for JSON5 style + return "'" + obj.replace("'", "\\'") + "'" + elif obj is True: + return 'true' + elif obj is False: + return 'false' + elif obj is None: + return 'null' + else: + return str(obj) + +def main(): + input_file = 'json5/shared-folders.json5' + output_file = 'json5/shared-folders-renumbered.json5' + + # Read and fix the JSON5 input + with open(input_file, 'r', encoding='utf-8') as f: + raw = f.read() + + fixed = fix_json5_syntax(raw) + + # Parse with json5 + try: + data = json5.loads(fixed) + except Exception as e: + print("Error parsing JSON5:", e) + return + + # Renumber Input fields + data, _ = renumber_inputs(data, 100) + + # Write out as JSON5 with unquoted field names + with open(output_file, 'w', encoding='utf-8') as f: + f.write(dict_to_json5(data, indent=0)) + + print(f"Renumbered file written to: {output_file}") + +if __name__ == '__main__': + main() \ No newline at end of file