luci2: major changes to RPC implementation
[project/luci2/ui.git] / luci2 / htdocs / luci2 / view / status.processes.js
1 L.ui.view.extend({
2     title: L.tr('Processes'),
3     description: L.tr('This list gives an overview over currently running system processes and their status.'),
4     execute: function() {
5         var allow_signals = this.options.acls.status;
6         return L.system.getProcessList().then(function(list) {
7             var procTable = new L.ui.table({
8                 columns: [ {
9                     caption: L.tr('PID'),
10                     key:     'pid'
11                 }, {
12                     caption: L.tr('Owner'),
13                     key:     'user'
14                 }, {
15                     caption: L.tr('Command'),
16                     key:     'command'
17                 }, {
18                     caption: L.tr('CPU usage (%)'),
19                     key:     'cpu_percent',
20                     format:  '%d%%'
21                 }, {
22                     caption: L.tr('Memory usage (%)'),
23                     key:     'vsize_percent',
24                     format:  '%d%%'
25                 }, {
26                     key:    'pid',
27                     format: function(v, n) {
28                         return $('<button />')
29                             .attr('disabled', !allow_signals)
30                             .addClass('cbi-button')
31                             .addClass('cbi-button-reload')
32                             .text(L.tr('Hang Up'))
33                             .click(function() { L.system.sendSignal(v, 1).then(status) });
34                     }
35                 }, {
36                     key:    'pid',
37                     format: function(v, n) {
38                         return $('<button />')
39                             .attr('disabled', !allow_signals)
40                             .addClass('cbi-button')
41                             .addClass('cbi-button-remove')
42                             .text(L.tr('Terminate'))
43                             .click(function() { L.system.sendSignal(v, 15).then(status) });
44                     }
45                 }, {
46                     key:    'pid',
47                     format: function(v, n) {
48                         return $('<button />')
49                             .attr('disabled', !allow_signals)
50                             .addClass('cbi-button')
51                             .addClass('cbi-button-reset')
52                             .text(L.tr('Kill'))
53                             .click(function() { L.system.sendSignal(v, 9).then(status); });
54                     }
55                 } ]
56             });
57
58             procTable.rows(list);
59             procTable.insertInto('#process_table');
60         });
61     }
62 });