]>
Commit | Line | Data |
---|---|---|
d28c1563 TL |
1 | Ext.define('PMG.PBSInputPanel', { |
2 | extend: 'Ext.tab.Panel', | |
3 | xtype: 'pmgPBSInputPanel', | |
4 | mixins: ['Proxmox.Mixin.CBind'], | |
5 | ||
6 | bodyPadding: 10, | |
7 | remoteId: undefined, | |
8 | ||
9 | cbindData: function(initialConfig) { | |
10 | let me = this; | |
11 | ||
12 | me.isCreate = initialConfig.isCreate || !initialConfig.remoteId; | |
13 | return { | |
14 | unsetValue: me.isCreate ? null : undefined, | |
15 | }; | |
16 | }, | |
17 | ||
18 | items: [ | |
19 | { | |
20 | xtype: 'inputpanel', | |
21 | title: gettext('Backup Server'), | |
22 | onGetValues: function(values) { | |
23 | values.disable = values.enable ? 0 : 1; | |
24 | delete values.enable; | |
25 | return values; | |
26 | }, | |
27 | column1: [ | |
28 | { | |
29 | xtype: 'pmxDisplayEditField', | |
30 | name: 'remote', | |
31 | cbind: { | |
32 | value: '{unsetValue}', | |
33 | editable: '{isCreate}', | |
34 | }, | |
35 | fieldLabel: gettext('ID'), | |
36 | allowBlank: false, | |
37 | }, | |
38 | { | |
39 | xtype: 'proxmoxtextfield', | |
40 | name: 'server', | |
41 | cbind: { | |
42 | value: '{unsetValue}', | |
43 | }, | |
44 | vtype: 'DnsOrIp', | |
45 | fieldLabel: gettext('Server'), | |
46 | allowBlank: false, | |
47 | }, | |
48 | { | |
49 | xtype: 'proxmoxtextfield', | |
50 | name: 'datastore', | |
51 | cbind: { | |
52 | value: '{unsetValue}', | |
53 | }, | |
54 | fieldLabel: 'Datastore', | |
55 | allowBlank: false, | |
56 | }, | |
71abce0a SI |
57 | { |
58 | xtype: 'proxmoxKVComboBox', | |
59 | name: 'notify', | |
60 | fieldLabel: gettext('Notify'), | |
61 | comboItems: [ | |
2f26d5e0 TL |
62 | ['always', gettext('Always')], |
63 | ['error', gettext('Errors')], | |
64 | ['never', gettext('Never')], | |
71abce0a SI |
65 | ], |
66 | deleteEmpty: false, | |
2f26d5e0 | 67 | emptyText: gettext('Never'), |
71abce0a | 68 | }, |
d28c1563 TL |
69 | ], |
70 | column2: [ | |
71 | { | |
72 | xtype: 'proxmoxtextfield', | |
73 | name: 'username', | |
74 | cbind: { | |
75 | value: '{unsetValue}', | |
76 | }, | |
77 | emptyText: gettext('Example') + ': admin@pbs', | |
78 | fieldLabel: gettext('Username'), | |
79 | regex: /\S+@\w+/, | |
80 | regexText: gettext('Example') + ': admin@pbs', | |
81 | allowBlank: false, | |
82 | }, | |
83 | { | |
84 | xtype: 'proxmoxtextfield', | |
85 | inputType: 'password', | |
86 | name: 'password', | |
87 | cbind: { | |
88 | value: '{unsetValue}', | |
89 | allowBlank: '{!isCreate}', | |
90 | emptyText: (get) => get('isCreate') ? '' : gettext('Unchanged'), | |
91 | }, | |
92 | fieldLabel: gettext('Password'), | |
93 | }, | |
94 | { | |
95 | xtype: 'proxmoxcheckbox', | |
96 | name: 'enable', | |
97 | checked: true, | |
98 | uncheckedValue: 0, | |
99 | fieldLabel: gettext('Enable'), | |
100 | }, | |
bd73a989 SI |
101 | { |
102 | xtype: 'proxmoxcheckbox', | |
103 | name: 'include-statistics', | |
104 | checked: true, | |
105 | uncheckedValue: 0, | |
106 | fieldLabel: gettext('Include Statistics'), | |
107 | }, | |
d28c1563 TL |
108 | ], |
109 | columnB: [ | |
110 | { | |
111 | xtype: 'proxmoxtextfield', | |
112 | name: 'fingerprint', | |
113 | cbind: { | |
114 | value: '{unsetValue}', | |
115 | }, | |
116 | fieldLabel: gettext('Fingerprint'), | |
117 | emptyText: gettext('Server certificate SHA-256 fingerprint, required for self-signed certificates'), | |
118 | regex: /[A-Fa-f0-9]{2}(:[A-Fa-f0-9]{2}){31}/, | |
119 | regexText: gettext('Example') + ': AB:CD:EF:...', | |
120 | allowBlank: true, | |
121 | }, | |
122 | ], | |
123 | }, | |
124 | { | |
125 | xtype: 'inputpanel', | |
126 | title: gettext('Prune Options'), | |
127 | defaults: { | |
128 | // set nested, else we'd only set the defaults for the two column containers | |
129 | defaults: { | |
130 | minValue: 1, | |
131 | labelWidth: 100, | |
132 | allowBlank: true, | |
133 | }, | |
134 | }, | |
135 | column1: [ | |
136 | { | |
137 | xtype: 'proxmoxintegerfield', | |
138 | fieldLabel: gettext('Keep Last'), | |
139 | name: 'keep-last', | |
140 | cbind: { deleteEmpty: '{!isCreate}' }, | |
141 | }, | |
142 | { | |
143 | xtype: 'proxmoxintegerfield', | |
144 | fieldLabel: gettext('Keep Daily'), | |
145 | name: 'keep-daily', | |
146 | cbind: { deleteEmpty: '{!isCreate}' }, | |
147 | }, | |
148 | { | |
149 | xtype: 'proxmoxintegerfield', | |
150 | fieldLabel: gettext('Keep Monthly'), | |
151 | name: 'keep-monthly', | |
152 | cbind: { deleteEmpty: '{!isCreate}' }, | |
153 | }, | |
154 | ], | |
155 | column2: [ | |
156 | { | |
157 | xtype: 'proxmoxintegerfield', | |
158 | fieldLabel: gettext('Keep Hourly'), | |
159 | name: 'keep-hourly', | |
160 | cbind: { deleteEmpty: '{!isCreate}' }, | |
161 | }, | |
162 | { | |
163 | xtype: 'proxmoxintegerfield', | |
164 | fieldLabel: gettext('Keep Weekly'), | |
165 | name: 'keep-weekly', | |
166 | cbind: { deleteEmpty: '{!isCreate}' }, | |
167 | }, | |
168 | { | |
169 | xtype: 'proxmoxintegerfield', | |
170 | fieldLabel: gettext('Keep Yearly'), | |
171 | name: 'keep-yearly', | |
172 | cbind: { deleteEmpty: '{!isCreate}' }, | |
173 | }, | |
174 | ], | |
175 | }, | |
176 | ], | |
177 | }); | |
178 | ||
179 | Ext.define('PMG.PBSEdit', { | |
180 | extend: 'Proxmox.window.Edit', | |
181 | xtype: 'pmgPBSEdit', | |
afb34731 | 182 | onlineHelp: 'pmgbackup_pbs_remotes', |
d28c1563 TL |
183 | |
184 | subject: 'Proxmox Backup Server', | |
185 | isAdd: true, | |
186 | ||
187 | bodyPadding: 0, | |
188 | ||
189 | initComponent: function() { | |
190 | let me = this; | |
191 | ||
192 | me.isCreate = !me.remoteId; | |
193 | ||
194 | me.method = 'POST'; | |
195 | me.url = '/api2/extjs/config/pbs'; | |
196 | if (!me.isCreate) { | |
197 | me.url += `/${me.remoteId}`; | |
198 | me.method = 'PUT'; | |
199 | } | |
200 | ||
201 | me.items = [{ | |
202 | xtype: 'pmgPBSInputPanel', | |
203 | isCreate: me.isCreate, | |
204 | remoteId: me.remoteId, | |
205 | }]; | |
206 | ||
207 | me.callParent(); | |
208 | ||
209 | if (!me.isCreate) { | |
210 | me.load({ | |
211 | success: function(response, options) { | |
212 | let values = response.result.data; | |
213 | ||
214 | values.enable = values.disable ? 0 : 1; | |
215 | me.setValues(values); | |
216 | }, | |
217 | }); | |
218 | } | |
219 | }, | |
220 | }); |