summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-10-02 19:45:36 +0200
committerJo-Philipp Wich <jo@mein.io>2019-10-07 11:53:39 +0200
commit641c82cb21da3167e271045bc88c0db1110845c2 (patch)
tree56d3fc11aba017ac549f1e19a8af5b8e0c7e8f83 /modules
parentdf8078d54242a056d815210d5a0a0d51ef02a24a (diff)
luci-mod-system: crontab.js: use common fs.js class
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-mod-system/htdocs/luci-static/resources/view/system/crontab.js25
1 files changed, 4 insertions, 21 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 512f601eb..bb0dd41f9 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,36 +1,19 @@
'use strict';
-'require rpc';
+'require fs';
return L.view.extend({
- callFileRead: rpc.declare({
- object: 'file',
- method: 'read',
- params: [ 'path' ],
- expect: { data: '' }
- }),
-
- callFileWrite: rpc.declare({
- object: 'file',
- method: 'write',
- params: [ 'path', 'data' ]
- }),
-
load: function() {
- return this.callFileRead('/etc/crontabs/root');
+ return L.resolveDefault(fs.read('/etc/crontabs/root'), '');
},
handleSave: function(ev) {
var value = (document.querySelector('textarea').value || '').trim().replace(/\r\n/g, '\n') + '\n';
- return this.callFileWrite('/etc/crontabs/root', value).then(function(rc) {
- if (rc != 0)
- throw rpc.getStatusText(rc);
-
+ 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');
-
}).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)));
});
},