Move more code to html and work on forms

This commit is contained in:
John Crisp 2025-04-19 01:39:57 +02:00
parent b42afb227a
commit 0d7f87c6aa
8 changed files with 260 additions and 165 deletions

View File

@ -14,7 +14,7 @@
% if ( stash 'error' ) { % if ( stash 'error' ) {
<br><div class=""> <br><div class="">
%= $c->render_to_string(inline => stash 'error') %= $c->render_to_string(inline => stash 'error')
</div> </div>
%} %}
<h1><%= $title%></h1> <h1><%= $title%></h1>

View File

@ -12,6 +12,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
%= content_for 'head_contrib' %= content_for 'head_contrib'
% if (config 'hasJquery') { % if (config 'hasJquery') {
%= include 'partials/_js_imports' %= include 'partials/_js_imports'
%= include 'common_js' %= include 'common_js'
@ -28,9 +29,6 @@
%= include 'partials/_nutups_overrides' %= include 'partials/_nutups_overrides'
% } % }
</head> </head>
<body class="sidebar-expand-lg bg-body-tertiary"> <body class="sidebar-expand-lg bg-body-tertiary">

View File

@ -1,7 +1,6 @@
<div> <div>
<!--<HR class="">--> <!--<HR class="">-->
<a href="https://mojolicious.org" target="_blank"><img src="images/sme-mojo-logo-white.png" style="position:relative;"></a> <a href="https://mojolicious.org" target="_blank"><img src="images/sme-mojo-logo-white.png" style="position:relative;"></a>
<font>
% if ( $c->is_logged_in && $c->is_admin) { % if ( $c->is_logged_in && $c->is_admin) {
SME Server <%= session 'releaseVersion' %>-<%= $c->app->VERSION %> Manager II SME Server <%= session 'releaseVersion' %>-<%= $c->app->VERSION %> Manager II
% my $mode; % my $mode;
@ -11,4 +10,3 @@
<br>Copyright 1999-2006 Mitel Corporation<br> <br>Copyright 1999-2006 Mitel Corporation<br>
%= session 'copyRight' %= session 'copyRight'
<br>Copyright (c) 2013-2024 Koozali Foundation Inc.<br> <br>Copyright (c) 2013-2024 Koozali Foundation Inc.<br>
</font>

View File

@ -1,40 +1,34 @@
<!-- Both Theme drop downs but only the first works curently --> <!-- Both Theme drop downs but only the first works curently -->
<div id=""> <div>
% my $btn = l('swt_THEME'); %# content_for 'module' => begin
%= form_for $c->url_for('swttheme') => (method => 'POST') => begin
% my $value = $c->session->{'CurrentTheme'};
% $value = session 'CurrentTheme';
% param 'Theme' => $value unless param 'Theme'; % my $value = $c->session->{'CurrentTheme'};
%= select_field 'Theme' => $c->theme_list(), class => ""
%= hidden_field 'From' => $c->tx->req->url
%= submit_button "$btn"
</div>
%# my $value = $c->session->{'CurrentTheme'};
% $value = session 'CurrentTheme'; % $value = session 'CurrentTheme';
% my $formUrl = $c->url_for('swttheme'); % my $formUrl = $c->url_for('swttheme');
% param 'Theme' => $value unless param 'Theme'; % param 'Theme' => $value unless param 'Theme';
% my @themes = $c->theme_list();
%# my @themes = $c->theme_list();
%#= dumper $c
%#= my $size = keys ($c->theme_list)
% my @themeList = $c->theme_list();
%# = dumper @themeList
% my @themes = $themeList[0];
% param 'Theme' => $value unless param 'Theme';
<form action="<%= $formUrl %>" method="POST" > <form action="<%= $formUrl %>" method="POST" >
<div class="row g-3 align-items-center"> <div class="row g-3 align-items-center">
<div class="col-auto"> <div class="col-auto">
<label class="visually-hidden" for="inlineFormSelectPref">Preference</label> <label class="visually-hidden" for="inlineFormSelectPref">Preference</label>
<select class="form-select" id="inlineFormSelectPref">
<option selected><%= $value %></option> %= select_field 'Theme' => $c->theme_list(), class => "form-select"
% foreach my $theme (@themes) {
<option value="<%= $theme %>"><%= $theme %></option>
% };
</select>
%= hidden_field 'From' => $c->tx->req->url %= hidden_field 'From' => $c->tx->req->url
</div> </div>
@ -45,4 +39,7 @@
</form> </form>
% end %# end
</div>

View File

@ -5,10 +5,9 @@
%= form_for '/useraccounts' => (method => 'POST') => begin %= form_for '/useraccounts' => (method => 'POST') => begin
<p> <div>
<br> <button type="submit" class="btn btn-primary"><%= $btn %> </button>
%= submit_button "$btn", class => "" </div>
</p>
% end % end
@ -23,132 +22,134 @@
% } else { % } else {
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
<tr>
<th>
%=l 'ACCOUNT'
</th>
<th>
%=l 'USER_NAME'
</th>
<th>
%=l 'usr_VPN_CLIENT_ACCESS'
</th>
<th>
%=l 'usr_FORWARDING_ADDRESS'
</th>
<th>
%=l 'ACTION'
</th>
</tr>
</thead><tbody>
% foreach my $user (@$users) {
% my $username = $user->key();
% my $first = $user->prop('FirstName');
% my $last = $user->prop('LastName');
% my $lockable = $user->prop('Lockable') || 'yes';
% my $removable = $user->prop('Removable') || 'yes';
% my $fwd = (($user->prop('EmailForward') || 'local') =~ m/^forward|both$/) ?
% $user->prop('ForwardAddress') : '';
% my $vpnaccess = $user->prop('VPNClientAccess') || 'no';
% $vpnaccess = $vpnaccess eq 'yes' ? $c->l('YES') : $c->l('NO');
% my $password_set = $user->prop('PasswordSet');
<tr> <tr>
%= t td => (class => "") => $username <th>
%= t td => (class => "") => "$first $last" %=l 'ACCOUNT'
%= t td => (class => "") => $vpnaccess </th>
%= t td => (class => "") => $fwd <th>
% my ($actionModify, $actionLock, $actionResetPw, $actionRemove,$actionroundcube) = '&nbsp;'; %=l 'USER_NAME'
% my $modify_text = l('MODIFY'); # Localized text </th>
% my $csrf_token = "TOKEN"; # CSRF token for security <th>
% my $useraccounts_user_name = $user->key; # useraccountss_entry name extracted from the data structure %=l 'usr_VPN_CLIENT_ACCESS'
% my $password_text = l("PASSWORD_RESET"); </th>
%if ($useraccounts_user_name eq 'admin') { <th>
%$actionModify = qq{ %=l 'usr_FORWARDING_ADDRESS'
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=UPS&user=$useraccounts_user_name"> </th>
% <button type='button' class="" title='$modify_text'> <th>
% $modify_text %=l 'ACTION'
% </button> </th>
%</a>
%};
%$actionResetPw = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=PWS&user=$useraccounts_user_name">
% <button type='button' class="" title='$password_text' >
% $password_text
% </button>
%</a>
%};
%} else {
%$actionModify = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=UPD&user=$useraccounts_user_name">
% <button type='button' class="" title='$modify_text' >
% $modify_text
% </button>
%</a>
%};
%}
%if ($password_set ne 'yes') {
%$actionLock = l('ACCOUNT_LOCKED');
%$actionResetPw = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=PWD&user=$useraccounts_user_name">
% <button type='button' class="" title="$password_text - currently unset" style = background:pink; >
% $password_text
% </button>
%</a>
%};
%} elsif ($useraccounts_user_name ne 'admin') {
% my $lock_text = l('ACCOUNT LOCKED'); # Localized text
% my $csrf_token = "TOKEN"; # CSRF token for security
% my $useraccounts_user_name = $user->key; # useraccountss_entry name extracted from the data structure
%$actionLock = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=LCK&user=$useraccounts_user_name">
% <button type='button' class="" title='$lock_text' >
% $lock_text
% </button>
%</a>
%};
%$actionResetPw = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=PWD&user=$useraccounts_user_name">
% <button type='button' class="" title='$password_text' >
% $password_text
% </button>
%</a>
%};
%}
%if ( $removable eq 'yes' ) {
% my $remove_text = l('REMOVE'); # Localized text
% my $csrf_token = "TOKEN"; # CSRF token for security
%$actionRemove = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=DEL&user=$useraccounts_user_name">
% <button type='button' class="" title='$remove_text' >
% $remove_text
% </button>
%</a>
%};
%}
% my $thisdomain = $c->req->url->to_abs->host;
% my $roundcube_text = l('Webmail'); # Localized text
% $csrf_token = "TOKEN"; # CSRF token for security
% $useraccounts_user_name = $user->key; # useraccountss_entry name extracted from the data structure
% $actionroundcube = qq{
%<a href="roundcubepanel?CsrfDef=$csrf_token&url=https://$thisdomain/roundcube?_user=$useraccounts_user_name&height=600px">
% <button type='button' class="" title='$roundcube_text' >
% $roundcube_text
% </button>
%</a>
%};
<td class="">
<%= $c->render_to_string(inline => $actionModify) %>
<%= $c->render_to_string(inline => $actionResetPw) %>
<%= $c->render_to_string(inline => $actionLock) %>
<%= $c->render_to_string(inline => $actionRemove) %>
<%= $c->render_to_string(inline => $actionroundcube) %>
</td>
</tr> </tr>
% } </thead>
<tbody>
% foreach my $user (@$users) {
% my $username = $user->key();
% my $first = $user->prop('FirstName');
% my $last = $user->prop('LastName');
% my $lockable = $user->prop('Lockable') || 'yes';
% my $removable = $user->prop('Removable') || 'yes';
% my $fwd = (($user->prop('EmailForward') || 'local') =~ m/^forward|both$/) ?
% $user->prop('ForwardAddress') : '';
% my $vpnaccess = $user->prop('VPNClientAccess') || 'no';
% $vpnaccess = $vpnaccess eq 'yes' ? $c->l('YES') : $c->l('NO');
% my $password_set = $user->prop('PasswordSet');
<tr>
<td><%= $username %></td>
<td><%=$first %>&nbsp<%=$last %></td>
<td><%= $vpnaccess %></td>
<td><%= $fwd %></td>
% my ($actionModify, $actionLock, $actionResetPw, $actionRemove,$actionroundcube) = '&nbsp;';
% my $modify_text = l('MODIFY'); # Localized text
% my $csrf_token = "TOKEN"; # CSRF token for security
% my $useraccounts_user_name = $user->key; # useraccountss_entry name extracted from the data structure
% my $password_text = l("PASSWORD_RESET");
%if ($useraccounts_user_name eq 'admin') {
%$actionModify = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=UPS&user=$useraccounts_user_name">
% <button type='button' class="btn btn-primary" title='$modify_text'>
% $modify_text
% </button>
%</a>&nbsp;
%};
%$actionResetPw = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=PWS&user=$useraccounts_user_name">
% <button type='button' class="btn btn-primary" title='$password_text' >
% $password_text
% </button>
%</a>&nbsp;
%};
%} else {
%$actionModify = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=UPD&user=$useraccounts_user_name">
% <button type='button' class="btn btn-primary" title='$modify_text' >
% $modify_text
% </button>
%</a>&nbsp;
%};
%}
%if ($password_set ne 'yes') {
%$actionLock = l('ACCOUNT_LOCKED');
%$actionResetPw = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=PWD&user=$useraccounts_user_name">
% <button type='button' class="btn btn-primary" title="$password_text - currently unset" style = background:pink; >
% $password_text
% </button>
%</a>&nbsp;
%};
%} elsif ($useraccounts_user_name ne 'admin') {
% my $lock_text = l('ACCOUNT LOCKED'); # Localized text
% my $csrf_token = "TOKEN"; # CSRF token for security
% my $useraccounts_user_name = $user->key; # useraccountss_entry name extracted from the data structure
%$actionLock = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=LCK&user=$useraccounts_user_name">
% <button type='button' class="btn btn-primary" title='$lock_text' >
% $lock_text
% </button>
%</a>&nbsp;
%};
%$actionResetPw = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=PWD&user=$useraccounts_user_name">
% <button type='button' class="btn btn-primary" title='$password_text' >
% $password_text
% </button>
%</a>&nbsp;
%};
%}
%if ( $removable eq 'yes' ) {
% my $remove_text = l('REMOVE'); # Localized text
% my $csrf_token = "TOKEN"; # CSRF token for security
%$actionRemove = qq{
%<a href="useraccountsd?CsrfDef=$csrf_token&trt=DEL&user=$useraccounts_user_name">
% <button type='button' class="btn btn-primary" title='$remove_text' >
% $remove_text
% </button>
%</a>&nbsp;
%};
%}
% my $thisdomain = $c->req->url->to_abs->host;
% my $roundcube_text = l('Webmail'); # Localized text
% $csrf_token = "TOKEN"; # CSRF token for security
% $useraccounts_user_name = $user->key; # useraccountss_entry name extracted from the data structure
% $actionroundcube = qq{
%<a href="roundcubepanel?CsrfDef=$csrf_token&url=https://$thisdomain/roundcube?_user=$useraccounts_user_name&height=600px">
% <button type='button' class="btn btn-primary" title='$roundcube_text' >
% $roundcube_text
% </button>
%</a>&nbsp;
%};
<td>
<%= $c->render_to_string(inline => $actionModify) %>
<%= $c->render_to_string(inline => $actionResetPw) %>
<%= $c->render_to_string(inline => $actionLock) %>
<%= $c->render_to_string(inline => $actionRemove) %>
<%= $c->render_to_string(inline => $actionroundcube) %>
</td>
</tr>
% }
</tbody> </tbody>
</table> </table>
@ -157,3 +158,8 @@
%= hidden_field 'trt' => $usr_datas->{trt} %= hidden_field 'trt' => $usr_datas->{trt}
</div> </div>
<div>
</div>

