luci-mod-system: sshkeys.js: explicitely require ui.js
While ui.js is implicitely autoloaded by other classes, we need to require it directly in the view to avoid race conditions during rendering. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
284918bfaf
commit
54163c95e1
1 changed files with 8 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
'require fs';
|
'require fs';
|
||||||
|
'require ui';
|
||||||
|
|
||||||
var SSHPubkeyDecoder = L.Class.singleton({
|
var SSHPubkeyDecoder = L.Class.singleton({
|
||||||
lengthDecode: function(s, off)
|
lengthDecode: function(s, off)
|
||||||
|
@ -119,8 +120,8 @@ function renderKeys(keys) {
|
||||||
function saveKeys(keys) {
|
function saveKeys(keys) {
|
||||||
return fs.write('/etc/dropbear/authorized_keys', keys.join('\n') + '\n', 384 /* 0600 */)
|
return fs.write('/etc/dropbear/authorized_keys', keys.join('\n') + '\n', 384 /* 0600 */)
|
||||||
.then(renderKeys.bind(this, keys))
|
.then(renderKeys.bind(this, keys))
|
||||||
.catch(function(e) { L.ui.addNotification(null, E('p', e.message)) })
|
.catch(function(e) { ui.addNotification(null, E('p', e.message)) })
|
||||||
.finally(L.ui.hideModal);
|
.finally(ui.hideModal);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addKey(ev) {
|
function addKey(ev) {
|
||||||
|
@ -138,13 +139,13 @@ function addKey(ev) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (keys.indexOf(key) !== -1) {
|
if (keys.indexOf(key) !== -1) {
|
||||||
L.ui.showModal(_('Add key'), [
|
ui.showModal(_('Add key'), [
|
||||||
E('div', { class: 'alert-message warning' }, _('The given SSH public key has already been added.')),
|
E('div', { class: 'alert-message warning' }, _('The given SSH public key has already been added.')),
|
||||||
E('div', { class: 'right' }, E('div', { class: 'btn', click: L.hideModal }, _('Close')))
|
E('div', { class: 'right' }, E('div', { class: 'btn', click: L.hideModal }, _('Close')))
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else if (!pubkey) {
|
else if (!pubkey) {
|
||||||
L.ui.showModal(_('Add key'), [
|
ui.showModal(_('Add key'), [
|
||||||
E('div', { class: 'alert-message warning' }, _('The given SSH public key is invalid. Please supply proper public RSA or ECDSA keys.')),
|
E('div', { class: 'alert-message warning' }, _('The given SSH public key is invalid. Please supply proper public RSA or ECDSA keys.')),
|
||||||
E('div', { class: 'right' }, E('div', { class: 'btn', click: L.hideModal }, _('Close')))
|
E('div', { class: 'right' }, E('div', { class: 'btn', click: L.hideModal }, _('Close')))
|
||||||
]);
|
]);
|
||||||
|
@ -178,7 +179,7 @@ function removeKey(ev) {
|
||||||
E('div', { class: 'right' }, [
|
E('div', { class: 'right' }, [
|
||||||
E('div', { class: 'btn', click: L.hideModal }, _('Cancel')),
|
E('div', { class: 'btn', click: L.hideModal }, _('Cancel')),
|
||||||
' ',
|
' ',
|
||||||
E('div', { class: 'btn danger', click: L.ui.createHandlerFn(this, saveKeys, keys) }, _('Delete key')),
|
E('div', { class: 'btn danger', click: ui.createHandlerFn(this, saveKeys, keys) }, _('Delete key')),
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -232,7 +233,7 @@ return L.view.extend({
|
||||||
}),
|
}),
|
||||||
E('button', {
|
E('button', {
|
||||||
'class': 'cbi-button',
|
'class': 'cbi-button',
|
||||||
'click': L.ui.createHandlerFn(this, addKey)
|
'click': ui.createHandlerFn(this, addKey)
|
||||||
}, _('Add key'))
|
}, _('Add key'))
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
|
@ -242,7 +243,7 @@ return L.view.extend({
|
||||||
if (pubkey)
|
if (pubkey)
|
||||||
list.insertBefore(E('div', {
|
list.insertBefore(E('div', {
|
||||||
class: 'item',
|
class: 'item',
|
||||||
click: L.ui.createHandlerFn(this, removeKey),
|
click: ui.createHandlerFn(this, removeKey),
|
||||||
'data-key': key
|
'data-key': key
|
||||||
}, [
|
}, [
|
||||||
E('strong', pubkey.comment || _('Unnamed key')), E('br'),
|
E('strong', pubkey.comment || _('Unnamed key')), E('br'),
|
||||||
|
|
Loading…
Reference in a new issue