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