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