ui: tape/BackupJobs.js - render task scheduling status

This commit is contained in:
Dietmar Maurer 2021-02-19 09:08:00 +01:00
parent 7690a8e7bd
commit 9e860ac01a
2 changed files with 88 additions and 2 deletions

View File

@ -188,6 +188,56 @@ Ext.define('PBS.Utils', {
return fingerprint.substring(0, 23);
},
render_task_status: function(value, metadata, record) {
if (!record.data['last-run-upid']) {
return '-';
}
if (!record.data['last-run-endtime']) {
metadata.tdCls = 'x-grid-row-loading';
return '';
}
let parsed = Proxmox.Utils.parse_task_status(value);
let text = value;
let icon = '';
switch (parsed) {
case 'unknown':
icon = 'question faded';
text = Proxmox.Utils.unknownText;
break;
case 'error':
icon = 'times critical';
text = Proxmox.Utils.errorText + ': ' + value;
break;
case 'warning':
icon = 'exclamation warning';
break;
case 'ok':
icon = 'check good';
text = gettext("OK");
}
return `<i class="fa fa-${icon}"></i> ${text}`;
},
render_next_task_run: function(value, metadat, record) {
if (!value) return '-';
let now = new Date();
let next = new Date(value*1000);
if (next < now) {
return gettext('pending');
}
return Proxmox.Utils.render_timestamp(value);
},
render_optional_timestamp: function(value, metadata, record) {
if (!value) return '-';
return Proxmox.Utils.render_timestamp(value);
},
parse_datastore_worker_id: function(type, id) {
let result;
let res;

View File

@ -3,12 +3,22 @@ Ext.define('pbs-tape-backup-job-status', {
fields: [
'id', 'store', 'pool', 'drive', 'store', 'schedule', 'comment',
{ name: 'eject-media', type: 'boolean' },
{ name: 'export-media-set', type: 'boolean' }
{ name: 'export-media-set', type: 'boolean' },
'next-run', 'last-run-upid', 'last-run-state', 'last-run-endtime',
{
name: 'duration',
calculate: function(data) {
let endtime = data['last-run-endtime'];
if (!endtime) return undefined;
let task = Proxmox.Utils.parse_task_upid(data['last-run-upid']);
return endtime - task.starttime;
},
}
],
idProperty: 'id',
proxy: {
type: 'proxmox',
url: '/api2/json/config/tape-backup-job',
url: '/api2/json/tape/backup',
},
});
@ -94,6 +104,32 @@ Ext.define('PBS.config.TapeBackupJobView', {
flex: 1,
sortable: true,
},
{
header: gettext('Last Backup'),
dataIndex: 'last-run-endtime',
renderer: PBS.Utils.render_optional_timestamp,
width: 150,
sortable: true,
},
{
text: gettext('Duration'),
dataIndex: 'duration',
renderer: Proxmox.Utils.render_duration,
width: 80,
},
{
header: gettext('Status'),
dataIndex: 'last-run-state',
renderer: PBS.Utils.render_task_status,
flex: 3,
},
{
header: gettext('Next Run'),
dataIndex: 'next-run',
renderer: PBS.Utils.render_next_task_run,
width: 150,
sortable: true,
},
{
header: gettext('Comment'),
dataIndex: 'comment',