]>
git.proxmox.com Git - pmg-gui.git/blob - js/QuarantineView.js
1 Ext
.define('PMG.QuarantineNavigationTree', {
2 extend
: 'Ext.list.Tree',
3 xtype
: 'quarantinenavigationtree',
5 select: function(path
) {
7 let item
= me
.getStore().findRecord('path', path
, 0, false, true, true);
16 text
: gettext('Spam Quarantine'),
17 iconCls
: 'fa fa-cubes',
18 path
: 'pmgSpamQuarantine',
22 text
: gettext('Whitelist'),
23 iconCls
: 'fa fa-file-o',
24 path
: 'pmgUserWhitelist',
28 text
: gettext('Blacklist'),
29 iconCls
: 'fa fa-file',
30 path
: 'pmgUserBlacklist',
45 Ext
.define('PMG.QuarantineView', {
46 extend
: 'Ext.container.Container',
47 xtype
: 'quarantineview',
49 title
: 'Proxmox Mail Gateway Quarantine',
52 xclass
: 'Ext.app.ViewController',
56 before
: 'beforeChangePath',
58 ':path': '(?:([%a-zA-Z0-9\\-\\_\\s,]+))',
59 ':subpath': '(?:(?::)([%a-zA-Z0-9\\-\\_\\s,]+))?',
64 beforeChangePath: function(path
, subpath
, action
) {
67 if (!Ext
.ClassManager
.getByAlias('widget.'+ path
)) {
68 console
.warn('xtype "'+path
+'" not found');
73 let lastpanel
= me
.lookupReference('contentpanel').getLayout().getActiveItem();
74 if (lastpanel
&& lastpanel
.xtype
=== path
) {
75 // we have the right component already,
76 // we just need to select the correct tab
77 // default to the first
78 subpath
= subpath
|| 0;
79 if (lastpanel
.getActiveTab
) {
80 // we assume lastpanel is a tabpanel
81 if (lastpanel
.getActiveTab().getItemId() !== subpath
) {
83 lastpanel
.setActiveTab(subpath
);
85 // else we are already there
94 changePath: function(path
, subpath
) {
96 let contentpanel
= me
.lookupReference('contentpanel');
97 let lastpanel
= contentpanel
.getLayout().getActiveItem();
99 let obj
= contentpanel
.add({ xtype
: path
, cselect
: subpath
});
100 let treelist
= me
.lookupReference('navtree');
102 treelist
.suspendEvents();
103 treelist
.select(path
);
104 treelist
.resumeEvents();
106 if (Ext
.isFunction(obj
.setActiveTab
)) {
107 obj
.setActiveTab(subpath
|| 0);
108 obj
.addListener('tabchange', function(tabpanel
, newc
, oldc
) {
111 // only add the subpath part for the
113 if (tabpanel
.items
.findIndex('id', newc
.id
) !== 0) {
114 newpath
+= ":" + newc
.getItemId();
117 me
.redirectTo(newpath
);
121 contentpanel
.setActiveItem(obj
);
124 contentpanel
.remove(lastpanel
, { destroy
: true });
132 changeLanguage: function() {
133 Ext
.create('Proxmox.window.LanguageEditWindow', {
134 cookieName
: 'PMGLangCookie',
138 navigate: function(treelist
, item
) {
139 this.redirectTo(item
.get('path'));
142 execQuarantineAction: function(qa
) {
143 PMG
.Utils
.doQuarantineAction(qa
.action
, qa
.cselect
);
147 '[reference=logoutButton]': {
150 '[reference=languageButton]': {
151 click
: 'changeLanguage',
155 init: function(view
) {
159 let username
= Proxmox
.UserName
.replace(/@quarantine$/, '');
160 me
.lookupReference('usernameinfo').setText(username
);
162 // show login on requestexception
163 // fixme: what about other errors
164 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
165 if (response
.status
=== 401) { // auth failure
170 let qa
= PMG
.Utils
.extractQuarantineAction();
173 token
= 'pmgSpamQuarantine';
174 if (qa
.action
=== 'blacklist') { token
= 'pmgUserBlacklist'; }
175 if (qa
.action
=== 'whitelist') { token
= 'pmgUserWhitelist'; }
177 token
+= ':' + qa
.cselect
;
179 this.redirectTo(token
, true);
181 me
.execQuarantineAction(qa
);
184 // select treeitem and load page from url fragment
186 token
= Ext
.util
.History
.getToken() || 'pmgSpamQuarantine';
187 this.redirectTo(token
, true);
210 xtype
: 'proxmoxlogo',
214 xtype
: 'versioninfo',
221 reference
: 'usernameinfo',
223 // proxmox dark grey p light grey as border
224 backgroundColor
: '#464d4d',
225 borderColor
: '#ABBABA',
228 iconCls
: 'fa fa-user',
231 iconCls
: 'fa fa-language',
232 text
: gettext('Language'),
233 reference
: 'languageButton',
237 reference
: 'logoutButton',
238 iconCls
: 'fa fa-sign-out',
239 text
: gettext('Logout'),
246 xtype
: 'quarantinenavigationtree',
247 reference
: 'navtree',
251 // we have to define it here until extjs 6.2
252 // because of a bug where a viewcontroller does not detect
253 // the selectionchange event of a treelist
255 selectionchange
: 'navigate',
265 reference
: 'contentpanel',