]>
git.proxmox.com Git - pmg-gui.git/blob - js/QuarantineList.js
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 xclass
: 'Ext.app.ViewController',
24 init: function(view
) {
26 if (PMG
.view
=== 'quarantineview') {
27 view
.emailSelection
= false;
30 var emailCombobox
= me
.lookupReference('email');
31 emailCombobox
.setVisible(view
.emailSelection
);
32 emailCombobox
.setDisabled(!view
.emailSelection
);
35 if (PMG
.QuarantineList
.from != 0) {
36 from = new Date(PMG
.QuarantineList
.from * 1000);
42 if (PMG
.QuarantineList
.to
!= 0) {
43 to
= new Date(PMG
.QuarantineList
.to
* 1000);
48 // we to this to trigger the change event of those fields
49 me
.lookupReference('from').setValue(from);
50 me
.lookupReference('to').setValue(to
);
52 Proxmox
.Utils
.monStoreErrors(view
.getView(), view
.getStore());
55 view
.setSelection(view
.getStore().getById(view
.cselect
));
59 // extjs has no method to dynamically change the emptytext on
60 // grids, so we have to do it this way
61 setEmptyText: function(emptyText
) {
63 var view
= me
.getView();
64 var tableview
= view
.getView();
65 tableview
.emptyText
= '<div class="x-grid-empty">'+ (emptyText
|| view
.notFoundText
) + '</div>';
68 load: function(callback
) {
70 var view
= me
.getView();
71 if (view
.emailSelection
) {
72 if (!me
.lookupReference('email').getSelection()) {
73 // if the combobox has no selection we do not reload
78 view
.getStore().load(callback
);
81 setFrom: function(from) {
82 var me
= this.getView();
83 var params
= me
.getStore().getProxy().getExtraParams();
84 params
.starttime
= from;
85 PMG
.QuarantineList
.from = from;
86 me
.getStore().getProxy().setExtraParams(params
);
90 var end_of_to
= to
+ 24*60*60; // we want the end of the day
91 var me
= this.getView();
92 var params
= me
.getStore().getProxy().getExtraParams();
93 params
.endtime
= end_of_to
;
94 PMG
.QuarantineList
.to
= to
; // we save the start of the day here
95 me
.getStore().getProxy().setExtraParams(params
);
98 setUser: function(user
) {
99 var me
= this.getView();
100 var params
= me
.getStore().getProxy().getExtraParams();
102 me
.getStore().getProxy().setExtraParams(params
);
106 changeTime: function(field
, value
) {
108 var list
= me
.getView();
114 var val
= value
.getTime()/1000;
115 var combobox
= me
.lookupReference('email');
116 var params
= combobox
.getStore().getProxy().getExtraParams();
118 var to
= me
.lookupReference('to');
119 var from = me
.lookupReference('from');
121 if (field
.name
=== 'from') {
123 params
.starttime
= val
;
124 to
.setMinValue(value
);
126 } else if (field
.name
=== 'to') {
128 params
.endtime
= val
+ 24*60*60;
129 from.setMaxValue(value
);
134 // the combobox does not know anything about the extraparams
135 // so we disable queryCaching until we expand (and query) again
136 combobox
.queryCaching
= false;
137 combobox
.getStore().getProxy().setExtraParams(params
);
142 resetEmail: function() {
144 var view
= me
.getView();
145 if (view
.emailSelection
) {
146 me
.setUser(undefined);
150 changeEmail: function(tb
, value
) {
156 setQueryCaching: function() {
157 this.lookupReference('email').queryCaching
= true;
162 beforedestroy
: 'resetEmail'
164 'combobox[reference=email]': {
169 expand
: 'setQueryCaching'
183 groupHeaderTpl
: '{columnName}: {name} ({children.length})'
197 fieldLabel
: gettext('From'),
204 fieldLabel
: gettext('To'),
213 displayField
: 'mail',
217 '<div class="x-grid-empty">' +
218 gettext('No Data in Database') +
224 url
: '/api2/json/quarantine/spamusers'
229 renderer
: Ext
.htmlEncode