2020-11-05 11:12:24 +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;
|
|
|
|
|
|
|
|
let store = me.store;
|
|
|
|
store.removeAll();
|
|
|
|
|
|
|
|
if (me.remote) {
|
|
|
|
me.setDisabled(false);
|
|
|
|
if (!me.firstLoad) {
|
|
|
|
me.clearValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
store.proxy.url = '/api2/json/config/remote/' + encodeURIComponent(me.remote) + '/scan';
|
|
|
|
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: ['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();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-05-29 08:53:41 +00:00
|
|
|
Ext.define('PBS.window.SyncJobEdit', {
|
|
|
|
extend: 'Proxmox.window.Edit',
|
|
|
|
alias: 'widget.pbsSyncJobEdit',
|
|
|
|
mixins: ['Proxmox.Mixin.CBind'],
|
|
|
|
|
|
|
|
userid: undefined,
|
|
|
|
|
2020-09-11 08:35:28 +00:00
|
|
|
onlineHelp: 'syncjobs',
|
|
|
|
|
2020-05-29 08:53:41 +00:00
|
|
|
isAdd: true,
|
|
|
|
|
|
|
|
subject: gettext('SyncJob'),
|
|
|
|
|
|
|
|
fieldDefaults: { labelWidth: 120 },
|
2020-11-04 18:05:46 +00:00
|
|
|
defaultFocus: 'proxmoxtextfield[name=comment]',
|
2020-05-29 08:53:41 +00:00
|
|
|
|
|
|
|
cbindData: function(initialConfig) {
|
|
|
|
let me = this;
|
|
|
|
|
|
|
|
let baseurl = '/api2/extjs/config/sync';
|
|
|
|
let id = initialConfig.id;
|
|
|
|
|
|
|
|
me.isCreate = !id;
|
|
|
|
me.url = id ? `${baseurl}/${id}` : baseurl;
|
|
|
|
me.method = id ? 'PUT' : 'POST';
|
|
|
|
me.autoLoad = !!id;
|
2020-11-04 18:04:06 +00:00
|
|
|
me.scheduleValue = id ? null : 'hourly';
|
2020-11-06 07:07:02 +00:00
|
|
|
me.userid = id ? null : Proxmox.UserName;
|
2020-05-29 08:53:41 +00:00
|
|
|
return { };
|
|
|
|
},
|
|
|
|
|
|
|
|
items: {
|
|
|
|
xtype: 'inputpanel',
|
2020-10-28 20:25:30 +00:00
|
|
|
onGetValues: function(values) {
|
|
|
|
let me = this;
|
|
|
|
|
|
|
|
if (!values.id && me.up('pbsSyncJobEdit').isCreate) {
|
|
|
|
values.id = 'auto-' + Ext.data.identifier.Uuid.Global.generate().slice(0, 23);
|
|
|
|
}
|
|
|
|
return values;
|
|
|
|
},
|
2020-05-29 08:53:41 +00:00
|
|
|
column1: [
|
|
|
|
{
|
2020-10-28 20:25:30 +00:00
|
|
|
xtype: 'displayfield',
|
|
|
|
name: 'store',
|
|
|
|
fieldLabel: gettext('Local Datastore'),
|
2020-05-29 08:53:41 +00:00
|
|
|
allowBlank: false,
|
2020-10-28 20:25:30 +00:00
|
|
|
submitValue: true,
|
2020-05-29 08:53:41 +00:00
|
|
|
cbind: {
|
2020-10-28 20:25:30 +00:00
|
|
|
value: '{datastore}',
|
2020-05-29 08:53:41 +00:00
|
|
|
},
|
|
|
|
},
|
2020-10-30 11:36:41 +00:00
|
|
|
{
|
2020-11-04 18:04:42 +00:00
|
|
|
fieldLabel: gettext('Local Owner'),
|
2020-10-30 11:36:41 +00:00
|
|
|
xtype: 'pbsUserSelector',
|
|
|
|
name: 'owner',
|
2020-11-04 10:34:14 +00:00
|
|
|
cbind: {
|
2020-11-06 07:07:02 +00:00
|
|
|
value: '{userid}',
|
2020-11-04 10:34:14 +00:00
|
|
|
deleteEmpty: '{!isCreate}',
|
2020-10-30 11:36:41 +00:00
|
|
|
},
|
|
|
|
},
|
2020-05-29 08:53:41 +00:00
|
|
|
{
|
|
|
|
fieldLabel: gettext('Remove vanished'),
|
|
|
|
xtype: 'proxmoxcheckbox',
|
|
|
|
name: 'remove-vanished',
|
2020-11-04 18:07:07 +00:00
|
|
|
autoEl: {
|
|
|
|
tag: 'div',
|
|
|
|
'data-qtip': gettext('Remove snapshots from local datastore if they vanished from source datastore?'),
|
|
|
|
},
|
2020-05-29 08:53:41 +00:00
|
|
|
uncheckedValue: false,
|
2020-07-21 16:48:30 +00:00
|
|
|
value: false,
|
2020-05-29 08:53:41 +00:00
|
|
|
},
|
2020-11-04 18:05:46 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
column2: [
|
|
|
|
{
|
|
|
|
fieldLabel: gettext('Source Remote'),
|
|
|
|
xtype: 'pbsRemoteSelector',
|
|
|
|
allowBlank: false,
|
|
|
|
name: 'remote',
|
2020-11-05 11:12:24 +00:00
|
|
|
listeners: {
|
|
|
|
change: function(f, value) {
|
|
|
|
let me = this;
|
|
|
|
let remoteStoreField = me.up('pbsSyncJobEdit').down('field[name=remote-store]');
|
|
|
|
remoteStoreField.setRemote(value);
|
|
|
|
},
|
|
|
|
},
|
2020-11-04 18:05:46 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldLabel: gettext('Source Datastore'),
|
2020-11-05 11:12:24 +00:00
|
|
|
xtype: 'pbsRemoteStoreSelector',
|
2020-11-04 18:05:46 +00:00
|
|
|
allowBlank: false,
|
|
|
|
name: 'remote-store',
|
2020-11-05 11:12:24 +00:00
|
|
|
disabled: true,
|
2020-11-04 18:05:46 +00:00
|
|
|
},
|
2020-05-29 08:53:41 +00:00
|
|
|
{
|
2020-11-04 18:05:46 +00:00
|
|
|
fieldLabel: gettext('Sync Schedule'),
|
2020-07-21 17:32:25 +00:00
|
|
|
xtype: 'pbsCalendarEvent',
|
2020-05-29 08:53:41 +00:00
|
|
|
name: 'schedule',
|
2020-10-28 20:25:30 +00:00
|
|
|
emptyText: gettext('none (disabled)'),
|
2020-06-23 13:29:57 +00:00
|
|
|
cbind: {
|
|
|
|
deleteEmpty: '{!isCreate}',
|
2020-11-04 18:04:06 +00:00
|
|
|
value: '{scheduleValue}',
|
2020-06-23 13:29:57 +00:00
|
|
|
},
|
2020-05-29 08:53:41 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
columnB: [
|
|
|
|
{
|
|
|
|
fieldLabel: gettext('Comment'),
|
|
|
|
xtype: 'proxmoxtextfield',
|
|
|
|
name: 'comment',
|
2020-06-23 13:29:57 +00:00
|
|
|
cbind: {
|
|
|
|
deleteEmpty: '{!isCreate}',
|
|
|
|
},
|
2020-05-29 08:53:41 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
});
|