2020-05-29 08:53:42 +00:00
|
|
|
Ext.define('pbs-sync-jobs-status', {
|
|
|
|
extend: 'Ext.data.Model',
|
|
|
|
fields: [
|
2020-10-30 11:36:41 +00:00
|
|
|
'id', 'owner', 'remote', 'remote-store', 'store', 'schedule',
|
2020-05-29 08:53:42 +00:00
|
|
|
'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);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-10-30 11:36:41 +00:00
|
|
|
render_optional_owner: function(value, metadata, record) {
|
|
|
|
if (!value) return '-';
|
|
|
|
return Ext.String.htmlEncode(value, metadata, record);
|
|
|
|
},
|
|
|
|
|
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-11-09 15:01:25 +00:00
|
|
|
let params = {};
|
|
|
|
if (view.datastore !== undefined) {
|
|
|
|
params.store = view.datastore;
|
|
|
|
}
|
|
|
|
view.getStore().rstore.getProxy().setExtraParams(params);
|
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
|
|
|
},
|
|
|
|
{
|
2020-11-10 12:18:01 +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
|
|
|
},
|
|
|
|
{
|
2020-11-10 12:18:01 +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
|
|
|
},
|
|
|
|
{
|
2020-11-10 12:18:01 +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
|
|
|
},
|
2020-10-30 11:36:41 +00:00
|
|
|
{
|
|
|
|
header: gettext('Owner'),
|
|
|
|
dataIndex: 'owner',
|
|
|
|
renderer: 'render_optional_owner',
|
|
|
|
flex: 2,
|
|
|
|
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',
|
2021-02-19 08:14:31 +00:00
|
|
|
renderer: PBS.Utils.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',
|
2021-02-19 08:14:31 +00:00
|
|
|
renderer: PBS.Utils.render_task_status,
|
2020-10-31 09:54:14 +00:00
|
|
|
flex: 3,
|
2020-05-29 08:53:42 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Next Run'),
|
|
|
|
dataIndex: 'next-run',
|
2021-02-19 08:14:31 +00:00
|
|
|
renderer: PBS.Utils.render_next_task_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
|
|
|
},
|
|
|
|
],
|
2020-11-10 11:58:00 +00:00
|
|
|
|
|
|
|
initComponent: function() {
|
|
|
|
let me = this;
|
|
|
|
let hideLocalDatastore = !!me.datastore;
|
|
|
|
|
2020-11-10 12:18:01 +00:00
|
|
|
for (let column of me.columns) {
|
|
|
|
if (column.dataIndex === 'store') {
|
|
|
|
column.hidden = hideLocalDatastore;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-11-10 11:58:00 +00:00
|
|
|
|
|
|
|
me.callParent();
|
|
|
|
},
|
2020-05-29 08:53:42 +00:00
|
|
|
});
|