Commit d6674d3988dfbf7a0276e77b1951acde8156a6dc
1 parent
977e2c07
Exists in
master
and in
111 other branches
Add error and info informations on services grid
Showing
3 changed files
with
37 additions
and
7 deletions
Show diff stats
js/app/views/EpnTapUI.js
... | ... | @@ -101,7 +101,9 @@ Ext.create('Ext.data.Store', { |
101 | 101 | {name: 'reference_url', type: 'string'}, |
102 | 102 | {name: 'created', type: 'date', dateFormat: 'c'}, |
103 | 103 | {name: 'updated', type: 'date', dateFormat: 'c'}, |
104 | - {name: 'nb_results', type: 'integer'} | |
104 | + {name: 'nb_results', type: 'integer'}, | |
105 | + {name: 'info', type: 'string'}, | |
106 | + {name: 'error', type: 'string'} | |
105 | 107 | ], |
106 | 108 | proxy: { |
107 | 109 | type: 'ajax', |
... | ... | @@ -476,7 +478,7 @@ Ext.define('amdaUI.EpnTapUI', { |
476 | 478 | */ |
477 | 479 | createServicesGrid: function() { |
478 | 480 | var nbResRender = function(val) { |
479 | - if(val<0 || isNaN(val)) { | |
481 | + if(val < 0) { | |
480 | 482 | return '-'; |
481 | 483 | } else if(val >= 1000*1000) { |
482 | 484 | return (val/(1000*1000)).toPrecision(3) + 'm'; |
... | ... | @@ -499,7 +501,9 @@ Ext.define('amdaUI.EpnTapUI', { |
499 | 501 | viewConfig: { |
500 | 502 | getRowClass: function(record, index) { |
501 | 503 | var nb_res = record.get('nb_results'); |
502 | - if (nb_res <= 0 || isNaN(nb_res)) { | |
504 | + if(record.get('error').length > 0) { | |
505 | + return 'error_row'; | |
506 | + } else if (nb_res <= 0) { | |
503 | 507 | return 'disabled_row'; |
504 | 508 | } |
505 | 509 | } |
... | ... | @@ -526,6 +530,11 @@ Ext.define('amdaUI.EpnTapUI', { |
526 | 530 | 'updated': 'Updated on'}; |
527 | 531 | var service = epnTapServicesGrid.getView().getRecord(tooltip.triggerElement); |
528 | 532 | var ttContent = '<h3>' + service.get('short_name') + '</h3><ul>'; |
533 | + if(service.get('error').length > 0) { | |
534 | + ttContent += '<p style="color:IndianRed">' + service.get('error') + '</p><br/>'; | |
535 | + } else if(service.get('info').length > 0) { | |
536 | + ttContent += '<p style="color:green">' + service.get('info') + '</p><br/>'; | |
537 | + } | |
529 | 538 | for (var column in column_titles) { |
530 | 539 | var col_content = service.get(column); |
531 | 540 | if(column === 'content_level' && col_content!=='') { |
... | ... |
js/resources/css/amda.css
php/epntap.php
... | ... | @@ -16,9 +16,11 @@ switch ($action) { |
16 | 16 | case 'getNbResults': |
17 | 17 | echo getNbResults(); |
18 | 18 | break; |
19 | - | |
20 | - default: | |
19 | + case 'getGranules': | |
20 | + echo json_encode(getGranules()); | |
21 | 21 | break; |
22 | + default: | |
23 | + echo 'unknown action'; | |
22 | 24 | } |
23 | 25 | |
24 | 26 | function resolver() { |
... | ... | @@ -50,6 +52,7 @@ function getServices() { |
50 | 52 | for($j=0; $j<count($services); $j++) { |
51 | 53 | $services[$j]['id'] = generateServiceId($services[$j]); |
52 | 54 | $services[$j]['nb_results'] = -1; |
55 | + $services[$j]['info'] = 'Please make a query first.'; | |
53 | 56 | if($services[$j]['id'] == 'cdpp/amda/amdadb') { |
54 | 57 | array_splice($services, $j, 1); |
55 | 58 | $j-=1; |
... | ... | @@ -88,6 +91,21 @@ function getNbResults() { |
88 | 91 | } |
89 | 92 | } |
90 | 93 | |
94 | +function getGranules() { | |
95 | + $url = filter_var($_GET['url'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); | |
96 | + $tableName = filter_var($_GET['tableName'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); | |
97 | + $targetName = filter_var($_GET['targetName'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); | |
98 | + $productTypes = filter_var($_GET['productTypes'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); | |
99 | + $timeMin = filter_var($_GET['timeMin'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); | |
100 | + $timeMax = filter_var($_GET['timeMax'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); | |
101 | + | |
102 | + // TODO: make this more beatiful | |
103 | + // TODO find a way to handle 'non existing key errors' (and then add access_format) | |
104 | + $query = "SELECT dataproduct_type, target_name, time_min, time_max, granule_uid, access_estsize, access_url, thumbnail_url FROM $tableName" . createFilter($targetName, $productTypes, $timeMin, $timeMax); | |
105 | + $result = request($url, $query); | |
106 | + return $result; | |
107 | +} | |
108 | + | |
91 | 109 | // ----- utils ----- |
92 | 110 | |
93 | 111 | function request($access_url, $query) { |
... | ... |