Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mapcentia committed Dec 20, 2021
2 parents 9307ed9 + a06e6cd commit ad4cb8f
Show file tree
Hide file tree
Showing 29 changed files with 898 additions and 307 deletions.
58 changes: 58 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,64 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [CalVer](https://calver.org/).

## [UNRELEASED]
### Added
- Field ignore setting from GC2 will now exclude the field from being queried in sqlQuery module (feature info).

## [2021.12.0]
### Changed
- The location circle marker is now orange in follow-mode and blue when not following. Location now works the same in both embed and default templates.
- The legend toast dialog in embed template will now be pushed to the right when sliding out the layer tree. This way the elements will not be stacked.
- The search-result element in `conflict.tmpl` now has a dynamic height, so it will fit the parent window.

### Fixed
- `slideOutLayerTree` is now inwoked after vidi is ready making it more stable.

## [2021.11.2] - 2021-17-11
### Fixed
- `layerTree` state was not updated when Vidi was initiated with layers in URL anchor, resulting in no active layers in state until some changes was done by user afterward.

## [2021.11.1] - 2021-16-11
### Changed
- Hit count added to the "Data fra konflikter" tab in `conflictSearch` module.
- Some changes in `conflict.tmpl`, so it's easier to customize it.

### Added
- API endpoint for proxify base layer requests to Datafordeler.dk. The API rewrites the URL and adds `username` and `password`. The base layer url follows this pattern: `/api/df/[Datafordeler URI]`. Example Setup in `config/config.js`:

```json
{
"df" : {
"userName" : "QMO.....",
"password" : "3Ps....."
},
"baseLayers": [
{
"type": "wms",
"url": "/api/df/GeoDanmarkOrto/orto_foraar/1.0.0/WMS",
"layers": [
"geodanmark_2020_12_5cm"
],
"id": "geodanmark_2020_12_5cm",
"name": "TEST geodanmark_2020_12_5cm",
"description": "geodanmark_2020_12_5cm",
"attribution": "Styrelsen for Dataforsyning og Effektivisering",
"minZoom": 8,
"maxZoom": 22,
"maxNativeZoom": 22,
"transparent": true
}
]
}
```

## [2021.11.0] - 2021-3-11
### Changed
- Draw tool bar will now be positioned beside the main tools, if screen height is below 700px.

### Fixed
- Vector table now only shows in `embed.tmpl`.

## [2021.10.3] - 2021-11-10
### Changed
- Session cookie (connect.gc2) will now be set as `secure=true` and `sameSite=none` if enviromental variable NODE_ENV is set to 'production'. This will fix issues with embeding Vidi and protected layers. To set NODE_ENV in docker-compose file, use this:
Expand Down
4 changes: 3 additions & 1 deletion browser/i18n/da_DK.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ module.exports = {
"Tsvector": "Tsvector",
"No searchable fields on layer": "Ingen søgbare felter på laget",
"Method": "Metode",
"Find me": "Find mig"
"Find me": "Find mig",

"Symbols": "Symboler"
}
};
49 changes: 26 additions & 23 deletions browser/modules/bindEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ let state;
let sqlQuery;
let applicationModules = false;
let isStarted = false;
let activeFromSnapshotHasLoaded = false;
let readyCallbackIsfired = false;
let firstGroupIsOpened = false;
let urlVars = urlparser.urlVars;


Expand Down Expand Up @@ -156,36 +157,38 @@ module.exports = {
});

