]>
git.proxmox.com Git - pmg-gui.git/blob - js/UserBlackWhiteList.js
1 Ext
.define('pmg-address-list', {
2 extend
: 'Ext.data.Model',
7 // base class - do not use directly
8 Ext
.define('PMG.UserBlackWhiteList', {
9 extend
: 'Ext.grid.GridPanel',
12 listname
: undefined, // 'blacklist' or 'whitelist',
14 selModel
: 'checkboxmodel',
16 emptyText
: gettext('No data in database'),
20 xclass
: 'Ext.app.ViewController',
22 onAddAddress: function() {
23 let view
= this.getView();
24 let params
= view
.getStore().getProxy().getExtraParams() || {};
26 let url
= '/quarantine/' + view
.listname
;
29 xtype
: 'proxmoxtextfield',
32 regex
: /^[^,;\s]*$/, // no whitespace no , and no ;
33 fieldLabel
: gettext("Address"),
36 Ext
.Object
.each(params
, function(key
, value
) {
47 onlineHelp
: 'pmg_userblackwhitelist',
53 if (view
.listname
=== 'blacklist') {
54 config
.subject
= gettext("Blacklist");
55 } else if (view
.listname
=== 'whitelist') {
56 config
.subject
= gettext("Whitelist");
58 throw "unknown list - internal error";
61 let win
= Ext
.createWidget('proxmoxWindowEdit', config
);
62 win
.on('destroy', function() { view
.store
.load(); });
66 onRemoveAddress: function() {
67 let view
= this.getView();
68 let records
= view
.selModel
.getSelection();
69 if (records
.length
< 1) {
73 let url
= '/quarantine/' + view
.listname
+ '/';
76 address
: records
.map((rec
) => rec
.getId()).join(','),
78 Ext
.applyIf(params
, view
.getStore().getProxy().getExtraParams());
80 Proxmox
.Utils
.API2Request({
81 url
: url
+ '?' + Ext
.Object
.toQueryString(params
),
84 callback: function(options
, success
, response
) {
87 failure: function(response
, opts
) {
88 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
93 changeEmail: function(combobox
, value
) {
94 let view
= this.getView();
95 if (value
&& combobox
.isValid()) {
96 view
.getStore().getProxy().setExtraParams({
99 view
.getStore().load();
103 init: function(view
) {
104 let emailcb
= this.lookupReference('email');
105 if (PMG
.view
=== 'quarantineview') {
106 emailcb
.setVisible(false);
107 view
.getStore().load();
109 emailcb
.getStore().getProxy().setExtraParams({
110 list
: view
.listname
=== 'blacklist' ? 'BL' : 'WL',
113 Proxmox
.Utils
.monStoreErrors(view
.getView(), view
.getStore(), true);
129 displayField
: 'mail',
136 url
: '/api2/json/quarantine/quarusers',
141 renderer
: Ext
.htmlEncode
,
152 '<div class="x-grid-empty">' +
153 gettext('No data in database') +
156 fieldLabel
: 'E-Mail',
159 text
: gettext('Add'),
160 handler
: 'onAddAddress',
163 xtype
: 'proxmoxButton',
164 text
: gettext('Remove'),
166 handler
: 'onRemoveAddress',
167 confirmMsg: function() {
168 let view
= this.up('gridpanel');
170 let selection
= view
.selModel
.getSelection();
172 if (selection
.length
> 1) {
173 text
= gettext('Are you sure you want to remove {0} entries');
174 param
= selection
.length
.toString();
175 } else if (selection
.length
> 0) {
176 let rec
= selection
[0];
177 let name
= rec
.getId();
178 text
= gettext('Are you sure you want to remove entry {0}');
179 param
= "'" + Ext
.String
.htmlEncode(name
) + "'";
183 return Ext
.String
.format(text
, param
);
192 header
: gettext('Address'),
193 dataIndex
: 'address',
194 renderer
: Ext
.String
.htmlEncode
,
200 Ext
.define('PMG.UserBlacklist', {
201 extend
: 'PMG.UserBlackWhiteList',
202 xtype
: 'pmgUserBlacklist',
204 title
: gettext('Blacklist'),
206 listname
: 'blacklist',
209 model
: 'pmg-address-list',
213 url
: "/api2/json/quarantine/blacklist",
225 'border-left': '0px',
226 'border-right': '0px',
228 html
: gettext('With this feature, you can manually mark E-mails from certain domains or addresses as spam.') + `<br><br>
229 <b>*.com</b> (all mails from <b>.com</b> domains)<br>
230 <b>*@example.com</b> (all mails from domain <b>example.com</b>)<br>
231 <b>john@example.com</b> (all mails from <b>john@example.com</b>)`,
236 Ext
.define('PMG.UserWhitelist', {
237 extend
: 'PMG.UserBlackWhiteList',
238 xtype
: 'pmgUserWhitelist',
240 title
: gettext('Whitelist'),
242 listname
: 'whitelist',
245 model
: 'pmg-address-list',
249 url
: "/api2/json/quarantine/whitelist",
261 'border-left': '0px',
262 'border-right': '0px',
264 html
: gettext('With this feature, you can manually bypass spam checking for certain domains or E-mail addresses.') + `<br><br>
265 <b>*.com</b> (all mails from <b>.com</b> domains)<br>
266 <b>*@example.com</b> (all mails from domain <b>example.com</b>)<br>
267 <b>john@example.com</b> (all mails from <b>john@example.com</b>)`,