diff --git a/root/usr/share/smanager/lib/SrvMngr/Controller/Userpanels-Custom.pm b/root/usr/share/smanager/lib/SrvMngr/Controller/Userpanels-Custom.pm new file mode 100644 index 0000000..c44e18d --- /dev/null +++ b/root/usr/share/smanager/lib/SrvMngr/Controller/Userpanels-Custom.pm @@ -0,0 +1,277 @@ +# +# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-23 10:18:18 +# +# +# 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 +#my $cdb +my $adb; +#my $ndb +#my $hdb +#my $ddb + +# Validation routines - parameters for each panel + + sub validate_USERTABLE { + my $c = shift; + my $usp_data = shift; #Data hash as parameter + # Validation for each field + my $ret = ""; + + if ($ret eq "") {$ret = 'ok';} + return $ret; + } + + sub validate_PANELTABLE { + my $c = shift; + my $usp_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_USERTABLE { + # Return a hash with the fields required which will be loaded into the shared data + my $c = shift; + my %ret = ( + 'Data1'=>'Data for USERTABLE', #Example + # fields from Inputs in USERTABLE $fields['USERTABLE'] + + ); + return %ret; + } + + sub get_data_for_panel_PANELTABLE { + # Return a hash with the fields required which will be loaded into the shared data + my $c = shift; + my %ret = ( + 'Data1'=>'Data for PANELTABLE', #Example + # fields from Inputs in PANELTABLE $fields['PANELTABLE'] + + ); + return %ret; + } + + + +use constant users_FIELD_MAPPING => ( + 'Account' => 'Name', # Output => Source + 'Description' => 'Description', + 'Modify' => 'Modify', +); + +sub actual_users { + my @ret = (); + + my $adb = esmith::AccountsDB->open() or die("Couldn't open Accounts db"); + + # Optionally add the local admin user + push @ret, { + 'Name' => 'admin', + 'Description' => 'Local Admin', + 'Modify' => "Modify" + }; + + my @users = $adb->users(); + my @groups = $adb->groups(); + my @accounts = (@users, @groups); # Combine into one array + + foreach my $i (@accounts) { + my $username = $i->key(); + my $userdesc = join(' ', grep { $_ } $i->prop('FirstName'), $i->prop('LastName')); + $userdesc ||= $i->prop('Description') || ''; # For groups, use 'Description' if no names + my $actionModify = "Modify"; + + my %hash = ( + 'Name' => $username, + 'Description' => $userdesc, + 'Modify' => $actionModify + ); + push @ret, \%hash; + } + return @ret; +} + +sub get_users { + my $c = shift; + my @source_records = $c->actual_users(); + my @transformed_records; + my %Field_Mapping = users_FIELD_MAPPING(); + + for my $source_record (@source_records) { + my %transformed_record; + while (my ($target, $source) = each %Field_Mapping) { + if (exists $source_record->{$source}) { + $transformed_record{$target} = $source_record->{$source}; + } + } + push @transformed_records, \%transformed_record if %transformed_record; + } + return \@transformed_records; +} +use constant panels_FIELD_MAPPING => ( + 'Panel' => 'name', + 'Description' => 'description', + 'Select' => 'selection' + # Add more mappings as needed +); + +sub actual_panels { + my $c = shift; + my %usp_data = shift; + my $adb = esmith::AccountsDB->open() or die("Couldn't open Accounts db"); + my $accounts_key = $c->param('Selected'); + # Pass it back to the template and then back to the perform routine via a hidden field + $c->stash(accounts_key=>$accounts_key); + #my $account = $adb->get_rec($accounts_key) || undef; + my $AdminPanels = $adb->get_prop($accounts_key,'AdminPanels') || ''; #"Backup,Quota"; # + + #$c->log->info("Key:$accounts_key AdminPanels:$AdminPanels usp_data:$usp_data{accounts_key}"); + + # Clean and split AdminPanel string (handles comma, whitespace, and quotes) + $AdminPanels =~ s/["']//g; # Remove quotes + my %admin_panels = map { $_ => 1 } grep { length } split(/\s*,\s*/, $AdminPanels); + my $dir = '/usr/share/smanager/lib/SrvMngr/Controller'; + my @panels; + + opendir(my $dh, $dir) or die "Can't open $dir: $!"; + FILE: + for my $file (grep { /\.pm$/ } readdir($dh)) { + #Skip the ones not real panels. + next FILE if $file =~ /-Custom/; + next FILE if $file =~ /^(Modules|Swttheme|Request)\.pm$/i; + #Pick up description from header in controller file + my $path = "$dir/$file"; + open(my $fh, '<', $path) or next; + my $description = ''; + while (my $line = <$fh>) { + if ($line =~ /^\s*#\s*description\s*:\s*(.+?)\s*$/i) { + $description = $1; + last; + } + } + close $fh; + + # Remove .pm extension + (my $panelname = $file) =~ s/\.pm$//; + + # Checkbox: checked if in admin_panels + my $checkbox = exists $admin_panels{$panelname} + ? "<%= check_box 'panelAccess', value => '$panelname', checked => 'checked' %>" + : "<%= check_box 'panelAccess', value => '$panelname' %>"; + + push @panels, { + name => $panelname, + description => $description, + selection => $checkbox + }; + } + closedir $dh; + return @panels; +} + + +sub get_panels { + my $c = shift; + # Return an arrayref of hashes for each panel with mapped fields + my @source_records = $c->actual_panels(); + my @transformed_records; + my %Field_Mapping = panels_FIELD_MAPPING(); + + for my $source_record (@source_records) { + my %transformed_record; + while (my ($target, $source) = each %Field_Mapping) { + if (exists $source_record->{$source}) { + $transformed_record{$target} = $source_record->{$source}; + } + } + push @transformed_records, \%transformed_record if %transformed_record; + } + #$c->log->info("get_panel:$usp_data{account_key}"); + return \@transformed_records; +} + + + +# Return hash with values from row in which link clicked on table + + sub get_selected_USERTABLE { + 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 get_selected_PANELTABLE { + 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; + } + + +#after sucessful modify or create or whatever and submit then perfom (if the params validate) + + sub perform_USERTABLE { + my $c = shift; + my $usp_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 perform_PANELTABLE { + my $c = shift; + my $usp_data = shift; #Data hash as parameter + my $ret = ""; + my $db = $adb; #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." + # Return from the panel table is an array of the values for the checked boxes. + my @selected = @{$c->every_param('panelAccess')}; +# my $count_of_checked = scalar @selected; +# $c->log->info("No of checked: $count_of_checked "); + my $AdminPanels = join(',', @selected); + #$c->log->info("Selected IDs: $joined"); + #Write back to the property AdminPanels + my $adb = esmith::AccountsDB->open() or die("Couldn't open Accounts db"); + my $accounts_key = $c->param('accounts_key'); #hidden field in form + #$c->log->info("AccKey: $accounts_key"); + $adb->set_prop($accounts_key,'AdminPanels',$AdminPanels); + 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/root/usr/share/smanager/lib/SrvMngr/Controller/Userpanels.pm b/root/usr/share/smanager/lib/SrvMngr/Controller/Userpanels.pm new file mode 100644 index 0000000..b103d05 --- /dev/null +++ b/root/usr/share/smanager/lib/SrvMngr/Controller/Userpanels.pm @@ -0,0 +1,317 @@ +package SrvMngr::Controller::Userpanels; +# +# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-23 10:18:18 +# +#---------------------------------------------------------------------- +# heading : System +# description : User panel access +# navigation : 2000 400 +# +# name : userpanels, method : get, url : /userpanels, ctlact : Userpanels#main +# name : userpanelsu, method : post, url : /userpanelsu, ctlact : Userpanels#do_update +# name : userpanelsd, method : get, url : /userpanelsd, ctlact : Userpanels#do_display +# +# routes : end +# +# Documentation: https://wiki.contribs.org/Userpanels +#---------------------------------------------------------------------- + +# +# 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; + +require '/usr/share/smanager/lib/SrvMngr/Controller/Userpanels-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"); + + my %usp_data = (); + my $title = $c->l('usp_User_panel_access_'); + my $modul = ''; + + $usp_data{'trt'} = 'PANELTABLE'; #'USERTABLE'; + + #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($usp_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 %usp_data = (); + my $title = $c->l('usp_User_panel_access_'); + + # 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}) { + # $usp_data{$key} = $value; + #} + + # the value of trt will tell you which panel has returned + my $trt = $c->param('trt') || 'USERTABLE'; #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 'USERTABLE'){ + #Validate form parameters for panel USERTABLE + $ret = $c->validate_USERTABLE(\%usp_data); + $thispanel = 'USERTABLE'; + } + + if ($trt eq 'PANELTABLE'){ + #Validate form parameters for panel PANELTABLE + $ret = $c->validate_PANELTABLE(\%usp_data); + $thispanel = 'PANELTABLE'; + } + + if ($ret ne "ok"){ + $c->do_display($thispanel); + } else { + #Do whatever is needed, including writing values to the DB + + + if ($trt eq 'USERTABLE'){ + #do whatever is required ... + $ret = $c->perform_USERTABLE(\%usp_data); + if ($ret ne "ok") { + # return to the panel with error message + $c->stash(error => $c->l($ret)); + $c->stash( + title => $title, + modul => $modul, + usp_data => \%usp_data + ); + $c->render(template => "userpanels"); + } else { + $c->stash( success => $c->l('usp_USERTABLE_panel_action_was_successful')); #A bit bland - edit it in the lex file + } + } + + if ($trt eq 'PANELTABLE'){ + #do whatever is required ... + $ret = $c->perform_PANELTABLE(\%usp_data); + if ($ret ne "ok") { + # return to the panel with error message + $c->stash(error => $c->l($ret)); + $c->stash( + title => $title, + modul => $modul, + usp_data => \%usp_data + ); + $c->render(template => "userpanels"); + } else { + $c->stash( success => $c->l('usp_PANELTABLE_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') { + $usp_data{'trt'} = 'USERTABLE'; + } else { + $usp_data{'trt'} = 'none'; + } + $c->do_display($usp_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 %usp_data = (); + my $title = $c->l('usp_User_panel_access_'); + 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}) { + # $usp_data{$key} = $value; + #} + + # the value of trt will tell you which panel has returned + if (! $trt){ + $trt = $c->param('trt') || 'PANELTABLE'; #'USERTABLE'; #Indicates where to go now + } + + # Now add in the params from the selected row from the table + + my %selectedrow; + + if ($trt eq 'USERTABLE'){ + #Validate Get selected row (if applicable) USERTABLE + %selectedrow = $c->get_selected_USERTABLE($usp_data{'Selected'},$is_new_record); + } + + if ($trt eq 'PANELTABLE'){ + #Validate Get selected row (if applicable) PANELTABLE + %selectedrow = $c->get_selected_PANELTABLE($usp_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){ + $usp_data{$key} = $value; + } + # Where to go now + $usp_data{'trt'} = $trt; + + # Set up other shared data according to the panel to go to + + if ($trt eq 'USERTABLE'){ + # 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_USERTABLE(); + # Copy each key-value pair from the returned hash to the prefix data hash + while (my ($key, $value) = each %returned_hash) { + $usp_data{$key} = $value; + } + } + + if ($trt eq 'PANELTABLE'){ + # 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_PANELTABLE(); + # Copy each key-value pair from the returned hash to the prefix data hash + while (my ($key, $value) = each %returned_hash) { + $usp_data{$key} = $value; + } + } + + + # and table control fields + $c->stash(users=>$c->get_users()); + $c->stash(panels=>$c->get_panels()); + + + # Data for panel + $c->stash( + title => $title, + modul => $modul, + usp_data => \%usp_data + ); + $c->render(template => "userpanels"); +} +1; \ No newline at end of file diff --git a/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Userpanels/en.pm b/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Userpanels/en.pm new file mode 100644 index 0000000..b39523f --- /dev/null +++ b/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Userpanels/en.pm @@ -0,0 +1,36 @@ +package SrvMngr::I18N::Modules::Userpanels::en; +use strict; +use warnings; +use utf8; +use Mojo::Base 'SrvMngr::I18N'; + +use SrvMngr::I18N::Modules::General::en; + +my %lexicon = ( +# +# Generated by SM2Gen version: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-23 10:04:56 +# +'usp_You_can_modify_individual_users' => 'You can modify individual users access to the server-manager panels below by clicking on the link next the account You can assign panels to the members of a group with their link Users or Groups in red have some form of extra access You can globally assign a panel by editing the global account', +'usp_Name/Description' => 'Name/description', +'usp_Modify' => 'Modify', +'usp_User_panel_access_' => 'User panel access', +'usp_APPLY' => 'Apply', +'usp_Account' => 'Account', +'usp_PANELTABLE_panel_action_was_successful' => 'PANELTABLE panel action was successful', +'usp_Choose_a_user' => 'Choose a user', +'usp_><%=l('Panel' => '><%=l('panel', +'usp_Description' => 'Description', +'usp_Select' => 'Select', +'usp_Save' => 'Save', +'usp_Allocate_panels_to_a_user' => 'Allocate panels to a user', +'usp_Select_panels_for_user' => 'Select panels for user', +'usp_USERTABLE_panel_action_was_successful' => 'USERTABLE panel action was successful', +); + +our %Lexicon = ( + %{ SrvMngr::I18N::Modules::General::en::Lexicon }, + %lexicon +); + + +1; diff --git a/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Userpanels/userpanels_en.lex b/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Userpanels/userpanels_en.lex new file mode 100644 index 0000000..f07350e --- /dev/null +++ b/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Userpanels/userpanels_en.lex @@ -0,0 +1,18 @@ +# +# Generated by SM2Gen version: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-23 10:04:56 +# +'usp_You_can_modify_individual_users' => 'You can modify individual users access to the server-manager panels below by clicking on the link next the account You can assign panels to the members of a group with their link Users or Groups in red have some form of extra access You can globally assign a panel by editing the global account', +'usp_Name/Description' => 'Name/description', +'usp_Modify' => 'Modify', +'usp_User_panel_access_' => 'User panel access', +'usp_APPLY' => 'Apply', +'usp_Account' => 'Account', +'usp_PANELTABLE_panel_action_was_successful' => 'PANELTABLE panel action was successful', +'usp_Choose_a_user' => 'Choose a user', +'usp_><%=l('Panel' => '><%=l('panel', +'usp_Description' => 'Description', +'usp_Select' => 'Select', +'usp_Save' => 'Save', +'usp_Allocate_panels_to_a_user' => 'Allocate panels to a user', +'usp_Select_panels_for_user' => 'Select panels for user', +'usp_USERTABLE_panel_action_was_successful' => 'USERTABLE panel action was successful', diff --git a/root/usr/share/smanager/themes/default/public/css/userpanels.css b/root/usr/share/smanager/themes/default/public/css/userpanels.css new file mode 100644 index 0000000..99bf27c --- /dev/null +++ b/root/usr/share/smanager/themes/default/public/css/userpanels.css @@ -0,0 +1,20 @@ +/* +Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-23 10:04:56 +*/ +.Userpanels-panel {} +.name {} +.rout {} +.head {} +.subh {} +.para1 {} +.tabl1 {} +thead .tabl1 {} +tbody .tabl1 {} +.name {} +.rout {} +.head {} +.subh {} +.tabl2 {} +thead .tabl2 {} +tbody .tabl2 {} +.subm {} diff --git a/root/usr/share/smanager/themes/default/public/js/userpanels.js b/root/usr/share/smanager/themes/default/public/js/userpanels.js new file mode 100644 index 0000000..1ad0c61 --- /dev/null +++ b/root/usr/share/smanager/themes/default/public/js/userpanels.js @@ -0,0 +1,5 @@ +// +//Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-23 10:04:56 +// +$(document).ready(function() { +}); diff --git a/root/usr/share/smanager/themes/default/templates/partials/_usp_PANELTABLE.html.ep b/root/usr/share/smanager/themes/default/templates/partials/_usp_PANELTABLE.html.ep new file mode 100644 index 0000000..bdf2b46 --- /dev/null +++ b/root/usr/share/smanager/themes/default/templates/partials/_usp_PANELTABLE.html.ep @@ -0,0 +1,53 @@ +%# +%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-23 10:18:18 +%# +
+ + % if (config->{debug} == 1) { +
+			%= dumper $usp_data
+		
+ % } + % my $btn = l('usp_APPLY'); + %= form_for "userpanelsu" => (method => 'POST') => begin + %# param 'trt' => $usp_data->{trt} unless param 'trt'; + %= hidden_field 'trt' => $usp_data->{trt} + %= hidden_field 'accounts_key' => $c->stash('accounts_key'); + %# Inputs etc in here. + +

