]>
Commit | Line | Data |
---|---|---|
6f3146c0 DC |
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(); | |
a3970d6c DC |
21 | |
22 | view.fireEvent('taskopened', view, record.data.upid); | |
6f3146c0 DC |
23 | }, |
24 | ||
25 | openTaskItemDblClick: function(grid, record) { | |
26 | this.openTask(record); | |
27 | }, | |
28 | ||
29 | openTaskActionColumn: function(grid, rowIndex) { | |
30 | this.openTask(grid.getStore().getAt(rowIndex)); | |
31 | }, | |
32 | ||
33 | render_status: function(value) { | |
34 | let cls = 'times-circle critical'; | |
35 | if (value === 'OK') { | |
36 | cls = 'check-circle good'; | |
37 | } else if (value.startsWith('WARNINGS:')) { | |
38 | cls = 'exclamation-circle warning'; | |
39 | } else if (value === 'unknown') { | |
40 | cls = 'question-circle faded'; | |
41 | } | |
42 | ||
43 | return `<i class="fa fa-${cls}"></i>`; | |
44 | }, | |
45 | }, | |
46 | ||
47 | updateTasks: function(data) { | |
48 | let me = this; | |
49 | me.getStore().setData(data); | |
50 | }, | |
51 | ||
52 | listeners: { | |
53 | itemdblclick: 'openTaskItemDblClick', | |
54 | }, | |
55 | ||
56 | store: { | |
57 | type: 'diff', | |
58 | autoDestroy: true, | |
6f3146c0 | 59 | sorters: 'starttime', |
cc83c136 | 60 | rstore: PBS.data.RunningTasksStore, |
6f3146c0 DC |
61 | }, |
62 | ||
63 | columns: [ | |
64 | { | |
65 | text: 'Task', | |
66 | dataIndex: 'upid', | |
67 | renderer: Proxmox.Utils.render_upid, | |
68 | flex: 2, | |
69 | }, | |
70 | { | |
71 | text: 'Starttime', | |
72 | dataIndex: 'starttime', | |
73 | renderer: function(value) { | |
74 | return Ext.Date.format(value, "Y-m-d H:i:s"); | |
75 | }, | |
76 | flex: 1, | |
77 | }, | |
78 | { | |
79 | text: 'Duration', | |
80 | dataIndex: 'duration', | |
81 | renderer: function(value, md, record) { | |
82 | return Proxmox.Utils.format_duration_human((Date.now() - record.data.starttime)/1000); | |
6ab77df3 | 83 | }, |
6f3146c0 DC |
84 | }, |
85 | { | |
86 | xtype: 'actioncolumn', | |
87 | width: 40, | |
88 | items: [ | |
89 | { | |
90 | iconCls: 'fa fa-chevron-right', | |
91 | tooltip: gettext('Open Task'), | |
92 | handler: 'openTaskActionColumn', | |
93 | }, | |
94 | ], | |
95 | }, | |
96 | ], | |
97 | }); | |
98 |