2 title
: L
.tr('Startup'),
4 getRcLocal
: L
.rpc
.declare({
5 object
: 'luci2.system',
10 setRcLocal
: L
.rpc
.declare({
11 object
: 'luci2.system',
12 method
: 'rclocal_set',
18 var redraw = function() { return self
.execute(); };
19 var allow_write
= self
.options
.acls
.startup
;
22 L
.system
.initList().then(function(list
) {
23 /* filter init scripts with no start prio */
24 for (var i
= 0; i
< list
.length
; i
++)
26 if (typeof(list
[i
].start
) != 'undefined')
32 var initTable
= new L
.ui
.table({
34 caption
: L
.tr('Start priority'),
37 caption
: L
.tr('Initscript'),
41 format: function(v
, n
) {
44 .addClass('btn-group pull-right')
45 .append($('<button />')
46 .attr('disabled', !allow_write
)
47 .attr('name', list
[n
].name
)
48 .addClass('btn btn-sm')
49 .addClass(v
? 'btn-success' : 'btn-danger')
50 .text(v
? L
.trc('Init script state', 'Enabled') : L
.trc('Init script state', 'Disabled'))
54 L
.system
.initDisable(this.getAttribute('name')).then(redraw
);
56 L
.system
.initEnable(this.getAttribute('name')).then(redraw
);
58 .append($('<button />')
59 .addClass('btn btn-primary btn-sm dropdown-toggle')
60 .attr('data-toggle', 'dropdown')
61 .attr('disabled', !allow_write
)
62 .text(L
.tr('Action…')))
64 .addClass('dropdown-menu pull-right')
69 .click(function(ev
) { L
.system
.initReload(v
).then(redraw
); ev
.preventDefault(); })))
73 .text(L
.tr('Restart'))
74 .click(function(ev
) { L
.system
.initRestart(v
).then(redraw
); ev
.preventDefault(); })))
79 .click(function(ev
) { L
.system
.initStop(v
).then(redraw
); ev
.preventDefault(); }))))
86 initTable
.insertInto('#init_table');
90 self
.getRcLocal().then(function(data
) {
91 $('textarea').val(data
).attr('disabled', !allow_write
);
92 $('input.cbi-button-save').attr('disabled', !allow_write
).click(function() {
93 var data
= ($('textarea').val() || '').replace(/\r/g, '').replace(/\n?$/, '\n');
95 self
.setRcLocal(data
).then(function() {
96 $('textarea').val(data
);