]>
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 PMG
.CSRFPreventionToken
= loginData
.CSRFPreventionToken
;
24 PMG
.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 PMG
.Utils
.authClear();
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 (!PMG
.Utils
.authOK()) {
70 me
.onLogin(me
.loginData
);
74 Ext
.TaskManager
.start({
76 var ticket
= PMG
.Utils
.authOK();
77 if (!ticket
|| !PMG
.UserName
) {
83 username
: PMG
.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 PMG
.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];
130 var msg
= Ext
.String
.format(gettext("You are logged in as {0}"), "'" + PMG
.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 xtype
: 'pmgPanelConfig',
220 title
: 'Mail Filter',
222 expandedOnInit
: true,
223 items
: [{ xtype
: 'pmgRuleConfiguration' }]
229 itemId
: 'filter-actions',
236 itemId
: 'filter-who',
243 itemId
: 'filter-what',
250 itemId
: 'filter-when',
256 title
: 'Configuration',
257 itemId
: 'configuration',
258 expandedOnInit
: true,
259 items
: [{ xtype
: 'pmgSystemConfiguration' }]
263 groups
: ['configuration'],
265 itemId
: 'config-mail-proxy',
270 groups
: ['configuration'],
271 title
: 'Spam Detector',
272 itemId
: 'config-spam',
273 html
: "Spam Detector"
277 groups
: ['configuration'],
278 title
: 'Virus Detector',
279 itemId
: 'config-virus',
280 html
: "Virus Detector"
284 groups
: ['configuration'],
285 title
: 'User Management',
286 itemId
: 'config-users',
287 html
: "User Management"
291 groups
: ['configuration'],
293 itemId
: 'config-cluster',
298 groups
: ['configuration'],
300 itemId
: 'config-license',
306 title
: 'Administration',
308 expandedOnInit
: true,
309 items
: [{ xtype
: 'pmgServerAdministration' }]
315 itemId
: 'statistics',
322 itemId
: 'quarantine',
328 title
: 'Tracking Center',
330 html
: "Tracking Center"
348 // on resize, center all modal windows
349 Ext
.on('resize', function(){
350 var wins
= Ext
.ComponentQuery
.query('window[modal]');
351 if (wins
.length
> 0) {
352 wins
.forEach(function(win
){
353 win
.alignTo(me
, 'c-c');