diff --git a/js/app/views/EpnTapUI.js b/js/app/views/EpnTapUI.js index eeebaf2..4939dd4 100644 --- a/js/app/views/EpnTapUI.js +++ b/js/app/views/EpnTapUI.js @@ -144,6 +144,7 @@ selected. - `access_url`: the access_url EPN-TAP parameter (ibid); - `thumbnail_url`: the thumbnail_url EPN-TAP parameter (ibid). */ +// TODO: Add granules filter (see http://docs.sencha.com/extjs/4.0.7/#!/example/grid-filtering/grid-filter-local.html) Ext.create('Ext.data.Store', { storeId: 'granulesStore', model: 'granulesModel', // Created dynamically @@ -155,6 +156,7 @@ Ext.create('Ext.data.Store', { type: 'ajax', url: 'php/epntap.php', reader: { type: 'json', root: 'data'}, + simpleSortMode: true }, listeners: { 'beforeprefetch': function(store, operation) { var servicesStore = Ext.data.StoreManager.lookup('servicesStore'); @@ -170,9 +172,11 @@ Ext.create('Ext.data.Store', { 'nbRes': service['nb_results'] }; }, - // 'prefetch': function(store, records, successful, operation) { + 'prefetch': function(store, records, successful, operation) { // console.log('(prefetch) operation ' + (successful ? 'success' : 'failed') + ': ', operation); - // }, + // console.log(operation.params); + // console.log(Ext.decode(operation.response.responseText)); + }, 'metachange': function(store, meta) { Ext.getCmp('epnTapGranulesGrid').reconfigure(store, meta.columns); } diff --git a/php/epntap.php b/php/epntap.php index 1b6db9c..c1a906c 100644 --- a/php/epntap.php +++ b/php/epntap.php @@ -162,9 +162,12 @@ function getGranules() { $start = getParam('start'); $limit = getParam('limit'); $nbRes = getParam('nbRes'); - + $sortKey = getParam('sort'); + $sortDir = getParam('dir'); + + $sort = is_null($sortKey) ? '' : "ORDER BY $sortKey $sortDir"; $filter = createFilter($targetName, $productTypes, $timeMin, $timeMax); - $query = "SELECT TOP $limit * FROM $tableName $filter OFFSET $start"; + $query = "SELECT TOP $limit * FROM $tableName $filter $sort OFFSET $start"; // error_log('getGranules query: ' . $query); $response = request($url, $query); if($response['success']) { -- libgit2 0.21.2