summaryrefslogtreecommitdiff
path: root/luci2/htdocs/luci2/view/system.cron.js
blob: c663e01a1f828ae4bfe97e292a505dcbce0fc151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
L.ui.view.extend({
	title: L.tr('Scheduled Tasks'),
	description: L.tr('This is the system crontab in which scheduled tasks can be defined.'),

	getCrontab: L.rpc.declare({
		object: 'luci2.system',
		method: 'crontab_get',
		expect: { data: '' }
	}),

	setCrontab: L.rpc.declare({
		object: 'luci2.system',
		method: 'crontab_set',
		params: [ 'data' ]
	}),

	execute: function() {
		var self = this;
		var allow_write = this.options.acls.cron;

		return self.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);
				self.setCrontab(data).then(function() {
					$('textarea').val(data);
					L.ui.loading(false);
				});
			});
		});
	}
});