2020-06-12 11:34:05 +00:00
|
|
|
Ext.define('PBS.TaskSummary', {
|
|
|
|
extend: 'Ext.panel.Panel',
|
|
|
|
alias: 'widget.pbsTaskSummary',
|
|
|
|
|
2020-10-06 10:25:25 +00:00
|
|
|
title: gettext('Task Summary'),
|
2020-06-12 11:34:05 +00:00
|
|
|
|
2020-11-09 15:01:26 +00:00
|
|
|
states: [
|
|
|
|
"",
|
|
|
|
"error",
|
|
|
|
"warning",
|
|
|
|
"ok",
|
|
|
|
],
|
|
|
|
|
|
|
|
types: [
|
|
|
|
"backup",
|
|
|
|
"prune",
|
|
|
|
"garbage_collection",
|
|
|
|
"sync",
|
|
|
|
"verify",
|
|
|
|
],
|
|
|
|
|
|
|
|
titles: {
|
|
|
|
"backup": gettext('Backups'),
|
|
|
|
"prune": gettext('Prunes'),
|
|
|
|
"garbage_collection": gettext('Garbage collections'),
|
|
|
|
"sync": gettext('Syncs'),
|
|
|
|
"verify": gettext('Verify'),
|
|
|
|
},
|
|
|
|
|
2020-11-09 15:01:27 +00:00
|
|
|
// set true to show the onclick panel as modal grid
|
|
|
|
subPanelModal: false,
|
|
|
|
|
|
|
|
// the datastore the onclick panel is filtered by
|
|
|
|
datastore: undefined,
|
|
|
|
|
2020-06-12 11:34:05 +00:00
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
2020-10-06 10:25:28 +00:00
|
|
|
|
|
|
|
openTaskList: function(grid, td, cellindex, record, tr, rowindex) {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
|
|
|
|
if (cellindex > 0) {
|
|
|
|
let tasklist = view.tasklist;
|
2020-11-09 15:01:26 +00:00
|
|
|
let state = view.states[cellindex];
|
|
|
|
let type = view.types[rowindex];
|
2020-10-06 10:25:28 +00:00
|
|
|
let filterParam = {
|
2020-10-30 14:02:12 +00:00
|
|
|
limit: 0,
|
2020-10-06 10:25:28 +00:00
|
|
|
'statusfilter': state,
|
|
|
|
'typefilter': type,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (me.since) {
|
|
|
|
filterParam.since = me.since;
|
|
|
|
}
|
|
|
|
|
2020-11-09 15:01:27 +00:00
|
|
|
if (view.datastore) {
|
|
|
|
filterParam.store = view.datastore;
|
|
|
|
}
|
|
|
|
|
2020-11-09 15:01:28 +00:00
|
|
|
if (record.data[state] === 0 || record.data[state] === undefined) {
|
2020-10-06 10:25:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tasklist === undefined) {
|
|
|
|
tasklist = Ext.create('Ext.grid.Panel', {
|
|
|
|
tools: [{
|
|
|
|
handler: () => tasklist.setVisible(false),
|
|
|
|
}],
|
|
|
|
floating: true,
|
|
|
|
scrollable: true,
|
|
|
|
|
|
|
|
height: 400,
|
|
|
|
width: 600,
|
|
|
|
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
text: gettext('Task'),
|
|
|
|
dataIndex: 'upid',
|
|
|
|
renderer: Proxmox.Utils.render_upid,
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext("Start Time"),
|
|
|
|
dataIndex: 'starttime',
|
|
|
|
width: 130,
|
|
|
|
renderer: function(value) {
|
|
|
|
return Ext.Date.format(value, "M d H:i:s");
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'actioncolumn',
|
|
|
|
width: 40,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
iconCls: 'fa fa-chevron-right',
|
|
|
|
tooltip: gettext('Open Task'),
|
|
|
|
handler: function(g, rowIndex) {
|
|
|
|
let rec = tasklist.getStore().getAt(rowIndex);
|
|
|
|
tasklist.setVisible(false);
|
|
|
|
Ext.create('Proxmox.window.TaskViewer', {
|
|
|
|
upid: rec.data.upid,
|
|
|
|
endtime: rec.data.endtime,
|
|
|
|
listeners: {
|
|
|
|
close: () => tasklist.setVisible(true),
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
store: {
|
|
|
|
sorters: [
|
|
|
|
{
|
|
|
|
property: 'starttime',
|
|
|
|
direction: 'DESC',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
type: 'store',
|
|
|
|
model: 'proxmox-tasks',
|
|
|
|
proxy: {
|
|
|
|
type: 'proxmox',
|
2020-10-30 14:02:12 +00:00
|
|
|
url: "/api2/json/nodes/localhost/tasks",
|
2020-10-06 10:25:28 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
view.on('destroy', function() {
|
|
|
|
tasklist.setVisible(false);
|
|
|
|
tasklist.destroy();
|
|
|
|
tasklist = undefined;
|
|
|
|
});
|
|
|
|
|
|
|
|
view.tasklist = tasklist;
|
|
|
|
} else {
|
|
|
|
let cidx = tasklist.cidx;
|
|
|
|
let ridx = tasklist.ridx;
|
|
|
|
|
|
|
|
if (cidx === cellindex && ridx === rowindex && tasklist.isVisible()) {
|
|
|
|
tasklist.setVisible(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasklist.cidx = cellindex;
|
|
|
|
tasklist.ridx = rowindex;
|
|
|
|
|
2020-11-09 15:01:26 +00:00
|
|
|
let task = view.titles[type];
|
2020-10-06 10:25:28 +00:00
|
|
|
let status = "";
|
|
|
|
switch (state) {
|
|
|
|
case 'ok': status = gettext("OK"); break;
|
|
|
|
case 'warnings': status = gettext("Warning"); break;
|
|
|
|
case 'error': status = Proxmox.Utils.errorText; break;
|
|
|
|
}
|
|
|
|
let icon = me.render_icon(state, 1);
|
|
|
|
tasklist.setTitle(`${task} - ${status} ${icon}`);
|
|
|
|
tasklist.getStore().getProxy().setExtraParams(filterParam);
|
|
|
|
tasklist.getStore().removeAll();
|
|
|
|
|
2020-11-09 15:01:27 +00:00
|
|
|
if (view.subPanelModal) {
|
|
|
|
tasklist.modal = true;
|
|
|
|
tasklist.showBy(Ext.getBody(), 'c-c');
|
|
|
|
} else {
|
|
|
|
tasklist.modal = false;
|
|
|
|
tasklist.showBy(td, 'bl-tl');
|
|
|
|
}
|
2020-10-06 10:25:28 +00:00
|
|
|
setTimeout(() => tasklist.getStore().reload(), 10);
|
|
|
|
}
|
2020-10-06 10:25:26 +00:00
|
|
|
},
|
|
|
|
|
2020-10-05 13:43:14 +00:00
|
|
|
render_icon: function(state, count) {
|
2020-06-12 11:34:05 +00:00
|
|
|
let cls = 'question';
|
2020-07-09 14:11:51 +00:00
|
|
|
let color = 'faded';
|
2020-10-05 13:43:14 +00:00
|
|
|
switch (state) {
|
|
|
|
case "error":
|
2020-07-09 14:11:51 +00:00
|
|
|
cls = "times-circle";
|
|
|
|
color = "critical";
|
|
|
|
break;
|
2020-10-05 13:43:14 +00:00
|
|
|
case "warning":
|
2020-07-09 14:11:51 +00:00
|
|
|
cls = "exclamation-circle";
|
|
|
|
color = "warning";
|
|
|
|
break;
|
2020-10-05 13:43:14 +00:00
|
|
|
case "ok":
|
2020-07-09 14:11:51 +00:00
|
|
|
cls = "check-circle";
|
|
|
|
color = "good";
|
|
|
|
break;
|
2020-06-12 11:34:05 +00:00
|
|
|
default: break;
|
|
|
|
}
|
2020-07-09 14:11:51 +00:00
|
|
|
|
2020-10-05 13:43:14 +00:00
|
|
|
if (count < 1) {
|
2020-07-09 14:11:51 +00:00
|
|
|
color = "faded";
|
|
|
|
}
|
|
|
|
cls += " " + color;
|
2020-10-05 13:43:14 +00:00
|
|
|
return `<i class="fa fa-${cls}"></i>`;
|
|
|
|
},
|
|
|
|
|
|
|
|
render_count: function(value, md, record, rowindex, colindex) {
|
|
|
|
let me = this;
|
2020-11-09 15:01:26 +00:00
|
|
|
let view = me.getView();
|
2020-11-09 17:09:05 +00:00
|
|
|
let count = value || 0;
|
|
|
|
if (count > 0) {
|
|
|
|
md.tdCls = 'pointer';
|
|
|
|
}
|
|
|
|
let icon = me.render_icon(view.states[colindex], count);
|
2020-11-09 15:01:28 +00:00
|
|
|
return `${icon} ${value || 0}`;
|
2020-06-12 11:34:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-10-06 10:25:28 +00:00
|
|
|
updateTasks: function(source, since) {
|
2020-06-12 11:34:05 +00:00
|
|
|
let me = this;
|
2020-10-06 10:25:26 +00:00
|
|
|
let controller = me.getController();
|
|
|
|
let data = [];
|
2020-11-09 15:01:28 +00:00
|
|
|
if (!source) {
|
|
|
|
source = {};
|
|
|
|
}
|
2020-11-09 15:01:26 +00:00
|
|
|
me.types.forEach((type) => {
|
2020-11-09 15:01:28 +00:00
|
|
|
if (!source[type]) {
|
|
|
|
source[type] = {
|
|
|
|
error: 0,
|
|
|
|
warning: 0,
|
|
|
|
ok: 0,
|
|
|
|
};
|
|
|
|
}
|
2020-11-09 15:01:26 +00:00
|
|
|
source[type].type = me.titles[type];
|
2020-10-06 10:25:26 +00:00
|
|
|
data.push(source[type]);
|
|
|
|
});
|
|
|
|
me.lookup('grid').getStore().setData(data);
|
2020-10-06 10:25:28 +00:00
|
|
|
controller.since = since;
|
2020-06-12 11:34:05 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
layout: 'fit',
|
|
|
|
bodyPadding: 15,
|
|
|
|
minHeight: 166,
|
|
|
|
|
|
|
|
// we have to wrap the grid in a panel to get the padding right
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'grid',
|
|
|
|
reference: 'grid',
|
|
|
|
hideHeaders: true,
|
|
|
|
border: false,
|
|
|
|
bodyBorder: false,
|
|
|
|
rowLines: false,
|
|
|
|
viewConfig: {
|
|
|
|
stripeRows: false,
|
2020-11-09 18:25:43 +00:00
|
|
|
trackOver: true,
|
2020-06-12 11:34:05 +00:00
|
|
|
},
|
|
|
|
scrollable: false,
|
|
|
|
disableSelection: true,
|
|
|
|
|
|
|
|
store: {
|
2020-09-25 16:40:03 +00:00
|
|
|
data: [],
|
2020-06-12 11:34:05 +00:00
|
|
|
},
|
|
|
|
|
2020-10-06 10:25:28 +00:00
|
|
|
listeners: {
|
|
|
|
cellclick: 'openTaskList',
|
|
|
|
},
|
|
|
|
|
2020-06-12 11:34:05 +00:00
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
dataIndex: 'type',
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dataIndex: 'error',
|
|
|
|
renderer: 'render_count',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dataIndex: 'warning',
|
|
|
|
renderer: 'render_count',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dataIndex: 'ok',
|
|
|
|
renderer: 'render_count',
|
|
|
|
},
|
|
|
|
],
|
2020-09-25 16:40:03 +00:00
|
|
|
},
|
2020-06-12 11:34:05 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
});
|