]>
git.proxmox.com Git - pmg-gui.git/blob - js/QuarantineList.js
cd2ef3e97463df146cbcff2fa14b15174ecfcc2c
2 Ext
.define('PMG.QuarantineList', {
3 extend
: 'Ext.grid.GridPanel',
4 xtype
: 'pmgQuarantineList',
6 emptyText
: gettext('No E-Mail address selected'),
12 emailSelection
: false,
13 notFoundText
: gettext('No data in database')
22 selType
: 'checkboxmodel'
26 xclass
: 'Ext.app.ViewController',
28 init: function(view
) {
30 if (PMG
.view
=== 'quarantineview') {
31 view
.emailSelection
= false;
34 var emailCombobox
= me
.lookupReference('email');
35 emailCombobox
.setVisible(view
.emailSelection
);
36 emailCombobox
.setDisabled(!view
.emailSelection
);
39 if (PMG
.QuarantineList
.from != 0) {
40 from = new Date(PMG
.QuarantineList
.from * 1000);
42 from = new Date(Date
.now() - 7*24*60*60*1000);
46 if (PMG
.QuarantineList
.to
!= 0) {
47 to
= new Date(PMG
.QuarantineList
.to
* 1000);
52 // we to this to trigger the change event of those fields
53 me
.lookupReference('from').setValue(from);
54 me
.lookupReference('to').setValue(to
);
56 Proxmox
.Utils
.monStoreErrors(view
.getView(), view
.getStore());
59 view
.setSelection(view
.getStore().getById(view
.cselect
));
63 // extjs has no method to dynamically change the emptytext on
64 // grids, so we have to do it this way
65 setEmptyText: function(emptyText
) {
67 var view
= me
.getView();
68 var tableview
= view
.getView();
69 tableview
.emptyText
= '<div class="x-grid-empty">'+ (emptyText
|| view
.notFoundText
) + '</div>';
72 load: function(callback
) {
74 var view
= me
.getView();
75 if (view
.emailSelection
) {
76 if (!me
.lookupReference('email').getSelection()) {
77 // if the combobox has no selection we do not reload
82 view
.getStore().load(callback
);
85 setFrom: function(from) {
86 var me
= this.getView();
87 var params
= me
.getStore().getProxy().getExtraParams();
88 params
.starttime
= from;
89 PMG
.QuarantineList
.from = from;
90 me
.getStore().getProxy().setExtraParams(params
);
94 var end_of_to
= to
+ 24*60*60; // we want the end of the day
95 var me
= this.getView();
96 var params
= me
.getStore().getProxy().getExtraParams();
97 params
.endtime
= end_of_to
;
98 PMG
.QuarantineList
.to
= to
; // we save the start of the day here
99 me
.getStore().getProxy().setExtraParams(params
);
102 setUser: function(user
) {
103 var me
= this.getView();
104 var params
= me
.getStore().getProxy().getExtraParams();
106 me
.getStore().getProxy().setExtraParams(params
);
110 changeTime: function(field
, value
) {
112 var list
= me
.getView();
118 var val
= value
.getTime()/1000;
119 var combobox
= me
.lookupReference('email');
120 var params
= combobox
.getStore().getProxy().getExtraParams();
122 var to
= me
.lookupReference('to');
123 var from = me
.lookupReference('from');
125 if (field
.name
=== 'from') {
127 params
.starttime
= val
;
128 to
.setMinValue(value
);
130 } else if (field
.name
=== 'to') {
132 params
.endtime
= val
+ 24*60*60;
133 from.setMaxValue(value
);
138 // the combobox does not know anything about the extraparams
139 // so we disable queryCaching until we expand (and query) again
140 combobox
.queryCaching
= false;
141 combobox
.getStore().getProxy().setExtraParams(params
);
146 resetEmail: function() {
148 var view
= me
.getView();
149 if (view
.emailSelection
) {
150 me
.setUser(undefined);
154 changeEmail: function(tb
, value
) {
160 setQueryCaching: function() {
161 this.lookupReference('email').queryCaching
= true;
166 beforedestroy
: 'resetEmail'
168 'combobox[reference=email]': {
173 expand
: 'setQueryCaching'
187 groupHeaderTpl
: '{columnName}: {name} ({children.length})'
201 fieldLabel
: gettext('From'),
208 fieldLabel
: gettext('To'),
217 displayField
: 'mail',
221 '<div class="x-grid-empty">' +
222 gettext('No data in database') +
228 url
: '/api2/json/quarantine/spamusers'
233 renderer
: Ext
.htmlEncode