]> git.proxmox.com Git - pmg-gui.git/blob - js/Utils.js
improve LDAP object nameing
[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 format_ldap_protocol: function(p) {
40 if (p === undefined) return 'LDAP';
41 if (p === 'ldap') return 'LDAP';
42 if (p === 'ldaps') return 'LDAPS';
43 return 'unknown';
44 },
45
46 object_editors: {
47 1000: {
48 xtype: 'proxmoxWindowEdit',
49 subdir: 'regex',
50 subject: gettext("Regular Expression"),
51 width: 400,
52 items: [
53 {
54 xtype: 'textfield',
55 name: 'regex',
56 labelWidth: 150,
57 fieldLabel: gettext("Regular Expression")
58 }
59 ]
60 },
61 1005: {
62 xtype: 'pmgLDAPGroupEditor',
63 subdir: 'ldap',
64 subject: gettext("LDAP Group")
65 },
66 1006: {
67 xtype: 'pmgLDAPUserEditor',
68 subdir: 'ldapuser',
69 subject: gettext("LDAP User")
70 },
71 1009: {
72 xtype: 'proxmoxWindowEdit',
73 subdir: 'receiver_regex',
74 subject: gettext("Regular Expression"),
75 receivertest: true,
76 width: 400,
77 items: [
78 {
79 xtype: 'textfield',
80 name: 'regex',
81 labelWidth: 150,
82 fieldLabel: gettext("Regular Expression")
83 }
84 ]
85 },
86 1001: {
87 xtype: 'proxmoxWindowEdit',
88 subdir: 'email',
89 subject: gettext("Email"),
90 width: 400,
91 items: [
92 {
93 xtype: 'textfield',
94 name: 'email',
95 fieldLabel: gettext("Email")
96 }
97 ]
98 },
99 1007: {
100 xtype: 'proxmoxWindowEdit',
101 subdir: 'receiver',
102 subject: gettext("Email"),
103 receivertest: true,
104 width: 400,
105 items: [
106 {
107 xtype: 'textfield',
108 name: 'email',
109 fieldLabel: gettext("Email")
110 }
111 ]
112 },
113 1002: {
114 xtype: 'proxmoxWindowEdit',
115 subdir: 'domain',
116 subject: gettext("Domain"),
117 width: 400,
118 items: [
119 {
120 xtype: 'textfield',
121 name: 'domain',
122 fieldLabel: gettext("Domain")
123 }
124 ]
125 },
126 1008: {
127 xtype: 'proxmoxWindowEdit',
128 subdir: 'receiver_domain',
129 subject: gettext("Domain"),
130 receivertest: true,
131 width: 400,
132 items: [
133 {
134 xtype: 'textfield',
135 name: 'domain',
136 fieldLabel: gettext("Domain")
137 }
138 ]
139 },
140 1003: {
141 xtype: 'proxmoxWindowEdit',
142 subdir: 'ip',
143 subject: gettext("IP Address"),
144 width: 400,
145 items: [
146 {
147 xtype: 'textfield',
148 name: 'ip',
149 fieldLabel: gettext("IP Address")
150 }
151 ]
152 },
153 1004: {
154 xtype: 'proxmoxWindowEdit',
155 subdir: 'network',
156 subject: gettext("IP Network"),
157 width: 400,
158 items: [
159 {
160 xtype: 'textfield',
161 name: 'cidr',
162 fieldLabel: gettext("IP Network")
163 }
164 ]
165 },
166 2000: {
167 xtype: 'proxmoxWindowEdit',
168 subdir: 'timeframe',
169 subject: gettext("TimeFrame"),
170 items: [
171 {
172 xtype: 'timefield',
173 name: 'start',
174 format: 'H:i',
175 fieldLabel: gettext("Start Time")
176 },
177 {
178 xtype: 'timefield',
179 name: 'end',
180 format: 'H:i',
181 fieldLabel: gettext("End Time")
182 }
183 ]
184 },
185 4005: {
186 xtype: 'proxmoxWindowEdit',
187 subdir: 'bcc',
188 subject: gettext('BCC'),
189 width: 400,
190 items: [
191 {
192 xtype: 'textfield',
193 name: 'name',
194 allowBlank: false,
195 fieldLabel: gettext('Name')
196 },
197 {
198 xtype: 'textareafield',
199 name: 'info',
200 fieldLabel: gettext("Description")
201 },
202 {
203 xtype: 'textfield',
204 name: 'target',
205 allowBlank: false,
206 fieldLabel: gettext("Target")
207 },
208 {
209 xtype: 'proxmoxcheckbox',
210 checked: true,
211 name: 'original',
212 fieldLabel: gettext("send orig. Mail")
213 }
214 ]
215
216 }
217 },
218
219 openVNCViewer: function(consoletype, nodename) {
220 var url = Ext.urlEncode({
221 console: consoletype, // upgrade or shell
222 novnc: 1,
223 node: nodename
224 });
225 var nw = window.open("?" + url, '_blank',
226 "innerWidth=745,innerheight=427");
227 nw.focus();
228 },
229
230 constructor: function() {
231 var me = this;
232
233 // do whatever you want here
234 }
235 });