]>
git.proxmox.com Git - pmg-gui.git/blob - js/Workspace.js
4 * popup login window when auth fails (call onLogin handler)
5 * update (re-login) ticket every 15 minutes
9 Ext
.define('PMG.Workspace', {
10 extend
: 'Ext.container.Viewport',
12 title
: 'Proxmox Mail Gateway',
14 loginData
: null, // Data from last login call
16 onLogin: function(loginData
) {},
19 updateLoginData: function(loginData
) {
22 me
.loginData
= loginData
;
23 Proxmox
.CSRFPreventionToken
= loginData
.CSRFPreventionToken
;
24 Proxmox
.UserName
= loginData
.username
;
26 // creates a session cookie (expire = null)
27 // that way the cookie gets deleted after browser window close
28 Ext
.util
.Cookies
.set('PMGAuthCookie', loginData
.ticket
, null, '/', null, true);
29 me
.onLogin(loginData
);
33 showLogin: function() {
36 Proxmox
.Utils
.authClear();
37 Proxmox
.UserName
= null;
41 me
.login
= Ext
.create('PMG.window.LoginWindow', {
42 handler: function(data
) {
44 me
.updateLoginData(data
);
52 initComponent : function() {
55 Ext
.tip
.QuickTipManager
.init();
57 // fixme: what about other errors
58 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
59 if (response
.status
== 401) { // auth failure
66 if (!Proxmox
.Utils
.authOK()) {
70 me
.onLogin(me
.loginData
);
74 Ext
.TaskManager
.start({
76 var ticket
= Proxmox
.Utils
.authOK();
77 if (!ticket
|| !Proxmox
.UserName
) {
83 username
: Proxmox
.UserName
,
86 url
: '/api2/json/access/ticket',
91 success: function(response
, opts
) {
92 var obj
= Ext
.decode(response
.responseText
);
93 me
.updateLoginData(obj
.data
);
102 Ext
.define('PMG.StdWorkspace', {
103 extend
: 'PMG.Workspace',
105 alias
: ['widget.pmgStdWorkspace'],
107 onLogin: function(loginData
) {
113 Proxmox
.Utils
.API2Request({
116 success: function(response
) {
117 PMG
.VersionInfo
= response
.result
.data
;
118 me
.updateVersionInfo();
124 updateUserInfo: function() {
127 var ui
= me
.query('#userinfo')[0];
129 if (Proxmox
.UserName
) {
130 var msg
= Ext
.String
.format(gettext("You are logged in as {0}"), "'" + Proxmox
.UserName
+ "'");
131 ui
.update('<div class="x-unselectable" style="white-space:nowrap;">' + msg
+ '</div>');
138 updateVersionInfo: function() {
141 var ui
= me
.query('#versioninfo')[0];
143 if (PMG
.VersionInfo
) {
144 var version
= PMG
.VersionInfo
.version
+ '-' + PMG
.VersionInfo
.release
+ '/' +
145 PMG
.VersionInfo
.repoid
;
146 ui
.update('Mail Gateway ' + version
);
148 ui
.update('Mail Gateway');
153 initComponent : function() {
158 // var sprovider = Ext.create('PVE.StateProvider');
159 // Ext.state.Manager.setProvider(sprovider);
162 layout
: { type
: 'border' },
179 html
: '<a class="x-unselectable" target=_blank href="http://www.proxmox.com">' +
180 '<img style="padding-top:4px;padding-right:5px" src="/pve2/images/proxmox_logo.png"/></a>'
200 iconCls
: 'fa fa-sign-out',
201 text
: gettext("Logout"),
202 handler: function() {
204 // fixme: me.setContent(null);
212 stateId
: 'pvecenter',
216 defaults
: { layout
: 'fit' },
217 xtype
: 'pmgPanelConfig',
221 title
: gettext('Mail Filter'),
223 expandedOnInit
: true,
224 items
: [{ xtype
: 'pmgRuleConfiguration' }]
229 title
: PMG
.Utils
.oclass_text
['action'],
230 itemId
: 'filter-actions',
231 items
: [{ xtype
: 'pmgActionConfiguration' }]
236 title
: PMG
.Utils
.oclass_text
['who'],
237 itemId
: 'filter-who',
238 items
: [{ xtype
: 'pmgWhoConfiguration' }]
243 title
: PMG
.Utils
.oclass_text
['what'],
244 itemId
: 'filter-what',
245 items
: [{ xtype
: 'pmgWhatConfiguration' }]
251 title
: PMG
.Utils
.oclass_text
['when'],
252 itemId
: 'filter-when',
253 items
: [{ xtype
: 'pmgWhenConfiguration' }]
257 title
: 'Configuration',
258 itemId
: 'configuration',
259 expandedOnInit
: true,
260 items
: [{ xtype
: 'pmgSystemConfiguration' }]
264 groups
: ['configuration'],
265 title
: gettext('Mail Proxy'),
266 itemId
: 'config-mail-proxy',
267 items
: [{ xtype
: 'pmgMailProxyConfiguration' }]
271 groups
: ['configuration'],
272 title
: gettext('Spam Detector'),
273 itemId
: 'config-spam',
274 items
: [{ xtype
: 'pmgSpamDetectorConfiguration' }]
278 groups
: ['configuration'],
279 title
: gettext('Virus Detector'),
280 itemId
: 'config-virus',
281 items
: [{ xtype
: 'pmgVirusDetectorConfiguration' }]
285 groups
: ['configuration'],
286 title
: gettext('User Management'),
287 itemId
: 'config-users',
288 html
: "User Management"
292 groups
: ['configuration'],
293 title
: gettext('Cluster'),
294 itemId
: 'config-cluster',
299 groups
: ['configuration'],
301 itemId
: 'config-license',
307 title
: gettext('Administration'),
309 expandedOnInit
: true,
310 items
: [{ xtype
: 'pmgServerAdministration' }]
315 title
: gettext('Statistics'),
316 itemId
: 'statistics',
322 title
: gettext('Quarantine'),
323 itemId
: 'quarantine',
329 title
: gettext('Tracking Center'),
331 html
: "Tracking Center"
336 title
: gettext('Queues'),
349 // on resize, center all modal windows
350 Ext
.on('resize', function(){
351 var wins
= Ext
.ComponentQuery
.query('window[modal]');
352 if (wins
.length
> 0) {
353 wins
.forEach(function(win
){
354 win
.alignTo(me
, 'c-c');