Commit 6d616600b066b5f0c9f2e6c58ce74fe3415dc816
1 parent
5454dd64
Exists in
master
and in
111 other branches
Fix granules sorter
Showing
2 changed files
with
11 additions
and
4 deletions
Show diff stats
js/app/views/EpnTapUI.js
... | ... | @@ -144,6 +144,7 @@ selected. |
144 | 144 | - `access_url`: the access_url EPN-TAP parameter (ibid); |
145 | 145 | - `thumbnail_url`: the thumbnail_url EPN-TAP parameter (ibid). |
146 | 146 | */ |
147 | +// TODO: Add granules filter (see http://docs.sencha.com/extjs/4.0.7/#!/example/grid-filtering/grid-filter-local.html) | |
147 | 148 | Ext.create('Ext.data.Store', { |
148 | 149 | storeId: 'granulesStore', |
149 | 150 | model: 'granulesModel', // Created dynamically |
... | ... | @@ -155,6 +156,7 @@ Ext.create('Ext.data.Store', { |
155 | 156 | type: 'ajax', |
156 | 157 | url: 'php/epntap.php', |
157 | 158 | reader: { type: 'json', root: 'data'}, |
159 | + simpleSortMode: true | |
158 | 160 | }, listeners: { |
159 | 161 | 'beforeprefetch': function(store, operation) { |
160 | 162 | var servicesStore = Ext.data.StoreManager.lookup('servicesStore'); |
... | ... | @@ -170,9 +172,11 @@ Ext.create('Ext.data.Store', { |
170 | 172 | 'nbRes': service['nb_results'] |
171 | 173 | }; |
172 | 174 | }, |
173 | - // 'prefetch': function(store, records, successful, operation) { | |
175 | + 'prefetch': function(store, records, successful, operation) { | |
174 | 176 | // console.log('(prefetch) operation ' + (successful ? 'success' : 'failed') + ': ', operation); |
175 | - // }, | |
177 | + // console.log(operation.params); | |
178 | + // console.log(Ext.decode(operation.response.responseText)); | |
179 | + }, | |
176 | 180 | 'metachange': function(store, meta) { |
177 | 181 | Ext.getCmp('epnTapGranulesGrid').reconfigure(store, meta.columns); |
178 | 182 | } |
... | ... |
php/epntap.php
... | ... | @@ -162,9 +162,12 @@ function getGranules() { |
162 | 162 | $start = getParam('start'); |
163 | 163 | $limit = getParam('limit'); |
164 | 164 | $nbRes = getParam('nbRes'); |
165 | - | |
165 | + $sortKey = getParam('sort'); | |
166 | + $sortDir = getParam('dir'); | |
167 | + | |
168 | + $sort = is_null($sortKey) ? '' : "ORDER BY $sortKey $sortDir"; | |
166 | 169 | $filter = createFilter($targetName, $productTypes, $timeMin, $timeMax); |
167 | - $query = "SELECT TOP $limit * FROM $tableName $filter OFFSET $start"; | |
170 | + $query = "SELECT TOP $limit * FROM $tableName $filter $sort OFFSET $start"; | |
168 | 171 | // error_log('getGranules query: ' . $query); |
169 | 172 | $response = request($url, $query); |
170 | 173 | if($response['success']) { |
... | ... |