From 01b4cf0864fbcdbd11d5acb8ac3af87ef2533646 Mon Sep 17 00:00:00 2001 From: Liangbin Lian Date: Wed, 6 Aug 2025 12:13:06 +0800 Subject: [PATCH] luci-app-ddns: fix toggle button not working `this.callInitAction('ddns', 'enable')` always return true, cause ddns service always disabled later. Signed-off-by: Liangbin Lian --- .../luci-static/resources/view/ddns/overview.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js b/applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js index f87931ec59..6a5afc9b79 100644 --- a/applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js +++ b/applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js @@ -59,6 +59,8 @@ return view.extend({ services: {}, + status: {}, + /* * Services list is generated by 3 different sources: * 1. /usr/share/ddns/default contains the service installed by package-manager @@ -178,9 +180,9 @@ return view.extend({ }, handleToggleDDns: function(m, ev) { - return this.callInitAction('ddns', 'enable') - .then(L.bind(function (action) { return this.callInitAction('ddns', action ? 'disable' : 'enable')}, this)) - .then(L.bind(function (action) { return this.callInitAction('ddns', action ? 'stop' : 'start')}, this)) + let action = this.status['_enabled']; + return this.callInitAction('ddns', action ? 'disable' : 'enable') + .then(L.bind(function () { return this.callInitAction('ddns', action ? 'stop' : 'start')}, this)) .then(L.bind(m.render, m)) .catch(function(e) { ui.addNotification(null, E('p', e.message)) }); }, @@ -191,12 +193,13 @@ return view.extend({ }, poll_status: function(map, data) { - var status = data[1] || [], service = data[0] || [], rows = map.querySelectorAll('.cbi-section-table-row[data-sid]'), + var status = this.status = data[1] || []; + var service = data[0] || [], rows = map.querySelectorAll('.cbi-section-table-row[data-sid]'), ddns_enabled = map.querySelector('[data-name="_enabled"]').querySelector('.cbi-value-field'), ddns_toggle = map.querySelector('[data-name="_toggle"]').querySelector('button'), services_list = map.querySelector('[data-name="_services_list"]').querySelector('.cbi-value-field'); - ddns_toggle.innerHTML = status['_enabled'] ? _('Stop DDNS') : _('Start DDNS') + ddns_toggle.innerHTML = status['_enabled'] ? _('Stop DDNS') : _('Start DDNS'); services_list.innerHTML = status['_services_list']; dom.content(ddns_enabled, function() { @@ -249,7 +252,7 @@ return view.extend({ render: function(data) { var resolved = data[0] || []; - var status = data[1] || []; + var status = this.status = data[1] || []; var env = data[2] || []; var logdir = uci.get('ddns', 'global', 'ddns_logdir') || "/var/log/ddns"; var wan_interface = data[5]; @@ -282,7 +285,7 @@ return view.extend({ o = s.taboption('info', form.Button, '_toggle'); o.title = ' '; - o.inputtitle = _((status['_enabled'] ? 'stop' : 'start').toUpperCase() + ' DDns'); + o.inputtitle = _((status['_enabled'] ? 'Stop' : 'Start') + ' DDNS'); o.inputstyle = 'apply'; o.onclick = L.bind(this.handleToggleDDns, this, m); -- 2.30.2