summaryrefslogtreecommitdiff
path: root/luci2/htdocs/luci2/view/system.cron.js
blob: aae4ce4bcbcecbfd8bf61dba88b78d3db2845077 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
L.ui.view.extend({
	title: L.tr('Scheduled Tasks'),
	description: L.tr('This is the system crontab in which scheduled tasks can be defined.'),
    execute: function() {
        var allow_write = this.options.acls.cron;

        return L.system.getCrontab().then(function(data) {
			$('textarea').val(data).attr('disabled', !allow_write);
			$('input.cbi-button-save').attr('disabled', !allow_write).click(function() {
				var data = ($('textarea').val() || '').replace(/\r/g, '').replace(/\n?$/, '\n');
				L.ui.loading(true);
				L.system.setCrontab(data).then(function() {
					$('textarea').val(data);
					L.ui.loading(false);
				});
			});
		});
    }
});