<%=l('usp_Allocate_panels_to_a_user')%>

+ +

<%=l('usp_Select_panels_for_user')%>

+ +
+ + + + + + + + + % my $control_data = $c->stash('panels'); + % foreach my $row (@$control_data) { + + + + + + %} + +
<%=l('Panel')%><%=l('usp_Description')%><%=l('usp_Select')%>
<%=$c->render_to_string(inline=>$row->{'Panel'})%><%=$c->render_to_string(inline=>$row->{'Description'})%><%=$c->render_to_string(inline=>$row->{'Select'})%>
+ + + + %= submit_button l('usp_Save'), class => 'action subm' + + + %# Probably finally by a submit. + %end +
\ No newline at end of file diff --git a/root/usr/share/smanager/themes/default/templates/partials/_usp_USERTABLE.html.ep b/root/usr/share/smanager/themes/default/templates/partials/_usp_USERTABLE.html.ep new file mode 100644 index 0000000..a38f5fe --- /dev/null +++ b/root/usr/share/smanager/themes/default/templates/partials/_usp_USERTABLE.html.ep @@ -0,0 +1,52 @@ +%# +%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-23 10:04:56 +%# +
+ + % if (config->{debug} == 1) { +
+			%= dumper $usp_data
+		
+ % } + % my $btn = l('usp_APPLY'); + %= form_for "userpanelsu" => (method => 'POST') => begin + % param 'trt' => $usp_data->{trt} unless param 'trt'; + %= hidden_field 'trt' => $usp_data->{trt} + %# Inputs etc in here. + +

