ui: add namespace fields to sync

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2022-05-10 15:02:23 +02:00 committed by Thomas Lamprecht
parent c06c1b4bd7
commit d895b26bb9
3 changed files with 208 additions and 24 deletions

View File

@ -1,8 +1,9 @@
Ext.define('pbs-sync-jobs-status', { Ext.define('pbs-sync-jobs-status', {
extend: 'Ext.data.Model', extend: 'Ext.data.Model',
fields: [ fields: [
'id', 'owner', 'remote', 'remote-store', 'store', 'schedule', 'group-filter', 'id', 'owner', 'remote', 'remote-store', 'remote-ns', 'store', 'ns',
'next-run', 'last-run-upid', 'last-run-state', 'last-run-endtime', 'schedule', 'group-filter', 'next-run', 'last-run-upid', 'last-run-state',
'last-run-endtime',
{ {
name: 'duration', name: 'duration',
calculate: function(data) { calculate: function(data) {
@ -195,6 +196,13 @@ Ext.define('PBS.config.SyncJobView', {
width: 120, width: 120,
sortable: true, sortable: true,
}, },
{
header: gettext('Namespace'),
dataIndex: 'ns',
width: 120,
sortable: true,
renderer: PBS.Utils.render_optional_namespace,
},
{ {
header: gettext('Remote ID'), header: gettext('Remote ID'),
dataIndex: 'remote', dataIndex: 'remote',
@ -207,6 +215,19 @@ Ext.define('PBS.config.SyncJobView', {
width: 120, width: 120,
sortable: true, sortable: true,
}, },
{
header: gettext('Remote Namespace'),
dataIndex: 'remote-ns',
width: 120,
sortable: true,
renderer: PBS.Utils.render_optional_namespace,
},
{
header: gettext('Max. Recursion'),
dataIndex: 'max-depth',
width: 10,
sortable: true,
},
{ {
header: gettext('Owner'), header: gettext('Owner'),
dataIndex: 'owner', dataIndex: 'owner',

View File

@ -210,8 +210,13 @@ Ext.define('PBS.form.GroupFilter', {
let url; let url;
if (me.remote) { if (me.remote) {
url = `/api2/json/config/remote/${me.remote}/scan/${me.datastore}/groups`; url = `/api2/json/config/remote/${me.remote}/scan/${me.datastore}/groups`;
if (me.namespace) {
url += `?namespace=${me.namespace}`;
}
} else if (me.datastore) { } else if (me.datastore) {
url = `/api2/json/admin/datastore/${me.datastore}/groups`; url = `/api2/json/admin/datastore/${me.datastore}/groups`;
} else {
return;
} }
me.setDsStoreUrl(url); me.setDsStoreUrl(url);
me.dsStore.load({ me.dsStore.load({
@ -237,11 +242,23 @@ Ext.define('PBS.form.GroupFilter', {
setRemoteDatastore: function(remote, datastore) { setRemoteDatastore: function(remote, datastore) {
let me = this; let me = this;
if (me.remote === remote && me.datastore === datastore) { if (me.remote === remote && me.datastore === datastore && me.namespace === undefined) {
return; return;
} }
me.remote = remote; me.remote = remote;
me.datastore = datastore; me.datastore = datastore;
me.namespace = undefined;
me.updateGroupSelectors();
},
setRemoteNamespace: function(remote, datastore, namespace) {
let me = this;
if (me.remote === remote && me.datastore === datastore && me.namespace === namespace) {
return;
}
me.remote = remote;
me.datastore = datastore;
me.namespace = namespace;
me.updateGroupSelectors(); me.updateGroupSelectors();
}, },

View File

@ -84,6 +84,109 @@ Ext.define('PBS.form.RemoteStoreSelector', {
}, },
}); });
Ext.define('PBS.form.RemoteNamespaceSelector', {
extend: 'Proxmox.form.ComboGrid',
alias: 'widget.pbsRemoteNamespaceSelector',
queryMode: 'local',
valueField: 'ns',
displayField: 'ns',
emptyText: PBS.Utils.render_optional_namespace(''),
notFoundIsValid: true,
matchFieldWidth: false,
listConfig: {
loadingText: gettext('Scanning...'),
width: 350,
columns: [
{
header: gettext('Namespace'),
sortable: true,
dataIndex: 'ns',
renderer: PBS.Utils.render_optional_namespace, // FIXME proper root-aware renderer
flex: 1,
},
{
header: gettext('Comment'),
dataIndex: 'comment',
renderer: Ext.String.htmlEncode,
flex: 1,
},
],
},
doRawQuery: function() {
// do nothing.
},
setRemote: function(remote) {
let me = this;
if (me.remote === remote) {
return;
}
me.remote = remote;
let store = me.store;
store.removeAll();
me.setDisabled(true);
me.clearValue();
},
setRemoteStore: function(remoteStore) {
let me = this;
if (me.remoteStore === remoteStore) {
return;
}
me.remoteStore = remoteStore;
let store = me.store;
store.removeAll();
if (me.remote && me.remoteStore) {
me.setDisabled(false);
if (!me.firstLoad) {
me.clearValue();
}
store.proxy.url = '/api2/json/config/remote/' + encodeURIComponent(me.remote) + '/scan/' + encodeURIComponent(me.remoteStore) + '/namespaces';
store.load();
me.firstLoad = false;
} else {
me.setDisabled(true);
me.clearValue();
}
},
initComponent: function() {
let me = this;
me.firstLoad = true;
let store = Ext.create('Ext.data.Store', {
fields: ['ns', 'comment'],
proxy: {
type: 'proxmox',
url: '/api2/json/config/remote/' + encodeURIComponent(me.remote) + '/scan',
},
});
store.sort('store', 'ASC');
Ext.apply(me, {
store: store,
});
me.callParent();
},
});
Ext.define('PBS.window.SyncJobEdit', { Ext.define('PBS.window.SyncJobEdit', {
extend: 'Proxmox.window.Edit', extend: 'Proxmox.window.Edit',
@ -156,6 +259,20 @@ Ext.define('PBS.window.SyncJobEdit', {
allowBlank: false, allowBlank: false,
}, },
}, },
// TODO: make this hot-reloadable based on local store selection?
{
xtype: 'pmxDisplayEditField',
fieldLabel: gettext('Local Namespace'),
name: 'ns',
cbind: {
datastore: '{datastore}',
},
editable: true,
submitValue: true,
//editConfig: {
// xtype: 'pbsNamespaceSelector',
//},
},
{ {
fieldLabel: gettext('Local Owner'), fieldLabel: gettext('Local Owner'),
xtype: 'pbsAuthidSelector', xtype: 'pbsAuthidSelector',
@ -165,49 +282,6 @@ Ext.define('PBS.window.SyncJobEdit', {
deleteEmpty: '{!isCreate}', deleteEmpty: '{!isCreate}',
}, },
}, },
{
fieldLabel: gettext('Remove vanished'),
xtype: 'proxmoxcheckbox',
name: 'remove-vanished',
autoEl: {
tag: 'div',
'data-qtip': gettext('Remove snapshots from local datastore if they vanished from source datastore?'),
},
uncheckedValue: false,
value: false,
},
],
column2: [
{
fieldLabel: gettext('Source Remote'),
xtype: 'pbsRemoteSelector',
allowBlank: false,
name: 'remote',
listeners: {
change: function(f, value) {
let me = this;
let remoteStoreField = me.up('pbsSyncJobEdit').down('field[name=remote-store]');
remoteStoreField.setRemote(value);
},
},
},
{
fieldLabel: gettext('Source Datastore'),
xtype: 'pbsRemoteStoreSelector',
allowBlank: false,
autoSelect: false,
name: 'remote-store',
disabled: true,
listeners: {
change: function(field, value) {
let me = this;
let remoteField = me.up('pbsSyncJobEdit').down('field[name=remote]');
let remote = remoteField.getValue();
me.up('tabpanel').down('pbsGroupFilter').setRemoteDatastore(remote, value);
},
},
},
{ {
fieldLabel: gettext('Sync Schedule'), fieldLabel: gettext('Sync Schedule'),
xtype: 'pbsCalendarEvent', xtype: 'pbsCalendarEvent',
@ -228,6 +302,78 @@ Ext.define('PBS.window.SyncJobEdit', {
}, },
], ],
column2: [
{
fieldLabel: gettext('Source Remote'),
xtype: 'pbsRemoteSelector',
allowBlank: false,
name: 'remote',
listeners: {
change: function(f, value) {
let me = this;
let remoteStoreField = me.up('pbsSyncJobEdit').down('field[name=remote-store]');
remoteStoreField.setRemote(value);
let remoteNamespaceField = me.up('pbsSyncJobEdit').down('field[name=remote-ns]');
remoteNamespaceField.setRemote(value);
},
},
},
{
fieldLabel: gettext('Source Datastore'),
xtype: 'pbsRemoteStoreSelector',
allowBlank: false,
autoSelect: false,
name: 'remote-store',
disabled: true,
listeners: {
change: function(field, value) {
let me = this;
let remoteField = me.up('pbsSyncJobEdit').down('field[name=remote]');
let remote = remoteField.getValue();
let remoteNamespaceField = me.up('pbsSyncJobEdit').down('field[name=remote-ns]');
remoteNamespaceField.setRemote(remote);
remoteNamespaceField.setRemoteStore(value);
me.up('tabpanel').down('pbsGroupFilter').setRemoteDatastore(remote, value);
},
},
},
{
fieldLabel: gettext('Source Namespace'),
xtype: 'pbsRemoteNamespaceSelector',
allowBlank: true,
autoSelect: false,
name: 'remote-ns',
disabled: true,
listeners: {
change: function(field, value) {
let me = this;
let remoteField = me.up('pbsSyncJobEdit').down('field[name=remote]');
let remote = remoteField.getValue();
let remoteStoreField = me.up('pbsSyncJobEdit').down('field[name=remote-store]');
let remoteStore = remoteStoreField.getValue();
me.up('tabpanel').down('pbsGroupFilter').setRemoteNamespace(remote, remoteStore, value);
},
},
},
{
xtype: 'pbsNamespaceMaxDepth',
name: 'max-depth',
fieldLabel: gettext('Max. Depth'),
deleteEmpty: true,
},
{
fieldLabel: gettext('Remove vanished'),
xtype: 'proxmoxcheckbox',
name: 'remove-vanished',
autoEl: {
tag: 'div',
'data-qtip': gettext('Remove snapshots from local datastore if they vanished from source datastore?'),
},
uncheckedValue: false,
value: false,
},
],
columnB: [ columnB: [
{ {
fieldLabel: gettext('Comment'), fieldLabel: gettext('Comment'),