]> git.proxmox.com Git - pmg-gui.git/blame - js/PBSRemoteEdit.js
backup config: add icons to tab buttons
[pmg-gui.git] / js / PBSRemoteEdit.js
CommitLineData
d28c1563
TL
1Ext.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)
967de4e4
TL
71 editConfig: {
72 xtype: 'proxmoxtextfield',
73 },
d28c1563
TL
74 inputType: 'password',
75 name: 'password',
76 cbind: {
d28c1563
TL
77 allowBlank: '{!isCreate}',
78 emptyText: (get) => get('isCreate') ? '' : gettext('Unchanged'),
79 },
80 fieldLabel: gettext('Password'),
81 },
b2aaec40
TL
82 {
83 xtype: 'proxmoxKVComboBox',
84 name: 'notify',
85 fieldLabel: gettext('Notify'),
86 comboItems: [
87 ['always', gettext('Always')],
88 ['error', gettext('Errors')],
89 ['never', gettext('Never')],
90 ],
91 deleteEmpty: false,
92 emptyText: gettext('Never'),
93 },
d28c1563
TL
94 {
95 xtype: 'proxmoxcheckbox',
96 name: 'enable',
97 checked: true,
98 uncheckedValue: 0,
99 fieldLabel: gettext('Enable'),
100 },
b2aaec40
TL
101 ],
102 columnB: [
bd73a989
SI
103 {
104 xtype: 'proxmoxcheckbox',
105 name: 'include-statistics',
106 checked: true,
107 uncheckedValue: 0,
b2aaec40
TL
108 fieldLabel: gettext('Statistics'),
109 boxLabel: gettext('Include in Backup'),
bd73a989 110 },
d28c1563
TL
111 {
112 xtype: 'proxmoxtextfield',
113 name: 'fingerprint',
d28c1563
TL
114 fieldLabel: gettext('Fingerprint'),
115 emptyText: gettext('Server certificate SHA-256 fingerprint, required for self-signed certificates'),
116 regex: /[A-Fa-f0-9]{2}(:[A-Fa-f0-9]{2}){31}/,
117 regexText: gettext('Example') + ': AB:CD:EF:...',
118 allowBlank: true,
119 },
120 ],
121 },
122 {
123 xtype: 'inputpanel',
124 title: gettext('Prune Options'),
125 defaults: {
126 // set nested, else we'd only set the defaults for the two column containers
127 defaults: {
128 minValue: 1,
129 labelWidth: 100,
130 allowBlank: true,
131 },
132 },
133 column1: [
134 {
135 xtype: 'proxmoxintegerfield',
136 fieldLabel: gettext('Keep Last'),
137 name: 'keep-last',
138 cbind: { deleteEmpty: '{!isCreate}' },
139 },
140 {
141 xtype: 'proxmoxintegerfield',
142 fieldLabel: gettext('Keep Daily'),
143 name: 'keep-daily',
144 cbind: { deleteEmpty: '{!isCreate}' },
145 },
146 {
147 xtype: 'proxmoxintegerfield',
148 fieldLabel: gettext('Keep Monthly'),
149 name: 'keep-monthly',
150 cbind: { deleteEmpty: '{!isCreate}' },
151 },
152 ],
153 column2: [
154 {
155 xtype: 'proxmoxintegerfield',
156 fieldLabel: gettext('Keep Hourly'),
157 name: 'keep-hourly',
158 cbind: { deleteEmpty: '{!isCreate}' },
159 },
160 {
161 xtype: 'proxmoxintegerfield',
162 fieldLabel: gettext('Keep Weekly'),
163 name: 'keep-weekly',
164 cbind: { deleteEmpty: '{!isCreate}' },
165 },
166 {
167 xtype: 'proxmoxintegerfield',
168 fieldLabel: gettext('Keep Yearly'),
169 name: 'keep-yearly',
170 cbind: { deleteEmpty: '{!isCreate}' },
171 },
172 ],
173 },
174 ],
175});
176
177Ext.define('PMG.PBSEdit', {
178 extend: 'Proxmox.window.Edit',
179 xtype: 'pmgPBSEdit',
afb34731 180 onlineHelp: 'pmgbackup_pbs_remotes',
d28c1563
TL
181
182 subject: 'Proxmox Backup Server',
183 isAdd: true,
184
185 bodyPadding: 0,
186
187 initComponent: function() {
188 let me = this;
189
190 me.isCreate = !me.remoteId;
191
192 me.method = 'POST';
193 me.url = '/api2/extjs/config/pbs';
194 if (!me.isCreate) {
195 me.url += `/${me.remoteId}`;
196 me.method = 'PUT';
197 }
198
199 me.items = [{
200 xtype: 'pmgPBSInputPanel',
201 isCreate: me.isCreate,
202 remoteId: me.remoteId,
203 }];
204
205 me.callParent();
206
207 if (!me.isCreate) {
208 me.load({
209 success: function(response, options) {
210 let values = response.result.data;
211
212 values.enable = values.disable ? 0 : 1;
213 me.setValues(values);
214 },
215 });
216 }
217 },
218});