]>
git.proxmox.com Git - pmg-gui.git/blob - js/QuarantineView.js
2 Ext
.define('PMG.QuarantineNavigationTree', {
3 extend
: 'Ext.list.Tree',
4 xtype
: 'quarantinenavigationtree',
6 select: function(path
) {
8 var item
= me
.getStore().findRecord('path', path
, 0, false, true, true);
17 text
: gettext('Spam Quarantine'),
18 iconCls
: 'fa fa-cubes',
19 path
: 'pmgSpamQuarantine',
23 text
: gettext('Whitelist'),
24 iconCls
: 'fa fa-file-o',
25 path
: 'pmgUserWhitelist',
29 text
: gettext('Blacklist'),
30 iconCls
: 'fa fa-file',
31 path
: 'pmgUserBlacklist',
46 Ext
.define('PMG.QuarantineView', {
47 extend
: 'Ext.container.Container',
48 xtype
: 'quarantineview',
50 title
: 'Proxmox Mail Gateway Quarantine',
53 xclass
: 'Ext.app.ViewController',
57 before
: 'beforeChangePath',
59 ':path': '(?:([%a-zA-Z0-9\\-\\_\\s,]+))',
60 ':subpath': '(?:(?::)([%a-zA-Z0-9\\-\\_\\s,]+))?',
65 beforeChangePath: function(path
, subpath
, action
) {
68 if (!Ext
.ClassManager
.getByAlias('widget.'+ path
)) {
69 console
.warn('xtype "'+path
+'" not found');
74 var lastpanel
= me
.lookupReference('contentpanel').getLayout().getActiveItem();
75 if (lastpanel
&& lastpanel
.xtype
=== path
) {
76 // we have the right component already,
77 // we just need to select the correct tab
78 // default to the first
79 subpath
= subpath
|| 0;
80 if (lastpanel
.getActiveTab
) {
81 // we assume lastpanel is a tabpanel
82 if (lastpanel
.getActiveTab().getItemId() !== subpath
) {
84 lastpanel
.setActiveTab(subpath
);
86 // else we are already there
95 changePath: function(path
, subpath
) {
97 var contentpanel
= me
.lookupReference('contentpanel');
98 var lastpanel
= contentpanel
.getLayout().getActiveItem();
100 var obj
= contentpanel
.add({ xtype
: path
, cselect
: subpath
});
101 var treelist
= me
.lookupReference('navtree');
103 treelist
.suspendEvents();
104 treelist
.select(path
);
105 treelist
.resumeEvents();
107 if (Ext
.isFunction(obj
.setActiveTab
)) {
108 obj
.setActiveTab(subpath
|| 0);
109 obj
.addListener('tabchange', function(tabpanel
, newc
, oldc
) {
112 // only add the subpath part for the
114 if (tabpanel
.items
.findIndex('id', newc
.id
) !== 0) {
115 newpath
+= ":" + newc
.getItemId();
118 me
.redirectTo(newpath
);
122 contentpanel
.setActiveItem(obj
);
125 contentpanel
.remove(lastpanel
, { destroy
: true });
133 changeLanguage: function() {
134 Ext
.create('Proxmox.window.LanguageEditWindow', {
135 cookieName
: 'PMGLangCookie',
139 navigate: function(treelist
, item
) {
140 this.redirectTo(item
.get('path'));
143 execQuarantineAction: function(qa
) {
144 PMG
.Utils
.doQuarantineAction(qa
.action
, qa
.cselect
);
148 '[reference=logoutButton]': {
151 '[reference=languageButton]': {
152 click
: 'changeLanguage',
156 init: function(view
) {
160 var username
= Proxmox
.UserName
.replace(/\@quarantine$/, '');
161 me
.lookupReference('usernameinfo').setText(username
);
163 // show login on requestexception
164 // fixme: what about other errors
165 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
166 if (response
.status
== 401) { // auth failure
171 var qa
= PMG
.Utils
.extractQuarantineAction();
174 token
= 'pmgSpamQuarantine';
175 if (qa
.action
=== 'blacklist') { token
= 'pmgUserBlacklist'; }
176 if (qa
.action
=== 'whitelist') { token
= 'pmgUserWhitelist'; }
178 token
+= ':' + qa
.cselect
;
180 this.redirectTo(token
, true);
182 me
.execQuarantineAction(qa
);
185 // select treeitem and load page from url fragment
187 token
= Ext
.util
.History
.getToken() || 'pmgSpamQuarantine';
188 this.redirectTo(token
, true);
211 xtype
: 'proxmoxlogo',
215 xtype
: 'versioninfo',
222 reference
: 'usernameinfo',
224 // proxmox dark grey p light grey as border
225 backgroundColor
: '#464d4d',
226 borderColor
: '#ABBABA',
229 iconCls
: 'fa fa-user',
232 iconCls
: 'fa fa-language',
233 text
: gettext('Language'),
234 reference
: 'languageButton',
238 reference
: 'logoutButton',
239 iconCls
: 'fa fa-sign-out',
240 text
: gettext('Logout'),
247 xtype
: 'quarantinenavigationtree',
248 reference
: 'navtree',
252 // we have to define it here until extjs 6.2
253 // because of a bug where a viewcontroller does not detect
254 // the selectionchange event of a treelist
256 selectionchange
: 'navigate',
266 reference
: 'contentpanel',