2019-09-12 16:48:58 +00:00
|
|
|
'use strict';
|
2020-04-03 08:00:06 +00:00
|
|
|
'require view';
|
2019-10-02 17:45:36 +00:00
|
|
|
'require fs';
|
2019-11-03 20:54:40 +00:00
|
|
|
'require ui';
|
2019-09-12 16:48:58 +00:00
|
|
|
|
2020-04-16 13:33:02 +00:00
|
|
|
var isReadonlyView = !L.hasViewPermission() || null;
|
|
|
|
|
2020-04-03 08:00:06 +00:00
|
|
|
return view.extend({
|
2019-09-12 16:48:58 +00:00
|
|
|
load: function() {
|
2019-10-02 17:45:36 +00:00
|
|
|
return L.resolveDefault(fs.read('/etc/crontabs/root'), '');
|
2019-09-12 16:48:58 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
handleSave: function(ev) {
|
|
|
|
var value = (document.querySelector('textarea').value || '').trim().replace(/\r\n/g, '\n') + '\n';
|
|
|
|
|
2019-10-02 17:45:36 +00:00
|
|
|
return fs.write('/etc/crontabs/root', value).then(function(rc) {
|
2019-09-12 16:48:58 +00:00
|
|
|
document.querySelector('textarea').value = value;
|
2019-11-03 20:54:40 +00:00
|
|
|
ui.addNotification(null, E('p', _('Contents have been saved.')), 'info');
|
2019-09-12 16:48:58 +00:00
|
|
|
}).catch(function(e) {
|
2019-11-03 20:54:40 +00:00
|
|
|
ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
|
2019-09-12 16:48:58 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function(crontab) {
|
|
|
|
return E([
|
|
|
|
E('h2', _('Scheduled Tasks')),
|
2020-03-23 20:56:55 +00:00
|
|
|
E('p', { 'class': 'cbi-section-descr' },
|
2019-09-12 16:48:58 +00:00
|
|
|
_('This is the system crontab in which scheduled tasks can be defined.') +
|
|
|
|
_('<br/>Note: you need to manually restart the cron service if the crontab file was empty before editing.')),
|
2020-04-16 13:33:02 +00:00
|
|
|
E('p', {}, E('textarea', { 'style': 'width:100%', 'rows': 10, 'disabled': isReadonlyView }, [ crontab != null ? crontab : '' ]))
|
2019-09-12 16:48:58 +00:00
|
|
|
]);
|
2019-09-18 05:23:01 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
handleSaveApply: null,
|
|
|
|
handleReset: null
|
2019-09-12 16:48:58 +00:00
|
|
|
});
|