Browse Source

code cleaning, refractoring of products

master
o.moresis 2 years ago
parent
commit
5e5f72c6cb
  1. 188
      public/js/extras.js
  2. 27
      public/js/layers.js
  3. 12
      public/js/loader.js
  4. 6
      public/js/treeview.js
  5. 104
      src/lib/common.old

188
public/js/extras.js

@ -206,61 +206,61 @@ async function getDepthOnPoint(latlng) {
} }
function downloadStationData(stationid) { // function downloadStationData(stationid) {
console.debug('stationid: ', stationid); // console.debug('stationid: ', stationid);
if (stationid.length === 0) { // if (stationid.length === 0) {
return; // return;
} // }
fetch(`${BASE_URL}/src/data/get_station_data.php?id=${stationid}`, { // fetch(`${BASE_URL}/src/data/get_station_data.php?id=${stationid}`, {
"credentials": "include", // "credentials": "include",
"headers": { // "headers": {
"Accept": "application/zip", // "Accept": "application/zip",
"Accept-Language": "en-US,en;q=0.5", // "Accept-Language": "en-US,en;q=0.5",
"Sec-Fetch-Dest": "empty", // "Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors", // "Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin", // "Sec-Fetch-Site": "same-origin",
"Pragma": "no-cache", // "Pragma": "no-cache",
"Cache-Control": "no-cache" // "Cache-Control": "no-cache"
}, // },
"method": "GET", // "method": "GET",
"mode": "cors" // "mode": "cors"
}).then(res => { return res.blob(); }) // }).then(res => { return res.blob(); })
.then((data) => { // .then((data) => {
var a = document.createElement("a"); // var a = document.createElement("a");
a.href = window.URL.createObjectURL(data); // a.href = window.URL.createObjectURL(data);
a.download = "request"; // a.download = "request";
a.click(); // a.click();
}); // });
} // }
function downloadCruiseData(cruiseId) { // function downloadCruiseData(cruiseId) {
if (cruiseId.length === 0) { // if (cruiseId.length === 0) {
return; // return;
} // }
console.debug("CRUISE ID: ", cruiseId); // console.debug("CRUISE ID: ", cruiseId);
//
fetch(`${BASE_URL}/src/data/get_cruise_data.php?id=${cruiseId}`, { // fetch(`${BASE_URL}/src/data/get_cruise_data.php?id=${cruiseId}`, {
"credentials": "include", // "credentials": "include",
"headers": { // "headers": {
"Accept": "application/zip", // "Accept": "application/zip",
"Accept-Language": "en-US,en;q=0.5", // "Accept-Language": "en-US,en;q=0.5",
"Sec-Fetch-Dest": "empty", // "Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors", // "Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin", // "Sec-Fetch-Site": "same-origin",
"Pragma": "no-cache", // "Pragma": "no-cache",
"Cache-Control": "no-cache" // "Cache-Control": "no-cache"
}, // },
"method": "GET", // "method": "GET",
"mode": "cors" // "mode": "cors"
}).then(res => { return res.blob(); }) // }).then(res => { return res.blob(); })
.then((data) => { // .then((data) => {
var a = document.createElement("a"); // var a = document.createElement("a");
a.href = window.URL.createObjectURL(data); // a.href = window.URL.createObjectURL(data);
a.download = "request"; // a.download = "request";
a.click(); // a.click();
}); // });
} // }
function getHabitat(layerCode) { function getHabitat(layerCode) {
@ -363,14 +363,13 @@ async function getPagePartial(partialName, target=null) {
} }
function getCoral(status) { function getProduct(layer) {
const url = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms"; let url = layer.endpoint;
const lgndUrl = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_cora" let legendUrl = layer.legend;
const lrs = 'mediseh_cora';
let l; let l;
l = L.tileLayer.betterWms(url, { transparent: true, layers: lrs, format: 'image/png'});
legends['CORAL'] = L.control.Legend({ l = L.tileLayer.betterWms(url, { transparent: true, layers: layer.code, format: 'image/png'});
legends[layer.code] = L.control.Legend({
position: "bottomright", position: "bottomright",
symbolWidth: 100, symbolWidth: 100,
symbolHeight: 200, symbolHeight: 200,
@ -379,7 +378,7 @@ function getCoral(status) {
legends: [{ legends: [{
type: "image", type: "image",
label: ' ', label: ' ',
url: lgndUrl url: legendUrl
}] }]
}).addTo(mapL); }).addTo(mapL);
mapL.on('click', e => { mapL.on('click', e => {
@ -390,68 +389,6 @@ function getCoral(status) {
} }
function getMaerl() {
const url = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms";
const lrs = 'mediseh_maerl';
maerl = L.tileLayer.betterWms(url, { transparent: true, layers: lrs, format: 'image/png'});
const lgndUrl = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_maerl"
legends['MAERL'] = L.control.Legend({
position: "bottomright",
symbolWidth: 100,
symbolHeight: 200,
collapsed: true,
title: 'Probability of habitat presence',
legends: [{
type: "image",
label: ' ',
url: lgndUrl
}]
}).addTo(mapL);
return maerl;
}
function getPosidonia(status) {
const url = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms";
const lrs = 'mediseh_posidonia';
const remoteLayer = L.tileLayer.betterWms(url, { transparent: true, layers: lrs, format: 'image/png'});
const lgndUrl = "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_posidonia"
legends['POSID'] = L.control.Legend({
position: "bottomright",
symbolWidth: 100,
symbolHeight: 200,
title: 'Probability of habitat presence',
collapsed: true,
legends: [{
type: "image",
label: ' ',
url: lgndUrl
}]
}).addTo(mapL);
return remoteLayer;
}
function getDescriptors() {
return {
isLoading: false,
descriptors: null,
fetchDescriptors() {
this.loading = true;
const url = BASE_URL + "/src/interface_calls/descriptor_dropdown.php"
fetch(url)
.then(res => res.json())
.then(data => {
this.isLoading = false;
this.descriptors = data;
});
}
}
}
/** /**
* Submit a request to the server and returns the entry inserted * Submit a request to the server and returns the entry inserted
@ -519,9 +456,6 @@ function getWFD(layerName) {
} }
async function searchForRequests() { async function searchForRequests() {
let response = await fetch(BASE_URL + '/actions/requests'); let response = await fetch(BASE_URL + '/actions/requests');

27
public/js/layers.js

@ -225,19 +225,28 @@ var layersList = [
active: false, active: false,
format: 'image', format: 'image',
leafletid: null, leafletid: null,
code: 'CORAL' isProduct: true,
endpoint: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms",
legend: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_cora",
code: 'mediseh_cora'
},{ },{
name: 'Probability of maerl habitat in the Mediterranean (MEDISEH)', name: 'Probability of maerl habitat in the Mediterranean (MEDISEH)',
active: false, active: false,
format: 'image', format: 'image',
leafletid: null, leafletid: null,
code: 'MAERL' isProduct: true,
endpoint: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms",
legend: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_cora",
code: 'mediseh_maerl'
},{ },{
name: 'Probability of Posidonia oceanica in the Mediterranean (MEDISEH)', name: 'Probability of Posidonia oceanica in the Mediterranean (MEDISEH)',
active: false, active: false,
format: 'image', format: 'image',
leafletid: null, leafletid: null,
code: 'POSID' isProduct: true,
endpoint: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/wms",
legend: "https://ows.emodnet-seabedhabitats.eu/geoserver/emodnet_view_maplibrary/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=mediseh_posidonia",
code: 'mediseh_posidonia'
},{ },{
name: 'Seagrass Meadows (<a target="_blank" class="is-link has-text-link" href="https://doi.org/10.1515/bot-2022-0011">citation</a>)', name: 'Seagrass Meadows (<a target="_blank" class="is-link has-text-link" href="https://doi.org/10.1515/bot-2022-0011">citation</a>)',
active: false, active: false,
@ -429,9 +438,8 @@ async function layerTreeSwitch(node) {
if (typeof intId == 'undefined') { if (typeof intId == 'undefined') {
return; return;
} }
console.debug('tree node: ', node);
const layer = await db.layers.where('code').equals(intId).first(); const layer = await db.layers.where('code').equals(intId).first();
console.debug('activating layer: ', layer);
let leafletId = layer.leafletid; let leafletId = layer.leafletid;
let l; let l;
if (!layer.active && node.checkStatus) { if (!layer.active && node.checkStatus) {
@ -442,12 +450,8 @@ async function layerTreeSwitch(node) {
}); });
} else if (intId === 'HABT') { } else if (intId === 'HABT') {
l = getHabitat(layer.code); l = getHabitat(layer.code);
} else if (intId === 'CORAL') { } else if (layer.isProduct) {
l = getCoral(); l = getProduct(layer);
} else if (intId === 'MAERL') {
l = getMaerl();
} else if (intId === 'POSID') {
l = getPosidonia();
} else if (intId === 'AFPPY') { } else if (intId === 'AFPPY') {
l = await getFisheriesProduct(); l = await getFisheriesProduct();
} else if (intId === 'PHPL') { } else if (intId === 'PHPL') {
@ -501,7 +505,6 @@ async function layerTreeSwitch(node) {
} }
function clearLegend(layerCode) { function clearLegend(layerCode) {
try{ try{
legends[layerCode].remove(); legends[layerCode].remove();

12
public/js/loader.js

@ -7,7 +7,7 @@ var admin=false;
/**** (var) global_date_format:date time format for all the date time variables****/ /**** (var) global_date_format:date time format for all the date time variables****/
var global_date_format = "dd/mm/yyyy"; var global_date_format = "dd/mm/yyyy";
var global_time_format = "hh:MM:ss"; var global_time_format = "hh:MM:ss";
var installing=false; // var installing=false;
const BASE_URL = 'https://msfd-test.hcmr.gr'; const BASE_URL = 'https://msfd-test.hcmr.gr';
const REPO_URL = 'https://msfd-repo.ath.hcmr.gr'; const REPO_URL = 'https://msfd-repo.ath.hcmr.gr';
/**** (function) fn_execOnloadFn:executes all the functions that are stored to the init_onload_fn variable****/ /**** (function) fn_execOnloadFn:executes all the functions that are stored to the init_onload_fn variable****/
@ -157,9 +157,9 @@ var loader_script_files=[
"js/tools/pickletree/pickletree.js", "js/tools/pickletree/pickletree.js",
"js/tools/extjs/ext-all.js", "js/tools/extjs/ext-all.js",
"js/tools/proj4js/lib/proj4js-combined.js", "js/tools/proj4js/lib/proj4js-combined.js",
"js/tools/shapefileToGeoJson/stream.js", // "js/tools/shapefileToGeoJson/stream.js",
"js/tools/shapefileToGeoJson/shapefile.js", // "js/tools/shapefileToGeoJson/shapefile.js",
"js/tools/shapefileToGeoJson/dbf.js", // "js/tools/shapefileToGeoJson/dbf.js",
"js/tools/OpenLayers/OpenLayers.2.13.2.full.js", "js/tools/OpenLayers/OpenLayers.2.13.2.full.js",
"js/tools/OpenLayers/OpenLayers_fix_error.js", "js/tools/OpenLayers/OpenLayers_fix_error.js",
"js/tools/OpenLayers/lib/OpenLayers/Control/ScaleBar.js", "js/tools/OpenLayers/lib/OpenLayers/Control/ScaleBar.js",
@ -181,8 +181,8 @@ var loader_script_files=[
"js/"+configFile, "js/"+configFile,
"js/main.js", "js/main.js",
"js/sidebar.js", "js/sidebar.js",
"js/maptab/maptab_toolbar_general.js", // "js/maptab/maptab_toolbar_general.js",
"js/maptab/maptab_toolbar_search.js", // "js/maptab/maptab_toolbar_search.js",
"js/treeview.js", "js/treeview.js",
"js/annual_fisheries.js", "js/annual_fisheries.js",
"js/maptab/maptab_services_manager/wms.js", "js/maptab/maptab_services_manager/wms.js",

6
public/js/treeview.js

@ -282,21 +282,21 @@ const myData = [{
{ {
n_id: 324, n_id: 324,
n_title: 'Probability of coralligenous habitat in the Mediterranean (MEDISEH)', n_title: 'Probability of coralligenous habitat in the Mediterranean (MEDISEH)',
code: 'CORAL', code: 'mediseh_cora',
n_parentid: 32, n_parentid: 32,
n_elements: nodeContextLink, n_elements: nodeContextLink,
n_hyperlink: "http://gis.ices.dk/geonetwork/srv/eng/catalog.search#/metadata/4da88de5-b0b8-4de4-8aac-99a9b0980736" n_hyperlink: "http://gis.ices.dk/geonetwork/srv/eng/catalog.search#/metadata/4da88de5-b0b8-4de4-8aac-99a9b0980736"
},{ },{
n_id: 325, n_id: 325,
n_title: 'Probability of maerl habitat in the Mediterranean (MEDISEH)', n_title: 'Probability of maerl habitat in the Mediterranean (MEDISEH)',
code: 'MAERL', code: 'mediseh_maerl',
n_parentid: 32, n_parentid: 32,
n_elements: nodeContextLink, n_elements: nodeContextLink,
n_hyperlink: "http://gis.ices.dk/geonetwork/srv/eng/catalog.search#/metadata/43c7ac30-04da-479d-b5c1-ba621f0981e4" n_hyperlink: "http://gis.ices.dk/geonetwork/srv/eng/catalog.search#/metadata/43c7ac30-04da-479d-b5c1-ba621f0981e4"
},{ },{
n_id: 326, n_id: 326,
n_title: 'Probability of Posidonia oceanica in the Mediterranean (MEDISEH)', n_title: 'Probability of Posidonia oceanica in the Mediterranean (MEDISEH)',
code: 'POSID', code: 'mediseh_posidonia',
n_parentid: 32, n_parentid: 32,
n_elements: nodeContextLink, n_elements: nodeContextLink,
n_hyperlink: "http://gis.ices.dk/geonetwork/srv/eng/catalog.search#/metadata/a93cffc8-8f45-47a4-a9bd-c8ffd9ad53fb" n_hyperlink: "http://gis.ices.dk/geonetwork/srv/eng/catalog.search#/metadata/a93cffc8-8f45-47a4-a9bd-c8ffd9ad53fb"

104
src/lib/common.old

@ -1,104 +0,0 @@
<?php
namespace MSFD\Configuration;
class Globals {
public static $importType;
public static $debugMode = true;
public static $filename = '';
public static $root_path = __DIR__ . '/../../';
}
class Constants {
const LINE_READ_LIMIT = 500;
const BYTE_READ_LIMIT = 450000000;
const MODE = 1;
const API_BASE_URL = "https://geoserver.hcmr.gr/geoserver/rest/";
const API_CREDENTIALS = ["portal", "@dm!n322"];
/* const REPO_API = "http://msfd-repo.ath.hcmr.gr"; */
const API_URL = array(
"REPO" => "http://msfd-repo.ath.hcmr.gr/",
"GSRV" => "https://geoserver.hcmr.gr/geoserver/",
"POSD" => "https://api.poseidon.hcmr.gr/",
"WFD" => "https://watermonitoring.hcmr.gr/api/"
);
// Database configuration
// Production / Development
const API_CREDS = array(
"REPO" => "",
"GSRV" => "",
"POSD" => "",
"WFD" => ""
);
const DB_CREDS = array(
"HOST" => "192.168.11.45",
"NAME" => "newschema",
"USER" => "vaslak",
"PASS" => "postgre2020"
);
// Header translations
const HEADER_TRANSLATIONS = [
'Cruise' => 'cruise',
'Station' => 'station',
'Type' => 'type',
'YYYY-MM-DDThh:mm:ss.sss' => 'datetime',
'YYYY-MM-DDThh:mm' => 'datetime',
'Longitude [degrees_east]' => 'lon',
'Latitude [degrees_north]' => 'lat',
'LOCAL_CDI_ID' => 'cdi',
'EDMO_code' => 'edmo',
'Bot. Depth [m]' => 'bottom_depth',
'DEPHPR01 [m]' => 'depth',
'DEPHPR01 [meter]' => 'depth',
'DEPH [m]' => 'depth',
'COREDIST [m]' => 'depth',
'DEPHPR01 [m]' => 'depth',
'MaximumObservationDepth [m]' => 'depth'
];
// Sequence according to which the tables are going to be updated through import
public static function getReplaceableChars() {
return self::REPLACEABLE_CHARS;
}
public static function getLineReadLimit()
{
return self::LINE_READ_LIMIT;
}
public static function getByteReadLimit()
{
return self::BYTE_READ_LIMIT;
}
public static function getItemSeparator()
{
return self::ITEM_SEPARATOR;
}
public static function getDatabaseCreds($mode = self::MODE)
{
return array(self::DB_CREDS['HOST'], self::DB_CREDS['NAME'], self::DB_CREDS['USER'], self::DB_CREDS['PASS']);
}
// GEOSERVER API CONSTANTS
public static function getAPIBaseURL($api_name) {
return self::API_URL[$api_name];
}
public static function getAPICredentials($api_name)
{
return self::API_CREDENTIALS;
}
}
?>
Loading…
Cancel
Save