<%=l('usp_Allocate_panels_to_a_user')%>

+ +

<%=l('usp_Choose_a_user')%>

+ +

+ %=l('usp_You_can_modify_individual_users') +

+ +
+ + + + + + + + + % my $control_data = $c->stash('users'); + % foreach my $row (@$control_data) { + + + + + + %} + +
<%=l('usp_Name/Description')%><%=l('usp_Modify')%>
<%=$c->render_to_string(inline=>$row->{'Description'})%><%=$c->render_to_string(inline=>$row->{'Modify'})%>
+ + + %# Probably finally by a submit. + %end +
\ No newline at end of file diff --git a/root/usr/share/smanager/themes/default/templates/userpanels.html.ep b/root/usr/share/smanager/themes/default/templates/userpanels.html.ep new file mode 100644 index 0000000..029a68c --- /dev/null +++ b/root/usr/share/smanager/themes/default/templates/userpanels.html.ep @@ -0,0 +1,62 @@ +%# +%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-23 10:18:18 +%# +% layout 'default', title => "Sme server 2 - User panel access ", share_dir => './'; +%# css specific to this panel: +% content_for 'module' => begin +%= stylesheet '/css/userpanels.css' +%= javascript '/js/userpanels.js' +
+ + % if (config->{debug} == 1) { +
+		%= dumper $c->current_route
+		%= dumper $usp_data->{trt}
+		%= dumper stash('users')
+		%= dumper stash 'panels'
+	
+ % } + +

<%=$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 ($usp_data->{trt} eq "USERTABLE") { + %= include 'partials/_usp_USERTABLE' + %} + + % if ($usp_data->{trt} eq "PANELTABLE") { + %= include 'partials/_usp_PANELTABLE' + %} + + + +
+%end \ No newline at end of file diff --git a/smeserver-userpanels.spec b/smeserver-userpanels.spec index a75ff2b..119bff6 100644 --- a/smeserver-userpanels.spec +++ b/smeserver-userpanels.spec @@ -5,8 +5,8 @@ Summary: Panels to let users to change server settings. %define name smeserver-userpanels Name: %{name} -%define version 1.3 -%define release 5 +%define version 11.0.0 +%define release 1 Version: %{version} Release: %{release}%{?dist} License: GNU GPL version 2 @@ -26,6 +26,9 @@ Change password,Forward mail, Backup users home directory, Delegate creation of users with restrictions. %changelog +* Wed Apr 23 2025 Brian Read 11.0.0-1.sme +- Add SM2 panel + * Sun Sep 08 2024 fix-e-smith-pkg.sh by Trevor Batley 1.3-5.sme - Fix e-smith references in smeserver-userpanels [SME: 12732]