mirror of
https://git.openwrt.org/project/luci.git
synced 2025-10-14 01:32:18 +08:00
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 <jjm2473@gmail.com>
This commit is contained in:

committed by
Paul Donald

parent
5425cc9e5f
commit
01b4cf0864
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user