- request.request(L.url('admin/uci', checked ? 'apply_rollback' : 'apply_unchecked'), {
- method: 'post',
- query: { sid: L.env.sessionid, token: L.env.token }
- }).then(function(r) {
- if (r.status === (checked ? 200 : 204)) {
- var tok = null; try { tok = r.json(); } catch(e) {}
- if (checked && tok !== null && typeof(tok) === 'object' && typeof(tok.token) === 'string')
- UI.prototype.changes.confirm_auth = tok;
-
- UI.prototype.changes.confirm(checked, Date.now() + L.env.apply_rollback * 1000);
- }
- else if (checked && r.status === 204) {
- UI.prototype.changes.displayStatus('notice',
- E('p', _('There are no changes to apply')));
+ (new Promise(function(resolveFn, rejectFn) {
+ if (!checked)
+ return resolveFn(false);
+
+ UI.prototype.changes.checkConnectivityAffected().then(function(affected) {
+ if (!affected)
+ return resolveFn(true);
+
+ UI.prototype.changes.displayStatus('warning', [
+ E('h4', _('Connectivity change')),
+ E('p', _('The network access to this device could be interrupted by changing settings of the "%h" interface.').format(affected)),
+ E('p', _('If the IP address used to access LuCI changes, a <strong>manual reconnect to the new IP</strong> is required within %d seconds to confirm the settings, otherwise modifications will be reverted.').format(L.env.apply_rollback)),
+ E('div', { 'class': 'right' }, [
+ E('button', {
+ 'class': 'btn',
+ 'click': rejectFn,
+ }, [ _('Cancel') ]), ' ',
+ E('button', {
+ 'class': 'btn cbi-button-action important',
+ 'click': resolveFn.bind(null, true)
+ }, [ _('Apply and revert on connectivity loss') ]), ' ',
+ E('button', {
+ 'class': 'btn cbi-button-negative important',
+ 'click': resolveFn.bind(null, false)
+ }, [ _('Apply and keep settings') ])
+ ])
+ ]);
+ });
+ })).then(function(checked) {
+ request.request(L.url('admin/uci', checked ? 'apply_rollback' : 'apply_unchecked'), {
+ method: 'post',
+ query: { sid: L.env.sessionid, token: L.env.token }
+ }).then(function(r) {
+ if (r.status === (checked ? 200 : 204)) {
+ var tok = null; try { tok = r.json(); } catch(e) {}
+ if (checked && tok !== null && typeof(tok) === 'object' && typeof(tok.token) === 'string')
+ UI.prototype.changes.confirm_auth = tok;
+
+ UI.prototype.changes.confirm(checked, Date.now() + L.env.apply_rollback * 1000);
+ }
+ else if (checked && r.status === 204) {
+ UI.prototype.changes.displayStatus('notice',
+ E('p', _('There are no changes to apply')));