]>
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 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 var store
= view
.getStore();
76 if (view
.emailSelection
) {
77 if (!me
.lookupReference('email').getSelection()) {
78 // if the combobox has no selection we do not reload
83 store
.load(function() {
84 if (me
.savedPosition
!== undefined) {
85 if (store
.getCount() - 1 < me
.savedPosition
) {
86 me
.savedPosition
= store
.getCount() - 1;
88 view
.setSelection(store
.getAt(me
.savedPosition
));
90 if (Ext
.isFunction(callback
)) {
96 setFrom: function(from) {
97 var me
= this.getView();
98 var params
= me
.getStore().getProxy().getExtraParams();
99 params
.starttime
= from;
100 PMG
.QuarantineList
.from = from;
101 me
.getStore().getProxy().setExtraParams(params
);
104 setTo: function(to
) {
105 var end_of_to
= to
+ 24*60*60; // we want the end of the day
106 var me
= this.getView();
107 var params
= me
.getStore().getProxy().getExtraParams();
108 params
.endtime
= end_of_to
;
109 PMG
.QuarantineList
.to
= to
; // we save the start of the day here
110 me
.getStore().getProxy().setExtraParams(params
);
113 setUser: function(user
) {
114 var me
= this.getView();
115 var params
= me
.getStore().getProxy().getExtraParams();
117 me
.getStore().getProxy().setExtraParams(params
);
121 changeTime: function(field
, value
) {
123 var list
= me
.getView();
129 var val
= value
.getTime()/1000;
130 var combobox
= me
.lookupReference('email');
131 var params
= combobox
.getStore().getProxy().getExtraParams();
133 var to
= me
.lookupReference('to');
134 var from = me
.lookupReference('from');
136 if (field
.name
=== 'from') {
138 params
.starttime
= val
;
139 to
.setMinValue(value
);
141 } else if (field
.name
=== 'to') {
143 params
.endtime
= val
+ 24*60*60;
144 from.setMaxValue(value
);
149 // the combobox does not know anything about the extraparams
150 // so we disable queryCaching until we expand (and query) again
151 combobox
.queryCaching
= false;
152 combobox
.getStore().getProxy().setExtraParams(params
);
157 resetEmail: function() {
159 var view
= me
.getView();
160 if (view
.emailSelection
) {
161 me
.setUser(undefined);
165 changeEmail: function(tb
, value
) {
171 setQueryCaching: function() {
172 this.lookupReference('email').queryCaching
= true;
176 savePosition: function(grid
, selected
, eopts
) {
177 if (!selected
.length
) {
182 var view
= me
.getView();
184 var id
= view
.getStore().indexOf(selected
[0]);
186 me
.savedPosition
= id
;
192 beforedestroy
: 'resetEmail',
193 selectionchange
: 'savePosition'
195 'combobox[reference=email]': {
200 expand
: 'setQueryCaching'
214 groupHeaderTpl
: '{columnName}: {name} ({children.length})'
228 fieldLabel
: gettext('From'),
235 fieldLabel
: gettext('To'),
244 displayField
: 'mail',
248 '<div class="x-grid-empty">' +
249 gettext('No data in database') +
255 url
: '/api2/json/quarantine/spamusers'
260 renderer
: Ext
.htmlEncode