]>
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 var 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-cubes',
24 path
: 'pmgUserWhitelist',
28 text
: gettext('Blacklist'),
29 //iconCls: 'fa fa-cubes',
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 var 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
) {
82 // we are already there
85 lastpanel
.setActiveTab(subpath
);
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 navigate: function(treelist
, item
) {
134 this.redirectTo(item
.get('path'));
137 execQuarantineAction: function(qa
) {
138 PMG
.Utils
.doQuarantineAction(qa
.action
, qa
.cselect
);
142 'button[reference=logoutButton]': {
147 init: function(view
) {
151 me
.lookupReference('usernameinfo').update({username
:Proxmox
.UserName
});
153 // show login on requestexception
154 // fixme: what about other errors
155 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
156 if (response
.status
== 401) { // auth failure
161 var qa
= PMG
.Utils
.extractQuarantineAction();
163 var token
= 'pmgSpamQuarantine';
164 if (qa
.action
=== 'blacklist') { token
= 'pmgUserBlacklist'; }
165 if (qa
.action
=== 'whitelist') { token
= 'pmgUserWhitelist'; }
167 token
+= ':' + qa
.cselect
;
169 this.redirectTo(token
, true);
171 me
.execQuarantineAction(qa
);
174 // select treeitem and load page from url fragment
176 var token
= Ext
.util
.History
.getToken() || 'pmgSpamQuarantine';
177 this.redirectTo(token
, true);
208 reference
: 'usernameinfo',
210 tpl
: Ext
.String
.format(gettext("You are logged in as '{0}'"), '{username}')
213 reference
: 'logoutButton',
215 iconCls
: 'fa fa-sign-out',
216 text
: gettext('Logout')
221 xtype
: 'quarantinenavigationtree',
222 reference
: 'navtree',
226 // we have to define it here until extjs 6.2
227 // because of a bug where a viewcontroller does not detect
228 // the selectionchange event of a treelist
230 selectionchange
: 'navigate'
238 reference
: 'contentpanel',