]>
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'), | |
012f0f49 | 13 | |
c790d2ab DM |
14 | oclass_text: { |
15 | who: gettext('Who Objects'), | |
16 | what: gettext('What Objects'), | |
17 | when: gettext('When Objects'), | |
076d6a72 DC |
18 | action: gettext('Action Objects'), |
19 | from: gettext('From'), | |
20 | to: gettext('To') | |
21 | }, | |
22 | ||
23 | oclass_icon: { | |
24 | who: '<span class="fa fa-fw fa-user-circle"></span> ', | |
25 | what: '<span class="fa fa-fw fa-cube"></span> ', | |
26 | when: '<span class="fa fa-fw fa-clock-o"></span> ', | |
27 | action: '<span class="fa fa-fw fa-flag"></span> ', | |
28 | from: '<span class="fa fa-fw fa-user-circle"></span> ', | |
29 | to: '<span class="fa fa-fw fa-user-circle"></span> ', | |
30 | }, | |
31 | ||
32 | format_oclass: function(oclass) { | |
33 | var icon = PMG.Utils.oclass_icon[oclass] || ''; | |
34 | var text = PMG.Utils.oclass_text[oclass] || oclass; | |
35 | return icon + text; | |
c790d2ab | 36 | }, |
ad834b6f DM |
37 | |
38 | rule_direction_text: { | |
39 | 0: gettext('In'), | |
40 | 1: gettext('Out'), | |
41 | 2: gettext('In & Out') | |
42 | }, | |
43 | ||
44 | format_rule_direction: function(dir) { | |
45 | return PMG.Utils.rule_direction_text[dir] || dir; | |
46 | }, | |
47 | ||
012f0f49 DM |
48 | format_otype: function(otype) { |
49 | var editor = PMG.Utils.object_editors[otype]; | |
50 | if (editor) { | |
51 | return editor.subject; | |
52 | } | |
53 | return 'unknown'; | |
f6b1b3bf DM |
54 | }, |
55 | ||
56 | format_ldap_protocol: function(p) { | |
57 | if (p === undefined) return 'LDAP'; | |
58 | if (p === 'ldap') return 'LDAP'; | |
59 | if (p === 'ldaps') return 'LDAPS'; | |
60 | return 'unknown'; | |
012f0f49 DM |
61 | }, |
62 | ||
63 | object_editors: { | |
64 | 1000: { | |
5f3ec152 | 65 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
66 | subdir: 'regex', |
67 | subject: gettext("Regular Expression"), | |
f7be608f | 68 | width: 400, |
012f0f49 DM |
69 | items: [ |
70 | { | |
71 | xtype: 'textfield', | |
72 | name: 'regex', | |
f7be608f | 73 | labelWidth: 150, |
012f0f49 DM |
74 | fieldLabel: gettext("Regular Expression") |
75 | } | |
76 | ] | |
77 | }, | |
5f3ec152 DM |
78 | 1005: { |
79 | xtype: 'pmgLDAPGroupEditor', | |
80 | subdir: 'ldap', | |
81 | subject: gettext("LDAP Group") | |
82 | }, | |
6c137003 DM |
83 | 1006: { |
84 | xtype: 'pmgLDAPUserEditor', | |
85 | subdir: 'ldapuser', | |
86 | subject: gettext("LDAP User") | |
87 | }, | |
012f0f49 | 88 | 1009: { |
5f3ec152 | 89 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
90 | subdir: 'receiver_regex', |
91 | subject: gettext("Regular Expression"), | |
f7be608f DM |
92 | receivertest: true, |
93 | width: 400, | |
012f0f49 DM |
94 | items: [ |
95 | { | |
96 | xtype: 'textfield', | |
97 | name: 'regex', | |
f7be608f | 98 | labelWidth: 150, |
012f0f49 DM |
99 | fieldLabel: gettext("Regular Expression") |
100 | } | |
101 | ] | |
102 | }, | |
103 | 1001: { | |
5f3ec152 | 104 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
105 | subdir: 'email', |
106 | subject: gettext("Email"), | |
f7be608f | 107 | width: 400, |
012f0f49 DM |
108 | items: [ |
109 | { | |
110 | xtype: 'textfield', | |
111 | name: 'email', | |
112 | fieldLabel: gettext("Email") | |
113 | } | |
114 | ] | |
115 | }, | |
116 | 1007: { | |
5f3ec152 | 117 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
118 | subdir: 'receiver', |
119 | subject: gettext("Email"), | |
f7be608f DM |
120 | receivertest: true, |
121 | width: 400, | |
012f0f49 DM |
122 | items: [ |
123 | { | |
124 | xtype: 'textfield', | |
125 | name: 'email', | |
126 | fieldLabel: gettext("Email") | |
127 | } | |
128 | ] | |
129 | }, | |
130 | 1002: { | |
5f3ec152 | 131 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
132 | subdir: 'domain', |
133 | subject: gettext("Domain"), | |
f7be608f | 134 | width: 400, |
012f0f49 DM |
135 | items: [ |
136 | { | |
137 | xtype: 'textfield', | |
138 | name: 'domain', | |
139 | fieldLabel: gettext("Domain") | |
140 | } | |
141 | ] | |
142 | }, | |
143 | 1008: { | |
5f3ec152 | 144 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
145 | subdir: 'receiver_domain', |
146 | subject: gettext("Domain"), | |
f7be608f DM |
147 | receivertest: true, |
148 | width: 400, | |
012f0f49 DM |
149 | items: [ |
150 | { | |
151 | xtype: 'textfield', | |
152 | name: 'domain', | |
153 | fieldLabel: gettext("Domain") | |
154 | } | |
155 | ] | |
156 | }, | |
157 | 1003: { | |
5f3ec152 | 158 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
159 | subdir: 'ip', |
160 | subject: gettext("IP Address"), | |
f7be608f | 161 | width: 400, |
012f0f49 DM |
162 | items: [ |
163 | { | |
164 | xtype: 'textfield', | |
165 | name: 'ip', | |
166 | fieldLabel: gettext("IP Address") | |
167 | } | |
168 | ] | |
169 | }, | |
170 | 1004: { | |
5f3ec152 | 171 | xtype: 'proxmoxWindowEdit', |
012f0f49 DM |
172 | subdir: 'network', |
173 | subject: gettext("IP Network"), | |
f7be608f | 174 | width: 400, |
012f0f49 DM |
175 | items: [ |
176 | { | |
177 | xtype: 'textfield', | |
178 | name: 'cidr', | |
179 | fieldLabel: gettext("IP Network") | |
180 | } | |
181 | ] | |
b4eee4f7 DM |
182 | }, |
183 | 2000: { | |
5f3ec152 | 184 | xtype: 'proxmoxWindowEdit', |
b4eee4f7 DM |
185 | subdir: 'timeframe', |
186 | subject: gettext("TimeFrame"), | |
187 | items: [ | |
188 | { | |
189 | xtype: 'timefield', | |
190 | name: 'start', | |
191 | format: 'H:i', | |
192 | fieldLabel: gettext("Start Time") | |
193 | }, | |
194 | { | |
195 | xtype: 'timefield', | |
196 | name: 'end', | |
197 | format: 'H:i', | |
198 | fieldLabel: gettext("End Time") | |
199 | } | |
200 | ] | |
f5de8682 DM |
201 | }, |
202 | 4005: { | |
5f3ec152 | 203 | xtype: 'proxmoxWindowEdit', |
f5de8682 DM |
204 | subdir: 'bcc', |
205 | subject: gettext('BCC'), | |
206 | width: 400, | |
207 | items: [ | |
208 | { | |
209 | xtype: 'textfield', | |
210 | name: 'name', | |
211 | allowBlank: false, | |
212 | fieldLabel: gettext('Name') | |
213 | }, | |
214 | { | |
215 | xtype: 'textareafield', | |
216 | name: 'info', | |
217 | fieldLabel: gettext("Description") | |
218 | }, | |
219 | { | |
220 | xtype: 'textfield', | |
221 | name: 'target', | |
222 | allowBlank: false, | |
223 | fieldLabel: gettext("Target") | |
224 | }, | |
225 | { | |
226 | xtype: 'proxmoxcheckbox', | |
227 | checked: true, | |
228 | name: 'original', | |
229 | fieldLabel: gettext("send orig. Mail") | |
230 | } | |
231 | ] | |
232 | ||
012f0f49 DM |
233 | } |
234 | }, | |
ad834b6f | 235 | |
e653eb82 DM |
236 | openVNCViewer: function(consoletype, nodename) { |
237 | var url = Ext.urlEncode({ | |
238 | console: consoletype, // upgrade or shell | |
239 | novnc: 1, | |
240 | node: nodename | |
241 | }); | |
242 | var nw = window.open("?" + url, '_blank', | |
243 | "innerWidth=745,innerheight=427"); | |
244 | nw.focus(); | |
245 | }, | |
246 | ||
f1ab2a14 DC |
247 | updateLoginData: function(data) { |
248 | Proxmox.CSRFPreventionToken = data.CSRFPreventionToken; | |
249 | Proxmox.UserName = data.username; | |
250 | Ext.util.Cookies.set('PMGAuthCookie', data.ticket, null, '/', null, true ); | |
251 | }, | |
252 | ||
fe81f069 DM |
253 | constructor: function() { |
254 | var me = this; | |
fe81f069 | 255 | |
2c7b542d | 256 | // do whatever you want here |
fe81f069 DM |
257 | } |
258 | }); |