]> git.proxmox.com Git - proxmox-backup.git/blob - www/dashboard/RunningTasks.js
ui: add TaskButton in header
[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 view.fireEvent('taskopened', view, record.data.upid);
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,
59 sorters: 'starttime',
60 rstore: PBS.data.RunningTasksStore,
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);
83 }
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