backboneEvents.get().on("allDoneLoading:layers", function () {
const openFirtIfNotOpen = () => {
let e = $('.js-toggle-layer-panel:first');
if (window?.vidiConfig?.extensionConfig?.embed?.expandFirstInLayerTree === true && e.hasClass('collapsed')) {
e.trigger('click');
}
}
if (!isStarted) {
if (mobile()) {
$('ul[role="tablist"]:last-child').attr('style', 'padding-bottom: 100px');
}
isStarted = true;
setTimeout(
function () {
if ($(document).width() > 1024 && typeof window.vidiConfig.activateMainTab === 'undefined') {
$('#search-border').trigger('click');
}
if (typeof window.vidiConfig.extensionConfig !== 'undefined' &&
typeof window.vidiConfig.extensionConfig.embed !== 'undefined' &&
window.vidiConfig.extensionConfig.embed.slideOutLayerTree === true
) {
$('#burger-btn').trigger('click');
}
if (typeof window.vidiConfig.extensionConfig !== 'undefined' &&
typeof window.vidiConfig.extensionConfig.embed !== 'undefined' &&
window.vidiConfig.extensionConfig.embed.expandFirstInLayerTree === true
) {
$('.js-toggle-layer-panel:first').trigger('click');
}
}, 200
);
if ($(document).width() > 1024 && typeof window.vidiConfig.activateMainTab === 'undefined') {
$('#search-border').trigger('click');
}
if (window?.vidiConfig?.extensionConfig?.embed?.slideOutLayerTree === true) {
$('#burger-btn').trigger('click');
}
openFirtIfNotOpen();

} else {
if (!activeFromSnapshotHasLoaded && urlVars?.readyCallback) {
if (!firstGroupIsOpened) {
openFirtIfNotOpen();
firstGroupIsOpened = true;
}
if (!readyCallbackIsfired && urlVars?.readyCallback) {
try {
if (state.activeLayersInSnapshot()) {
window.parent.postMessage({type: "snapshotLayersCallback", method: urlVars.readyCallback}, "*");
activeFromSnapshotHasLoaded = true;
window.parent.postMessage({
type: "snapshotLayersCallback",
method: urlVars.readyCallback
}, "*");
readyCallbackIsfired = true;
}
} catch (e) {
}
Expand Down
43 changes: 16 additions & 27 deletions browser/modules/cloud.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
/*
* @author Martin Høgh <[email protected]>
* @copyright 2013-2018 MapCentia ApS
* @copyright 2013-2021 MapCentia ApS
* @license http://www.gnu.org/licenses/#AGPL GNU AFFERO GENERAL PUBLIC LICENSE 3
*/

'use strict';

/**
*
*/
var cloud;
var lc;

let cloud;
let lc;

module.exports = {

/**
*
* @param o
* @returns {exports}
*/
set: function (o) {
set: function() {
return this;
},

/**
*
*/
init: function () {
var me = this;
const me = this;
try {
geocloud.setHost(window.gc2host);
} catch (e) {
Expand All @@ -50,18 +47,15 @@ module.exports = {
maxBoundsViscosity: 1.0
});

/**
*
*/
var map = cloud.map;
let map = cloud.map;

var zoomControl = L.control.zoom({
let zoomControl = L.control.zoom({
position: 'topright'
});

cloud.map.addControl(zoomControl);

var scaleControl = L.control.scale({
let scaleControl = L.control.scale({
position: "bottomright",
imperial: false
});
Expand All @@ -70,7 +64,7 @@ module.exports = {
/**
*
*/
lc =L.control.locate({
lc = L.control.locate({
position: 'topright',
strings: {
title: __("Find me")
Expand All @@ -79,17 +73,12 @@ module.exports = {
drawCircle: false,
locateOptions: {
enableHighAccuracy: true
}
},
followMarkerStyle: {
fillColor: '#FFB000'
},
}).addTo(map);

var localization;
if (window._vidiLocale === "da_DK") {
localization = "da";
}
if (window._vidiLocale === "en_US") {
localization = "en";
}

L.Edit.Poly = L.Edit.Poly.extend({
options: {
icon: me.iconMedium
Expand All @@ -113,11 +102,11 @@ module.exports = {
* Return the cloud object
* @returns {*}
*/
get: function () {
get: () => {
return cloud;
},

getLc: function() {
getLc: () => {
return lc;
},

Expand Down
3 changes: 2 additions & 1 deletion browser/modules/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ module.exports = {
par.pop();
}
tmpl = par.join();
window.vidiConfig.template = tmpl;
}

// If px and py is provided for print templates,
Expand Down Expand Up @@ -328,7 +329,7 @@ module.exports = {

/**
* Fetch meta > initialize settings > create layer tree >
* initialize state > load layers > initialize extensions > finish
* load layers > initialize extensions > initialize state > finish
*/
modules.meta.init().then((schemataStr) => {
return modules.setting.init(schemataStr);
Expand Down
16 changes: 9 additions & 7 deletions browser/modules/layerTree/LayerFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,13 +693,15 @@ class VectorLayerFilter extends React.Component {
<div>
{tabControl}
{activeFiltersTab}
{buildWhereClauseField()}
<div className="row">
<div className="col-md-6">{buildResetButton()}</div>
<div className="col-md-6">{buildFitBoundsButton()}</div>
</div>
<div className="row">
<div className="col-md-6">{buildDownloadButton()}</div>
<div className="filter-functions">
{buildWhereClauseField()}
<div className="row">
<div className="col-md-6">{buildResetButton()}</div>
<div className="col-md-6">{buildFitBoundsButton()}</div>
</div>
<div className="row">
<div className="col-md-6">{buildDownloadButton()}</div>
</div>
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion browser/modules/layerTree/MarkupGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MarkupGenerator {
<input type="checkbox" data-gc2-group-name="${name}">
</label>
</span>
<a style="display: inline" class="accordion-toggle js-toggle-layer-panel" data-toggle="collapse" data-parent="#layers" href="#collapse${base64GroupName}">${name}</a>
<a style="display: inline" class="accordion-toggle js-toggle-layer-panel collapsed" data-toggle="collapse" data-parent="#layers" href="#collapse${base64GroupName}">${name}</a>
</h4>
</div>
<ul class="list-group" id="group-${base64GroupName}" role="tabpanel"></ul>
Expand Down
5 changes: 1 addition & 4 deletions browser/modules/layerTree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1083,10 +1083,7 @@ module.exports = {

if (layersThatAreNotInMeta.length > 0) {
let fetchMetaRequests = [];
layersThatAreNotInMeta.map(item => {
fetchMetaRequests.push(meta.init(item, true, true).catch(error => { return false }))
});

fetchMetaRequests.push(meta.init(layersThatAreNotInMeta.join(','), true, true).catch(error => { return false }))
Promise.all(fetchMetaRequests).then(() => {
proceedWithBuilding();
});
Expand Down
32 changes: 18 additions & 14 deletions browser/modules/measurements.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,22 +378,26 @@ module.exports = {
*/
recreateDrawnings: (parr) => {
let v = parr;
$.each(v[0].geojson.features, (n, m) => {
let json = L.geoJson(m, {
style: function (f) {
return f.style;
try {
$.each(v[0].geojson.features, (n, m) => {
let json = L.geoJson(m, {
style: function (f) {
return f.style;
}
});

let g = json._layers[Object.keys(json._layers)[0]];
g._vidi_type = m._vidi_type;
drawnItems.addLayer(g);
g.showMeasurements(m._vidi_measurementOptions);
if (m._vidi_extremities) {
g.showExtremities(m._vidi_extremities.pattern, m._vidi_extremities.size, m._vidi_extremities.where);
}
});

let g = json._layers[Object.keys(json._layers)[0]];
g._vidi_type = m._vidi_type;
drawnItems.addLayer(g);
g.showMeasurements(m._vidi_measurementOptions);
if (m._vidi_extremities) {
g.showExtremities(m._vidi_extremities.pattern, m._vidi_extremities.size, m._vidi_extremities.where);
}
});
},
} catch(e) {
console.error(e.message)
}
},


/**
Expand Down
12 changes: 5 additions & 7 deletions browser/modules/sqlQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,11 @@ module.exports = {
let layerTitel = (metaDataKeys[value].f_table_title !== null && metaDataKeys[value].f_table_title !== "") ? metaDataKeys[value].f_table_title : metaDataKeys[value].f_table_name;
let not_querable = metaDataKeys[value].not_querable;
let versioning = metaDataKeys[value].versioning;
let fields = typeof metaDataKeys[value].fields !== "undefined" ? metaDataKeys[value].fields : null;
let fields = metaDataKeys?.[value]?.fields || null;
let onLoad;
let fieldConf = (typeof metaDataKeys[value].fieldconf !== "undefined"
&& metaDataKeys[value].fieldconf !== "")
? $.parseJSON(metaDataKeys[value].fieldconf) : null;
let fieldConf = metaDataKeys?.[value]?.fieldconf !== "" ? JSON.parse(metaDataKeys[value].fieldconf) : null;
let parsedMeta = layerTree.parseLayerMeta(metaDataKeys[value]);

let featureInfoTableOnMap = (typeof window.vidiConfig.featureInfoTableOnMap !== "undefined" && window.vidiConfig.featureInfoTableOnMap === true && simple);
let featureInfoTableOnMap = window.vidiConfig?.featureInfoTableOnMap === true && simple;
let f_geometry_column = metaDataKeys[value].f_geometry_column
let styleForSelectedFeatures;

Expand Down Expand Up @@ -566,12 +563,13 @@ module.exports = {
cloud.get().addGeoJsonStore(qstore[index]);

let sql, fieldNames = [], fieldStr;
console.log(fieldConf)

if (fields) {
$.each(fields, function (i, v) {
if (v.type === "bytea") {
fieldNames.push("encode(\"" + i + "\",'escape') as \"" + i + "\"");
} else {
} else if (fieldConf?.[i]?.ignore !== true) {
fieldNames.push("\"" + i + "\"");
}
});
Expand Down
5 changes: 4 additions & 1 deletion browser/modules/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ module.exports = {
*/
const createPromise = (data) => {
return new Promise(resolve => {
switchLayer.init(data, true, true).then(resolve);
switchLayer.init(data, true, true).then(() => {
backboneEvents.get().trigger(`layerTree:activeLayersChange`);
resolve()
});
})
};

Expand Down
Loading

0 comments on commit ad4cb8f

Please sign in to comment.