]>
Commit | Line | Data |
---|---|---|
6f3146c0 DC |
1 | Ext.define('PBS.LongestTasks', { |
2 | extend: 'Ext.grid.Panel', | |
3 | alias: 'widget.pbsLongestTasks', | |
4 | ||
5 | title: gettext('Longest Tasks (last Month)'), | |
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; | |
17 | let view = me.getView(); | |
18 | Ext.create('Proxmox.window.TaskViewer', { | |
19 | upid: record.data.upid, | |
20 | endtime: record.data.endtime, | |
21 | }).show(); | |
22 | }, | |
23 | ||
24 | openTaskItemDblClick: function(grid, record) { | |
25 | this.openTask(record); | |
26 | }, | |
27 | ||
28 | openTaskActionColumn: function(grid, rowIndex) { | |
29 | this.openTask(grid.getStore().getAt(rowIndex)); | |
30 | }, | |
31 | ||
32 | render_status: function(value) { | |
33 | let cls = 'times-circle critical'; | |
34 | if (value === 'OK') { | |
35 | cls = 'check-circle good'; | |
36 | } else if (value.startsWith('WARNINGS:')) { | |
37 | cls = 'exclamation-circle warning'; | |
38 | } else if (value === 'unknown') { | |
39 | cls = 'question-circle faded'; | |
40 | } | |
41 | ||
42 | return `<i class="fa fa-${cls}"></i>`; | |
43 | }, | |
44 | }, | |
45 | ||
46 | updateTasks: function(data) { | |
47 | let me = this; | |
48 | me.getStore().setData(data); | |
49 | }, | |
50 | ||
51 | listeners: { | |
52 | itemdblclick: 'openTaskItemDblClick', | |
53 | }, | |
54 | ||
55 | store: { | |
56 | type: 'diff', | |
57 | autoDestroy: true, | |
58 | autoDestroyRstore: true, | |
3f0b9c10 DC |
59 | sorters: [ |
60 | { | |
61 | property: 'duration', | |
62 | direction: 'DESC', | |
63 | }, | |
64 | { | |
65 | property: 'upid', | |
66 | direction: 'ASC', | |
67 | }, | |
68 | ], | |
6f3146c0 DC |
69 | rstore: { |
70 | storeid: 'proxmox-tasks-dash', | |
71 | type: 'store', | |
72 | model: 'proxmox-tasks', | |
73 | proxy: { | |
74 | type: 'memory', | |
75 | } | |
76 | }, | |
77 | }, | |
78 | ||
79 | columns: [ | |
80 | { | |
81 | text: gettext('Task'), | |
82 | dataIndex: 'upid', | |
83 | renderer: Proxmox.Utils.render_upid, | |
84 | flex: 1, | |
85 | }, | |
86 | { | |
87 | text: gettext('Duration'), | |
88 | dataIndex: 'duration', | |
89 | renderer: Proxmox.Utils.format_duration_human, | |
90 | }, | |
91 | { | |
92 | text: gettext('Status'), | |
93 | align: 'center', | |
94 | width: 40, | |
95 | dataIndex: 'status', | |
96 | renderer: 'render_status', | |
97 | }, | |
98 | { | |
99 | xtype: 'actioncolumn', | |
100 | width: 40, | |
101 | items: [ | |
102 | { | |
103 | iconCls: 'fa fa-chevron-right', | |
104 | tooltip: gettext('Open Task'), | |
105 | handler: 'openTaskActionColumn', | |
106 | }, | |
107 | ], | |
108 | }, | |
109 | ], | |
110 | }); |