]>
Commit | Line | Data |
---|---|---|
9e2a4653 DC |
1 | Ext.define('PBS.window.RemoteEdit', { |
2 | extend: 'Proxmox.window.Edit', | |
3 | alias: 'widget.pbsRemoteEdit', | |
4 | mixins: ['Proxmox.Mixin.CBind'], | |
5 | ||
298c6aae OB |
6 | onlineHelp: 'backup_remote', |
7 | ||
9e2a4653 DC |
8 | userid: undefined, |
9 | ||
10 | isAdd: true, | |
11 | ||
12 | subject: gettext('Remote'), | |
13 | ||
14 | fieldDefaults: { labelWidth: 120 }, | |
15 | ||
16 | cbindData: function(initialConfig) { | |
17 | let me = this; | |
18 | ||
19 | let baseurl = '/api2/extjs/config/remote'; | |
20 | let name = initialConfig.name; | |
21 | ||
22 | me.isCreate = !name; | |
23 | me.url = name ? `${baseurl}/${name}` : baseurl; | |
24 | me.method = name ? 'PUT' : 'POST'; | |
25 | me.autoLoad = !!name; | |
26 | return { | |
27 | passwordEmptyText: me.isCreate ? '' : gettext('Unchanged'), | |
28 | }; | |
29 | }, | |
30 | ||
31 | items: { | |
32 | xtype: 'inputpanel', | |
33 | column1: [ | |
34 | { | |
35 | xtype: 'pmxDisplayEditField', | |
36 | name: 'name', | |
37 | fieldLabel: gettext('Remote'), | |
38 | renderer: Ext.htmlEncode, | |
39 | allowBlank: false, | |
40 | minLength: 4, | |
41 | cbind: { | |
42 | editable: '{isCreate}', | |
43 | }, | |
44 | }, | |
45 | { | |
46 | xtype: 'proxmoxtextfield', | |
47 | allowBlank: false, | |
48 | name: 'host', | |
49 | fieldLabel: gettext('Host'), | |
50 | }, | |
51 | ], | |
52 | ||
53 | column2: [ | |
54 | { | |
55 | xtype: 'proxmoxtextfield', | |
56 | allowBlank: false, | |
57 | name: 'userid', | |
58 | fieldLabel: gettext('Userid'), | |
59 | }, | |
60 | { | |
61 | xtype: 'textfield', | |
62 | inputType: 'password', | |
63 | fieldLabel: gettext('Password'), | |
64 | name: 'password', | |
65 | cbind: { | |
66 | emptyText: '{passwordEmptyText}', | |
67 | allowBlank: '{!isCreate}', | |
68 | }, | |
69 | }, | |
70 | ], | |
71 | ||
72 | columnB: [ | |
73 | { | |
74 | xtype: 'proxmoxtextfield', | |
75 | name: 'fingerprint', | |
76 | fieldLabel: gettext('Fingerprint'), | |
77 | }, | |
c6887a8a DM |
78 | { |
79 | xtype: 'proxmoxtextfield', | |
80 | name: 'comment', | |
81 | fieldLabel: gettext('Comment'), | |
82 | }, | |
9e2a4653 DC |
83 | ], |
84 | }, | |
6bba120d DC |
85 | |
86 | getValues: function() { | |
87 | let me = this; | |
88 | let values = me.callParent(arguments); | |
89 | ||
90 | if (values.password === '') { | |
91 | delete values.password; | |
92 | } | |
93 | ||
94 | return values; | |
95 | }, | |
9e2a4653 | 96 | }); |