From 2727d948c6d1bd1bec86a6287c06b91528018d7b Mon Sep 17 00:00:00 2001 From: Brian Read Date: Sun, 11 May 2025 10:43:35 +0100 Subject: [PATCH] * Sat May 10 2025 Brian Read 11.0.0-3.sme - Get javascript working and password visible icon [SME: 13001] - Fix missing cmd in panel - Delete out of date list of protocols/device/services etc from controller source --- .../lib/SrvMngr/Controller/Ddclient.pm | 72 +------------------ .../themes/default/public/js/ddclient.js | 62 ++++++++++++++++ .../themes/default/templates/ddclient.html.ep | 1 + .../partials/_ddc_create_cust.html.ep | 18 +---- .../partials/_ddc_modify_domain.html.ep | 41 +---------- .../templates/partials/_ddc_paramlist.html.ep | 43 ++--------- smeserver-ddclient.spec | 7 +- 7 files changed, 81 insertions(+), 163 deletions(-) create mode 100644 root/usr/share/smanager/themes/default/public/js/ddclient.js diff --git a/root/usr/share/smanager/lib/SrvMngr/Controller/Ddclient.pm b/root/usr/share/smanager/lib/SrvMngr/Controller/Ddclient.pm index 6ddc84f..7d19b1d 100644 --- a/root/usr/share/smanager/lib/SrvMngr/Controller/Ddclient.pm +++ b/root/usr/share/smanager/lib/SrvMngr/Controller/Ddclient.pm @@ -19,74 +19,6 @@ package SrvMngr::Controller::Ddclient; # # Documentation: https://wiki.contribs.org/Ddclient # -#---------------------------------------------------------------------- -# -# ddclient 3.9.1 Supportted services -# -#DynDNS.com - See http://www.dyndns.com for details on obtaining a free account. -#Hammernode - See http://www.hn.org for details on obtaining a free account. -#Zoneedit - See http://www.zoneedit.com for details. -#EasyDNS - See http://www.easydns.com for details. -#NameCheap - See http://www.namecheap.com for details -#DslReports - See http://www.dslreports.com for details -#Sitelutions - See http://www.sitelutions.com for details -#Loopia - See http://www.loopia.se for details -#Noip - See http://www.noip.com/ for details -#Freedns - See http://freedns.afraid.org/ for details -#ChangeIP - See http://www.changeip.com/ for details -#dtdns - See http://www.dtdns.com/ for details -#nsupdate - See nsupdate(1) and ddns-confgen(8) for details -#CloudFlare - See https://www.cloudflare.com/ for details -#Google - See http://www.google.com/domains for details -#Duckdns - See https://duckdns.org/ for details -#Freemyip - See https://freemyip.com for details -#woima.fi - See https://woima.fi/ for details -#Yandex - See https://domain.yandex.com/ for details -#DNS Made Easy - See https://dnsmadeeasy.com/ for details -#DonDominio - See https://www.dondominio.com for details -#NearlyFreeSpeech.net - See https://www.nearlyfreespeech.net/services/dns for details -#OVH - See https://www.ovh.com for details -#ClouDNS - See https://www.cloudns.net - -# ddclient 3.11.1 Supported Services -# 1984:https://kb.1984hosting.com/doku.php?id=freedns -# changeip: https://changeip.com -# cloudflare: https://cloudflare.com -# cloudns: https://cloudns.com -# digitalocean: https://digitalocean.com -# dinahosting: https://dinahosting.com -# dnsexit: https://dnsexit.com/ -# dnsmadeeasy: https://dnsmadeeasy.com -# domeneshop: https://domeneshop.com -# dondominio: https://dondominio.com -# dslreports: https://www.dslreports.com/ -# duckdns: https://duckdns.com -# dyndns1:https://account.dyn.com/ -# dyndns2: https://account.dyn.com/ -# easydns: https://easydns.com -# enom: https://enom.com -# freedns: http://freedns.com -# freemyip: https://freemyip.com -# gandi: https://gandi.com -# godaddy: https://godaddy.com -# googledomains: https://googledomains.com -# hetzner: https://hetzner.com -# infomaniak: https://infomaniak.com -# keysystems: https://keysystems.com -# mythicdyn: https://www.mythic-beasts.com/support/api/dnsv2/dynamic-dns -# namecheap: https://namecheap.com -# nfsn: http://nfsn.com -# njalla: https://njalla.com -# noip: https://noip.com -# nsupdate: http://nsupdate.com -# ovh: https://ovh.com -# porkbun: https://porkbun.com -# regfishde: Cannot find link for this one -# sitelutions: https://sitelutions.com -# woima: http://woima.com -# yandex: https://yandex.com -# zoneedit: https://www.zoneedit.com/dynamic-dns/ - use strict; use warnings; use Mojo::Base 'Mojolicious::Controller'; @@ -311,7 +243,7 @@ sub do_display { [ $c->l('Router/Firewall') => 'router' ], [ $c->l('Interface') => 'if' ], [ $c->l('IP') => 'ip' ], - [ $c->l('Command') => 'cmdv4' ] + [ $c->l('Command') => 'cmd' ] ] ); @@ -656,7 +588,7 @@ sub get_params { my $ssl = $ddretrieve->prop('SSL') || 'yes'; my $method = $ddretrieve->prop('method') || 'web'; my $Extinterface = $ddretrieve->prop('Extinterface') || ''; - my $cmd = $ddretrieve->prop('cmd') || ''; + my $cmd = $ddretrieve->prop('cmd') || '/usr/sbin/e-smith/getmyip'; my $forceIP = $ddretrieve->prop('ForceIP') || ''; my $fwlogin = $ddretrieve->prop('fwlogin') || ''; my $fwpassword = $ddretrieve->prop('fwpassword') || ''; diff --git a/root/usr/share/smanager/themes/default/public/js/ddclient.js b/root/usr/share/smanager/themes/default/public/js/ddclient.js new file mode 100644 index 0000000..df7d4cd --- /dev/null +++ b/root/usr/share/smanager/themes/default/public/js/ddclient.js @@ -0,0 +1,62 @@ +function showPass() { + var x = document.getElementById("ddcPass"); + if (x.type === "password") { + x.type = "text"; + } else { + x.type = "password"; + } +} + +document.addEventListener('DOMContentLoaded', function() { + // Run on page load + SelectInput_custom(); + + // Attach onchange event to the select element + var dnsSelect = document.getElementById('dns'); + if (dnsSelect) { + dnsSelect.addEventListener('change', SelectInput_custom); + } +}); + + +function SelectInput_custom() { + var method = document.querySelector("#dns"); + const types=['custom']; + types.forEach((type)=>{ + var service = document.querySelector(`.${type}`); + if (service != null) { + if (method.value == type) { + service.style.display = 'block'; + } else { + service.style.display = 'none'; + } + } + }) +} + +document.addEventListener('DOMContentLoaded', function() { + // Run on page load (replaces onload) + SelectInput_params(); + + // Attach onchange event (replaces inline onchange) + var dnsSelect = document.getElementById('retrievemethod'); + if (dnsSelect) { + dnsSelect.addEventListener('change', SelectInput_params); + } +}); + + +function SelectInput_params() { + var method = document.querySelector("#retrievemethod"); + const types=['smeIF','smeCMD','web','router','if','ip','cmd','custom']; + types.forEach((type)=>{ + var service = document.querySelector(`.${type}`); + if (service != null) { + if (method.value == type) { + service.style.display = 'block'; + } else { + service.style.display = 'none'; + } + } + }) +} \ No newline at end of file diff --git a/root/usr/share/smanager/themes/default/templates/ddclient.html.ep b/root/usr/share/smanager/themes/default/templates/ddclient.html.ep index f09c67b..7516f8f 100644 --- a/root/usr/share/smanager/themes/default/templates/ddclient.html.ep +++ b/root/usr/share/smanager/themes/default/templates/ddclient.html.ep @@ -1,6 +1,7 @@ % layout 'default', title => "Sme server 2 - Dynamic Clients", share_dir => './'; % content_for 'module' => begin +%= javascript '/js/ddclient.js'
% if (config->{debug} == 1) { diff --git a/root/usr/share/smanager/themes/default/templates/partials/_ddc_create_cust.html.ep b/root/usr/share/smanager/themes/default/templates/partials/_ddc_create_cust.html.ep index edb5a08..e85106b 100644 --- a/root/usr/share/smanager/themes/default/templates/partials/_ddc_create_cust.html.ep +++ b/root/usr/share/smanager/themes/default/templates/partials/_ddc_create_cust.html.ep @@ -39,19 +39,7 @@ %=l 'PASSWORD_LABEL' - %=password_field 'password',id=>"ddcPass" - %=label_for show=>"Show" - %=check_box show=>1,onclick=>"showPass()",style=>"vertical-align:middle;" - %= javascript begin - function showPass() { - var x = document.getElementById("ddcPass"); - if (x.type === "password") { - x.type = "text"; - } else { - x.type = "password"; - } - } - % end + %=password_field 'password',id=>"ddcPass", class=>'sme-password'
%=l 'MX' @@ -60,6 +48,4 @@
%= submit_button "$btn", class => 'action' % end -
- - + \ No newline at end of file diff --git a/root/usr/share/smanager/themes/default/templates/partials/_ddc_modify_domain.html.ep b/root/usr/share/smanager/themes/default/templates/partials/_ddc_modify_domain.html.ep index 6ff74a2..ed38238 100644 --- a/root/usr/share/smanager/themes/default/templates/partials/_ddc_modify_domain.html.ep +++ b/root/usr/share/smanager/themes/default/templates/partials/_ddc_modify_domain.html.ep @@ -1,9 +1,4 @@
-

%= l 'MODIFY_DESCRIPTION'


@@ -34,23 +29,7 @@ %=l 'SERVERS_LABEL' % param dns=>$ddc_datas->{"Domain_details"}->{"dns"}; - %=select_field dns=>$dnslabels,id=>"dns",onchange=>"SelectInput()",onload=>"SelectInput()" - %= javascript begin - function SelectInput() { - var method = document.querySelector("#dns"); - const types=['custom']; - types.forEach((type)=>{ - var service = document.querySelector(`.${type}`); - if (service != null) { - if (method.value == type) { - service.style.display = 'block'; - } else { - service.style.display = 'none'; - } - } - }) - } - %end + %=select_field dns=>$dnslabels,id=>"dns",class=>'selectinputcustom'
%# Dependant on the custom choice from above @@ -79,19 +58,7 @@ %=l 'PASSWORD_LABEL' % param password=>$ddc_datas->{"Domain_details"}->{"password"}; - %=password_field 'password',id=>"ddcPass",value=>$ddc_datas->{"Domain_details"}->{"password"} - %=label_for show=>"Show" - %=check_box show=>1,onclick=>"showPass()",style=>"vertical-align:middle;" - %= javascript begin - function showPass() { - var x = document.getElementById("ddcPass"); - if (x.type === "password") { - x.type = "text"; - } else { - x.type = "password"; - } - } - % end + %=password_field 'password',id=>"ddcPass",value=>$ddc_datas->{"Domain_details"}->{"password"}, class=>'sme-password'
%=l 'MX' @@ -103,6 +70,4 @@ %= hidden_field Route=>$c->current_route %= submit_button "$btn", class => 'action' % end -
- - + \ No newline at end of file diff --git a/root/usr/share/smanager/themes/default/templates/partials/_ddc_paramlist.html.ep b/root/usr/share/smanager/themes/default/templates/partials/_ddc_paramlist.html.ep index d6d43ec..de52877 100644 --- a/root/usr/share/smanager/themes/default/templates/partials/_ddc_paramlist.html.ep +++ b/root/usr/share/smanager/themes/default/templates/partials/_ddc_paramlist.html.ep @@ -1,9 +1,4 @@
-

%= l 'Params_for_IP_Retrieval'

@@ -25,23 +20,7 @@ %=l 'RETRIEVE_METHOD' % param retrievemethod=>$ddc_datas->{"params"}->{"method"} unless param 'retrievemethod'; - %=select_field retrievemethod=>$methodlabels,id=>"retrievemethod",onchange=>"SelectInput()" - %= javascript begin - function SelectInput() { - var method = document.querySelector("#retrievemethod"); - const types=['smeIF','smeCMD','web','router','if','ip','cmdv4','custom']; - types.forEach((type)=>{ - var service = document.querySelector(`.${type}`); - if (service != null) { - if (method.value == type) { - service.style.display = 'block'; - } else { - service.style.display = 'none'; - } - } - }) - } - % end + %=select_field retrievemethod=>$methodlabels,id=>"retrievemethod"
%# %# From here the one that is shown depends on the choice above @@ -65,19 +44,7 @@ %=l 'Router password' % param retrieverouterpassword=>$ddc_datas->{"params"}->{"FWPassword"} unless param 'retrieverouterpassword'; - %=password_field 'retrieverouterpassword', id=>'ddcPass' - %=label_for show=>"Show" - %=check_box show=>1,onclick=>"showPass()",style=>"vertical-align:middle;" - %= javascript begin - function showPass() { - var x = document.getElementById("ddcPass"); - if (x.type === "password") { - x.type = "text"; - } else { - x.type = "password"; - } - } - % end + %=password_field 'retrieverouterpassword', id=>'ddcPass', class=>'sme-password'
@@ -102,11 +69,11 @@ %# Only if "cmd" is chosen -
+
%=l 'RETRIEVE_CMD' - % param retrievecmd=>$ddc_datas->{"params"}->{"cmdv4"} unless param 'retrievecmd'; + % param retrievecmd=>$ddc_datas->{"params"}->{"cmd"} unless param 'retrievecmd'; %=text_field 'retrievecmd'
@@ -133,4 +100,4 @@ %= submit_button "$btn", class => 'action' % end -
+ \ No newline at end of file diff --git a/smeserver-ddclient.spec b/smeserver-ddclient.spec index 8228f12..e160ae2 100644 --- a/smeserver-ddclient.spec +++ b/smeserver-ddclient.spec @@ -4,7 +4,7 @@ %define name smeserver-ddclient %define version 11.0.0 -%define release 2 +%define release 3 Summary: ddclient panel for SME Server Name: %{name} @@ -25,6 +25,11 @@ Requires: smeserver-formmagick AutoReqProv: no %changelog +* Sat May 10 2025 Brian Read 11.0.0-3.sme +- Get javascript working and password visible icon [SME: 13001] +- Fix missing cmd in panel +- Delete out of date list of protocols/device/services etc from controller source + * Sat May 10 2025 Brian Read 11.0.0-2.sme - correct $config (remove $) and get protocols, services and devices by interrogating ddclient [SME: 13001]