]>
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 console
.dir(loginData
);
24 me
.loginData
= loginData
;
25 PMG
.CSRFPreventionToken
= loginData
.CSRFPreventionToken
;
26 PMG
.UserName
= loginData
.username
;
28 // creates a session cookie (expire = null)
29 // that way the cookie gets deleted after browser window close
30 Ext
.util
.Cookies
.set('PMGAuthCookie', loginData
.ticket
, null, '/', null, true);
31 me
.onLogin(loginData
);
35 showLogin: function() {
38 PMG
.Utils
.authClear();
43 me
.login
= Ext
.create('PMG.window.LoginWindow', {
44 handler: function(data
) {
46 me
.updateLoginData(data
);
54 initComponent : function() {
57 Ext
.tip
.QuickTipManager
.init();
59 // fixme: what about other errors
60 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
61 if (response
.status
== 401) { // auth failure
68 if (!PMG
.Utils
.authOK()) {
72 me
.onLogin(me
.loginData
);
76 Ext
.TaskManager
.start({
78 var ticket
= PMG
.Utils
.authOK();
79 if (!ticket
|| !PMG
.UserName
) {
85 username
: PMG
.UserName
,
88 url
: '/api2/json/access/ticket',
90 success: function(response
, opts
) {
91 var obj
= Ext
.decode(response
.responseText
);
92 me
.updateLoginData(obj
.data
);
101 Ext
.define('PMG.StdWorkspace', {
102 extend
: 'PMG.Workspace',
104 alias
: ['widget.pmgStdWorkspace'],
106 onLogin: function(loginData
) {
112 PMG
.Utils
.API2Request({
115 success: function(response
) {
116 PMG
.VersionInfo
= response
.result
.data
;
117 me
.updateVersionInfo();
123 updateUserInfo: function() {
126 var ui
= me
.query('#userinfo')[0];
129 var msg
= Ext
.String
.format(gettext("You are logged in as {0}"), "'" + PMG
.UserName
+ "'");
130 ui
.update('<div class="x-unselectable" style="white-space:nowrap;">' + msg
+ '</div>');
137 updateVersionInfo: function() {
140 var ui
= me
.query('#versioninfo')[0];
142 if (PMG
.VersionInfo
) {
143 var version
= PMG
.VersionInfo
.version
+ '-' + PMG
.VersionInfo
.release
+ '/' +
144 PMG
.VersionInfo
.repoid
;
145 ui
.update('Mail Gateway ' + version
);
147 ui
.update('Mail Gateway');
152 initComponent : function() {
157 // var sprovider = Ext.create('PVE.StateProvider');
158 // Ext.state.Manager.setProvider(sprovider);
161 layout
: { type
: 'border' },
178 html
: '<a class="x-unselectable" target=_blank href="http://www.proxmox.com">' +
179 '<img style="padding-top:4px;padding-right:5px" src="/pve2/images/proxmox_logo.png"/></a>'
199 iconCls
: 'fa fa-sign-out',
200 text
: gettext("Logout"),
201 handler: function() {
203 // fixme: me.setContent(null);
211 stateId
: 'pvecenter',
215 xtype
: 'pmgPanelConfig',
219 title
: 'Mail Filter',
221 expandedOnInit
: true,
228 itemId
: 'filter-actions',
235 itemId
: 'filter-who',
242 itemId
: 'filter-what',
249 itemId
: 'filter-when',
255 title
: 'Configuration',
256 itemId
: 'configuration',
257 expandedOnInit
: true,
258 html
: "System Configuration"
262 groups
: ['configuration'],
264 itemId
: 'config-mail-proxy',
269 groups
: ['configuration'],
270 title
: 'Spam Detector',
271 itemId
: 'config-spam',
272 html
: "Spam Detector"
276 groups
: ['configuration'],
277 title
: 'Virus Detector',
278 itemId
: 'config-virus',
279 html
: "Virus Detector"
283 groups
: ['configuration'],
284 title
: 'User Management',
285 itemId
: 'config-users',
286 html
: "User Management"
290 groups
: ['configuration'],
292 itemId
: 'config-cluster',
297 groups
: ['configuration'],
299 itemId
: 'config-license',
305 title
: 'Administration',
307 expandedOnInit
: true,
309 xtype
: 'pmgServerAdministration',
316 itemId
: 'statistics',
323 itemId
: 'quarantine',
329 title
: 'Tracking Center',
331 html
: "Tracking Center"
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');