Skip to content

Commit 8d89aa1

Browse files
authored
Merge pull request #8002 from TDT-AG/pr/20251010-luci-mod-network
luci-mod-network: show stop button if interface start is pending
2 parents ad6591f + b4d5ca6 commit 8d89aa1

File tree

2 files changed

+61
-9
lines changed
  • modules
    • luci-base/htdocs/luci-static/resources
    • luci-mod-network/htdocs/luci-static/resources/view/network

2 files changed

+61
-9
lines changed

modules/luci-base/htdocs/luci-static/resources/network.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,6 +2560,16 @@ Protocol = baseclass.extend(/** @lends LuCI.network.Protocol.prototype */ {
25602560
return (this._ubus('dynamic') == true);
25612561
},
25622562

2563+
/**
2564+
* Checks whether this logical interface is pending.
2565+
*
2566+
* @returns {boolean}
2567+
* returns `true` when the interface is pending or `false` when it is not.
2568+
*/
2569+
isPending: function() {
2570+
return (this._ubus('pending') == true);
2571+
},
2572+
25632573
/**
25642574
* Checks whether this interface is an alias interface.
25652575
*

modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ return view.extend({
269269
stat = document.querySelector('[id="%s-ifc-status"]'.format(ifc.getName())),
270270
resolveZone = render_ifacebox_status(box, ifc),
271271
disabled = ifc ? !ifc.isUp() : true,
272-
dynamic = ifc ? ifc.isDynamic() : false;
272+
dynamic = ifc ? ifc.isDynamic() : false,
273+
pending = ifc ? ifc.isPending() : false;
273274

274275
if (dsc.hasAttribute('reconnect')) {
275276
dom.content(dsc, E('em', _('Interface is starting...')));
@@ -305,8 +306,30 @@ return view.extend({
305306
]);
306307
}
307308

308-
btn1.disabled = isReadonlyView || btn1.classList.contains('spinning') || btn2.classList.contains('spinning') || dynamic;
309-
btn2.disabled = isReadonlyView || btn1.classList.contains('spinning') || btn2.classList.contains('spinning') || dynamic || disabled;
309+
if (isReadonlyView === true) {
310+
btn1.disabled = true;
311+
btn2.disabled = true;
312+
}
313+
else if (btn1.classList.contains('spinning') || btn2.classList.contains('spinning')) {
314+
btn1.disabled = true;
315+
btn2.disabled = true;
316+
}
317+
else if (dynamic === true) {
318+
btn1.disabled = true;
319+
btn2.disabled = true;
320+
}
321+
else if (pending === true) {
322+
btn1.disabled = true;
323+
btn2.disabled = false;
324+
}
325+
else if (disabled === true) {
326+
btn1.disabled = false;
327+
btn2.disabled = true;
328+
}
329+
else {
330+
btn1.disabled = false;
331+
btn2.disabled = false;
332+
}
310333
}
311334

312335
document.querySelectorAll('.port-status-device[data-device]').forEach(function(node) {
@@ -482,34 +505,53 @@ return view.extend({
482505
var tdEl = this.super('renderRowActions', [ section_id, _('Edit') ]),
483506
net = this.networks.filter(function(n) { return n.getName() == section_id })[0],
484507
disabled = net ? !net.isUp() : true,
485-
dynamic = net ? net.isDynamic() : false;
508+
dynamic = net ? net.isDynamic() : false,
509+
pending = net ? net.isPending() : false;
486510

487511
dom.content(tdEl.lastChild, [
488512
E('button', {
489513
'class': 'cbi-button cbi-button-neutral reconnect',
490514
'click': iface_updown.bind(this, true, section_id),
491515
'title': _('Reconnect this interface'),
492-
'disabled': dynamic ? 'disabled' : null
493516
}, _('Restart')),
494517
E('button', {
495518
'class': 'cbi-button cbi-button-neutral down',
496519
'click': iface_updown.bind(this, false, section_id),
497520
'title': _('Shutdown this interface'),
498-
'disabled': (dynamic || disabled) ? 'disabled' : null
499521
}, _('Stop')),
500522
tdEl.lastChild.firstChild,
501523
tdEl.lastChild.lastChild
502524
]);
503525

504526
if (!dynamic && net && !uci.get('network', net.getName())) {
505527
tdEl.lastChild.childNodes[0].disabled = true;
528+
tdEl.lastChild.childNodes[1].disabled = true;
506529
tdEl.lastChild.childNodes[2].disabled = true;
507530
tdEl.lastChild.childNodes[3].disabled = true;
508531
}
509-
510-
if (dynamic) {
511-
//disable the 'Edit' button on dynamic interfaces
532+
else if(dynamic === true) {
533+
tdEl.lastChild.childNodes[0].disabled = true;
534+
tdEl.lastChild.childNodes[1].disabled = true;
512535
tdEl.lastChild.childNodes[2].disabled = true;
536+
tdEl.lastChild.childNodes[3].disabled = true;
537+
}
538+
else if(pending === true) {
539+
tdEl.lastChild.childNodes[0].disabled = true;
540+
tdEl.lastChild.childNodes[1].disabled = false;
541+
tdEl.lastChild.childNodes[2].disabled = false;
542+
tdEl.lastChild.childNodes[3].disabled = false;
543+
}
544+
else if (disabled === true){
545+
tdEl.lastChild.childNodes[0].disabled = false;
546+
tdEl.lastChild.childNodes[1].disabled = true;
547+
tdEl.lastChild.childNodes[2].disabled = false;
548+
tdEl.lastChild.childNodes[3].disabled = false;
549+
}
550+
else {
551+
tdEl.lastChild.childNodes[0].disabled = false;
552+
tdEl.lastChild.childNodes[1].disabled = false;
553+
tdEl.lastChild.childNodes[2].disabled = false;
554+
tdEl.lastChild.childNodes[3].disabled = false;
513555
}
514556

515557
return tdEl;

0 commit comments

Comments
 (0)