2020-05-26 10:23:25 +00:00
|
|
|
Ext.define('PBS.window.RemoteEdit', {
|
|
|
|
extend: 'Proxmox.window.Edit',
|
|
|
|
alias: 'widget.pbsRemoteEdit',
|
|
|
|
mixins: ['Proxmox.Mixin.CBind'],
|
|
|
|
|
2020-09-21 11:25:48 +00:00
|
|
|
onlineHelp: 'backup_remote',
|
|
|
|
|
2020-05-26 10:23:25 +00:00
|
|
|
userid: undefined,
|
|
|
|
|
|
|
|
isAdd: true,
|
|
|
|
|
|
|
|
subject: gettext('Remote'),
|
|
|
|
|
|
|
|
fieldDefaults: { labelWidth: 120 },
|
|
|
|
|
|
|
|
cbindData: function(initialConfig) {
|
|
|
|
let me = this;
|
|
|
|
|
|
|
|
let baseurl = '/api2/extjs/config/remote';
|
|
|
|
let name = initialConfig.name;
|
|
|
|
|
|
|
|
me.isCreate = !name;
|
|
|
|
me.url = name ? `${baseurl}/${name}` : baseurl;
|
|
|
|
me.method = name ? 'PUT' : 'POST';
|
|
|
|
me.autoLoad = !!name;
|
|
|
|
return {
|
|
|
|
passwordEmptyText: me.isCreate ? '' : gettext('Unchanged'),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
items: {
|
|
|
|
xtype: 'inputpanel',
|
|
|
|
column1: [
|
|
|
|
{
|
|
|
|
xtype: 'pmxDisplayEditField',
|
|
|
|
name: 'name',
|
|
|
|
fieldLabel: gettext('Remote'),
|
|
|
|
renderer: Ext.htmlEncode,
|
|
|
|
allowBlank: false,
|
|
|
|
minLength: 4,
|
|
|
|
cbind: {
|
|
|
|
editable: '{isCreate}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxtextfield',
|
|
|
|
allowBlank: false,
|
2020-10-01 07:57:57 +00:00
|
|
|
name: 'hostport',
|
|
|
|
submitValue: false,
|
|
|
|
vtype: 'HostPort',
|
2020-05-26 10:23:25 +00:00
|
|
|
fieldLabel: gettext('Host'),
|
2020-10-01 07:57:57 +00:00
|
|
|
listeners: {
|
|
|
|
change: function(field, newvalue) {
|
|
|
|
let host = newvalue;
|
|
|
|
let port;
|
|
|
|
|
|
|
|
let match = Proxmox.Utils.HostPort_match.exec(newvalue);
|
|
|
|
if (match === null) {
|
|
|
|
match = Proxmox.Utils.HostPortBrackets_match.exec(newvalue);
|
|
|
|
if (match === null) {
|
|
|
|
match = Proxmox.Utils.IP6_dotnotation_match.exec(newvalue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match !== null) {
|
|
|
|
host = match[1];
|
|
|
|
if (match[2] !== undefined) {
|
|
|
|
port = match[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
field.up('inputpanel').down('field[name=host]').setValue(host);
|
|
|
|
field.up('inputpanel').down('field[name=port]').setValue(port);
|
|
|
|
}
|
|
|
|
}
|
2020-05-26 10:23:25 +00:00
|
|
|
},
|
2020-09-29 14:18:59 +00:00
|
|
|
{
|
2020-10-01 07:57:57 +00:00
|
|
|
xtype: 'proxmoxtextfield',
|
|
|
|
hidden: true,
|
|
|
|
name: 'host',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxtextfield',
|
|
|
|
hidden: true,
|
2020-09-29 14:18:59 +00:00
|
|
|
deleteEmpty: true,
|
2020-10-01 07:57:57 +00:00
|
|
|
name: 'port',
|
2020-09-29 14:18:59 +00:00
|
|
|
},
|
2020-05-26 10:23:25 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
column2: [
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxtextfield',
|
|
|
|
allowBlank: false,
|
|
|
|
name: 'userid',
|
|
|
|
fieldLabel: gettext('Userid'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'textfield',
|
|
|
|
inputType: 'password',
|
|
|
|
fieldLabel: gettext('Password'),
|
|
|
|
name: 'password',
|
|
|
|
cbind: {
|
|
|
|
emptyText: '{passwordEmptyText}',
|
|
|
|
allowBlank: '{!isCreate}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
columnB: [
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxtextfield',
|
|
|
|
name: 'fingerprint',
|
2020-09-29 14:05:53 +00:00
|
|
|
deleteEmpty: true,
|
2020-05-26 10:23:25 +00:00
|
|
|
fieldLabel: gettext('Fingerprint'),
|
|
|
|
},
|
2020-05-29 04:46:56 +00:00
|
|
|
{
|
|
|
|
xtype: 'proxmoxtextfield',
|
|
|
|
name: 'comment',
|
2020-09-29 14:05:53 +00:00
|
|
|
deleteEmpty: true,
|
2020-05-29 04:46:56 +00:00
|
|
|
fieldLabel: gettext('Comment'),
|
|
|
|
},
|
2020-05-26 10:23:25 +00:00
|
|
|
],
|
|
|
|
},
|
2020-05-28 15:15:15 +00:00
|
|
|
|
2020-10-01 07:57:57 +00:00
|
|
|
setValues: function(values) {
|
|
|
|
let me = this;
|
|
|
|
|
|
|
|
let host = values.host;
|
|
|
|
if (values.port !== undefined) {
|
|
|
|
if (Proxmox.Utils.IP6_match.test(host)) {
|
|
|
|
host = `[${host}]`;
|
|
|
|
}
|
|
|
|
host += `:${values.port}`;
|
|
|
|
}
|
|
|
|
values.hostport = host;
|
|
|
|
|
|
|
|
return me.callParent([values]);
|
|
|
|
},
|
|
|
|
|
2020-05-28 15:15:15 +00:00
|
|
|
getValues: function() {
|
|
|
|
let me = this;
|
|
|
|
let values = me.callParent(arguments);
|
|
|
|
|
|
|
|
if (values.password === '') {
|
|
|
|
delete values.password;
|
|
|
|
}
|
|
|
|
|
|
|
|
return values;
|
|
|
|
},
|
2020-05-26 10:23:25 +00:00
|
|
|
});
|