]> git.proxmox.com Git - pmg-gui.git/blob - js/Utils.js
ServerStatus.js: panel to view server status and console button
[pmg-gui.git] / js / Utils.js
1 Ext.ns('PMG');
2
3 console.log("Starting PMG Manager");
4
5
6 Ext.define('PMG.Utils', {
7 singleton: true,
8
9 // this singleton contains miscellaneous utilities
10
11 senderText: gettext('Sender'),
12 receiverText: gettext('Receiver'),
13
14 oclass_text: {
15 who: gettext('Who Objects'),
16 what: gettext('What Objects'),
17 when: gettext('When Objects'),
18 action: gettext('Action Objects')
19 },
20
21 rule_direction_text: {
22 0: gettext('In'),
23 1: gettext('Out'),
24 2: gettext('In & Out')
25 },
26
27 format_rule_direction: function(dir) {
28 return PMG.Utils.rule_direction_text[dir] || dir;
29 },
30
31 format_otype: function(otype) {
32 var editor = PMG.Utils.object_editors[otype];
33 if (editor) {
34 return editor.subject;
35 }
36 return 'unknown';
37 },
38
39 object_editors: {
40 1000: {
41 subdir: 'regex',
42 subject: gettext("Regular Expression"),
43 width: 400,
44 items: [
45 {
46 xtype: 'textfield',
47 name: 'regex',
48 labelWidth: 150,
49 fieldLabel: gettext("Regular Expression")
50 }
51 ]
52 },
53 1009: {
54 subdir: 'receiver_regex',
55 subject: gettext("Regular Expression"),
56 receivertest: true,
57 width: 400,
58 items: [
59 {
60 xtype: 'textfield',
61 name: 'regex',
62 labelWidth: 150,
63 fieldLabel: gettext("Regular Expression")
64 }
65 ]
66 },
67 1001: {
68 subdir: 'email',
69 subject: gettext("Email"),
70 width: 400,
71 items: [
72 {
73 xtype: 'textfield',
74 name: 'email',
75 fieldLabel: gettext("Email")
76 }
77 ]
78 },
79 1007: {
80 subdir: 'receiver',
81 subject: gettext("Email"),
82 receivertest: true,
83 width: 400,
84 items: [
85 {
86 xtype: 'textfield',
87 name: 'email',
88 fieldLabel: gettext("Email")
89 }
90 ]
91 },
92 1002: {
93 subdir: 'domain',
94 subject: gettext("Domain"),
95 width: 400,
96 items: [
97 {
98 xtype: 'textfield',
99 name: 'domain',
100 fieldLabel: gettext("Domain")
101 }
102 ]
103 },
104 1008: {
105 subdir: 'receiver_domain',
106 subject: gettext("Domain"),
107 receivertest: true,
108 width: 400,
109 items: [
110 {
111 xtype: 'textfield',
112 name: 'domain',
113 fieldLabel: gettext("Domain")
114 }
115 ]
116 },
117 1003: {
118 subdir: 'ip',
119 subject: gettext("IP Address"),
120 width: 400,
121 items: [
122 {
123 xtype: 'textfield',
124 name: 'ip',
125 fieldLabel: gettext("IP Address")
126 }
127 ]
128 },
129 1004: {
130 subdir: 'network',
131 subject: gettext("IP Network"),
132 width: 400,
133 items: [
134 {
135 xtype: 'textfield',
136 name: 'cidr',
137 fieldLabel: gettext("IP Network")
138 }
139 ]
140 },
141 2000: {
142 subdir: 'timeframe',
143 subject: gettext("TimeFrame"),
144 items: [
145 {
146 xtype: 'timefield',
147 name: 'start',
148 format: 'H:i',
149 fieldLabel: gettext("Start Time")
150 },
151 {
152 xtype: 'timefield',
153 name: 'end',
154 format: 'H:i',
155 fieldLabel: gettext("End Time")
156 }
157 ]
158 },
159 4005: {
160 subdir: 'bcc',
161 subject: gettext('BCC'),
162 width: 400,
163 items: [
164 {
165 xtype: 'textfield',
166 name: 'name',
167 allowBlank: false,
168 fieldLabel: gettext('Name')
169 },
170 {
171 xtype: 'textareafield',
172 name: 'info',
173 fieldLabel: gettext("Description")
174 },
175 {
176 xtype: 'textfield',
177 name: 'target',
178 allowBlank: false,
179 fieldLabel: gettext("Target")
180 },
181 {
182 xtype: 'proxmoxcheckbox',
183 checked: true,
184 name: 'original',
185 fieldLabel: gettext("send orig. Mail")
186 }
187 ]
188
189 }
190 },
191
192 openVNCViewer: function(consoletype, nodename) {
193 var url = Ext.urlEncode({
194 console: consoletype, // upgrade or shell
195 novnc: 1,
196 node: nodename
197 });
198 var nw = window.open("?" + url, '_blank',
199 "innerWidth=745,innerheight=427");
200 nw.focus();
201 },
202
203 constructor: function() {
204 var me = this;
205
206 // do whatever you want here
207 }
208 });