View File

@ -1,3 +1,99 @@
% content_for 'module' => begin
<div class="container-sm">
<br>
<h2><%= l 'usr_MODIFY_ADMIN_TITLE' %></h2>
<%= l 'usr_ACCOUNT_NAME' %> : <%= $usr_datas->{user} %>
<form>
% param 'FirstName' => $usr_datas->{firstname} unless param 'FirstName';
<div class="row g-3 align-items-center">
<div class="col-auto p-33">
<label for="inputFirstName" class="col-form-label"><%= l 'usr_FIRSTNAME' %></label>
</div>
<div class="col-auto p-3">
<input type="text" id="inputFirstName" class="form-control" aria-describedby="FirstName" value=<%= $usr_datas->{firstname} %> >
</div>
<div class="col-auto p-3">
<span id="passwordHelpInline" class="form-text">
First Name
</span>
</div>
</div>
% param 'LastName' => $usr_datas->{lastname} unless param 'LastName';
<div class="row g-3 align-items-center">
<div class="col-auto p-33">
<label for="inputLastNAme" class="col-form-label"><%= l 'usr_LASTNAME' %></label>
</div>
<div class="col-auto p-3">
<input type="text" id="inputLastName" class="form-control" aria-describedby="LastName" value=<%= $usr_datas->{lastname} %>>
</div>
<div class="col-auto p-3">
<span id="passwordHelpInline" class="form-text">
Last Name
</span>
</div>
</div>
% param 'EmailForward' => $usr_datas->{emailforward} unless param 'EmailForward';
<div class="row g-3 align-items-center">
<div class="col-auto p-33">
<label for="inputEmailDelivery" class="col-form-label"><%= l 'usr_EMAIL_DELIVERY' %></label>
</div>
<div class="col-auto p-3">
%= select_field 'EmailForward' => $c->emailForward_list(), class => "form-select"
</div>
% param 'ForwardAddress' => $usr_datas->{forwardaddress} unless param 'ForwardAddress';
<div class="row g-3 align-items-center">
<div class="col-auto">
<label for="inputForwardAddress" class="col-form-label"><%= l 'usr_FORWARDING_ADDRESS' %></label>
</div>
<div class="col-auto">
<input type="password" id="inputPassword6" class="form-control" aria-describedby="passwordHelpInline">
</div>
<div class="col-auto">
<span id="passwordHelpInline" class="form-text">
Email forwarding address
</span>
</div>
</div>
% param 'VPNClientAccess' => $usr_datas->{vpnclientaccess} unless param 'VPNClientAccess';
<div class="row g-3 align-items-center">
<div class="col-auto p-33">
<label for="inputVPNClientAccess" class="col-form-label"><%= l 'usr_VPN_CLIENT_ACCESS' %></label>
</div>
<div class="col-auto p-3">
%= select_field 'VPNClientAccess' => [[ (l 'NO') => 'no'], [ (l 'YES') => 'yes']], class => "form-select"
</div>
<div class="row g-3 align-items-center">
<div class="col-auto p-33">
<button type="submit" class="btn btn-primary">Save</button>
</div>
</div>
</form>
% end
</div>
<div> <div>
% my $btn = l('SAVE'); % my $btn = l('SAVE');

