2020-10-20 09:10:08 +00:00
|
|
|
Ext.define('pbs-verify-jobs-status', {
|
|
|
|
extend: 'Ext.data.Model',
|
|
|
|
fields: [
|
|
|
|
'id', 'store', 'outdated-after', 'ignore-verified', 'schedule',
|
|
|
|
'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;
|
|
|
|
},
|
|
|
|
},
|
2020-10-27 15:20:08 +00:00
|
|
|
'comment',
|
2020-10-20 09:10:08 +00:00
|
|
|
],
|
|
|
|
idProperty: 'id',
|
|
|
|
proxy: {
|
|
|
|
type: 'proxmox',
|
|
|
|
url: '/api2/json/admin/verify',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
Ext.define('PBS.config.VerifyJobView', {
|
|
|
|
extend: 'Ext.grid.GridPanel',
|
|
|
|
alias: 'widget.pbsVerifyJobView',
|
|
|
|
|
|
|
|
stateful: true,
|
|
|
|
stateId: 'grid-verify-jobs',
|
|
|
|
|
|
|
|
title: gettext('Verify Jobs'),
|
|
|
|
|
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
|
|
|
addVerifyJob: function() {
|
|
|
|
let me = this;
|
2020-10-27 15:20:08 +00:00
|
|
|
let view = me.getView();
|
2020-10-20 09:10:08 +00:00
|
|
|
Ext.create('PBS.window.VerifyJobEdit', {
|
2020-10-27 15:20:08 +00:00
|
|
|
datastore: view.datastore,
|
2020-10-20 09:10:08 +00:00
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
|
|
|
editVerifyJob: function() {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
let selection = view.getSelection();
|
|
|
|
if (selection.length < 1) return;
|
|
|
|
|
|
|
|
Ext.create('PBS.window.VerifyJobEdit', {
|
2020-10-27 15:20:08 +00:00
|
|
|
datastore: view.datastore,
|
2020-10-20 09:10:08 +00:00
|
|
|
id: selection[0].data.id,
|
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
|
|
|
openTaskLog: function() {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
let selection = view.getSelection();
|
|
|
|
if (selection.length < 1) return;
|
|
|
|
|
|
|
|
let upid = selection[0].data['last-run-upid'];
|
|
|
|
if (!upid) return;
|
|
|
|
|
|
|
|
Ext.create('Proxmox.window.TaskViewer', {
|
2020-10-21 13:53:54 +00:00
|
|
|
upid,
|
2020-10-20 09:10:08 +00:00
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
|
|
|
runVerifyJob: function() {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
let selection = view.getSelection();
|
|
|
|
if (selection.length < 1) return;
|
|
|
|
|
|
|
|
let id = selection[0].data.id;
|
|
|
|
Proxmox.Utils.API2Request({
|
|
|
|
method: 'POST',
|
|
|
|
url: `/admin/verify/${id}/run`,
|
|
|
|
success: function(response, opt) {
|
|
|
|
Ext.create('Proxmox.window.TaskViewer', {
|
|
|
|
upid: response.result.data,
|
|
|
|
taskDone: function(success) {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
failure: function(response, opt) {
|
|
|
|
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
render_verify_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_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);
|
|
|
|
},
|
|
|
|
|
2020-10-27 15:20:08 +00:00
|
|
|
startStore: function() { this.getView().getStore().rstore.startUpdate(); },
|
|
|
|
stopStore: function() { this.getView().getStore().rstore.stopUpdate(); },
|
|
|
|
|
2020-10-20 09:10:08 +00:00
|
|
|
reload: function() { this.getView().getStore().rstore.load(); },
|
|
|
|
|
|
|
|
init: function(view) {
|
2020-10-27 15:20:08 +00:00
|
|
|
view.getStore().rstore.getProxy().setExtraParams({
|
|
|
|
store: view.datastore,
|
|
|
|
});
|
2020-10-20 09:10:08 +00:00
|
|
|
Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
listeners: {
|
2020-10-27 15:20:08 +00:00
|
|
|
activate: 'startStore',
|
|
|
|
deactivate: 'stopStore',
|
2020-10-20 09:10:08 +00:00
|
|
|
itemdblclick: 'editVerifyJob',
|
|
|
|
},
|
|
|
|
|
|
|
|
store: {
|
|
|
|
type: 'diff',
|
|
|
|
autoDestroy: true,
|
|
|
|
autoDestroyRstore: true,
|
|
|
|
sorters: 'id',
|
|
|
|
rstore: {
|
|
|
|
type: 'update',
|
|
|
|
storeid: 'pbs-verify-jobs-status',
|
|
|
|
model: 'pbs-verify-jobs-status',
|
|
|
|
interval: 5000,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
tbar: [
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Add'),
|
|
|
|
handler: 'addVerifyJob',
|
|
|
|
selModel: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Edit'),
|
|
|
|
handler: 'editVerifyJob',
|
|
|
|
disabled: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxStdRemoveButton',
|
|
|
|
baseurl: '/config/verify/',
|
|
|
|
callback: 'reload',
|
|
|
|
},
|
|
|
|
'-',
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
2020-10-28 20:25:07 +00:00
|
|
|
text: gettext('Show Log'),
|
2020-10-20 09:10:08 +00:00
|
|
|
handler: 'openTaskLog',
|
|
|
|
enableFn: (rec) => !!rec.data['last-run-upid'],
|
|
|
|
disabled: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Run now'),
|
|
|
|
handler: 'runVerifyJob',
|
|
|
|
disabled: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
viewConfig: {
|
|
|
|
trackOver: false,
|
|
|
|
},
|
|
|
|
|
|
|
|
columns: [
|
|
|
|
{
|
2020-10-28 20:25:07 +00:00
|
|
|
header: gettext('Job ID'),
|
2020-10-20 09:10:08 +00:00
|
|
|
dataIndex: 'id',
|
2020-10-28 20:25:07 +00:00
|
|
|
renderer: Ext.String.htmlEncode,
|
|
|
|
flex: 2,
|
|
|
|
sortable: true,
|
|
|
|
hidden: true,
|
2020-10-20 09:10:08 +00:00
|
|
|
},
|
|
|
|
{
|
2020-10-28 20:25:07 +00:00
|
|
|
header: gettext('Skip Verified'),
|
|
|
|
dataIndex: 'ignore-verified',
|
|
|
|
renderer: Proxmox.Utils.format_boolean,
|
|
|
|
flex: 2,
|
2020-10-20 09:10:08 +00:00
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
{
|
2020-10-28 20:25:07 +00:00
|
|
|
header: gettext('Re-Verfiy Age'),
|
|
|
|
dataIndex: 'outdated-after',
|
|
|
|
renderer: v => v ? v +' '+ gettext('Days') : gettext('Never'),
|
|
|
|
flex: 2,
|
2020-10-20 09:10:08 +00:00
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Schedule'),
|
|
|
|
dataIndex: 'schedule',
|
2020-10-28 20:25:07 +00:00
|
|
|
sortable: true,
|
|
|
|
flex: 2,
|
2020-10-20 09:10:08 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Status'),
|
|
|
|
dataIndex: 'last-run-state',
|
|
|
|
renderer: 'render_verify_status',
|
2020-10-28 20:25:07 +00:00
|
|
|
flex: 4,
|
2020-10-20 09:10:08 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Last Verification'),
|
|
|
|
dataIndex: 'last-run-endtime',
|
2020-10-28 20:25:07 +00:00
|
|
|
renderer: 'render_optional_timestamp',
|
|
|
|
flex: 3,
|
|
|
|
sortable: true,
|
2020-10-20 09:10:08 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext('Duration'),
|
|
|
|
dataIndex: 'duration',
|
|
|
|
renderer: Proxmox.Utils.render_duration,
|
2020-10-28 20:25:07 +00:00
|
|
|
flex: 2,
|
2020-10-20 09:10:08 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Next Run'),
|
|
|
|
dataIndex: 'next-run',
|
2020-10-28 20:25:07 +00:00
|
|
|
renderer: 'render_next_run',
|
|
|
|
flex: 3,
|
|
|
|
sortable: true,
|
2020-10-20 09:10:08 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Comment'),
|
|
|
|
dataIndex: 'comment',
|
2020-10-28 20:25:07 +00:00
|
|
|
renderer: Ext.String.htmlEncode,
|
|
|
|
flex: 4,
|
|
|
|
sortable: true,
|
2020-10-20 09:10:08 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|