diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-11-03 21:54:40 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-11-03 21:55:50 +0100 |
commit | 86f492173d1daab8b75e4d4bd70ba06872ea70fa (patch) | |
tree | 3a64f76424681b0a0bb613c6966079a530ffd057 /modules/luci-mod-system/htdocs/luci-static | |
parent | b2a46e131b778ae14156676de8daf8231ab8e151 (diff) |
treewide: require ui.js explicitly
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-system/htdocs/luci-static')
6 files changed, 55 insertions, 49 deletions
diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/crontab.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/crontab.js index bb0dd41f99..c2ab770c51 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/crontab.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/crontab.js @@ -1,5 +1,6 @@ 'use strict'; 'require fs'; +'require ui'; return L.view.extend({ load: function() { @@ -11,9 +12,9 @@ return L.view.extend({ return fs.write('/etc/crontabs/root', value).then(function(rc) { document.querySelector('textarea').value = value; - L.ui.addNotification(null, E('p', _('Contents have been saved.')), 'info'); + ui.addNotification(null, E('p', _('Contents have been saved.')), 'info'); }).catch(function(e) { - L.ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); + ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); }); }, diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js index 440ed9acc8..05e1434f15 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js @@ -2,6 +2,7 @@ 'require form'; 'require rpc'; 'require fs'; +'require ui'; var callSystemValidateFirmwareImage = rpc.declare({ object: 'system', @@ -89,46 +90,46 @@ return L.view.extend({ if (!confirm(_('Do you really want to erase all settings?'))) return; - L.ui.showModal(_('Erasing...'), [ + ui.showModal(_('Erasing...'), [ E('p', { 'class': 'spinning' }, _('The system is erasing the configuration partition now and will reboot itself when finished.')) ]); /* Currently the sysupgrade rpc call will not return, hence no promise handling */ fs.exec('/sbin/firstboot', [ '-r', '-y' ]); - L.ui.awaitReconnect('192.168.1.1', 'openwrt.lan'); + ui.awaitReconnect('192.168.1.1', 'openwrt.lan'); }, handleRestore: function(ev) { - return L.ui.uploadFile('/tmp/backup.tar.gz', ev.target) + return ui.uploadFile('/tmp/backup.tar.gz', ev.target) .then(L.bind(function(btn, res) { btn.firstChild.data = _('Checking archive…'); return fs.exec('/bin/tar', [ '-tzf', '/tmp/backup.tar.gz' ]); }, this, ev.target)) .then(L.bind(function(btn, res) { if (res.code != 0) { - L.ui.addNotification(null, E('p', _('The uploaded backup archive is not readable'))); + ui.addNotification(null, E('p', _('The uploaded backup archive is not readable'))); return fs.remove('/tmp/backup.tar.gz'); } - L.ui.showModal(_('Apply backup?'), [ + ui.showModal(_('Apply backup?'), [ E('p', _('The uploaded backup archive appears to be valid and contains the files listed below. Press "Continue" to restore the backup and reboot, or "Cancel" to abort the operation.')), E('pre', {}, [ res.stdout ]), E('div', { 'class': 'right' }, [ E('button', { 'class': 'btn', - 'click': L.ui.createHandlerFn(this, function(ev) { - return fs.remove('/tmp/backup.tar.gz').finally(L.ui.hideModal); + 'click': ui.createHandlerFn(this, function(ev) { + return fs.remove('/tmp/backup.tar.gz').finally(ui.hideModal); }) }, [ _('Cancel') ]), ' ', E('button', { 'class': 'btn cbi-button-action important', - 'click': L.ui.createHandlerFn(this, 'handleRestoreConfirm', btn) + 'click': ui.createHandlerFn(this, 'handleRestoreConfirm', btn) }, [ _('Continue') ]) ]) ]); }, this, ev.target)) - .catch(function(e) { L.ui.addNotification(null, E('p', e.message)) }) + .catch(function(e) { ui.addNotification(null, E('p', e.message)) }) .finally(L.bind(function(btn, input) { btn.firstChild.data = _('Upload archive...'); }, this, ev.target)); @@ -138,7 +139,7 @@ return L.view.extend({ return fs.exec('/sbin/sysupgrade', [ '--restore-backup', '/tmp/backup.tar.gz' ]) .then(L.bind(function(btn, res) { if (res.code != 0) { - L.ui.addNotification(null, [ + ui.addNotification(null, [ E('p', _('The restore command failed with code %d').format(res.code)), res.stderr ? E('pre', {}, [ res.stderr ]) : '' ]); @@ -150,17 +151,17 @@ return L.view.extend({ }, this, ev.target)) .then(L.bind(function(res) { if (res.code != 0) { - L.ui.addNotification(null, E('p', _('The reboot command failed with code %d').format(res.code))); + ui.addNotification(null, E('p', _('The reboot command failed with code %d').format(res.code))); L.raise('Error', 'Reboot failed'); } - L.ui.showModal(_('Rebooting…'), [ + ui.showModal(_('Rebooting…'), [ E('p', { 'class': 'spinning' }, _('The system is rebooting now. If the restored configuration changed the current LAN IP address, you might need to reconnect manually.')) ]); - L.ui.awaitReconnect(window.location.host, '192.168.1.1', 'openwrt.lan'); + ui.awaitReconnect(window.location.host, '192.168.1.1', 'openwrt.lan'); }, this)) - .catch(function(e) { L.ui.addNotification(null, E('p', e.message)) }) + .catch(function(e) { ui.addNotification(null, E('p', e.message)) }) .finally(function() { btn.firstChild.data = _('Upload archive...') }); }, @@ -183,11 +184,11 @@ return L.view.extend({ }, handleSysupgrade: function(storage_size, ev) { - return L.ui.uploadFile('/tmp/firmware.bin', ev.target.firstChild) + return ui.uploadFile('/tmp/firmware.bin', ev.target.firstChild) .then(L.bind(function(btn, reply) { btn.firstChild.data = _('Checking image…'); - L.ui.showModal(_('Checking image…'), [ + ui.showModal(_('Checking image…'), [ E('span', { 'class': 'spinning' }, _('Verifying the uploaded image file.')) ]); @@ -254,15 +255,15 @@ return L.view.extend({ var cntbtn = E('button', { 'class': 'btn cbi-button-action important', - 'click': L.ui.createHandlerFn(this, 'handleSysupgradeConfirm', btn, keep, force), + 'click': ui.createHandlerFn(this, 'handleSysupgradeConfirm', btn, keep, force), 'disabled': (!is_valid || is_too_big) ? true : null }, [ _('Continue') ]); body.push(E('div', { 'class': 'right' }, [ E('button', { 'class': 'btn', - 'click': L.ui.createHandlerFn(this, function(ev) { - return fs.remove('/tmp/firmware.bin').finally(L.ui.hideModal); + 'click': ui.createHandlerFn(this, function(ev) { + return fs.remove('/tmp/firmware.bin').finally(ui.hideModal); }) }, [ _('Cancel') ]), ' ', cntbtn ])); @@ -271,9 +272,9 @@ return L.view.extend({ cntbtn.disabled = !ev.target.checked; }); - L.ui.showModal(_('Flash image?'), body); + ui.showModal(_('Flash image?'), body); }, this, ev.target)) - .catch(function(e) { L.ui.addNotification(null, E('p', e.message)) }) + .catch(function(e) { ui.addNotification(null, E('p', e.message)) }) .finally(L.bind(function(btn) { btn.firstChild.data = _('Flash image...'); }, this, ev.target)); @@ -282,7 +283,7 @@ return L.view.extend({ handleSysupgradeConfirm: function(btn, keep, force, ev) { btn.firstChild.data = _('Flashing…'); - L.ui.showModal(_('Flashing…'), [ + ui.showModal(_('Flashing…'), [ E('p', { 'class': 'spinning' }, _('The system is flashing now.<br /> DO NOT POWER OFF THE DEVICE!<br /> Wait a few minutes before you try to reconnect. It might be necessary to renew the address of your computer to reach the device again, depending on your settings.')) ]); @@ -300,28 +301,28 @@ return L.view.extend({ fs.exec('/sbin/sysupgrade', opts); if (keep.checked) - L.ui.awaitReconnect(window.location.host); + ui.awaitReconnect(window.location.host); else - L.ui.awaitReconnect('192.168.1.1', 'openwrt.lan'); + ui.awaitReconnect('192.168.1.1', 'openwrt.lan'); }, handleBackupList: function(ev) { return fs.exec('/sbin/sysupgrade', [ '--list-backup' ]).then(function(res) { if (res.code != 0) { - L.ui.addNotification(null, [ + ui.addNotification(null, [ E('p', _('The sysupgrade command failed with code %d').format(res.code)), res.stderr ? E('pre', {}, [ res.stderr ]) : '' ]); L.raise('Error', 'Sysupgrade failed'); } - L.ui.showModal(_('Backup file list'), [ + ui.showModal(_('Backup file list'), [ E('p', _('Below is the determined list of files to backup. It consists of changed configuration files marked by opkg, essential base files and the user defined backup patterns.')), E('ul', {}, (res.stdout || '').trim().split(/\n/).map(function(ln) { return E('li', {}, ln) })), E('div', { 'class': 'right' }, [ E('button', { 'class': 'btn', - 'click': L.ui.hideModal + 'click': ui.hideModal }, [ _('Dismiss') ]) ]) ], 'cbi-modal'); @@ -332,9 +333,9 @@ return L.view.extend({ return m.save(function() { return fs.write('/etc/sysupgrade.conf', mapdata.config.editlist.trim().replace(/\r\n/g, '\n') + '\n'); }).then(function() { - L.ui.addNotification(null, E('p', _('Contents have been saved.')), 'info'); + ui.addNotification(null, E('p', _('Contents have been saved.')), 'info'); }).catch(function(e) { - L.ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e))); + ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e))); }); }, @@ -419,7 +420,7 @@ return L.view.extend({ node.appendChild(E('div', { 'class': 'cbi-page-actions' }, [ E('button', { 'class': 'cbi-button cbi-button-save', - 'click': L.ui.createHandlerFn(view, 'handleBackupSave', this.map) + 'click': ui.createHandlerFn(view, 'handleBackupSave', this.map) }, [ _('Save') ]) ])); diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/mounts.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/mounts.js index b4f5cf71a5..ec5d44cad0 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/mounts.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/mounts.js @@ -1,5 +1,6 @@ 'use strict'; 'require fs'; +'require ui'; 'require uci'; 'require rpc'; 'require form'; @@ -79,7 +80,7 @@ return L.view.extend({ return fs.exec('/sbin/block', ['mount']) .then(function(res) { if (res.code != 0) - L.ui.addNotification(null, E('p', _('The <em>block mount</em> command failed with code %d').format(res.code))); + ui.addNotification(null, E('p', _('The <em>block mount</em> command failed with code %d').format(res.code))); }) .then(L.bind(uci.unload, uci, 'fstab')) .then(L.bind(m.render, m)); @@ -89,7 +90,7 @@ return L.view.extend({ return fs.exec('/bin/umount', [path]) .then(L.bind(uci.unload, uci, 'fstab')) .then(L.bind(m.render, m)) - .catch(function(e) { L.ui.addNotification(null, E('p', e.message)) }); + .catch(function(e) { ui.addNotification(null, E('p', e.message)) }); }, load: function() { @@ -210,7 +211,7 @@ return L.view.extend({ '%.2f%% (%1024.2mB)'.format(100 / this.mounts[i].size * used, used), umount ? E('button', { 'class': 'btn cbi-button-remove', - 'click': L.ui.createHandlerFn(view, 'handleUmount', m, this.mounts[i].mount) + 'click': ui.createHandlerFn(view, 'handleUmount', m, this.mounts[i].mount) }, [ _('Unmount') ]) : '-' ]); } diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/password.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/password.js index 6c5ffa1b26..c3d317062f 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/password.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/password.js @@ -1,4 +1,5 @@ 'use strict'; +'require ui'; 'require form'; 'require rpc'; @@ -71,15 +72,15 @@ return L.view.extend({ return; if (formData.password.pw1 != formData.password.pw2) { - L.ui.addNotification(null, E('p', _('Given password confirmation did not match, password not changed!')), 'danger'); + ui.addNotification(null, E('p', _('Given password confirmation did not match, password not changed!')), 'danger'); return; } return callSetPassword('root', formData.password.pw1).then(function(success) { if (success) - L.ui.addNotification(null, E('p', _('The system password has been successfully changed.')), 'info'); + ui.addNotification(null, E('p', _('The system password has been successfully changed.')), 'info'); else - L.ui.addNotification(null, E('p', _('Failed to change the system password.')), 'danger'); + ui.addNotification(null, E('p', _('Failed to change the system password.')), 'danger'); formData.password.pw1 = null; formData.password.pw2 = null; diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/startup.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/startup.js index 07eede2f07..560282de77 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/startup.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/startup.js @@ -1,6 +1,7 @@ 'use strict'; 'require rpc'; 'require fs'; +'require ui'; return L.view.extend({ callInitList: rpc.declare({ @@ -30,7 +31,7 @@ return L.view.extend({ return true; }).catch(function(e) { - L.ui.addNotification(null, E('p', _('Failed to execute "/etc/init.d/%s %s" action: %s').format(name, action, e))); + ui.addNotification(null, E('p', _('Failed to execute "/etc/init.d/%s %s" action: %s').format(name, action, e))); }); }, @@ -48,16 +49,16 @@ return L.view.extend({ return fs.write('/etc/rc.local', value).then(function() { document.querySelector('textarea').value = value; - L.ui.addNotification(null, E('p', _('Contents have been saved.')), 'info'); + ui.addNotification(null, E('p', _('Contents have been saved.')), 'info'); }).catch(function(e) { - L.ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); + ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); }); }, renderEnableDisable: function(init) { return E('button', { class: 'btn cbi-button-%s'.format(init.enabled ? 'positive' : 'negative'), - click: L.ui.createHandlerFn(this, 'handleEnableDisable', init.name, init.enabled) + click: ui.createHandlerFn(this, 'handleEnableDisable', init.name, init.enabled) }, init.enabled ? _('Enabled') : _('Disabled')); }, @@ -93,9 +94,9 @@ return L.view.extend({ '%02d'.format(list[i].index), list[i].name, this.renderEnableDisable(list[i]), - E('button', { 'class': 'btn cbi-button-action', 'click': L.ui.createHandlerFn(this, 'handleAction', list[i].name, 'start') }, _('Start')), - E('button', { 'class': 'btn cbi-button-action', 'click': L.ui.createHandlerFn(this, 'handleAction', list[i].name, 'restart') }, _('Restart')), - E('button', { 'class': 'btn cbi-button-action', 'click': L.ui.createHandlerFn(this, 'handleAction', list[i].name, 'stop') }, _('Stop')) + E('button', { 'class': 'btn cbi-button-action', 'click': ui.createHandlerFn(this, 'handleAction', list[i].name, 'start') }, _('Start')), + E('button', { 'class': 'btn cbi-button-action', 'click': ui.createHandlerFn(this, 'handleAction', list[i].name, 'restart') }, _('Restart')), + E('button', { 'class': 'btn cbi-button-action', 'click': ui.createHandlerFn(this, 'handleAction', list[i].name, 'stop') }, _('Stop')) ]); } @@ -114,14 +115,14 @@ return L.view.extend({ E('div', { 'class': 'cbi-page-actions' }, [ E('button', { 'class': 'btn cbi-button-save', - 'click': L.ui.createHandlerFn(this, 'handleRcLocalSave') + 'click': ui.createHandlerFn(this, 'handleRcLocalSave') }, _('Save')) ]) ]) ]) ]); - L.ui.tabs.initTabGroup(view.lastElementChild.childNodes); + ui.tabs.initTabGroup(view.lastElementChild.childNodes); return view; }, diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js index 492784cc95..ccc9342cc6 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js @@ -1,4 +1,5 @@ 'use strict'; +'require ui'; 'require uci'; 'require rpc'; 'require form'; @@ -58,14 +59,14 @@ CBILocalTime = form.DummyValue.extend({ ' ', E('button', { 'class': 'cbi-button cbi-button-apply', - 'click': L.ui.createHandlerFn(this, function() { + 'click': ui.createHandlerFn(this, function() { return callSetLocaltime(Math.floor(Date.now() / 1000)); }) }, _('Sync with browser')), ' ', this.ntpd_support ? E('button', { 'class': 'cbi-button cbi-button-apply', - 'click': L.ui.createHandlerFn(this, function() { + 'click': ui.createHandlerFn(this, function() { return callInitAction('sysntpd', 'restart'); }) }, _('Sync with NTP-Server')) : '' |