diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-10-02 19:58:09 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-10-07 11:53:39 +0200 |
commit | 811012cab56099cafb68ac98a08c01e28d3e42ad (patch) | |
tree | 9e0acc1adc03dc0f2e689970401cf76f73d57c3e /modules/luci-mod-system | |
parent | 807dd506402624ef36d0cd5b7221099d0e2a3e4c (diff) |
luci-mod-system: startup.js: use common fs.js class
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-system')
-rw-r--r-- | modules/luci-mod-system/htdocs/luci-static/resources/view/system/startup.js | 23 |
1 files changed, 4 insertions, 19 deletions
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 77f61d607..07eede2f0 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,5 +1,6 @@ 'use strict'; 'require rpc'; +'require fs'; return L.view.extend({ callInitList: rpc.declare({ @@ -15,22 +16,9 @@ return L.view.extend({ expect: { result: false } }), - callFileRead: rpc.declare({ - object: 'file', - method: 'read', - params: [ 'path' ], - expect: { data: '' } - }), - - callFileWrite: rpc.declare({ - object: 'file', - method: 'write', - params: [ 'path', 'data' ] - }), - load: function() { return Promise.all([ - this.callFileRead('/etc/rc.local'), + L.resolveDefault(fs.read('/etc/rc.local'), ''), this.callInitList() ]); }, @@ -58,14 +46,11 @@ return L.view.extend({ handleRcLocalSave: function(ev) { var value = (document.querySelector('textarea').value || '').trim().replace(/\r\n/g, '\n') + '\n'; - return this.callFileWrite('/etc/rc.local', value).then(function(rc) { - if (rc != 0) - throw rpc.getStatusText(rc); - + 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'); }).catch(function(e) { - L.ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e))); + L.ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); }); }, |