]> git.proxmox.com Git - pmg-gui.git/blob - js/PBSRemoteEdit.js
backup: pbs: add onlineHelp anchors
[pmg-gui.git] / js / PBSRemoteEdit.js
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 },
57 ],
58 column2: [
59 {
60 xtype: 'proxmoxtextfield',
61 name: 'username',
62 cbind: {
63 value: '{unsetValue}',
64 },
65 emptyText: gettext('Example') + ': admin@pbs',
66 fieldLabel: gettext('Username'),
67 regex: /\S+@\w+/,
68 regexText: gettext('Example') + ': admin@pbs',
69 allowBlank: false,
70 },
71 {
72 xtype: 'proxmoxtextfield',
73 inputType: 'password',
74 name: 'password',
75 cbind: {
76 value: '{unsetValue}',
77 allowBlank: '{!isCreate}',
78 emptyText: (get) => get('isCreate') ? '' : gettext('Unchanged'),
79 },
80 fieldLabel: gettext('Password'),
81 },
82 {
83 xtype: 'proxmoxcheckbox',
84 name: 'enable',
85 checked: true,
86 uncheckedValue: 0,
87 fieldLabel: gettext('Enable'),
88 },
89 ],
90 columnB: [
91 {
92 xtype: 'proxmoxtextfield',
93 name: 'fingerprint',
94 cbind: {
95 value: '{unsetValue}',
96 },
97 fieldLabel: gettext('Fingerprint'),
98 emptyText: gettext('Server certificate SHA-256 fingerprint, required for self-signed certificates'),
99 regex: /[A-Fa-f0-9]{2}(:[A-Fa-f0-9]{2}){31}/,
100 regexText: gettext('Example') + ': AB:CD:EF:...',
101 allowBlank: true,
102 },
103 ],
104 },
105 {
106 xtype: 'inputpanel',
107 title: gettext('Prune Options'),
108 defaults: {
109 // set nested, else we'd only set the defaults for the two column containers
110 defaults: {
111 minValue: 1,
112 labelWidth: 100,
113 allowBlank: true,
114 },
115 },
116 column1: [
117 {
118 xtype: 'proxmoxintegerfield',
119 fieldLabel: gettext('Keep Last'),
120 name: 'keep-last',
121 cbind: { deleteEmpty: '{!isCreate}' },
122 },
123 {
124 xtype: 'proxmoxintegerfield',
125 fieldLabel: gettext('Keep Daily'),
126 name: 'keep-daily',
127 cbind: { deleteEmpty: '{!isCreate}' },
128 },
129 {
130 xtype: 'proxmoxintegerfield',
131 fieldLabel: gettext('Keep Monthly'),
132 name: 'keep-monthly',
133 cbind: { deleteEmpty: '{!isCreate}' },
134 },
135 ],
136 column2: [
137 {
138 xtype: 'proxmoxintegerfield',
139 fieldLabel: gettext('Keep Hourly'),
140 name: 'keep-hourly',
141 cbind: { deleteEmpty: '{!isCreate}' },
142 },
143 {
144 xtype: 'proxmoxintegerfield',
145 fieldLabel: gettext('Keep Weekly'),
146 name: 'keep-weekly',
147 cbind: { deleteEmpty: '{!isCreate}' },
148 },
149 {
150 xtype: 'proxmoxintegerfield',
151 fieldLabel: gettext('Keep Yearly'),
152 name: 'keep-yearly',
153 cbind: { deleteEmpty: '{!isCreate}' },
154 },
155 ],
156 },
157 ],
158 });
159
160 Ext.define('PMG.PBSEdit', {
161 extend: 'Proxmox.window.Edit',
162 xtype: 'pmgPBSEdit',
163 onlineHelp: 'pmgbackup_pbs_remotes',
164
165 subject: 'Proxmox Backup Server',
166 isAdd: true,
167
168 bodyPadding: 0,
169
170 initComponent: function() {
171 let me = this;
172
173 me.isCreate = !me.remoteId;
174
175 me.method = 'POST';
176 me.url = '/api2/extjs/config/pbs';
177 if (!me.isCreate) {
178 me.url += `/${me.remoteId}`;
179 me.method = 'PUT';
180 }
181
182 me.items = [{
183 xtype: 'pmgPBSInputPanel',
184 isCreate: me.isCreate,
185 remoteId: me.remoteId,
186 }];
187
188 me.callParent();
189
190 if (!me.isCreate) {
191 me.load({
192 success: function(response, options) {
193 let values = response.result.data;
194
195 values.enable = values.disable ? 0 : 1;
196 me.setValues(values);
197 },
198 });
199 }
200 },
201 });