]> git.proxmox.com Git - proxmox-backup.git/blob - www/dashboard/RunningTasks.js
9b53d1becc18bc482fbc1a827ba960ed8a660e3b
[proxmox-backup.git] / www / dashboard / RunningTasks.js
1 Ext.define('PBS.RunningTasks', {
2 extend: 'Ext.grid.Panel',
3 alias: 'widget.pbsRunningTasks',
4
5 title: gettext('Running Tasks'),
6 emptyText: gettext('No running tasks'),
7
8 hideHeaders: true,
9 rowLines: false,
10
11 controller: {
12 xclass: 'Ext.app.ViewController',
13
14 openTask: function(record) {
15 let me = this;
16 let view = me.getView();
17 Ext.create('Proxmox.window.TaskViewer', {
18 upid: record.data.upid,
19 endtime: record.data.endtime,
20 }).show();
21 },
22
23 openTaskItemDblClick: function(grid, record) {
24 this.openTask(record);
25 },
26
27 openTaskActionColumn: function(grid, rowIndex) {
28 this.openTask(grid.getStore().getAt(rowIndex));
29 },
30
31 render_status: function(value) {
32 let cls = 'times-circle critical';
33 if (value === 'OK') {
34 cls = 'check-circle good';
35 } else if (value.startsWith('WARNINGS:')) {
36 cls = 'exclamation-circle warning';
37 } else if (value === 'unknown') {
38 cls = 'question-circle faded';
39 }
40
41 return `<i class="fa fa-${cls}"></i>`;
42 },
43 },
44
45 updateTasks: function(data) {
46 let me = this;
47 me.getStore().setData(data);
48 },
49
50 listeners: {
51 itemdblclick: 'openTaskItemDblClick',
52 },
53
54 store: {
55 type: 'diff',
56 autoDestroy: true,
57 autoDestroyRstore: true,
58 sorters: 'starttime',
59 rstore: {
60 type: 'update',
61 autoStart: true,
62 interval: 3000,
63 storeid: 'pbs-running-tasks-dash',
64 model: 'proxmox-tasks',
65 proxy: {
66 type: 'proxmox',
67 // maybe separate api call?
68 url: '/api2/json/nodes/localhost/tasks?running=1'
69 },
70 },
71 },
72
73 columns: [
74 {
75 text: 'Task',
76 dataIndex: 'upid',
77 renderer: Proxmox.Utils.render_upid,
78 flex: 2,
79 },
80 {
81 text: 'Starttime',
82 dataIndex: 'starttime',
83 renderer: function(value) {
84 return Ext.Date.format(value, "Y-m-d H:i:s");
85 },
86 flex: 1,
87 },
88 {
89 text: 'Duration',
90 dataIndex: 'duration',
91 renderer: function(value, md, record) {
92 return Proxmox.Utils.format_duration_human((Date.now() - record.data.starttime)/1000);
93 }
94 },
95 {
96 xtype: 'actioncolumn',
97 width: 40,
98 items: [
99 {
100 iconCls: 'fa fa-chevron-right',
101 tooltip: gettext('Open Task'),
102 handler: 'openTaskActionColumn',
103 },
104 ],
105 },
106 ],
107 });
108