Commit 11f8b45b540260e2544fc622b967166dbf8b7991
1 parent
598754b6
Exists in
master
and in
112 other branches
Use buffered scroll on granulesGrid
Showing
2 changed files
with
30 additions
and
63 deletions
Show diff stats
js/app/controllers/EpnTapModule.js
... | ... | @@ -27,8 +27,6 @@ Ext.define('amdaDesktop.EpnTapModule', { |
27 | 27 | Module initialisation. Called the first time that the user open the epnTap module. |
28 | 28 | */ |
29 | 29 | init: function() { |
30 | - this.selectedService = null; | |
31 | - | |
32 | 30 | this.launcher = { |
33 | 31 | text: this.title, |
34 | 32 | iconCls: this.icon, |
... | ... | @@ -63,7 +61,6 @@ Ext.define('amdaDesktop.EpnTapModule', { |
63 | 61 | this.granulesGrid = Ext.getCmp('epnTapGranulesGrid'); |
64 | 62 | this.productTypeCB = Ext.getCmp('epnTapProductTypeCB'); |
65 | 63 | this.targetNameCB = Ext.getCmp('epnTapTargetNameCB'); |
66 | - this.pagingTB = Ext.getCmp('epnTapPagingTB'); | |
67 | 64 | this.timeSelector = Ext.getCmp('epnTapTimeSelector'); |
68 | 65 | this.getBtn = Ext.getCmp('epnTapGetBtn'); |
69 | 66 | |
... | ... | @@ -87,10 +84,6 @@ Ext.define('amdaDesktop.EpnTapModule', { |
87 | 84 | this.onServiceSelected(record); |
88 | 85 | }, this); |
89 | 86 | |
90 | - this.pagingTB.on('beforechange', function(grid, td, cellIndex, record) { | |
91 | - this.onPageChanged(); | |
92 | - }, this); | |
93 | - | |
94 | 87 | this.getBtn.on('click', function() { |
95 | 88 | this.getServices(); |
96 | 89 | }, this); |
... | ... | @@ -165,40 +158,26 @@ Ext.define('amdaDesktop.EpnTapModule', { |
165 | 158 | loadMask.hide(); |
166 | 159 | }, |
167 | 160 | |
168 | - getGranuleParams: function() { | |
169 | - return { | |
170 | - 'action': 'getGranules', | |
171 | - 'url': this.selectedService.data['access_url'], | |
172 | - 'tableName': this.selectedService.data['table_name'], | |
173 | - 'targetName': this.targetNameCB.rawValue, | |
174 | - 'productTypes': this.productTypeCB.value.join(';'), | |
175 | - 'timeMin': Ext.Date.format(this.timeSelector.getStartTime(), 'd/m/Y H:i:s'), | |
176 | - 'timeMax': Ext.Date.format(this.timeSelector.getStopTime(), 'd/m/Y H:i:s'), | |
177 | - 'nbRes': this.selectedService.get('nb_results') | |
178 | - } | |
179 | - }, | |
180 | - | |
181 | - onPageChanged: function() { | |
182 | - this.granulesStore.getProxy().extraParams = this.getGranuleParams(); | |
183 | - }, | |
184 | - | |
185 | 161 | /** |
186 | 162 | Trigerred when a row is clicked in `servicesGrid` table (see `EpnTapUI.createServicesGrid()`). Among other things, |
187 | 163 | send a new query and fill `granulesGrid`. |
188 | 164 | */ |
189 | 165 | onServiceSelected: function(record) { |
166 | + this.servicesStore.each(function(record) { | |
167 | + record.set('selected', false); | |
168 | + }, this); | |
169 | + record.set('selected', true); | |
190 | 170 | Ext.Ajax.suspendEvent('requestexception'); |
191 | 171 | Ext.Ajax.abortAll(); |
192 | - this.selectedService = record; | |
193 | - var nbRes = this.selectedService.get('nb_results'); | |
172 | + var nbRes = record.get('nb_results'); | |
194 | 173 | |
195 | 174 | if(nbRes > 0 && !isNaN(nbRes)) { // TODO replace !isNaN(nbRes) by this.selectedService.get('success') |
196 | 175 | this.granulesStore.load({ |
197 | - params: this.getGranuleParams(), | |
176 | + params: {'action': 'getGranules'}, | |
198 | 177 | callback: function (records, operation, success) { |
199 | 178 | Ext.Ajax.resumeEvents('requestexception'); |
200 | 179 | // console.log(Ext.decode(operation.response.responseText)); |
201 | - }, | |
180 | + }, | |
202 | 181 | start: 0, |
203 | 182 | limit: this.granulesStore.pageSize, |
204 | 183 | scope: this |
... | ... |
js/app/views/EpnTapUI.js
... | ... | @@ -25,7 +25,6 @@ Notes: |
25 | 25 | in this store and an information message is displayed on the JavaScript console during the panel creation. |
26 | 26 | - if a data product type is not present in any of the granules from the EPN-TAP services, it is not present in this |
27 | 27 | store. |
28 | -TODO: try "var arrayStore = Ext.create(...);" | |
29 | 28 | */ |
30 | 29 | Ext.create('Ext.data.Store', { |
31 | 30 | storeId: 'productTypesStore', |
... | ... | @@ -49,8 +48,6 @@ Ext.create('Ext.data.Store', { |
49 | 48 | ] |
50 | 49 | }); |
51 | 50 | |
52 | -// TODO: Create a generic epntap stop from which all other stores inherits. | |
53 | - | |
54 | 51 | /** |
55 | 52 | `targetNamesStore`: An ExtJS Store containing the list of the different target names defined on all granules, on |
56 | 53 | all available EPN-TAP services (defined in `generic_data/EpnTapData/metadata.json`, updated periodically with a cron |
... | ... | @@ -112,7 +109,7 @@ Ext.create('Ext.data.Store', { |
112 | 109 | {name: 'updated', type: 'date', dateFormat: 'c'}, |
113 | 110 | {name: 'nb_results', type: 'integer'}, |
114 | 111 | {name: 'info', type: 'string'}, |
115 | - {name: 'error', type: 'string'} | |
112 | + {name: 'selected', type: 'boolean'} | |
116 | 113 | ], |
117 | 114 | proxy: { |
118 | 115 | type: 'ajax', |
... | ... | @@ -150,16 +147,32 @@ selected. |
150 | 147 | Ext.create('Ext.data.Store', { |
151 | 148 | storeId: 'granulesStore', |
152 | 149 | model: 'granulesModel', // Created dynamically |
150 | + buffered: true, | |
151 | + leadingBufferZone: 50, | |
153 | 152 | autoload: false, |
154 | - pageSize: 25, | |
153 | + pageSize: 50, | |
155 | 154 | proxy: { |
156 | 155 | type: 'ajax', |
157 | 156 | url: 'php/epntap.php', |
158 | - reader: { | |
159 | - type: 'json', | |
160 | - root: 'data' | |
161 | - } | |
157 | + reader: { type: 'json', root: 'data'}, | |
162 | 158 | }, listeners: { |
159 | + 'beforeprefetch': function(store, operation) { | |
160 | + var servicesStore = Ext.data.StoreManager.lookup('servicesStore'); | |
161 | + var service = servicesStore.getAt(servicesStore.findExact('selected', true)).data; | |
162 | + store.getProxy().extraParams = { | |
163 | + 'action': 'getGranules', | |
164 | + 'url': service['access_url'], | |
165 | + 'tableName': service['table_name'], | |
166 | + 'targetName': Ext.getCmp('epnTapTargetNameCB').rawValue, | |
167 | + 'productTypes': Ext.getCmp('epnTapProductTypeCB').value.join(';'), | |
168 | + 'timeMin': Ext.Date.format(Ext.getCmp('epnTapTimeSelector').getStartTime(), 'd/m/Y H:i:s'), | |
169 | + 'timeMax': Ext.Date.format(Ext.getCmp('epnTapTimeSelector').getStopTime(), 'd/m/Y H:i:s'), | |
170 | + 'nbRes': service['nb_results'] | |
171 | + }; | |
172 | + }, | |
173 | + 'prefetch': function(store, records, successful, operation) { | |
174 | + console.log('(prefetch) operation ' + (successful ? 'success' : 'failed') + ': ', operation); | |
175 | + }, | |
163 | 176 | 'metachange': function(store, meta) { |
164 | 177 | Ext.getCmp('epnTapGranulesGrid').reconfigure(store, meta.columns); |
165 | 178 | } |
... | ... | @@ -611,7 +624,6 @@ Ext.define('amdaUI.EpnTapUI', { |
611 | 624 | - currently only the granule thumbnail, in full size. |
612 | 625 | |
613 | 626 | A click on a granule triggers `EpnTapModule.onGranuleSelected()`. |
614 | - TODO: infinite scroll! http://docs.sencha.com/extjs/4.2.3/extjs-build/examples/grid/infinite-scroll-with-filter.html | |
615 | 627 | */ |
616 | 628 | createGranulesGrid: function() { |
617 | 629 | return { |
... | ... | @@ -620,31 +632,7 @@ Ext.define('amdaUI.EpnTapUI', { |
620 | 632 | title: 'Granules', |
621 | 633 | store: Ext.data.StoreManager.lookup('granulesStore'), |
622 | 634 | flex: 4, |
623 | - columns: [], | |
624 | - dockedItems: [{ | |
625 | - xtype: 'pagingtoolbar', | |
626 | - id: 'epnTapPagingTB', | |
627 | - store: Ext.data.StoreManager.lookup('granulesStore'), | |
628 | - dock: 'bottom', | |
629 | - displayInfo: true, | |
630 | - items: [{ | |
631 | - xtype: 'tbseparator' | |
632 | - }, { | |
633 | - xtype: 'numberfield', | |
634 | - id: 'epnTapRowsPerPageNf', | |
635 | - fieldLabel: 'Rows per page', | |
636 | - labelWidth: 78, | |
637 | - width: 150, | |
638 | - value: Ext.data.StoreManager.lookup('granulesStore').pageSize, | |
639 | - minValue: 1, | |
640 | - maxValue: 2000, | |
641 | - listeners: { | |
642 | - change: function(newValue, oldValue) { | |
643 | - Ext.data.StoreManager.lookup('granulesStore').pageSize = newValue; | |
644 | - } | |
645 | - } | |
646 | - }] | |
647 | - }] | |
635 | + columns: [] | |
648 | 636 | }; |
649 | 637 | } |
650 | 638 | }); |
... | ... |