diff --git a/public/js/extras.js b/public/js/extras.js index 2a3b986..75378cd 100644 --- a/public/js/extras.js +++ b/public/js/extras.js @@ -130,6 +130,7 @@ function zoomToFeature(e) { selectedEntityId = e.target.feature.properties.id; } lonlat = {lon: e.latlng.lng, lat: e.latlng.lat}; + console.debug('zoomed feature: ', e.target.feature); moreInfoPopup(e.target.feature.properties); try { @@ -246,12 +247,12 @@ function moreInfoPopup(props) { } else { title = `Grid — ${props.cellcode}`; } - console.debug(props); - // if (typeof props.code == 'undefined' && typeof props.name == 'undefined') + if (typeof props.tspr !== 'undefined') { title = `POSEIDON — ${props.pid}`; - props.entityGroup = 'POSEIDON'; + props.entity_group = 'POSEIDON'; } + if (typeof props.ctStationCode !== 'undefined') title = `WFD — ${props.ctStationCode}`; diff --git a/public/js/layers.js b/public/js/layers.js index 65885b9..1412444 100644 --- a/public/js/layers.js +++ b/public/js/layers.js @@ -346,8 +346,7 @@ var layersList = [ active: false, format: 'image', leafletid: null - }, - + } ]; diff --git a/public/js/more-info.js b/public/js/more-info.js index 9e4fd68..84cdfff 100644 --- a/public/js/more-info.js +++ b/public/js/more-info.js @@ -1,7 +1,7 @@ function moreInfo() { return { lineChart: {}, - entityGroup: Alpine.store('entity').entityGroup, + entityGroup: Alpine.store('entity').entity_group || Alpine.store('entity').category, entityId: selectedEntityId || Alpine.store('entity').id, params: (Alpine.store('entity').entityGroup == 'POSEIDON' ? Alpine.store('entity').params.split(' ') : []), dopen: false, @@ -74,7 +74,7 @@ function moreInfo() { console.debug("entity group:::: ", this.entityGroup); switch(dropdown) { case 'd': - url += '/interface/dropdowns/descriptors?entity_id=' + this.entityId + '&cellcode=' + gridCode; + url += '/interface/dropdowns/descriptors?entity_id=' + this.entityId + '&cellcode=' + gridCode + '&entity_group=' + this.entityGroup; break; case 'c': url += '/interface/dropdowns/criterias?desc_id=' + this.did + '&cellcode=' + gridCode; diff --git a/src/Controllers/InterfaceController.php b/src/Controllers/InterfaceController.php index 9b11f2c..6943441 100644 --- a/src/Controllers/InterfaceController.php +++ b/src/Controllers/InterfaceController.php @@ -96,6 +96,12 @@ class InterfaceController { public function getPage($input) { return 0; } + + + public function getLayerTreeConfig() { + require __DIR__.'/../Data/actions/fetch_tree_config.php'; + return 0; + } } diff --git a/src/Data/actions/fetch_tree_config.php b/src/Data/actions/fetch_tree_config.php new file mode 100644 index 0000000..9b8a167 --- /dev/null +++ b/src/Data/actions/fetch_tree_config.php @@ -0,0 +1,21 @@ +0->>'critId'::text as criteria_ids, status, downloadable FROM webapp.requests + WHERE user_uuid = '${user_id}' ORDER BY request_timestamp"; +$rows = $db->getRows($sql_fetch); +foreach($rows as $row) { + if (!empty($row->criteria_ids)) { + $sql_crits = "SELECT code FROM criterias WHERE id IN ({$row->criteria_ids})"; + $criterias = implode(',', $db->getColValues($sql_crits)); + $row->criterias = $criterias; + } else { + $row->criterias = ''; + } +} +$result = json_encode($rows); +echo $result; diff --git a/src/Data/descriptors.php b/src/Data/descriptors.php index 6ea2f4d..e2decdc 100644 --- a/src/Data/descriptors.php +++ b/src/Data/descriptors.php @@ -3,10 +3,12 @@ use MSFD\Services\PgSql; $body_id = $_GET['body_id']; $entity_id = $_GET['entity_id']; +$entity_group = $_GET['entity_group']; /* $cellcode = $_GET['cellcode']; */ $cellcode = $_GET['cellcode'] === 'undefined' ? '' : $_GET['cellcode']; $query = ''; + if (!empty($cellcode)) { if ($cellcode == '10km') { $query = "SELECT DISTINCT d.code as code, d.id as id, (d.code || ' ' || d.description_en) as label FROM criterias_per_sampling_station cps @@ -21,6 +23,12 @@ if (!empty($cellcode)) { JOIN descriptors d ON c.parent_id = d.id where d.code = 'D11'"; } +} else if ($entity_group === 'cruise') { + $query = "SELECT DISTINCT d.code as code, d.id as id, (d.code || ' ' || d.description_en) as label FROM cruise_stations tss + JOIN criterias_per_sampling_station cps on tss.id = cps.sampling_station_id + JOIN criterias c on cps.criteria_id = c.id + JOIN descriptors d on c.parent_id = d.id + WHERE tss.cruise_id = {$entity_id}"; } else { if (isset($body_id)) { $query = "SELECT DISTINCT d.code as code, d.id as id, (d.code || ' ' || d.description_en) as label FROM criterias_per_sampling_station cps