]>
Commit | Line | Data |
---|---|---|
6f3146c0 DC |
1 | Ext.define('PBS.LongestTasks', { |
2 | extend: 'Ext.grid.Panel', | |
3 | alias: 'widget.pbsLongestTasks', | |
4 | ||
ad9d1625 | 5 | title: gettext('Longest Tasks'), |
6f3146c0 DC |
6 | |
7 | hideHeaders: true, | |
8 | rowLines: false, | |
9 | ||
10 | emptyText: gettext('No Tasks'), | |
11 | ||
12 | controller: { | |
13 | xclass: 'Ext.app.ViewController', | |
14 | ||
15 | openTask: function(record) { | |
16 | let me = this; | |
6f3146c0 DC |
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, | |
3f0b9c10 DC |
58 | sorters: [ |
59 | { | |
60 | property: 'duration', | |
61 | direction: 'DESC', | |
62 | }, | |
63 | { | |
64 | property: 'upid', | |
65 | direction: 'ASC', | |
66 | }, | |
67 | ], | |
6f3146c0 DC |
68 | rstore: { |
69 | storeid: 'proxmox-tasks-dash', | |
70 | type: 'store', | |
71 | model: 'proxmox-tasks', | |
72 | proxy: { | |
73 | type: 'memory', | |
6ab77df3 | 74 | }, |
6f3146c0 DC |
75 | }, |
76 | }, | |
77 | ||
78 | columns: [ | |
79 | { | |
80 | text: gettext('Task'), | |
81 | dataIndex: 'upid', | |
82 | renderer: Proxmox.Utils.render_upid, | |
83 | flex: 1, | |
84 | }, | |
85 | { | |
86 | text: gettext('Duration'), | |
87 | dataIndex: 'duration', | |
88 | renderer: Proxmox.Utils.format_duration_human, | |
89 | }, | |
90 | { | |
91 | text: gettext('Status'), | |
92 | align: 'center', | |
93 | width: 40, | |
94 | dataIndex: 'status', | |
95 | renderer: 'render_status', | |
96 | }, | |
97 | { | |
98 | xtype: 'actioncolumn', | |
99 | width: 40, | |
100 | items: [ | |
101 | { | |
102 | iconCls: 'fa fa-chevron-right', | |
103 | tooltip: gettext('Open Task'), | |
104 | handler: 'openTaskActionColumn', | |
105 | }, | |
106 | ], | |
107 | }, | |
108 | ], | |
109 | }); |