]>
Commit | Line | Data |
---|---|---|
fe81f069 DM |
1 | Ext.ns('PMG'); |
2 | ||
fe81f069 DM |
3 | console.log("Starting PMG Manager"); |
4 | ||
fe81f069 | 5 | |
2c7b542d DM |
6 | Ext.define('PMG.Utils', { |
7 | singleton: true, | |
ad834b6f | 8 | |
fe81f069 DM |
9 | // this singleton contains miscellaneous utilities |
10 | ||
f9b851e8 DM |
11 | senderText: gettext('Sender'), |
12 | receiverText: gettext('Receiver'), | |
ad88af09 | 13 | scoreText: gettext('Score'), |
012f0f49 | 14 | |
c790d2ab DM |
15 | oclass_text: { |
16 | who: gettext('Who Objects'), | |
17 | what: gettext('What Objects'), | |
18 | when: gettext('When Objects'), | |
076d6a72 DC |
19 | action: gettext('Action Objects'), |
20 | from: gettext('From'), | |
21 | to: gettext('To') | |
22 | }, | |
23 | ||
24 | oclass_icon: { | |
25 | who: '<span class="fa fa-fw fa-user-circle"></span> ', | |
26 | what: '<span class="fa fa-fw fa-cube"></span> ', | |
27 | when: '<span class="fa fa-fw fa-clock-o"></span> ', | |
28 | action: '<span class="fa fa-fw fa-flag"></span> ', | |
29 | from: '<span class="fa fa-fw fa-user-circle"></span> ', | |
cc6b80b6 | 30 | to: '<span class="fa fa-fw fa-user-circle"></span> ' |
076d6a72 DC |
31 | }, |
32 | ||
cf248533 DM |
33 | mail_status_map: { |
34 | 2: 'delivered', | |
35 | 4: 'deferred', | |
36 | 5: 'bounced', | |
37 | N: 'rejected', | |
38 | G: 'greylisted', | |
39 | A: 'accepted', | |
40 | B: 'blocked', | |
41 | Q: 'quarantine' | |
42 | }, | |
43 | ||
076d6a72 DC |
44 | format_oclass: function(oclass) { |
45 | var icon = PMG.Utils.oclass_icon[oclass] || ''; | |
46 | var text = PMG.Utils.oclass_text[oclass] || oclass; | |
47 | return icon + text; | |
c790d2ab | 48 | }, |
ad834b6f DM |
49 | |
50 | rule_direction_text: { | |
51 | 0: gettext('In'), | |
52 | 1: gettext('Out'), | |
53 | 2: gettext('In & Out') | |
54 | }, | |
55 | ||
4b7e5c48 | 56 | rule_direction_icon: { |
2b97521b DC |
57 | 0: '<span class="fa fa-fw fa-long-arrow-left"></span> ', |
58 | 1: '<span class="fa fa-fw fa-long-arrow-right"></span> ', | |
59 | 2: '<span class="fa fa-fw fa-exchange"></span> ' | |
4b7e5c48 DC |
60 | }, |
61 | ||
ad834b6f | 62 | format_rule_direction: function(dir) { |
4b7e5c48 DC |
63 | var icon = PMG.Utils.rule_direction_icon[dir] || ''; |
64 | var text = PMG.Utils.rule_direction_text[dir] || dir; | |
65 | return icon + text; | |
ad834b6f DM |
66 | }, |
67 | ||
012f0f49 DM |
68 | format_otype: function(otype) { |
69 | var editor = PMG.Utils.object_editors[otype]; | |
70 | if (editor) { | |
71 | return editor.subject; | |
72 | } | |
73 | return 'unknown'; | |
f6b1b3bf DM |
74 | }, |
75 | ||
76 | format_ldap_protocol: function(p) { | |
cc6b80b6 DM |
77 | if (p === undefined) { return 'LDAP'; } |
78 | if (p === 'ldap') { return 'LDAP'; } | |
79 | if (p === 'ldaps') { return 'LDAPS'; } | |
f6b1b3bf | 80 | return 'unknown'; |
012f0f49 DM |
81 | }, |
82 | ||
83 | object_editors: { | |
84 | 1000: { | |
5f3ec152 | 85 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
86 | subdir: 'regex', |
87 | subject: gettext("Regular Expression"), | |
f7be608f | 88 | width: 400, |
012f0f49 DM |
89 | items: [ |
90 | { | |
91 | xtype: 'textfield', | |
92 | name: 'regex', | |
f7be608f | 93 | labelWidth: 150, |
012f0f49 DM |
94 | fieldLabel: gettext("Regular Expression") |
95 | } | |
96 | ] | |
97 | }, | |
5f3ec152 DM |
98 | 1005: { |
99 | xtype: 'pmgLDAPGroupEditor', | |
100 | subdir: 'ldap', | |
101 | subject: gettext("LDAP Group") | |
102 | }, | |
6c137003 DM |
103 | 1006: { |
104 | xtype: 'pmgLDAPUserEditor', | |
105 | subdir: 'ldapuser', | |
106 | subject: gettext("LDAP User") | |
107 | }, | |
012f0f49 | 108 | 1009: { |
5f3ec152 | 109 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
110 | subdir: 'receiver_regex', |
111 | subject: gettext("Regular Expression"), | |
f7be608f DM |
112 | receivertest: true, |
113 | width: 400, | |
012f0f49 DM |
114 | items: [ |
115 | { | |
116 | xtype: 'textfield', | |
117 | name: 'regex', | |
f7be608f | 118 | labelWidth: 150, |
012f0f49 DM |
119 | fieldLabel: gettext("Regular Expression") |
120 | } | |
121 | ] | |
122 | }, | |
123 | 1001: { | |
5f3ec152 | 124 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
125 | subdir: 'email', |
126 | subject: gettext("Email"), | |
f7be608f | 127 | width: 400, |
012f0f49 DM |
128 | items: [ |
129 | { | |
130 | xtype: 'textfield', | |
131 | name: 'email', | |
132 | fieldLabel: gettext("Email") | |
133 | } | |
134 | ] | |
135 | }, | |
136 | 1007: { | |
5f3ec152 | 137 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
138 | subdir: 'receiver', |
139 | subject: gettext("Email"), | |
f7be608f DM |
140 | receivertest: true, |
141 | width: 400, | |
012f0f49 DM |
142 | items: [ |
143 | { | |
144 | xtype: 'textfield', | |
145 | name: 'email', | |
146 | fieldLabel: gettext("Email") | |
147 | } | |
148 | ] | |
149 | }, | |
150 | 1002: { | |
5f3ec152 | 151 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
152 | subdir: 'domain', |
153 | subject: gettext("Domain"), | |
f7be608f | 154 | width: 400, |
012f0f49 DM |
155 | items: [ |
156 | { | |
157 | xtype: 'textfield', | |
158 | name: 'domain', | |
159 | fieldLabel: gettext("Domain") | |
160 | } | |
161 | ] | |
162 | }, | |
163 | 1008: { | |
5f3ec152 | 164 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
165 | subdir: 'receiver_domain', |
166 | subject: gettext("Domain"), | |
f7be608f DM |
167 | receivertest: true, |
168 | width: 400, | |
012f0f49 DM |
169 | items: [ |
170 | { | |
171 | xtype: 'textfield', | |
172 | name: 'domain', | |
173 | fieldLabel: gettext("Domain") | |
174 | } | |
175 | ] | |
176 | }, | |
177 | 1003: { | |
5f3ec152 | 178 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
179 | subdir: 'ip', |
180 | subject: gettext("IP Address"), | |
f7be608f | 181 | width: 400, |
012f0f49 DM |
182 | items: [ |
183 | { | |
184 | xtype: 'textfield', | |
185 | name: 'ip', | |
186 | fieldLabel: gettext("IP Address") | |
187 | } | |
188 | ] | |
189 | }, | |
190 | 1004: { | |
5f3ec152 | 191 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
192 | subdir: 'network', |
193 | subject: gettext("IP Network"), | |
f7be608f | 194 | width: 400, |
012f0f49 DM |
195 | items: [ |
196 | { | |
197 | xtype: 'textfield', | |
198 | name: 'cidr', | |
199 | fieldLabel: gettext("IP Network") | |
200 | } | |
201 | ] | |
b4eee4f7 DM |
202 | }, |
203 | 2000: { | |
5f3ec152 | 204 | xtype: 'proxmoxWindowEdit', |
b4eee4f7 DM |
205 | subdir: 'timeframe', |
206 | subject: gettext("TimeFrame"), | |
207 | items: [ | |
208 | { | |
209 | xtype: 'timefield', | |
210 | name: 'start', | |
211 | format: 'H:i', | |
212 | fieldLabel: gettext("Start Time") | |
213 | }, | |
214 | { | |
215 | xtype: 'timefield', | |
216 | name: 'end', | |
217 | format: 'H:i', | |
218 | fieldLabel: gettext("End Time") | |
219 | } | |
220 | ] | |
f5de8682 | 221 | }, |
bed64e74 DC |
222 | 3000: { |
223 | xtype: 'proxmoxWindowEdit', | |
224 | subdir: 'spamfilter', | |
225 | subject: gettext('Spam Filter'), | |
226 | items: [ | |
227 | { | |
228 | xtype: 'proxmoxintegerfield', | |
229 | name: 'spamlevel', | |
230 | allowBlank: false, | |
231 | minValue: 0, | |
232 | fieldLabel: gettext('Level') | |
cc6b80b6 | 233 | } |
bed64e74 DC |
234 | ] |
235 | }, | |
3a9b95a7 DC |
236 | 3002: { |
237 | xtype: 'proxmoxWindowEdit', | |
238 | subdir: 'matchfield', | |
239 | subject: gettext('Match Field'), | |
50fa6520 | 240 | width: 400, |
3a9b95a7 DC |
241 | items: [ |
242 | { | |
243 | xtype: 'textfield', | |
244 | name: 'field', | |
50fa6520 | 245 | labelWidth: 150, |
3a9b95a7 DC |
246 | allowBlank: false, |
247 | fieldLabel: gettext('Field') | |
248 | }, | |
249 | { | |
250 | xtype: 'textfield', | |
50fa6520 | 251 | reference: 'value', |
3a9b95a7 | 252 | name: 'value', |
50fa6520 | 253 | labelWidth: 150, |
3a9b95a7 DC |
254 | allowBlank: false, |
255 | fieldLabel: gettext('Value') | |
256 | }, | |
50fa6520 DC |
257 | { |
258 | labelWidth: 150, | |
259 | fieldLabel: gettext('Test String'), | |
260 | xtype: 'pmgRegexTester', | |
cc6b80b6 | 261 | regexFieldReference: 'value' |
50fa6520 | 262 | } |
3a9b95a7 DC |
263 | ] |
264 | }, | |
265 | 3003: { | |
266 | xtype: 'proxmoxWindowEdit', | |
267 | subdir: 'contenttype', | |
268 | width: 400, | |
3fb5067f | 269 | subject: gettext('Content Type Filter'), |
3a9b95a7 DC |
270 | items: [ |
271 | { | |
272 | xtype: 'combobox', | |
273 | displayField: 'text', | |
274 | labelWidth: 150, | |
275 | valueField: 'mimetype', | |
276 | name: 'contenttype', | |
277 | editable: true, | |
278 | queryMode: 'local', | |
279 | store: { | |
280 | autoLoad: true, | |
281 | proxy: { | |
282 | type: 'proxmox', | |
283 | url: '/api2/json/config/mimetypes' | |
cc6b80b6 | 284 | } |
3a9b95a7 DC |
285 | }, |
286 | fieldLabel: gettext('Content Type'), | |
287 | anyMatch: true, | |
288 | matchFieldWidth: false, | |
289 | listeners: { | |
290 | change: function(cb, value) { | |
291 | var me = this; | |
292 | me.up().down('displayfield').setValue(value); | |
293 | } | |
294 | } | |
295 | }, | |
296 | { | |
297 | xtype: 'displayfield', | |
298 | fieldLabel: gettext('Value'), | |
299 | labelWidth: 150, | |
300 | allowBlank: false, | |
3fb5067f | 301 | reset: Ext.emptyFn |
cc6b80b6 | 302 | } |
3a9b95a7 DC |
303 | ] |
304 | }, | |
6af39772 DC |
305 | 3004: { |
306 | xtype: 'proxmoxWindowEdit', | |
307 | subdir: 'filenamefilter', | |
308 | width: 400, | |
309 | subject: gettext('Match Filename'), | |
310 | items: [ | |
311 | { | |
312 | xtype: 'textfield', | |
313 | name: 'filename', | |
314 | reference: 'filename', | |
315 | fieldLabel: gettext('Filename'), | |
316 | labelWidth: 150, | |
317 | allowBlank: false | |
318 | }, | |
319 | { | |
320 | labelWidth: 150, | |
321 | fieldLabel: gettext('Test String'), | |
322 | wholeMatch: true, | |
323 | xtype: 'pmgRegexTester', | |
324 | regexFieldReference: 'filename' | |
325 | } | |
326 | ] | |
327 | }, | |
e234e99d DC |
328 | 3005: { |
329 | xtype: 'proxmoxWindowEdit', | |
330 | subdir: 'archivefilter', | |
331 | width: 400, | |
332 | subject: gettext('Archive Filter'), | |
333 | items: [ | |
334 | { | |
335 | xtype: 'combobox', | |
336 | displayField: 'text', | |
337 | labelWidth: 150, | |
338 | valueField: 'mimetype', | |
339 | name: 'contenttype', | |
340 | editable: true, | |
341 | queryMode: 'local', | |
342 | store: { | |
343 | autoLoad: true, | |
344 | proxy: { | |
345 | type: 'proxmox', | |
346 | url: '/api2/json/config/mimetypes' | |
cc6b80b6 | 347 | } |
e234e99d DC |
348 | }, |
349 | fieldLabel: gettext('Content Type'), | |
350 | anyMatch: true, | |
351 | matchFieldWidth: false, | |
352 | listeners: { | |
353 | change: function(cb, value) { | |
354 | var me = this; | |
355 | me.up().down('displayfield').setValue(value); | |
356 | } | |
357 | } | |
358 | }, | |
359 | { | |
360 | xtype: 'displayfield', | |
361 | fieldLabel: gettext('Value'), | |
362 | labelWidth: 150, | |
363 | allowBlank: false, | |
364 | reset: Ext.emptyFn | |
365 | } | |
366 | ] | |
367 | }, | |
f5de8682 | 368 | 4005: { |
5f3ec152 | 369 | xtype: 'proxmoxWindowEdit', |
f5de8682 DM |
370 | subdir: 'bcc', |
371 | subject: gettext('BCC'), | |
372 | width: 400, | |
373 | items: [ | |
374 | { | |
375 | xtype: 'textfield', | |
376 | name: 'name', | |
377 | allowBlank: false, | |
378 | fieldLabel: gettext('Name') | |
379 | }, | |
380 | { | |
381 | xtype: 'textareafield', | |
382 | name: 'info', | |
383 | fieldLabel: gettext("Description") | |
384 | }, | |
385 | { | |
386 | xtype: 'textfield', | |
387 | name: 'target', | |
388 | allowBlank: false, | |
389 | fieldLabel: gettext("Target") | |
390 | }, | |
391 | { | |
392 | xtype: 'proxmoxcheckbox', | |
393 | checked: true, | |
394 | name: 'original', | |
395 | fieldLabel: gettext("send orig. Mail") | |
396 | } | |
397 | ] | |
398 | ||
012f0f49 DM |
399 | } |
400 | }, | |
ad834b6f | 401 | |
e653eb82 DM |
402 | openVNCViewer: function(consoletype, nodename) { |
403 | var url = Ext.urlEncode({ | |
404 | console: consoletype, // upgrade or shell | |
405 | novnc: 1, | |
406 | node: nodename | |
407 | }); | |
408 | var nw = window.open("?" + url, '_blank', | |
409 | "innerWidth=745,innerheight=427"); | |
410 | nw.focus(); | |
411 | }, | |
412 | ||
f1ab2a14 DC |
413 | updateLoginData: function(data) { |
414 | Proxmox.CSRFPreventionToken = data.CSRFPreventionToken; | |
415 | Proxmox.UserName = data.username; | |
416 | Ext.util.Cookies.set('PMGAuthCookie', data.ticket, null, '/', null, true ); | |
417 | }, | |
418 | ||
258d48b5 DM |
419 | quarantineActionExtracted: false, |
420 | ||
421 | extractQuarantineAction: function() { | |
422 | ||
cc6b80b6 | 423 | if (PMG.Utils.quarantineActionExtracted) { return; } |
258d48b5 DM |
424 | |
425 | PMG.Utils.quarantineActionExtracted = true; | |
426 | ||
427 | var qs = Ext.Object.fromQueryString(location.search); | |
428 | ||
429 | var cselect = qs.cselect; | |
430 | var action = qs.action; | |
431 | var ticket = qs.ticket; | |
432 | ||
433 | delete qs.cselect; | |
434 | delete qs.action; | |
435 | delete qs.ticket; | |
436 | ||
437 | var newsearch = Ext.Object.toQueryString(qs); | |
438 | ||
439 | var newurl = location.protocol + "//" + location.host + location.pathname; | |
cc6b80b6 | 440 | if (newsearch) { newurl += '?' + newsearch; } |
258d48b5 DM |
441 | newurl += location.hash; |
442 | ||
443 | if (window.history) { | |
444 | window.history.pushState({ path:newurl }, '', newurl); | |
445 | } | |
446 | ||
447 | if (action && cselect) { | |
448 | return { action: action, cselect: cselect }; | |
449 | } | |
450 | }, | |
451 | ||
fe81f069 DM |
452 | constructor: function() { |
453 | var me = this; | |
fe81f069 | 454 | |
2c7b542d | 455 | // do whatever you want here |
fe81f069 DM |
456 | } |
457 | }); |