View File

@ -3,9 +3,6 @@
% content_for 'module' => begin % content_for 'module' => begin
%#= include 'partials/_panel_card_top'
%#= include 'partials/_panel_card_header'
<div class="card-body"> <div class="card-body">
<h1> <%= $title %> </h1> <h1> <%= $title %> </h1>
@ -25,7 +22,5 @@
</div> </div>
%#= include 'partials/_panel_card_footer'
%#= include 'partials/_panel_card_bottom'
% end % end

View File

@ -1,6 +1,6 @@
%define name smeserver-manager-AdminLTE %define name smeserver-manager-AdminLTE
%define version 11.0.0 %define version 11.0.0
%define release 8 %define release 9
Summary: AdminLTE is an html framework for admin consoles - this rpm adds it to smeserver manager2 Summary: AdminLTE is an html framework for admin consoles - this rpm adds it to smeserver manager2
Name: %{name} Name: %{name}
Version: %{version} Version: %{version}
@ -26,6 +26,11 @@ AdminLTE is an html framework for admin consoles
wget https://github.com/ColorlibHQ/AdminLTE/archive/master.zip wget https://github.com/ColorlibHQ/AdminLTE/archive/master.zip
%changelog %changelog
* Sat Apr 19 2025 John Crisp <jcrisp@safeandsoundit.co.uk> 11.0.0-9.sme
- Starting to update forms
- Moving as much formatting to simple html as possible
- Use Mojo helpers for some parts eg theme chooser - may come back to that
* Fri Apr 18 2025 John Crisp <jcrisp@safeandsoundit.co.uk> 11.0.0-8.sme * Fri Apr 18 2025 John Crisp <jcrisp@safeandsoundit.co.uk> 11.0.0-8.sme
- More cleanup - More cleanup
- Add Card support across all panels except login - Add Card support across all panels except login