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