Browse Source

fixing cruise moreinfo dynamic descriptor issue

master
o.moresis 2 years ago
parent
commit
4c461e35d1
  1. 7
      public/js/extras.js
  2. 3
      public/js/layers.js
  3. 4
      public/js/more-info.js
  4. 6
      src/Controllers/InterfaceController.php
  5. 21
      src/Data/actions/fetch_tree_config.php
  6. 8
      src/Data/descriptors.php

7
public/js/extras.js

@ -130,6 +130,7 @@ function zoomToFeature(e) { @@ -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) { @@ -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}`;

3
public/js/layers.js

@ -346,8 +346,7 @@ var layersList = [ @@ -346,8 +346,7 @@ var layersList = [
active: false,
format: 'image',
leafletid: null
},
}
];

4
public/js/more-info.js

@ -1,7 +1,7 @@ @@ -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() { @@ -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;

6
src/Controllers/InterfaceController.php

@ -96,6 +96,12 @@ class InterfaceController { @@ -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;
}
}

21
src/Data/actions/fetch_tree_config.php

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
<?php
use MSFD\Services\PgSql;
$user_id = $_SESSION['user_id'];
$db = new PgSql();
$sql_fetch = "SELECT uuid, request_timestamp as requested_at, attributes->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;

8
src/Data/descriptors.php

@ -3,10 +3,12 @@ use MSFD\Services\PgSql; @@ -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)) { @@ -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

Loading…
Cancel
Save