]>
Commit | Line | Data |
---|---|---|
2c1d504e | 1 | /*global Proxmox */ |
fe81f069 DM |
2 | Ext.ns('PMG'); |
3 | ||
fe81f069 DM |
4 | console.log("Starting PMG Manager"); |
5 | ||
fe81f069 | 6 | |
2c7b542d DM |
7 | Ext.define('PMG.Utils', { |
8 | singleton: true, | |
ad834b6f | 9 | |
fe81f069 DM |
10 | // this singleton contains miscellaneous utilities |
11 | ||
f9b851e8 DM |
12 | senderText: gettext('Sender'), |
13 | receiverText: gettext('Receiver'), | |
ad88af09 | 14 | scoreText: gettext('Score'), |
012f0f49 | 15 | |
7818f0a3 DM |
16 | user_role_text: { |
17 | root: gettext('Superuser'), | |
18 | admin: gettext('Administrator'), | |
19 | qmanager: gettext('Quarantine Manager'), | |
771bd0b9 | 20 | audit: gettext('Auditor') |
7818f0a3 DM |
21 | }, |
22 | ||
23 | format_user_role: function(role) { | |
24 | return PMG.Utils.user_role_text[role] || role; | |
25 | }, | |
26 | ||
c790d2ab DM |
27 | oclass_text: { |
28 | who: gettext('Who Objects'), | |
29 | what: gettext('What Objects'), | |
30 | when: gettext('When Objects'), | |
076d6a72 DC |
31 | action: gettext('Action Objects'), |
32 | from: gettext('From'), | |
33 | to: gettext('To') | |
34 | }, | |
35 | ||
36 | oclass_icon: { | |
37 | who: '<span class="fa fa-fw fa-user-circle"></span> ', | |
38 | what: '<span class="fa fa-fw fa-cube"></span> ', | |
39 | when: '<span class="fa fa-fw fa-clock-o"></span> ', | |
40 | action: '<span class="fa fa-fw fa-flag"></span> ', | |
41 | from: '<span class="fa fa-fw fa-user-circle"></span> ', | |
cc6b80b6 | 42 | to: '<span class="fa fa-fw fa-user-circle"></span> ' |
076d6a72 DC |
43 | }, |
44 | ||
cf248533 DM |
45 | mail_status_map: { |
46 | 2: 'delivered', | |
47 | 4: 'deferred', | |
48 | 5: 'bounced', | |
49 | N: 'rejected', | |
50 | G: 'greylisted', | |
51 | A: 'accepted', | |
52 | B: 'blocked', | |
53 | Q: 'quarantine' | |
54 | }, | |
55 | ||
20d8d037 DC |
56 | icon_status_map_class: { |
57 | 2: 'check-circle', | |
58 | 4: 'clock-o', | |
59 | 5: 'mail-reply', | |
60 | N: 'times-circle', | |
61 | G: 'list', | |
62 | A: 'check', | |
63 | B: 'ban', | |
64 | Q: 'cube' | |
65 | }, | |
66 | ||
67 | icon_status_map_color: { | |
68 | 2: 'green', | |
69 | 5: 'gray', | |
70 | A: 'green', | |
71 | B: 'red' | |
c4ff49f7 DC |
72 | }, |
73 | ||
74 | format_status_icon: function(status) { | |
20d8d037 DC |
75 | var icon = PMG.Utils.icon_status_map_class[status] || 'question-circle'; |
76 | var color = PMG.Utils.icon_status_map_color[status] || ''; | |
77 | return '<i class="fa fa-' + icon + ' ' + color + '"></i> '; | |
c4ff49f7 DC |
78 | }, |
79 | ||
076d6a72 DC |
80 | format_oclass: function(oclass) { |
81 | var icon = PMG.Utils.oclass_icon[oclass] || ''; | |
82 | var text = PMG.Utils.oclass_text[oclass] || oclass; | |
83 | return icon + text; | |
c790d2ab | 84 | }, |
ad834b6f DM |
85 | |
86 | rule_direction_text: { | |
87 | 0: gettext('In'), | |
88 | 1: gettext('Out'), | |
89 | 2: gettext('In & Out') | |
90 | }, | |
91 | ||
4b7e5c48 | 92 | rule_direction_icon: { |
2b97521b DC |
93 | 0: '<span class="fa fa-fw fa-long-arrow-left"></span> ', |
94 | 1: '<span class="fa fa-fw fa-long-arrow-right"></span> ', | |
95 | 2: '<span class="fa fa-fw fa-exchange"></span> ' | |
4b7e5c48 DC |
96 | }, |
97 | ||
ad834b6f | 98 | format_rule_direction: function(dir) { |
4b7e5c48 DC |
99 | var icon = PMG.Utils.rule_direction_icon[dir] || ''; |
100 | var text = PMG.Utils.rule_direction_text[dir] || dir; | |
101 | return icon + text; | |
ad834b6f DM |
102 | }, |
103 | ||
012f0f49 DM |
104 | format_otype: function(otype) { |
105 | var editor = PMG.Utils.object_editors[otype]; | |
ea4f2a79 | 106 | var iconCls = 'fa fa-question-circle'; |
012f0f49 | 107 | if (editor) { |
ea4f2a79 DC |
108 | var icon = '<span class="fa-fw ' + (editor.iconCls || iconCls) + '"></span> '; |
109 | return icon + editor.subject; | |
012f0f49 | 110 | } |
ea4f2a79 DC |
111 | |
112 | return '<span class="fa-fw ' + iconCls + '"></span> unknown'; | |
f6b1b3bf DM |
113 | }, |
114 | ||
115 | format_ldap_protocol: function(p) { | |
cc6b80b6 DM |
116 | if (p === undefined) { return 'LDAP'; } |
117 | if (p === 'ldap') { return 'LDAP'; } | |
118 | if (p === 'ldaps') { return 'LDAPS'; } | |
f6b1b3bf | 119 | return 'unknown'; |
012f0f49 DM |
120 | }, |
121 | ||
b79fbba8 DC |
122 | convert_field_to_per_min: function(value, record) { |
123 | return (value/(record.data.timespan/60)); | |
124 | }, | |
125 | ||
012f0f49 DM |
126 | object_editors: { |
127 | 1000: { | |
ea4f2a79 | 128 | iconCls: 'fa fa-filter', |
5f3ec152 | 129 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
130 | subdir: 'regex', |
131 | subject: gettext("Regular Expression"), | |
f7be608f | 132 | width: 400, |
012f0f49 DM |
133 | items: [ |
134 | { | |
135 | xtype: 'textfield', | |
136 | name: 'regex', | |
f7be608f | 137 | labelWidth: 150, |
6994550a | 138 | reference: 'regex', |
012f0f49 | 139 | fieldLabel: gettext("Regular Expression") |
6994550a DC |
140 | }, |
141 | { | |
142 | labelWidth: 150, | |
143 | fieldLabel: gettext('Test String'), | |
144 | xtype: 'pmgRegexTester', | |
145 | regexFieldReference: 'regex' | |
012f0f49 DM |
146 | } |
147 | ] | |
148 | }, | |
5f3ec152 | 149 | 1005: { |
ea4f2a79 | 150 | iconCls: 'fa fa-users', |
5f3ec152 DM |
151 | xtype: 'pmgLDAPGroupEditor', |
152 | subdir: 'ldap', | |
153 | subject: gettext("LDAP Group") | |
154 | }, | |
6c137003 | 155 | 1006: { |
ea4f2a79 | 156 | iconCls: 'fa fa-user', |
6c137003 DM |
157 | xtype: 'pmgLDAPUserEditor', |
158 | subdir: 'ldapuser', | |
159 | subject: gettext("LDAP User") | |
160 | }, | |
012f0f49 | 161 | 1009: { |
ea4f2a79 | 162 | iconCls: 'fa fa-filter', |
5f3ec152 | 163 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
164 | subdir: 'receiver_regex', |
165 | subject: gettext("Regular Expression"), | |
f7be608f DM |
166 | receivertest: true, |
167 | width: 400, | |
012f0f49 DM |
168 | items: [ |
169 | { | |
170 | xtype: 'textfield', | |
171 | name: 'regex', | |
f7be608f | 172 | labelWidth: 150, |
012f0f49 DM |
173 | fieldLabel: gettext("Regular Expression") |
174 | } | |
175 | ] | |
176 | }, | |
177 | 1001: { | |
ea4f2a79 | 178 | iconCls: 'fa fa-envelope-o', |
5f3ec152 | 179 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
180 | subdir: 'email', |
181 | subject: gettext("Email"), | |
f7be608f | 182 | width: 400, |
012f0f49 DM |
183 | items: [ |
184 | { | |
185 | xtype: 'textfield', | |
186 | name: 'email', | |
187 | fieldLabel: gettext("Email") | |
188 | } | |
189 | ] | |
190 | }, | |
191 | 1007: { | |
ea4f2a79 | 192 | iconCls: 'fa fa-envelope-o', |
5f3ec152 | 193 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
194 | subdir: 'receiver', |
195 | subject: gettext("Email"), | |
f7be608f DM |
196 | receivertest: true, |
197 | width: 400, | |
012f0f49 DM |
198 | items: [ |
199 | { | |
200 | xtype: 'textfield', | |
201 | name: 'email', | |
202 | fieldLabel: gettext("Email") | |
203 | } | |
204 | ] | |
205 | }, | |
206 | 1002: { | |
ea4f2a79 | 207 | iconCls: 'fa fa-globe', |
5f3ec152 | 208 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
209 | subdir: 'domain', |
210 | subject: gettext("Domain"), | |
f7be608f | 211 | width: 400, |
012f0f49 DM |
212 | items: [ |
213 | { | |
214 | xtype: 'textfield', | |
215 | name: 'domain', | |
216 | fieldLabel: gettext("Domain") | |
217 | } | |
218 | ] | |
219 | }, | |
220 | 1008: { | |
ea4f2a79 | 221 | iconCls: 'fa fa-globe', |
5f3ec152 | 222 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
223 | subdir: 'receiver_domain', |
224 | subject: gettext("Domain"), | |
f7be608f DM |
225 | receivertest: true, |
226 | width: 400, | |
012f0f49 DM |
227 | items: [ |
228 | { | |
229 | xtype: 'textfield', | |
230 | name: 'domain', | |
231 | fieldLabel: gettext("Domain") | |
232 | } | |
233 | ] | |
234 | }, | |
235 | 1003: { | |
ea4f2a79 | 236 | iconCls: 'fa fa-globe', |
5f3ec152 | 237 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
238 | subdir: 'ip', |
239 | subject: gettext("IP Address"), | |
f7be608f | 240 | width: 400, |
012f0f49 DM |
241 | items: [ |
242 | { | |
243 | xtype: 'textfield', | |
244 | name: 'ip', | |
245 | fieldLabel: gettext("IP Address") | |
246 | } | |
247 | ] | |
248 | }, | |
249 | 1004: { | |
ea4f2a79 | 250 | iconCls: 'fa fa-globe', |
5f3ec152 | 251 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
252 | subdir: 'network', |
253 | subject: gettext("IP Network"), | |
f7be608f | 254 | width: 400, |
012f0f49 DM |
255 | items: [ |
256 | { | |
257 | xtype: 'textfield', | |
258 | name: 'cidr', | |
259 | fieldLabel: gettext("IP Network") | |
260 | } | |
261 | ] | |
b4eee4f7 DM |
262 | }, |
263 | 2000: { | |
ea4f2a79 | 264 | iconCls: 'fa fa-clock-o', |
5f3ec152 | 265 | xtype: 'proxmoxWindowEdit', |
b4eee4f7 DM |
266 | subdir: 'timeframe', |
267 | subject: gettext("TimeFrame"), | |
268 | items: [ | |
269 | { | |
270 | xtype: 'timefield', | |
271 | name: 'start', | |
272 | format: 'H:i', | |
273 | fieldLabel: gettext("Start Time") | |
274 | }, | |
275 | { | |
276 | xtype: 'timefield', | |
277 | name: 'end', | |
278 | format: 'H:i', | |
279 | fieldLabel: gettext("End Time") | |
280 | } | |
281 | ] | |
f5de8682 | 282 | }, |
bed64e74 | 283 | 3000: { |
ea4f2a79 | 284 | iconCls: 'fa fa-bullhorn', |
bed64e74 DC |
285 | xtype: 'proxmoxWindowEdit', |
286 | subdir: 'spamfilter', | |
287 | subject: gettext('Spam Filter'), | |
288 | items: [ | |
289 | { | |
290 | xtype: 'proxmoxintegerfield', | |
291 | name: 'spamlevel', | |
292 | allowBlank: false, | |
293 | minValue: 0, | |
294 | fieldLabel: gettext('Level') | |
cc6b80b6 | 295 | } |
bed64e74 DC |
296 | ] |
297 | }, | |
8ddd9c44 | 298 | 3001: { |
ea4f2a79 | 299 | iconCls: 'fa fa-bug', |
8ddd9c44 DC |
300 | xtype: 'proxmoxWindowEdit', |
301 | subdir: 'virusfilter', | |
302 | subject: gettext('Virus Filter'), | |
303 | uneditable: true, | |
304 | // there are no parameters to give, so we simply submit it | |
305 | listeners: { | |
306 | show: function(win) { | |
307 | win.submit(); | |
308 | } | |
309 | } | |
310 | }, | |
3a9b95a7 | 311 | 3002: { |
ea4f2a79 | 312 | iconCls: 'fa fa-code', |
3a9b95a7 DC |
313 | xtype: 'proxmoxWindowEdit', |
314 | subdir: 'matchfield', | |
315 | subject: gettext('Match Field'), | |
50fa6520 | 316 | width: 400, |
3a9b95a7 DC |
317 | items: [ |
318 | { | |
319 | xtype: 'textfield', | |
320 | name: 'field', | |
50fa6520 | 321 | labelWidth: 150, |
3a9b95a7 DC |
322 | allowBlank: false, |
323 | fieldLabel: gettext('Field') | |
324 | }, | |
325 | { | |
326 | xtype: 'textfield', | |
50fa6520 | 327 | reference: 'value', |
3a9b95a7 | 328 | name: 'value', |
50fa6520 | 329 | labelWidth: 150, |
3a9b95a7 DC |
330 | allowBlank: false, |
331 | fieldLabel: gettext('Value') | |
332 | }, | |
50fa6520 DC |
333 | { |
334 | labelWidth: 150, | |
335 | fieldLabel: gettext('Test String'), | |
336 | xtype: 'pmgRegexTester', | |
cc6b80b6 | 337 | regexFieldReference: 'value' |
50fa6520 | 338 | } |
3a9b95a7 DC |
339 | ] |
340 | }, | |
341 | 3003: { | |
ea4f2a79 | 342 | iconCls: 'fa fa-file-image-o', |
3a9b95a7 DC |
343 | xtype: 'proxmoxWindowEdit', |
344 | subdir: 'contenttype', | |
345 | width: 400, | |
3fb5067f | 346 | subject: gettext('Content Type Filter'), |
3a9b95a7 DC |
347 | items: [ |
348 | { | |
349 | xtype: 'combobox', | |
350 | displayField: 'text', | |
351 | labelWidth: 150, | |
352 | valueField: 'mimetype', | |
353 | name: 'contenttype', | |
354 | editable: true, | |
355 | queryMode: 'local', | |
356 | store: { | |
357 | autoLoad: true, | |
358 | proxy: { | |
359 | type: 'proxmox', | |
360 | url: '/api2/json/config/mimetypes' | |
cc6b80b6 | 361 | } |
3a9b95a7 DC |
362 | }, |
363 | fieldLabel: gettext('Content Type'), | |
364 | anyMatch: true, | |
365 | matchFieldWidth: false, | |
366 | listeners: { | |
367 | change: function(cb, value) { | |
368 | var me = this; | |
369 | me.up().down('displayfield').setValue(value); | |
370 | } | |
371 | } | |
372 | }, | |
373 | { | |
374 | xtype: 'displayfield', | |
375 | fieldLabel: gettext('Value'), | |
376 | labelWidth: 150, | |
377 | allowBlank: false, | |
3fb5067f | 378 | reset: Ext.emptyFn |
cc6b80b6 | 379 | } |
3a9b95a7 DC |
380 | ] |
381 | }, | |
6af39772 | 382 | 3004: { |
ea4f2a79 | 383 | iconCls: 'fa fa-file-o', |
6af39772 DC |
384 | xtype: 'proxmoxWindowEdit', |
385 | subdir: 'filenamefilter', | |
386 | width: 400, | |
387 | subject: gettext('Match Filename'), | |
388 | items: [ | |
389 | { | |
390 | xtype: 'textfield', | |
391 | name: 'filename', | |
392 | reference: 'filename', | |
393 | fieldLabel: gettext('Filename'), | |
394 | labelWidth: 150, | |
395 | allowBlank: false | |
396 | }, | |
397 | { | |
398 | labelWidth: 150, | |
399 | fieldLabel: gettext('Test String'), | |
400 | wholeMatch: true, | |
401 | xtype: 'pmgRegexTester', | |
402 | regexFieldReference: 'filename' | |
403 | } | |
404 | ] | |
405 | }, | |
e234e99d | 406 | 3005: { |
ea4f2a79 | 407 | iconCls: 'fa fa-file-archive-o', |
e234e99d DC |
408 | xtype: 'proxmoxWindowEdit', |
409 | subdir: 'archivefilter', | |
410 | width: 400, | |
411 | subject: gettext('Archive Filter'), | |
412 | items: [ | |
413 | { | |
414 | xtype: 'combobox', | |
415 | displayField: 'text', | |
416 | labelWidth: 150, | |
417 | valueField: 'mimetype', | |
418 | name: 'contenttype', | |
419 | editable: true, | |
420 | queryMode: 'local', | |
421 | store: { | |
422 | autoLoad: true, | |
423 | proxy: { | |
424 | type: 'proxmox', | |
425 | url: '/api2/json/config/mimetypes' | |
cc6b80b6 | 426 | } |
e234e99d DC |
427 | }, |
428 | fieldLabel: gettext('Content Type'), | |
429 | anyMatch: true, | |
430 | matchFieldWidth: false, | |
431 | listeners: { | |
432 | change: function(cb, value) { | |
433 | var me = this; | |
434 | me.up().down('displayfield').setValue(value); | |
435 | } | |
436 | } | |
437 | }, | |
438 | { | |
439 | xtype: 'displayfield', | |
440 | fieldLabel: gettext('Value'), | |
441 | labelWidth: 150, | |
442 | allowBlank: false, | |
443 | reset: Ext.emptyFn | |
444 | } | |
445 | ] | |
446 | }, | |
628eccdb DC |
447 | 4002: { |
448 | xtype: 'proxmoxWindowEdit', | |
449 | subdir: 'notification', | |
450 | subject: gettext('Notification'), | |
451 | width: 400, | |
452 | items: [ | |
453 | { | |
454 | xtype: 'textfield', | |
455 | name: 'name', | |
456 | allowBlank: false, | |
457 | fieldLabel: gettext('Name') | |
458 | }, | |
459 | { | |
460 | xtype: 'textareafield', | |
461 | name: 'info', | |
462 | fieldLabel: gettext("Description") | |
463 | }, | |
464 | { | |
465 | xtype: 'textfield', | |
466 | name: 'to', | |
467 | allowBlank: false, | |
468 | value: '__ADMIN__', | |
469 | fieldLabel: gettext('Receiver') | |
470 | }, | |
471 | { | |
472 | xtype: 'textfield', | |
473 | name: 'subject', | |
474 | allowBlank: false, | |
475 | value: 'Notification: __SUBJECT__', | |
476 | fieldLabel: gettext('Subject') | |
477 | }, | |
478 | { | |
479 | xtype: 'textarea', | |
480 | name: 'body', | |
481 | allowBlank: false, | |
482 | grow: true, | |
483 | growMax: 250, | |
484 | value: | |
485 | "Proxmox Notifcation:\n\n" + | |
486 | "Sender: __SENDER__\n" + | |
487 | "Receiver: __RECEIVERS__\n" + | |
488 | "Targets: __TARGETS__\n\n" + | |
489 | "Subject: __SUBJECT__\n\n" + | |
490 | "Matching Rule: __RULE__\n\n" + | |
491 | "__RULE_INFO__\n\n" + | |
492 | "__VIRUS_INFO__\n" + | |
493 | "__SPAM_INFO__\n", | |
494 | fieldLabel: gettext('Body') | |
495 | }, | |
496 | { | |
497 | xtype: 'proxmoxcheckbox', | |
498 | name: 'attach', | |
499 | fieldLabel: gettext("Attach orig. Mail") | |
500 | } | |
501 | ] | |
502 | }, | |
503 | 4003: { | |
504 | xtype: 'proxmoxWindowEdit', | |
505 | subdir: 'field', | |
506 | subject: gettext('Header Attribute'), | |
507 | width: 400, | |
508 | items: [ | |
509 | { | |
510 | xtype: 'textfield', | |
511 | name: 'name', | |
512 | allowBlank: false, | |
513 | fieldLabel: gettext('Name') | |
514 | }, | |
515 | { | |
516 | xtype: 'textareafield', | |
517 | name: 'info', | |
518 | fieldLabel: gettext("Description") | |
519 | }, | |
520 | { | |
521 | xtype: 'textfield', | |
522 | name: 'field', | |
523 | allowBlank: false, | |
524 | fieldLabel: gettext('Field') | |
525 | }, | |
526 | { | |
527 | xtype: 'textfield', | |
528 | reference: 'value', | |
529 | name: 'value', | |
530 | allowBlank: false, | |
531 | fieldLabel: gettext('Value') | |
532 | } | |
533 | ] | |
534 | }, | |
f5de8682 | 535 | 4005: { |
5f3ec152 | 536 | xtype: 'proxmoxWindowEdit', |
f5de8682 DM |
537 | subdir: 'bcc', |
538 | subject: gettext('BCC'), | |
539 | width: 400, | |
540 | items: [ | |
541 | { | |
542 | xtype: 'textfield', | |
543 | name: 'name', | |
544 | allowBlank: false, | |
545 | fieldLabel: gettext('Name') | |
546 | }, | |
547 | { | |
548 | xtype: 'textareafield', | |
549 | name: 'info', | |
550 | fieldLabel: gettext("Description") | |
551 | }, | |
552 | { | |
553 | xtype: 'textfield', | |
554 | name: 'target', | |
555 | allowBlank: false, | |
556 | fieldLabel: gettext("Target") | |
557 | }, | |
558 | { | |
559 | xtype: 'proxmoxcheckbox', | |
560 | checked: true, | |
561 | name: 'original', | |
562 | fieldLabel: gettext("send orig. Mail") | |
563 | } | |
564 | ] | |
565 | ||
628eccdb DC |
566 | }, |
567 | 4007: { | |
568 | xtype: 'proxmoxWindowEdit', | |
569 | subdir: 'removeattachments', | |
570 | subject: gettext('Remove Attachments'), | |
571 | width: 500, | |
572 | fieldDefaults: { | |
573 | labelWidth: 150 | |
574 | }, | |
575 | items: [ | |
576 | { | |
577 | xtype: 'textfield', | |
578 | name: 'name', | |
579 | allowBlank: false, | |
580 | fieldLabel: gettext('Name') | |
581 | }, | |
582 | { | |
583 | xtype: 'textareafield', | |
584 | name: 'info', | |
585 | fieldLabel: gettext("Description") | |
586 | }, | |
587 | { | |
588 | xtype: 'textareafield', | |
589 | name: 'text', | |
590 | grow: true, | |
591 | growMax: 250, | |
592 | fieldLabel: gettext("Text Replacement") | |
593 | }, | |
594 | { | |
595 | xtype: 'proxmoxcheckbox', | |
596 | checked: true, | |
597 | name: 'all', | |
598 | fieldLabel: gettext("Remove all attachments") | |
599 | } | |
600 | ] | |
601 | }, | |
602 | 4009: { | |
603 | xtype: 'proxmoxWindowEdit', | |
604 | subdir: 'disclaimer', | |
605 | subject: gettext('Disclaimer'), | |
606 | width: 400, | |
607 | items: [ | |
608 | { | |
609 | xtype: 'textfield', | |
610 | name: 'name', | |
611 | allowBlank: false, | |
612 | fieldLabel: gettext('Name') | |
613 | }, | |
614 | { | |
615 | xtype: 'textareafield', | |
616 | name: 'info', | |
617 | fieldLabel: gettext("Description") | |
618 | }, | |
619 | { | |
620 | xtype: 'textareafield', | |
621 | name: 'disclaimer', | |
622 | grow: true, | |
623 | growMax: 250, | |
624 | fieldLabel: gettext("Disclaimer") | |
625 | } | |
626 | ] | |
012f0f49 DM |
627 | } |
628 | }, | |
ad834b6f | 629 | |
f1ab2a14 DC |
630 | updateLoginData: function(data) { |
631 | Proxmox.CSRFPreventionToken = data.CSRFPreventionToken; | |
632 | Proxmox.UserName = data.username; | |
633 | Ext.util.Cookies.set('PMGAuthCookie', data.ticket, null, '/', null, true ); | |
634 | }, | |
635 | ||
258d48b5 DM |
636 | quarantineActionExtracted: false, |
637 | ||
638 | extractQuarantineAction: function() { | |
639 | ||
cc6b80b6 | 640 | if (PMG.Utils.quarantineActionExtracted) { return; } |
258d48b5 DM |
641 | |
642 | PMG.Utils.quarantineActionExtracted = true; | |
643 | ||
644 | var qs = Ext.Object.fromQueryString(location.search); | |
645 | ||
646 | var cselect = qs.cselect; | |
647 | var action = qs.action; | |
648 | var ticket = qs.ticket; | |
a0a98b8d DC |
649 | var dateString = qs.date; |
650 | ||
651 | if (dateString) { | |
652 | var date = new Date(dateString).getTime()/1000; | |
653 | ||
654 | // set from date for QuarantineList | |
655 | /*jslint confusion: true*/ | |
656 | /*from is a string above and number here */ | |
657 | PMG.QuarantineList.from = date; | |
658 | /*jslint confusion: false*/ | |
659 | } | |
258d48b5 DM |
660 | |
661 | delete qs.cselect; | |
662 | delete qs.action; | |
663 | delete qs.ticket; | |
a0a98b8d | 664 | delete qs.date; |
258d48b5 DM |
665 | |
666 | var newsearch = Ext.Object.toQueryString(qs); | |
667 | ||
668 | var newurl = location.protocol + "//" + location.host + location.pathname; | |
cc6b80b6 | 669 | if (newsearch) { newurl += '?' + newsearch; } |
258d48b5 DM |
670 | newurl += location.hash; |
671 | ||
672 | if (window.history) { | |
673 | window.history.pushState({ path:newurl }, '', newurl); | |
674 | } | |
675 | ||
207471c0 | 676 | if (action || cselect) { |
258d48b5 DM |
677 | return { action: action, cselect: cselect }; |
678 | } | |
679 | }, | |
680 | ||
cf5268ca DC |
681 | doQuarantineAction: function(action, id, callback) { |
682 | Proxmox.Utils.API2Request({ | |
683 | url: '/quarantine/content/', | |
684 | params: { | |
685 | action: action, | |
686 | id: id | |
687 | }, | |
688 | method: 'POST', | |
689 | failure: function(response, opts) { | |
690 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
691 | }, | |
692 | success: function(response, opts) { | |
2fa0b505 DC |
693 | var win = Ext.create('Ext.window.MessageBox',{ |
694 | closeAction: 'destroy' | |
695 | }).show({ | |
cf5268ca DC |
696 | title: gettext('Info'), |
697 | message: "Action '" + action + ' ' + | |
698 | id + "' successful", | |
699 | buttons: Ext.Msg.OK, | |
700 | icon: Ext.MessageBox.INFO | |
701 | }); | |
702 | ||
703 | if (Ext.isFunction(callback)) { | |
704 | callback(); | |
705 | } | |
706 | } | |
707 | }); | |
708 | }, | |
709 | ||
710 | sender_renderer: function(value, metaData, rec) { | |
711 | var subject = Ext.htmlEncode(value); | |
712 | var from = Ext.htmlEncode(rec.data.from); | |
713 | var sender = Ext.htmlEncode(rec.data.sender); | |
714 | if (sender) { | |
de0ebd99 DC |
715 | /*jslint confusion: true*/ |
716 | /*format is a string above*/ | |
cf5268ca DC |
717 | from = Ext.String.format(gettext("{0} on behalf of {1}"), |
718 | sender, from); | |
de0ebd99 | 719 | /*jslint confusion: false*/ |
cf5268ca DC |
720 | } |
721 | return '<small>' + from + '</small><br>' + subject; | |
722 | }, | |
723 | ||
fe81f069 DM |
724 | constructor: function() { |
725 | var me = this; | |
fe81f069 | 726 | |
2c7b542d | 727 | // do whatever you want here |
fe81f069 DM |
728 | } |
729 | }); |