diff --git a/Targets/Nfsshare.html.ep b/Targets/Nfsshare.html.ep new file mode 100644 index 0000000..0635265 --- /dev/null +++ b/Targets/Nfsshare.html.ep @@ -0,0 +1,50 @@ +% layout 'default', title => "Sme server 2 - NFS data share", share_dir => './'; +% content_for 'module' => begin +
+%end diff --git a/Targets/Nfsshare.pm b/Targets/Nfsshare.pm new file mode 100644 index 0000000..18b23bb --- /dev/null +++ b/Targets/Nfsshare.pm @@ -0,0 +1,135 @@ +package SrvMngr::Controller::Nfsshare; + +#---------------------------------------------------------------------- +# heading : Network +# description : NFS data share +# navigation : 2000 400 +# +# name : nfsshare, method : get, url : /nfsshare, ctlact : nfsshare#main +# name : nfsshared, method : post, url : /nfsshared, ctlact : nfsshare#do_update +# +# routes : end +# +# Documentation: https://wiki.contribs.org/{PackageName} +#---------------------------------------------------------------------- + +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::HostsDB; +use esmith::AccountsDB; +use esmith::NetworksDB; +use esmith::HostsDB; +use esmith::DomainsDB; + + +#The most common ones +our $db = esmith::ConfigDB->open() || die("Couldn't open config db"); +our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db"); +our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db"); +our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); +our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); + +sub main { + + my $c = shift; + $c->app->log->info( $c->log_req ); + + my %nfs_data = (); + my $title = $c->l("nfs_NFS data share"); + my $modul = ''; + + $nfs_data{trt} = 'PARAMS'; + + $c->stash( + title => $title, + modul => $modul, + nfs_data => \%nfs_data + ); + $c->render( template => "Nfsshare" ); +} + +sub do_update { + my $c = shift; + $c->app->log->info($c->log_req); + + my %nfs_data = (); + my $title = $c->l("nfs_NFS data share"); + + # Accessing all POST parameters + my %params = $c->req->params->to_hash; + + # Get number of POST parameters + my $num_params = keys %params; + + #Params are available in the hash "params" + # you may use: + foreach my $key (keys %params) { + my $value = $params{$key}; + $c->app->log->debug("$key: $value"); + } + + # the value of trt will tell you which panel has returned + my $trt = $c->param('trt') || 'PARAMS' ; #hidden control on every form. + my $ret = 'ok'; + #Validate the parameters accordingly + + if ($trt eq 'PARAMS'){ + #Validate for panel PARAMS + # set $ret = $c->l(''Error message') if invalid' + } + + if ($trt eq 'TABLE'){ + #Validate for panel TABLE + # set $ret = $c->l(''Error message') if invalid' + } + + if ($ret ne "ok"){ + $c->stash(error => $c->l($ret)) + } else { + $c->stash( success => $c->l('ok message')) + } + if ($ret eq 'ok'){ + #Do whatever + } + # set nfs_data{trt} =