From 90b4340f4a07b4005324ea1abe2c6a6ffdccb54c Mon Sep 17 00:00:00 2001 From: Just van den Broecke Date: Wed, 22 Apr 2020 12:33:19 +0200 Subject: [PATCH] #36 PoC success for app config/dir restructure --- app/.gitignore | 5 +- app/WguApp.vue | 17 +++ app/WguAppTemplate.vue | 143 +++++++++++++++++++++ app/components/AppFooter.vue | 30 +++++ app/components/AppHeader.vue | 145 +++++++++++++++++++++ app/components/layerlist/LayerList.vue | 131 +++++++++++++++++++ app/components/layerlist/LayerListWin.vue | 57 +++++++++ app/components/layerlist/ToggleButton.vue | 49 +++++++ app/css/app.css | 1 + app/static/app-conf.json | 132 +++++++++++++++++++ build/dev-server.js | 6 + build/webpack.base.conf.js | 4 +- src/WguAppTemplate.vue | 15 +-- src/components/AppHeader.vue | 9 +- src/main.js | 35 +++-- static/app-conf.json | 149 +++++++++++++--------- 16 files changed, 831 insertions(+), 97 deletions(-) create mode 100644 app/WguApp.vue create mode 100644 app/WguAppTemplate.vue create mode 100644 app/components/AppFooter.vue create mode 100644 app/components/AppHeader.vue create mode 100644 app/components/layerlist/LayerList.vue create mode 100644 app/components/layerlist/LayerListWin.vue create mode 100644 app/components/layerlist/ToggleButton.vue create mode 100644 app/css/app.css create mode 100644 app/static/app-conf.json diff --git a/app/.gitignore b/app/.gitignore index 5e7d2734..a6b8e0d6 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,4 +1,5 @@ # Ignore everything in this directory -* +# * # Except this file -!.gitignore +# !.gitignore +.DS_Store diff --git a/app/WguApp.vue b/app/WguApp.vue new file mode 100644 index 00000000..406ce71d --- /dev/null +++ b/app/WguApp.vue @@ -0,0 +1,17 @@ + + + + diff --git a/app/WguAppTemplate.vue b/app/WguAppTemplate.vue new file mode 100644 index 00000000..5c2d5a36 --- /dev/null +++ b/app/WguAppTemplate.vue @@ -0,0 +1,143 @@ + + + diff --git a/app/components/AppFooter.vue b/app/components/AppFooter.vue new file mode 100644 index 00000000..b499e401 --- /dev/null +++ b/app/components/AppFooter.vue @@ -0,0 +1,30 @@ + + + + + + diff --git a/app/components/AppHeader.vue b/app/components/AppHeader.vue new file mode 100644 index 00000000..1dbdef20 --- /dev/null +++ b/app/components/AppHeader.vue @@ -0,0 +1,145 @@ + + + + + + diff --git a/app/components/layerlist/LayerList.vue b/app/components/layerlist/LayerList.vue new file mode 100644 index 00000000..c48a1487 --- /dev/null +++ b/app/components/layerlist/LayerList.vue @@ -0,0 +1,131 @@ + + + + + diff --git a/app/components/layerlist/LayerListWin.vue b/app/components/layerlist/LayerListWin.vue new file mode 100644 index 00000000..a69ddedf --- /dev/null +++ b/app/components/layerlist/LayerListWin.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/app/components/layerlist/ToggleButton.vue b/app/components/layerlist/ToggleButton.vue new file mode 100644 index 00000000..e5ff21fe --- /dev/null +++ b/app/components/layerlist/ToggleButton.vue @@ -0,0 +1,49 @@ + + + + + + diff --git a/app/css/app.css b/app/css/app.css new file mode 100644 index 00000000..58dd7590 --- /dev/null +++ b/app/css/app.css @@ -0,0 +1 @@ +/* Created by init-app.js at Tue Mar 10 2020 16:02:41 GMT+0100 (GMT+01:00) */ \ No newline at end of file diff --git a/app/static/app-conf.json b/app/static/app-conf.json new file mode 100644 index 00000000..88482799 --- /dev/null +++ b/app/static/app-conf.json @@ -0,0 +1,132 @@ +{ + + "title": "Naturpark Lüneburger Heide", + + "baseColor": "rgba(226, 0, 122, 1)", + + "logoText": "NPLH Logo", + + "footerTextLeft": "Powered by Wegue WebGIS and Geolicious GeoCMS", + "footerTextRight": "Geolicious", + "showCopyrightYear": true, + + "mapCenter": [1113871, 7012966], + "mapZoom": 9, + + "permalink": { + "location": "search", + "layers": true, + "extent": true, + "projection": "EPSG:4326", + "paramPrefix": "", + "history": false + }, + + "mapLayers": [ + { + "type": "VECTOR", + "lid": "np_lh_border", + "name": "Naturpark Grenze", + "url": "./static/data/np_lh_border_4326.geojson", + "formatConfig": { + }, + "format": "GeoJSON", + "visible": true, + "selectable": false, + "style": { + "strokeColor": "rgba(226, 0, 122, 1)", + "strokeWidth": 4 + } + }, + { + "type": "VECTOR", + "lid": "heide", + "name": "Heide", + "url": "./static/data/overpass_natural-heath.geojson", + "formatConfig": { + }, + "format": "GeoJSON", + "visible": true, + "selectable": false, + "style": { + "strokeColor": "rgb(162, 114, 240)", + "strokeWidth": 4, + "fillColor": "rgba(162, 114, 240, 0.5)" + } + }, + { + "type": "LAYERCOLLECTION", + "url": "http://staging.nplh.geolicious.de/api/layer_list_wegue_format" + }, + { + "type": "OSM", + "lid": "osm-bg", + "name": "OSM", + "isBaseLayer": true, + "visible": true, + "displayInLayerList": false + } + ], + + "modules": { + "wgu-layerlist": { + "target": "toolbar", + "darkLayout": true, + "win": true, + "draggable": false + }, + "wgu-measuretool": { + "target": "menu", + "win": true, + "draggable": false, + "strokeColor": "#c62828", + "fillColor": "rgba(198,40,40,0.2)", + "sketchStrokeColor": "rgba(198,40,40,0.8)", + "sketchFillColor": "rgba(198,40,40,0.1)", + "sketchVertexStrokeColor": "#c62828", + "sketchVertexFillColor": "rgba(198,40,40,0.2)" + }, + "wgu-infoclick": { + "target": "menu", + "win": true, + "draggable": false, + "darkLayout": true, + "initPos": { + "left": 8, + "top": 74 + } + }, + "wgu-zoomtomaxextent": { + "target": "toolbar", + "darkLayout": true + }, + "wgu-share": { + "target": "toolbar", + "darkLayout": true + }, + "wgu-feature-info-window": { + "win": true, + "draggable": true, + "width": 360, + "icon": "info", + "layers": [ + { + "layerId": "layer", + "title": "Info", + "titleProp": "name", + "imageProp": "image_url", + "descProp": "description", + "imageWidth": 360 + } + ] + }, + "wgu-routing": { + "transportModes": ["car", "publicTransport"], + "panel": true, + "target": "toolbar", + "icon": "info", + "darkLayout": true + } + } + +} diff --git a/build/dev-server.js b/build/dev-server.js index 6c37b783..2a7e09ad 100644 --- a/build/dev-server.js +++ b/build/dev-server.js @@ -65,6 +65,12 @@ app.use(hotMiddleware) var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory) app.use(staticPath, express.static('./static')) +console.log(config.dev.assetsPublicPath); +// assetsSubDirectory: 'static', +// assetsPublicPath: './', +var staticPath2 = path.posix.join(config.dev.assetsPublicPath, 'app/static') +app.use(staticPath2, express.static('./app/static')) + var uri = 'http://localhost:' + port var _resolve diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index 7a2d5fc8..407cda62 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -33,7 +33,7 @@ module.exports = { test: /\.(js|vue)$/, loader: 'eslint-loader', enforce: 'pre', - include: [resolve('src'), resolve('test')], + include: [resolve('app'), resolve('src'), resolve('test')], options: { formatter: require('eslint-friendly-formatter') } @@ -46,7 +46,7 @@ module.exports = { { test: /\.js$/, loader: 'babel-loader', - include: [resolve('src'), resolve('test'), resolve('node_modules/ol')], + include: [resolve('app'), resolve('src'), resolve('test'), resolve('node_modules/ol')], }, { test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, diff --git a/src/WguAppTemplate.vue b/src/WguAppTemplate.vue index 8ef4a56c..5570dc78 100644 --- a/src/WguAppTemplate.vue +++ b/src/WguAppTemplate.vue @@ -19,7 +19,6 @@ - @@ -34,9 +33,6 @@ :color="baseColor" :draggable="moduleWin.draggable" :initPos="moduleWin.initPos" - :width="moduleWin.width" - :title="moduleWin.title" - :icon="moduleWin.icon" /> @@ -67,8 +63,6 @@ import LayerListWin from './components/layerlist/LayerListWin' import InfoClickWin from './components/infoclick/InfoClickWin' import MapLoadingStatus from './components/progress/MapLoadingStatus' - import FeatureInfoWindow from './components/FeatureInfoWindow' - import RoutingPanel from './components/routing/RoutingPanel' export default { name: 'wgu-app-tpl', @@ -80,9 +74,7 @@ 'wgu-measuretool-win': MeasureWin, 'wgu-layerlist-win': LayerListWin, 'wgu-infoclick-win': InfoClickWin, - 'wgu-maploading-status': MapLoadingStatus, - 'wgu-feature-info-window-win': FeatureInfoWindow, - 'wgu-routing-panel': RoutingPanel + 'wgu-maploading-status': MapLoadingStatus }, data () { return { @@ -129,10 +121,7 @@ moduleWins.push({ type: key + '-win', draggable: moduleOpts.draggable, - initPos: moduleOpts.initPos, - title: moduleOpts.title, - width: moduleOpts.width, - icon: moduleOpts.icon + initPos: moduleOpts.initPos }); } } diff --git a/src/components/AppHeader.vue b/src/components/AppHeader.vue index 3a8e6e7c..bb5f2520 100644 --- a/src/components/AppHeader.vue +++ b/src/components/AppHeader.vue @@ -10,7 +10,7 @@ - + {{title}} @@ -58,22 +58,18 @@ import LayerListToggleButton from './layerlist/ToggleButton' import HelpWinToggleButton from './helpwin/ToggleButton' import MeasureToolToggleButton from './measuretool/ToggleButton' import InfoClickButton from './infoclick/ToggleButton' -import ShareButton from './sharebutton/ShareButton' import ZoomToMaxExtentButton from './maxextentbutton/ZoomToMaxExtentButton' -import RoutingToggleButton from './routing/RoutingToggleButton' import Geocoder from './geocoder/Geocoder' export default { name: 'wgu-app-header', components: { - 'wgu-share-btn': ShareButton, 'wgu-geocoder-btn': Geocoder, 'wgu-zoomtomaxextent-btn': ZoomToMaxExtentButton, 'wgu-layerlist-btn': LayerListToggleButton, 'wgu-helpwin-btn': HelpWinToggleButton, 'wgu-measuretool-btn': MeasureToolToggleButton, - 'wgu-infoclick-btn': InfoClickButton, - 'wgu-routing-btn': RoutingToggleButton + 'wgu-infoclick-btn': InfoClickButton }, props: { color: {type: String, required: false, default: 'red darken-3'} @@ -123,7 +119,6 @@ export default { const appConfig = Vue.prototype.$appConfig || {}; const modulesConfs = appConfig.modules || {}; let moduleWins = []; - for (const key of Object.keys(modulesConfs)) { const moduleOpts = appConfig.modules[key]; if (moduleOpts.target === 'toolbar') { diff --git a/src/main.js b/src/main.js index 867734eb..32852839 100644 --- a/src/main.js +++ b/src/main.js @@ -33,17 +33,28 @@ if (appCtx) { appCtxFile = '-' + appCtx.replace(/(\.\.[/])+/g, ''); } -fetch('static/app-conf' + appCtxFile + '.json') +const createApp = function (appConfig) { + // make app config accessible for all components + Vue.prototype.$appConfig = appConfig; + /* eslint-disable no-new */ + new Vue({ + el: '#app', + template: '', + components: { WguApp } + }); +}; + +fetch('app/static/app-conf' + appCtxFile + '.json') .then(function (response) { - return response.json(); - }) - .then(function (appConfig) { - // make app config accessible for all components - Vue.prototype.$appConfig = appConfig; - /* eslint-disable no-new */ - new Vue({ - el: '#app', - template: '', - components: { WguApp } - }); + return response.json().then(function (appConfig) { + // console.log('app', appConfig); + createApp(appConfig); + }) + }).catch(function () { + fetch('static/app-conf' + appCtxFile + '.json').then(function (response) { + return response.json().then(function (appConfig) { + // console.log('static', appConfig); + createApp(appConfig); + }) + }) }); diff --git a/static/app-conf.json b/static/app-conf.json index 88482799..ad512fd2 100644 --- a/static/app-conf.json +++ b/static/app-conf.json @@ -1,77 +1,114 @@ { - "title": "Naturpark Lüneburger Heide", + "title": "Vue.js / OpenLayers WebGIS", - "baseColor": "rgba(226, 0, 122, 1)", + "baseColor": "red darken-3", - "logoText": "NPLH Logo", + "logo": "https://dummyimage.com/100x100/aaa/fff&text=Wegue", + "logoSize": "100", - "footerTextLeft": "Powered by Wegue WebGIS and Geolicious GeoCMS", - "footerTextRight": "Geolicious", + "footerTextLeft": "Powered by Wegue WebGIS", + "footerTextRight": "meggsimum", "showCopyrightYear": true, - "mapCenter": [1113871, 7012966], - "mapZoom": 9, - - "permalink": { - "location": "search", - "layers": true, - "extent": true, - "projection": "EPSG:4326", - "paramPrefix": "", - "history": false - }, + "mapZoom": 2, + "mapCenter": [0, 0], "mapLayers": [ + { "type": "VECTOR", - "lid": "np_lh_border", - "name": "Naturpark Grenze", - "url": "./static/data/np_lh_border_4326.geojson", + "lid": "Shops", + "name": "Shops DaSchau", + "url": "./static/data/shops-dannstadt.geojson", "formatConfig": { }, "format": "GeoJSON", "visible": true, - "selectable": false, + "selectable": true, "style": { - "strokeColor": "rgba(226, 0, 122, 1)", - "strokeWidth": 4 + "radius": 4, + "strokeColor": "purple", + "strokeWidth": 2, + "fillColor": "rgba(155,153,51,0.5)" } }, + { "type": "VECTOR", - "lid": "heide", - "name": "Heide", - "url": "./static/data/overpass_natural-heath.geojson", + "lid": "earthquakes", + "name": "Earthquakes 2012 (Mag 5)", + "url": "./static/data/2012_Earthquakes_Mag5.kml", "formatConfig": { + "extractStyles": false }, - "format": "GeoJSON", + "format": "KML", "visible": true, - "selectable": false, + "attributions": "U.S. Geological Survey", + "selectable": true, + "hoverable": true, + "hoverAttribute": "name", + "style": { + "radius": 4, + "strokeColor": "rgb(207, 16, 32)", + "strokeWidth": 1, + "fillColor": "rgba(207, 16, 32, 0.6)" + } + }, + + { + "type": "WMS", + "lid": "ahocevar-wms", + "name": "WMS (ahocevar)", + "format": "image/png", + "layers": "topp:states", + "url": "https://ahocevar.com/geoserver/wms", + "transparent": true, + "singleTile": false, + "projection": "EPSG:3857", + "attribution": "", + "isBaseLayer": false, + "visible": false, + "displayInLayerList": true + }, + + { + "type": "VECTORTILE", + "name": "Vector Tile Layer", + "url": "https://ahocevar.com/geoserver/gwc/service/tms/1.0.0/ne:ne_10m_admin_0_countries@EPSG%3A900913@pbf/{z}/{x}/{-y}.pbf", + "format": "MVT", + "visible": false, "style": { - "strokeColor": "rgb(162, 114, 240)", - "strokeWidth": 4, - "fillColor": "rgba(162, 114, 240, 0.5)" + "strokeColor": "gray", + "strokeWidth": 1, + "fillColor": "rgba(20,20,20,0.1)" } }, + { - "type": "LAYERCOLLECTION", - "url": "http://staging.nplh.geolicious.de/api/layer_list_wegue_format" + "type": "XYZ", + "name": "OpenTopoMap", + "url": "https://tile.opentopomap.org/{z}/{x}/{y}.png", + "attributions": "Map data: ©OpenStreetMap-contributors, SRTM | Map representation (Kartendarstellung): © OpenTopoMap (CC-BY-SA)", + "lid": "opentopomap", + "displayInLayerList": true, + "visible": false }, + { "type": "OSM", "lid": "osm-bg", "name": "OSM", - "isBaseLayer": true, + "isBaseLayer": false, "visible": true, - "displayInLayerList": false + "displayInLayerList": true } + ], "modules": { "wgu-layerlist": { - "target": "toolbar", - "darkLayout": true, + "target": "menu", "win": true, "draggable": false }, @@ -90,43 +127,33 @@ "target": "menu", "win": true, "draggable": false, - "darkLayout": true, "initPos": { "left": 8, "top": 74 } }, - "wgu-zoomtomaxextent": { + "wgu-geocoder": { "target": "toolbar", - "darkLayout": true + "darkLayout": true, + "minChars": 2, + "queryDelay": 200, + "selectZoom": 16, + "debug": false, + "placeHolder": "Search address", + "provider": "osm", + "providerOptions": { + "lang": "en-US", + "countrycodes": "", + "limit": 6 + } }, - "wgu-share": { + "wgu-zoomtomaxextent": { "target": "toolbar", "darkLayout": true }, - "wgu-feature-info-window": { - "win": true, - "draggable": true, - "width": 360, - "icon": "info", - "layers": [ - { - "layerId": "layer", - "title": "Info", - "titleProp": "name", - "imageProp": "image_url", - "descProp": "description", - "imageWidth": 360 - } - ] - }, - "wgu-routing": { - "transportModes": ["car", "publicTransport"], - "panel": true, + "wgu-helpwin": { "target": "toolbar", - "icon": "info", "darkLayout": true } } - }