2022-05-11 15:34:34 +00:00
|
|
|
Ext.define('PBS.form.RemoteStoreSelector', {
|
|
|
|
extend: 'Proxmox.form.ComboGrid',
|
|
|
|
alias: 'widget.pbsRemoteStoreSelector',
|
|
|
|
|
|
|
|
queryMode: 'local',
|
|
|
|
|
|
|
|
valueField: 'store',
|
|
|
|
displayField: 'store',
|
|
|
|
notFoundIsValid: true,
|
|
|
|
|
|
|
|
matchFieldWidth: false,
|
|
|
|
listConfig: {
|
|
|
|
loadingText: gettext('Scanning...'),
|
|
|
|
width: 350,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
header: gettext('Datastore'),
|
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'store',
|
|
|
|
renderer: Ext.String.htmlEncode,
|
|
|
|
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;
|
|
|
|
|
2022-05-11 16:00:15 +00:00
|
|
|
me.store.removeAll();
|
2022-05-11 15:34:34 +00:00
|
|
|
|
|
|
|
if (me.remote) {
|
|
|
|
me.setDisabled(false);
|
|
|
|
if (!me.firstLoad) {
|
|
|
|
me.clearValue();
|
|
|
|
}
|
|
|
|
|
2022-05-11 16:00:15 +00:00
|
|
|
me.store.proxy.url = `/api2/json/config/remote/${encodeURIComponent(me.remote)}/scan`;
|
|
|
|
me.store.load();
|
2022-05-11 15:34:34 +00:00
|
|
|
|
|
|
|
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: ['store', '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.form.RemoteNamespaceSelector', {
|
|
|
|
extend: 'Proxmox.form.ComboGrid',
|
|
|
|
alias: 'widget.pbsRemoteNamespaceSelector',
|
|
|
|
|
|
|
|
queryMode: 'local',
|
|
|
|
|
|
|
|
valueField: 'ns',
|
|
|
|
displayField: 'ns',
|
2022-05-14 16:39:52 +00:00
|
|
|
emptyText: gettext('Root'),
|
2022-05-11 15:34:34 +00:00
|
|
|
notFoundIsValid: true,
|
|
|
|
|
2022-05-14 16:40:51 +00:00
|
|
|
triggers: {
|
|
|
|
clear: {
|
|
|
|
cls: 'pmx-clear-trigger',
|
|
|
|
weight: -1,
|
|
|
|
hidden: true,
|
|
|
|
handler: function() {
|
|
|
|
this.triggers.clear.setVisible(false);
|
|
|
|
this.setValue('');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
listeners: {
|
|
|
|
change: function(field, value) {
|
|
|
|
let canClear = value !== '';
|
|
|
|
field.triggers.clear.setVisible(canClear);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2022-05-11 15:34:34 +00:00
|
|
|
matchFieldWidth: false,
|
|
|
|
listConfig: {
|
|
|
|
loadingText: gettext('Scanning...'),
|
|
|
|
width: 350,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
header: gettext('Namespace'),
|
|
|
|
sortable: true,
|
|
|
|
dataIndex: 'ns',
|
2022-05-14 16:39:52 +00:00
|
|
|
renderer: PBS.Utils.render_optional_namespace,
|
2022-05-11 15:34:34 +00:00
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
header: gettext('Comment'),
|
|
|
|
dataIndex: 'comment',
|
|
|
|
renderer: Ext.String.htmlEncode,
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
doRawQuery: function() {
|
|
|
|
// do nothing.
|
|
|
|
},
|
|
|
|
|
|
|
|
setRemote: function(remote) {
|
|
|
|
let me = this;
|
2022-05-14 16:29:09 +00:00
|
|
|
let previousRemote = me.remote;
|
|
|
|
if (previousRemote === remote) {
|
2022-05-11 15:34:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
me.remote = remote;
|
|
|
|
|
2022-05-11 16:00:15 +00:00
|
|
|
me.store.removeAll();
|
2022-05-11 15:34:34 +00:00
|
|
|
|
2022-05-14 16:29:09 +00:00
|
|
|
if (previousRemote) {
|
|
|
|
me.setDisabled(true);
|
|
|
|
me.clearValue();
|
|
|
|
}
|
2022-05-11 15:34:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setRemoteStore: function(remoteStore) {
|
|
|
|
let me = this;
|
2022-05-14 16:29:09 +00:00
|
|
|
let previousStore = me.remoteStore;
|
|
|
|
if (previousStore === remoteStore) {
|
2022-05-11 15:34:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
me.remoteStore = remoteStore;
|
|
|
|
|
2022-05-11 16:00:15 +00:00
|
|
|
me.store.removeAll();
|
2022-05-11 15:34:34 +00:00
|
|
|
|
|
|
|
if (me.remote && me.remoteStore) {
|
|
|
|
me.setDisabled(false);
|
|
|
|
if (!me.firstLoad) {
|
|
|
|
me.clearValue();
|
|
|
|
}
|
2022-05-11 16:00:15 +00:00
|
|
|
let encodedRemote = encodeURIComponent(me.remote);
|
|
|
|
let encodedStore = encodeURIComponent(me.remoteStore);
|
2022-05-11 15:34:34 +00:00
|
|
|
|
2022-05-11 16:00:15 +00:00
|
|
|
me.store.proxy.url = `/api2/json/config/remote/${encodedRemote}/scan/${encodedStore}/namespaces`;
|
|
|
|
me.store.load();
|
2022-05-11 15:34:34 +00:00
|
|
|
|
|
|
|
me.firstLoad = false;
|
2022-05-14 16:29:09 +00:00
|
|
|
} else if (previousStore) {
|
2022-05-11 15:34:34 +00:00
|
|
|
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',
|
2022-05-11 16:00:15 +00:00
|
|
|
url: `/api2/json/config/remote/${encodeURIComponent(me.remote)}/scan`,
|
2022-05-11 15:34:34 +00:00
|
|
|
},
|
|
|
|
});
|
2022-05-11 16:00:15 +00:00
|
|
|
store.sort('ns', 'ASC');
|
2022-05-11 15:34:34 +00:00
|
|
|
|
|
|
|
Ext.apply(me, {
|
|
|
|
store: store,
|
|
|
|
});
|
|
|
|
|
|
|
|
me.callParent();
|
|
|
|
},
|
|
|
|
});
|