]>
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
, subpathOrAction
, action
) {
67 let subpath
= subpathOrAction
;
69 action
= subpathOrAction
;
73 if (!Ext
.ClassManager
.getByAlias('widget.'+ path
)) {
74 console
.warn('xtype "'+path
+'" not found');
79 let lastpanel
= me
.lookupReference('contentpanel').getLayout().getActiveItem();
80 if (lastpanel
&& lastpanel
.xtype
=== path
) {
81 // we have the right component already,
82 // we just need to select the correct tab
83 // default to the first
84 subpath
= subpath
|| 0;
85 if (lastpanel
.getActiveTab
) {
86 // we assume lastpanel is a tabpanel
87 if (lastpanel
.getActiveTab().getItemId() !== subpath
) {
89 lastpanel
.setActiveTab(subpath
);
91 // else we are already there
100 changePath: function(path
, subpath
) {
102 let contentpanel
= me
.lookupReference('contentpanel');
103 let lastpanel
= contentpanel
.getLayout().getActiveItem();
105 let obj
= contentpanel
.add({ xtype
: path
, cselect
: subpath
});
106 let treelist
= me
.lookupReference('navtree');
108 treelist
.suspendEvents();
109 treelist
.select(path
);
110 treelist
.resumeEvents();
112 if (Ext
.isFunction(obj
.setActiveTab
)) {
113 obj
.setActiveTab(subpath
|| 0);
114 obj
.addListener('tabchange', function(tabpanel
, newc
, oldc
) {
117 // only add the subpath part for the
119 if (tabpanel
.items
.findIndex('id', newc
.id
) !== 0) {
120 newpath
+= ":" + newc
.getItemId();
123 me
.redirectTo(newpath
);
127 contentpanel
.setActiveItem(obj
);
130 contentpanel
.remove(lastpanel
, { destroy
: true });
138 changeLanguage: function() {
139 Ext
.create('Proxmox.window.LanguageEditWindow', {
140 cookieName
: 'PMGLangCookie',
144 changeTheme
: () => Ext
.create('Proxmox.window.ThemeEditWindow', {
145 cookieName
: 'PMGThemeCookie',
148 navigate: function(treelist
, item
) {
149 this.redirectTo(item
.get('path'));
152 execQuarantineAction: function(qa
) {
153 PMG
.Utils
.doQuarantineAction(qa
.action
, qa
.cselect
);
157 '[reference=logoutButton]': {
160 '[reference=languageButton]': {
161 click
: 'changeLanguage',
163 '[reference=themeButton]': {
164 click
: 'changeTheme',
168 init: function(view
) {
172 let username
= Proxmox
.UserName
.replace(/@quarantine$/, '');
173 me
.lookupReference('usernameinfo').setText(username
);
175 // show login on requestexception
176 // fixme: what about other errors
177 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
178 if (response
.status
=== 401) { // auth failure
183 let qa
= PMG
.Utils
.extractQuarantineAction();
186 token
= 'pmgSpamQuarantine';
187 if (qa
.action
=== 'blacklist') { token
= 'pmgUserBlacklist'; }
188 if (qa
.action
=== 'whitelist') { token
= 'pmgUserWhitelist'; }
190 token
+= ':' + qa
.cselect
;
192 this.redirectTo(token
, true);
194 me
.execQuarantineAction(qa
);
197 // select treeitem and load page from url fragment
199 token
= Ext
.util
.History
.getToken() || 'pmgSpamQuarantine';
200 this.redirectTo(token
, true);
223 xtype
: 'proxmoxlogo',
227 xtype
: 'versioninfo',
234 reference
: 'usernameinfo',
236 // proxmox dark grey p light grey as border
237 backgroundColor
: '#464d4d',
238 borderColor
: '#ABBABA',
241 iconCls
: 'fa fa-user',
244 reference
: 'themeButton',
245 iconCls
: 'fa fa-paint-brush',
246 text
: gettext('Color Theme'),
249 iconCls
: 'fa fa-language',
250 text
: gettext('Language'),
251 reference
: 'languageButton',
255 reference
: 'logoutButton',
256 iconCls
: 'fa fa-sign-out',
257 text
: gettext('Logout'),
274 xtype
: 'quarantinenavigationtree',
275 reference
: 'navtree',
277 // we have to define it here until extjs 6.2 because of a bug where a
278 // viewcontroller does not detect the selectionchange event of a treelist
280 selectionchange
: 'navigate',
285 cls
: 'x-treelist-pve-nav',
297 reference
: 'contentpanel',