]> git.proxmox.com Git - proxmox-backup.git/blob - www/dashboard/RunningTasks.js
e31218efaf4bce3f80d4f1aceec2a38fce3655e3
[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 sorters: 'starttime',
58 rstore: PBS.data.RunningTasksStore,
59 },
60
61 columns: [
62 {
63 text: 'Task',
64 dataIndex: 'upid',
65 renderer: Proxmox.Utils.render_upid,
66 flex: 2,
67 },
68 {
69 text: 'Starttime',
70 dataIndex: 'starttime',
71 renderer: function(value) {
72 return Ext.Date.format(value, "Y-m-d H:i:s");
73 },
74 flex: 1,
75 },
76 {
77 text: 'Duration',
78 dataIndex: 'duration',
79 renderer: function(value, md, record) {
80 return Proxmox.Utils.format_duration_human((Date.now() - record.data.starttime)/1000);
81 }
82 },
83 {
84 xtype: 'actioncolumn',
85 width: 40,
86 items: [
87 {
88 iconCls: 'fa fa-chevron-right',
89 tooltip: gettext('Open Task'),
90 handler: 'openTaskActionColumn',
91 },
92 ],
93 },
94 ],
95 });
96