2020-05-29 08:53:42 +00:00
|
|
|
Ext.define('pbs-sync-jobs-status', {
|
|
|
|
extend: 'Ext.data.Model',
|
|
|
|
fields: [
|
|
|
|
'id', 'remote', 'remote-store', 'store', '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-05-29 08:53:42 +00:00
|
|
|
],
|
|
|
|
idProperty: 'id',
|
|
|
|
proxy: {
|
|
|
|
type: 'proxmox',
|
|
|
|
url: '/api2/json/admin/sync',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
Ext.define('PBS.config.SyncJobView', {
|
|
|
|
extend: 'Ext.grid.GridPanel',
|
|
|
|
alias: 'widget.pbsSyncJobView',
|
|
|
|
|
|
|
|
stateful: true,
|
2020-10-31 09:58:42 +00:00
|
|
|
stateId: 'grid-sync-jobs-v1',
|
2020-05-29 08:53:42 +00:00
|
|
|
|
|
|
|
title: gettext('Sync Jobs'),
|
|
|
|
|
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
|
|
|
|
addSyncJob: function() {
|
|
|
|
let me = this;
|
2020-10-27 15:20:08 +00:00
|
|
|
let view = me.getView();
|
2020-05-29 08:53:42 +00:00
|
|
|
Ext.create('PBS.window.SyncJobEdit', {
|
2020-10-27 15:20:08 +00:00
|
|
|
datastore: view.datastore,
|
2020-05-29 08:53:42 +00:00
|
|
|
listeners: {
|
|
|
|
destroy: function() {
|
|
|
|
me.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
|
|
|
editSyncJob: function() {
|
|
|
|
let me = this;
|
|
|
|
let view = me.getView();
|
|
|
|
let selection = view.getSelection();
|
|
|
|
if (selection.length < 1) return;
|
|
|
|
|
|
|
|
Ext.create('PBS.window.SyncJobEdit', {
|
2020-10-27 15:20:08 +00:00
|
|
|
datastore: view.datastore,
|
2020-05-29 08:53:42 +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-09-25 16:40:03 +00:00
|
|
|
upid,
|
2020-05-29 08:53:42 +00:00
|
|
|
}).show();
|
|
|
|
},
|
|
|
|
|
|
|
|
runSyncJob: 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/sync/${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_sync_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 '';
|
|
|
|
}
|
|
|
|
|
2020-08-13 08:29:20 +00:00
|
|
|
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':
|
2020-09-25 16:40:03 +00:00
|
|
|
icon = 'times critical';
|
2020-08-13 08:29:20 +00:00
|
|
|
text = Proxmox.Utils.errorText + ': ' + value;
|
|
|
|
break;
|
|
|
|
case 'warning':
|
|
|
|
icon = 'exclamation warning';
|
|
|
|
break;
|
2020-09-25 16:40:03 +00:00
|
|
|
case 'ok':
|
2020-08-13 08:29:20 +00:00
|
|
|
icon = 'check good';
|
|
|
|
text = gettext("OK");
|
2020-05-29 08:53:42 +00:00
|
|
|
}
|
|
|
|
|
2020-08-13 08:29:20 +00:00
|
|
|
return `<i class="fa fa-${icon}"></i> ${text}`;
|
2020-05-29 08:53:42 +00:00
|
|
|
},
|
|
|
|
|
2020-06-03 14:34:07 +00:00
|
|
|
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) {
|
2020-05-29 08:53:42 +00:00
|
|
|
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-05-29 08:53:42 +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-05-29 08:53:42 +00:00
|
|
|
Proxmox.Utils.monStoreErrors(view, view.getStore().rstore);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
listeners: {
|
2020-10-27 15:20:08 +00:00
|
|
|
activate: 'startStore',
|
|
|
|
deactivate: 'stopStore',
|
2020-05-29 08:53:42 +00:00
|
|
|
itemdblclick: 'editSyncJob',
|
|
|
|
},
|
|
|
|
|
|
|
|
store: {
|
|
|
|
type: 'diff',
|
|
|
|
autoDestroy: true,
|
|
|
|
autoDestroyRstore: true,
|
|
|
|
sorters: 'id',
|
|
|
|
rstore: {
|
|
|
|
type: 'update',
|
|
|
|
storeid: 'pbs-sync-jobs-status',
|
|
|
|
model: 'pbs-sync-jobs-status',
|
|
|
|
interval: 5000,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
tbar: [
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Add'),
|
|
|
|
handler: 'addSyncJob',
|
|
|
|
selModel: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Edit'),
|
|
|
|
handler: 'editSyncJob',
|
|
|
|
disabled: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxStdRemoveButton',
|
|
|
|
baseurl: '/config/sync/',
|
2020-10-29 13:34:31 +00:00
|
|
|
confirmMsg: gettext('Remove entry?'),
|
2020-05-29 08:53:42 +00:00
|
|
|
callback: 'reload',
|
|
|
|
},
|
|
|
|
'-',
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
2020-10-28 20:25:30 +00:00
|
|
|
text: gettext('Show Log'),
|
2020-05-29 08:53:42 +00:00
|
|
|
handler: 'openTaskLog',
|
|
|
|
enableFn: (rec) => !!rec.data['last-run-upid'],
|
|
|
|
disabled: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxButton',
|
|
|
|
text: gettext('Run now'),
|
|
|
|
handler: 'runSyncJob',
|
|
|
|
disabled: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
viewConfig: {
|
|
|
|
trackOver: false,
|
|
|
|
},
|
|
|
|
|
|
|
|
columns: [
|
|
|
|
{
|
2020-10-31 09:54:14 +00:00
|
|
|
header: gettext('Job ID'),
|
2020-05-29 08:53:42 +00:00
|
|
|
dataIndex: 'id',
|
2020-10-28 20:25:30 +00:00
|
|
|
renderer: Ext.String.htmlEncode,
|
2020-10-31 09:54:14 +00:00
|
|
|
maxWidth: 220,
|
|
|
|
minWidth: 75,
|
|
|
|
flex: 1,
|
2020-10-28 20:25:30 +00:00
|
|
|
sortable: true,
|
2020-05-29 08:53:42 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Remote'),
|
|
|
|
dataIndex: 'remote',
|
2020-10-31 09:54:14 +00:00
|
|
|
width: 120,
|
2020-10-28 20:25:30 +00:00
|
|
|
sortable: true,
|
2020-05-29 08:53:42 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Remote Store'),
|
|
|
|
dataIndex: 'remote-store',
|
2020-10-31 09:54:14 +00:00
|
|
|
width: 120,
|
2020-10-28 20:25:30 +00:00
|
|
|
sortable: true,
|
2020-05-29 08:53:42 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Local Store'),
|
|
|
|
dataIndex: 'store',
|
2020-10-31 09:54:14 +00:00
|
|
|
width: 120,
|
2020-10-28 20:25:30 +00:00
|
|
|
sortable: true,
|
2020-05-29 08:53:42 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Schedule'),
|
|
|
|
dataIndex: 'schedule',
|
2020-10-31 09:54:14 +00:00
|
|
|
maxWidth: 220,
|
|
|
|
minWidth: 80,
|
|
|
|
flex: 1,
|
2020-10-28 20:25:30 +00:00
|
|
|
sortable: true,
|
2020-05-29 08:53:42 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Last Sync'),
|
|
|
|
dataIndex: 'last-run-endtime',
|
2020-10-28 20:25:30 +00:00
|
|
|
renderer: 'render_optional_timestamp',
|
2020-10-31 09:54:14 +00:00
|
|
|
width: 150,
|
2020-10-28 20:25:30 +00:00
|
|
|
sortable: true,
|
2020-05-29 08:53:42 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: gettext('Duration'),
|
|
|
|
dataIndex: 'duration',
|
|
|
|
renderer: Proxmox.Utils.render_duration,
|
2020-10-31 09:54:14 +00:00
|
|
|
width: 80,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Status'),
|
|
|
|
dataIndex: 'last-run-state',
|
|
|
|
renderer: 'render_sync_status',
|
|
|
|
flex: 3,
|
2020-05-29 08:53:42 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Next Run'),
|
|
|
|
dataIndex: 'next-run',
|
2020-10-28 20:25:30 +00:00
|
|
|
renderer: 'render_next_run',
|
2020-10-31 09:54:14 +00:00
|
|
|
width: 150,
|
2020-10-28 20:25:30 +00:00
|
|
|
sortable: true,
|
2020-05-29 08:53:42 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Comment'),
|
|
|
|
dataIndex: 'comment',
|
2020-10-28 20:25:30 +00:00
|
|
|
renderer: Ext.String.htmlEncode,
|
2020-10-31 09:54:14 +00:00
|
|
|
flex: 2,
|
2020-10-28 20:25:30 +00:00
|
|
|
sortable: true,
|
2020-05-29 08:53:42 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|