From ff8e70d627e4cebee1f3bc49a2d98c3b4920931f Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 28 Dec 2024 13:22:28 +0100 Subject: [PATCH] Date and Time enhancements - Give warning when no suitable interfaces are present for PTP --- emhttp/plugins/dynamix/DateTime.page | 27 +++++++++++++++------- emhttp/plugins/dynamix/sheets/DateTime.css | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/emhttp/plugins/dynamix/DateTime.page b/emhttp/plugins/dynamix/DateTime.page index ba0cb122a..e109c9e5d 100644 --- a/emhttp/plugins/dynamix/DateTime.page +++ b/emhttp/plugins/dynamix/DateTime.page @@ -23,16 +23,16 @@ $tmzones = file("$docroot/webGui/include/timezones.key",FILE_IGNORE_NEW_LINES|F $system = "/sys/class/net"; $hwclock = $ports = $member = []; -exec("ls --indicator-style=none $system|grep -P '^(br|bond|eth)[0-9]*$'",$net); +exec("ls --indicator-style=none $system|grep -P '^(bond|br|eth)[0-9]*$'",$net); foreach ($net as $port) { switch (preg_replace('/[0-9]+$/','',$port)) { - case 'br': - $member = array_merge($member,explode(' ',exec("ls --indicator-style=none $system/$port/brif"))); - break; case 'bond': if (!file_exists($system.'/'.str_replace('bond','br',$port))) $ports[] = $port; $member = array_merge($member,explode(' ',exec("cat $system/$port/bonding/slaves"))); break; + case 'br': + $member = array_merge($member,explode(' ',exec("ls --indicator-style=none $system/$port/brif"))); + break; case 'eth': if (!in_array($port,$member)) $ports[] = $port; break; @@ -76,9 +76,10 @@ _(Time zone)_: _(Time sync)_: : + _(No suitable interfaces found for PTP)_
_(NTP interval)_: @@ -146,7 +147,7 @@ _(PTP interface)_: _(PTP clock)_: : @@ -218,7 +219,7 @@ function dispatch(form) { let index = form.USE_NTP.selectedIndex; let cmd = index==1 ? (ptpd ? 'restart' : 'start') : 'stop'; save['#cfg'] = "/boot/config/plugins/dynamix/dynamix.cfg"; - save.PTP_SYNC = index==1 ? 'yes' : 'no'; + save.PTP_SYNC = index==1 ? 'yes' : 'no'; $(form).find('select[name^="display_"],select[name="NTP_POLL"],select[name^="PTP_"],input[name^="display_"],input[name^="PTP_"]').each(function(){ save[$(this).attr('name')] = $(this).val(); // exclude setting for emhttpd @@ -256,6 +257,7 @@ function updatePage(form,step) { // ntp $('#ptp-setup,#manual-setup').hide(step); $('#ntp-setup').show(step); + $('#noports').hide(); form.newDateTime.disabled=true; form.NTP_SERVER1.disabled=false; form.NTP_SERVER2.disabled=false; @@ -265,6 +267,11 @@ function updatePage(form,step) { // ptp $('#ntp-setup,#manual-setup').hide(step); $('#ptp-setup').show(step); + + $('#noports').show(); + + $('#noports').hide(); + if (form.PTP_MODE.selectedIndex==0) $('#unicast').hide(step); else $('#unicast').show(step); form.newDateTime.disabled=true; form.NTP_SERVER1.disabled=true; @@ -281,6 +288,7 @@ function updatePage(form,step) { // manual $('#ntp-setup,#ptp-setup').hide(step); $('#manual-setup').show(step); + $('#noports').hide(); form.newDateTime.disabled=false; form.NTP_SERVER1.disabled=true; form.NTP_SERVER2.disabled=true; @@ -295,7 +303,10 @@ $(function() { oldDate = form.display_date.selectedIndex; oldTime = form.display_time.selectedIndex; oldZone = form.timeZone.selectedIndex; - form.USE_NTP.selectedIndex = ; + form.USE_NTP.selectedIndex = ; + + if (form.USE_NTP.selectedIndex==1) $('#noports').show(); + updatePage(form); }); diff --git a/emhttp/plugins/dynamix/sheets/DateTime.css b/emhttp/plugins/dynamix/sheets/DateTime.css index b3012f111..22a0368b9 100644 --- a/emhttp/plugins/dynamix/sheets/DateTime.css +++ b/emhttp/plugins/dynamix/sheets/DateTime.css @@ -1,3 +1,3 @@ -div.extra,span.ipv4,span.ipv6,span.mac{display:none} +div.extra,span.ipv4,span.ipv6,span.mac,span#noports{display:none} select,input[type=text]{margin-right:40px} select[name=timeZone]{max-width:166px}