]>
git.proxmox.com Git - pmg-gui.git/blob - js/QuarantineView.js
3d0e9e1d8d7bd130db7ff4c4a5690d9b19c533a7
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('Ext.window.Window', {
135 title
: gettext('Language'),
139 xtype
: 'proxmoxLanguageSelector',
140 fieldLabel
: gettext('Language'),
141 value
: Ext
.util
.Cookies
.get('PMGLangCookie') || 'en',
148 handler: function() {
150 let win
= this.up('window');
151 let value
= win
.down('proxmoxLanguageSelector').getValue();
152 var dt
= Ext
.Date
.add(new Date(), Ext
.Date
.YEAR
, 10);
153 Ext
.util
.Cookies
.set('PMGLangCookie', value
, dt
);
154 win
.mask(gettext('Please wait...'), 'x-mask-loading');
155 window
.location
.reload();
162 navigate: function(treelist
, item
) {
163 this.redirectTo(item
.get('path'));
166 execQuarantineAction: function(qa
) {
167 PMG
.Utils
.doQuarantineAction(qa
.action
, qa
.cselect
);
171 '[reference=logoutButton]': {
174 '[reference=languageButton]': {
175 click
: 'changeLanguage',
179 init: function(view
) {
183 var username
= Proxmox
.UserName
.replace(/\@quarantine$/, '');
184 me
.lookupReference('usernameinfo').setText(username
);
186 // show login on requestexception
187 // fixme: what about other errors
188 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
189 if (response
.status
== 401) { // auth failure
194 var qa
= PMG
.Utils
.extractQuarantineAction();
197 token
= 'pmgSpamQuarantine';
198 if (qa
.action
=== 'blacklist') { token
= 'pmgUserBlacklist'; }
199 if (qa
.action
=== 'whitelist') { token
= 'pmgUserWhitelist'; }
201 token
+= ':' + qa
.cselect
;
203 this.redirectTo(token
, true);
205 me
.execQuarantineAction(qa
);
208 // select treeitem and load page from url fragment
210 token
= Ext
.util
.History
.getToken() || 'pmgSpamQuarantine';
211 this.redirectTo(token
, true);
245 reference
: 'usernameinfo',
247 // proxmox dark grey p light grey as border
248 backgroundColor
: '#464d4d',
249 borderColor
: '#ABBABA'
252 iconCls
: 'fa fa-user',
255 iconCls
: 'fa fa-language',
256 text
: gettext('Language'),
257 reference
: 'languageButton',
261 reference
: 'logoutButton',
262 iconCls
: 'fa fa-sign-out',
263 text
: gettext('Logout')
270 xtype
: 'quarantinenavigationtree',
271 reference
: 'navtree',
275 // we have to define it here until extjs 6.2
276 // because of a bug where a viewcontroller does not detect
277 // the selectionchange event of a treelist
279 selectionchange
: 'navigate'
289 reference
: 'contentpanel'