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
|
|
|
|
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
2020-10-06 10:25:28 +00:00
|
|
|
states: [
|
|
|
|
"",
|
|
|
|
"error",
|
|
|
|
"warning",
|
|
|
|
"ok",
|
|
|
|
],
|
|
|
|
|
2020-10-06 10:25:26 +00:00
|
|
|
types: [
|
|
|
|
"backup",
|
|
|
|
"prune",
|
|
|
|
"garbage_collection",
|
|
|
|
"sync",
|
2020-10-06 10:25:27 +00:00
|
|
|
"verify",
|
2020-10-06 10:25:26 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
titles: {
|
|
|
|
"backup": gettext('Backups'),
|
|
|
|
"prune": gettext('Prunes'),
|
|
|
|
"garbage_collection": gettext('Garbage collections'),
|
|
|
|
"sync": gettext('Syncs'),
|
2020-10-06 10:25:28 +00:00
|
|
|
"verify": gettext('Verify'),
|
|
|
|
},
|
|
|
|
|
|
|
|
openTaskList: function(grid, td, cellindex, record, tr, rowindex) {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
|
|
|
|
if (cellindex > 0) {
|
|
|
|
let tasklist = view.tasklist;
|
|
|
|
let state = me.states[cellindex];
|
|
|
|
let type = me.types[rowindex];
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (record.data[state] === 0) {
|
|
|
|
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;
|
|
|
|
|
|
|
|
let task = me.titles[type];
|
|
|
|
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();
|
|
|
|
|
|
|
|
tasklist.showBy(td, 'bl-tl');
|
|
|
|
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;
|
|
|
|
let icon = me.render_icon(me.states[colindex], value);
|
|
|
|
return `${icon} ${value}`;
|
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 = [];
|
|
|
|
controller.types.forEach((type) => {
|
|
|
|
source[type].type = controller.titles[type];
|
|
|
|
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,
|
|
|
|
trackOver: false,
|
|
|
|
},
|
|
|
|
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
|
|
|
],
|
|
|
|
|
|
|
|
});
|