From 38f519092ecec97260389285387d0081ccd7cbb0 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Mon, 26 Aug 2019 10:17:08 +0200 Subject: [PATCH 01/12] working basic routing --- static/css/custom.css | 6 +++- static/index.html | 3 +- static/js/components/Map.js | 66 +++++++++++++++++++++++++++++++++++++ static/js/config.js | 12 +++++++ static/js/main.js | 15 +++++++-- static/js/map.js | 2 -- static/js/nomodule.js | 2 +- static/js/routes.js | 13 ++++++++ 8 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 static/js/components/Map.js create mode 100644 static/js/config.js create mode 100644 static/js/routes.js diff --git a/static/css/custom.css b/static/css/custom.css index 343f9a5..0fa2fcc 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -4,7 +4,11 @@ body { overflow: hidden; } -#image-map { +#app { + height: 100%; +} + +.full-screen { width: 100%; height: 100%; border: 1px solid #ccc; diff --git a/static/index.html b/static/index.html index 5b98d85..f1d1e29 100644 --- a/static/index.html +++ b/static/index.html @@ -15,8 +15,7 @@ Minetest Mapserver -
-
+
diff --git a/static/js/components/Map.js b/static/js/components/Map.js new file mode 100644 index 0000000..9bb358b --- /dev/null +++ b/static/js/components/Map.js @@ -0,0 +1,66 @@ +import wsChannel from '../WebSocketChannel.js'; +import SimpleCRS from '../SimpleCRS.js'; +import CoordinatesDisplay from '../CoordinatesDisplay.js'; +import WorldInfoDisplay from '../WorldInfoDisplay.js'; +import SearchControl from '../SearchControl.js'; +import Overlaysetup from '../Overlaysetup.js'; +import layerManager from '../LayerManager.js'; +import config from '../config.js'; + +export default { + view(vnode){ + return m("div", { class: "full-screen" }); + }, + + oncreate(vnode){ + console.log("oncreate", vnode); + const cfg = config.get(); + + var map = L.map(vnode.dom, { + minZoom: 2, + maxZoom: 12, + center: [+vnode.attrs.lat, +vnode.attrs.lon], + zoom: +vnode.attrs.zoom, + crs: SimpleCRS + }); + + vnode.state.map = map; + + map.attributionControl.addAttribution('Minetest Mapserver'); + + var overlays = {}; + + layerManager.setup(wsChannel, cfg.layers, map, +vnode.attrs.layerId); + + //All overlays + Overlaysetup(cfg, map, overlays, wsChannel, layerManager); + + new CoordinatesDisplay({ position: 'bottomleft' }).addTo(map); + new WorldInfoDisplay(wsChannel, { position: 'bottomright' }).addTo(map); + + if (cfg.enablesearch){ + new SearchControl(wsChannel, { position: 'topright' }).addTo(map); + } + + //layer control + L.control.layers(layerManager.layerObjects, overlays, { position: "topright" }).addTo(map); + + //TODO: overlay persistence (state, localstorage) + //TODO: update hash + }, + + onbeforeupdate(newVnode, oldVnode) { + return false; + }, + + onupdate(vnode){ + console.log("onupdate", vnode); + + //TODO: compare and update center,zoom,layer + }, + + onremove(vnode){ + console.log("onremove", vnode); + vnode.state.map.remove(); + } +} diff --git a/static/js/config.js b/static/js/config.js new file mode 100644 index 0000000..16cc3d5 --- /dev/null +++ b/static/js/config.js @@ -0,0 +1,12 @@ + +var config; + +export default { + get(){ + return config; + }, + + set(cfg){ + config = cfg; + } +} diff --git a/static/js/main.js b/static/js/main.js index 080e9ee..378adf1 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1,5 +1,16 @@ import { getConfig } from './api.js'; -import { setup } from './map.js'; +//import { setup } from './map.js'; +import routes from './routes.js'; +import wsChannel from './WebSocketChannel.js'; +import config from './config.js'; -getConfig().then(setup); +//TODO: migrate #/layer/zoom/lat/lon to #!/map/... +//TODO: migrate #/zoom/lat/lon to #!/map/... + +getConfig().then(cfg => { + config.set(cfg); + wsChannel.connect(); + m.route(document.getElementById("app"), "/map/0/13/0/0", routes); + //setup(cfg); +}); diff --git a/static/js/map.js b/static/js/map.js index 882c015..9bf6705 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -9,8 +9,6 @@ import layerManager from './LayerManager.js'; export function setup(cfg){ - wsChannel.connect(); - var map = L.map('image-map', { minZoom: 2, maxZoom: 12, diff --git a/static/js/nomodule.js b/static/js/nomodule.js index 4adba96..c46af90 100644 --- a/static/js/nomodule.js +++ b/static/js/nomodule.js @@ -1,5 +1,5 @@ -m.mount(document.getElementById("image-map"), { +m.mount(document.getElementById("app"), { view: function(){ return m("div", "I'm sorry, your browser is just too old ;)"); } diff --git a/static/js/routes.js b/static/js/routes.js new file mode 100644 index 0000000..376e4b1 --- /dev/null +++ b/static/js/routes.js @@ -0,0 +1,13 @@ + +import Map from './components/Map.js'; + +var Home = { + view: function() { + return "Home" + } +} + +export default { + "/": Home, + "/map/:layerId/:zoom/:lon/:lat": Map +} From dc7653ffbc3a2e3aa23a83669bfbd7ec53787f26 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Thu, 29 Aug 2019 10:28:52 +0200 Subject: [PATCH 02/12] directory move --- static/js/map.js | 40 ------------------- static/js/{ => map}/CoordinatesDisplay.js | 0 static/js/{ => map}/Hashroute.js | 0 static/js/{ => map}/LayerManager.js | 0 .../Map.js => map/MapComponent.js} | 14 +++---- static/js/{ => map}/Overlaysetup.js | 0 static/js/{ => map}/RealtimeTileLayer.js | 0 static/js/{ => map}/SearchControl.js | 4 +- static/js/{ => map}/SimpleCRS.js | 0 static/js/{ => map}/WorldInfoDisplay.js | 0 static/js/{ => map}/overlays/ATMOverlay.js | 0 .../overlays/AbstractGeoJsonOverlay.js | 0 .../{ => map}/overlays/AbstractIconOverlay.js | 0 static/js/{ => map}/overlays/BonesOverlay.js | 0 static/js/{ => map}/overlays/BorderOverlay.js | 0 .../js/{ => map}/overlays/DigitermOverlay.js | 0 static/js/{ => map}/overlays/LabelOverlay.js | 0 static/js/{ => map}/overlays/LcdOverlay.js | 0 .../js/{ => map}/overlays/LocatorOverlay.js | 0 .../overlays/LuacontrollerOverlay.js | 0 .../js/{ => map}/overlays/MinecartOverlay.js | 0 .../js/{ => map}/overlays/MissionOverlay.js | 0 static/js/{ => map}/overlays/PlayerOverlay.js | 0 static/js/{ => map}/overlays/PoiOverlay.js | 0 .../overlays/PrivProtectorOverlay.js | 0 .../js/{ => map}/overlays/ProtectorOverlay.js | 0 static/js/{ => map}/overlays/ShopOverlay.js | 0 .../overlays/TechnicAnchorOverlay.js | 0 .../overlays/TechnicQuarryOverlay.js | 0 .../overlays/TechnicSwitchOverlay.js | 0 static/js/{ => map}/overlays/TrainOverlay.js | 0 .../js/{ => map}/overlays/TrainlineOverlay.js | 0 .../{ => map}/overlays/TrainsignalOverlay.js | 0 .../js/{ => map}/overlays/TravelnetOverlay.js | 0 .../{ => map}/overlays/XPProtectorOverlay.js | 0 static/js/routes.js | 4 +- 36 files changed, 11 insertions(+), 51 deletions(-) delete mode 100644 static/js/map.js rename static/js/{ => map}/CoordinatesDisplay.js (100%) rename static/js/{ => map}/Hashroute.js (100%) rename static/js/{ => map}/LayerManager.js (100%) rename static/js/{components/Map.js => map/MapComponent.js} (80%) rename static/js/{ => map}/Overlaysetup.js (100%) rename static/js/{ => map}/RealtimeTileLayer.js (100%) rename static/js/{ => map}/SearchControl.js (79%) rename static/js/{ => map}/SimpleCRS.js (100%) rename static/js/{ => map}/WorldInfoDisplay.js (100%) rename static/js/{ => map}/overlays/ATMOverlay.js (100%) rename static/js/{ => map}/overlays/AbstractGeoJsonOverlay.js (100%) rename static/js/{ => map}/overlays/AbstractIconOverlay.js (100%) rename static/js/{ => map}/overlays/BonesOverlay.js (100%) rename static/js/{ => map}/overlays/BorderOverlay.js (100%) rename static/js/{ => map}/overlays/DigitermOverlay.js (100%) rename static/js/{ => map}/overlays/LabelOverlay.js (100%) rename static/js/{ => map}/overlays/LcdOverlay.js (100%) rename static/js/{ => map}/overlays/LocatorOverlay.js (100%) rename static/js/{ => map}/overlays/LuacontrollerOverlay.js (100%) rename static/js/{ => map}/overlays/MinecartOverlay.js (100%) rename static/js/{ => map}/overlays/MissionOverlay.js (100%) rename static/js/{ => map}/overlays/PlayerOverlay.js (100%) rename static/js/{ => map}/overlays/PoiOverlay.js (100%) rename static/js/{ => map}/overlays/PrivProtectorOverlay.js (100%) rename static/js/{ => map}/overlays/ProtectorOverlay.js (100%) rename static/js/{ => map}/overlays/ShopOverlay.js (100%) rename static/js/{ => map}/overlays/TechnicAnchorOverlay.js (100%) rename static/js/{ => map}/overlays/TechnicQuarryOverlay.js (100%) rename static/js/{ => map}/overlays/TechnicSwitchOverlay.js (100%) rename static/js/{ => map}/overlays/TrainOverlay.js (100%) rename static/js/{ => map}/overlays/TrainlineOverlay.js (100%) rename static/js/{ => map}/overlays/TrainsignalOverlay.js (100%) rename static/js/{ => map}/overlays/TravelnetOverlay.js (100%) rename static/js/{ => map}/overlays/XPProtectorOverlay.js (100%) diff --git a/static/js/map.js b/static/js/map.js deleted file mode 100644 index 9bf6705..0000000 --- a/static/js/map.js +++ /dev/null @@ -1,40 +0,0 @@ -import wsChannel from './WebSocketChannel.js'; -import Hashroute from './Hashroute.js'; -import SimpleCRS from './SimpleCRS.js'; -import CoordinatesDisplay from './CoordinatesDisplay.js'; -import WorldInfoDisplay from './WorldInfoDisplay.js'; -import SearchControl from './SearchControl.js'; -import Overlaysetup from './Overlaysetup.js'; -import layerManager from './LayerManager.js'; - -export function setup(cfg){ - - var map = L.map('image-map', { - minZoom: 2, - maxZoom: 12, - center: Hashroute.getCenter(), - zoom: Hashroute.getZoom(), - crs: SimpleCRS - }); - - map.attributionControl.addAttribution('Minetest Mapserver'); - - var overlays = {}; - - layerManager.setup(wsChannel, cfg.layers, map, Hashroute.getLayerId()); - - //All overlays - Overlaysetup(cfg, map, overlays, wsChannel, layerManager); - - new CoordinatesDisplay({ position: 'bottomleft' }).addTo(map); - new WorldInfoDisplay(wsChannel, { position: 'bottomright' }).addTo(map); - - if (cfg.enablesearch){ - new SearchControl(wsChannel, { position: 'topright' }).addTo(map); - } - - //layer control - L.control.layers(layerManager.layerObjects, overlays, { position: "topright" }).addTo(map); - - Hashroute.setup(map, layerManager); -} diff --git a/static/js/CoordinatesDisplay.js b/static/js/map/CoordinatesDisplay.js similarity index 100% rename from static/js/CoordinatesDisplay.js rename to static/js/map/CoordinatesDisplay.js diff --git a/static/js/Hashroute.js b/static/js/map/Hashroute.js similarity index 100% rename from static/js/Hashroute.js rename to static/js/map/Hashroute.js diff --git a/static/js/LayerManager.js b/static/js/map/LayerManager.js similarity index 100% rename from static/js/LayerManager.js rename to static/js/map/LayerManager.js diff --git a/static/js/components/Map.js b/static/js/map/MapComponent.js similarity index 80% rename from static/js/components/Map.js rename to static/js/map/MapComponent.js index 9bb358b..4458d54 100644 --- a/static/js/components/Map.js +++ b/static/js/map/MapComponent.js @@ -1,10 +1,10 @@ -import wsChannel from '../WebSocketChannel.js'; -import SimpleCRS from '../SimpleCRS.js'; -import CoordinatesDisplay from '../CoordinatesDisplay.js'; -import WorldInfoDisplay from '../WorldInfoDisplay.js'; -import SearchControl from '../SearchControl.js'; -import Overlaysetup from '../Overlaysetup.js'; -import layerManager from '../LayerManager.js'; +import wsChannel from './WebSocketChannel.js'; +import SimpleCRS from './SimpleCRS.js'; +import CoordinatesDisplay from './CoordinatesDisplay.js'; +import WorldInfoDisplay from './WorldInfoDisplay.js'; +import SearchControl from './SearchControl.js'; +import Overlaysetup from './Overlaysetup.js'; +import layerManager from './LayerManager.js'; import config from '../config.js'; export default { diff --git a/static/js/Overlaysetup.js b/static/js/map/Overlaysetup.js similarity index 100% rename from static/js/Overlaysetup.js rename to static/js/map/Overlaysetup.js diff --git a/static/js/RealtimeTileLayer.js b/static/js/map/RealtimeTileLayer.js similarity index 100% rename from static/js/RealtimeTileLayer.js rename to static/js/map/RealtimeTileLayer.js diff --git a/static/js/SearchControl.js b/static/js/map/SearchControl.js similarity index 79% rename from static/js/SearchControl.js rename to static/js/map/SearchControl.js index 1aa228f..8aefdf0 100644 --- a/static/js/SearchControl.js +++ b/static/js/map/SearchControl.js @@ -1,5 +1,5 @@ -import SearchMenu from './search/SearchMenu.js'; -import SearchInput from './search/SearchInput.js'; +import SearchMenu from '../search/SearchMenu.js'; +import SearchInput from '../search/SearchInput.js'; export default L.Control.extend({ initialize: function(wsChannel, opts) { diff --git a/static/js/SimpleCRS.js b/static/js/map/SimpleCRS.js similarity index 100% rename from static/js/SimpleCRS.js rename to static/js/map/SimpleCRS.js diff --git a/static/js/WorldInfoDisplay.js b/static/js/map/WorldInfoDisplay.js similarity index 100% rename from static/js/WorldInfoDisplay.js rename to static/js/map/WorldInfoDisplay.js diff --git a/static/js/overlays/ATMOverlay.js b/static/js/map/overlays/ATMOverlay.js similarity index 100% rename from static/js/overlays/ATMOverlay.js rename to static/js/map/overlays/ATMOverlay.js diff --git a/static/js/overlays/AbstractGeoJsonOverlay.js b/static/js/map/overlays/AbstractGeoJsonOverlay.js similarity index 100% rename from static/js/overlays/AbstractGeoJsonOverlay.js rename to static/js/map/overlays/AbstractGeoJsonOverlay.js diff --git a/static/js/overlays/AbstractIconOverlay.js b/static/js/map/overlays/AbstractIconOverlay.js similarity index 100% rename from static/js/overlays/AbstractIconOverlay.js rename to static/js/map/overlays/AbstractIconOverlay.js diff --git a/static/js/overlays/BonesOverlay.js b/static/js/map/overlays/BonesOverlay.js similarity index 100% rename from static/js/overlays/BonesOverlay.js rename to static/js/map/overlays/BonesOverlay.js diff --git a/static/js/overlays/BorderOverlay.js b/static/js/map/overlays/BorderOverlay.js similarity index 100% rename from static/js/overlays/BorderOverlay.js rename to static/js/map/overlays/BorderOverlay.js diff --git a/static/js/overlays/DigitermOverlay.js b/static/js/map/overlays/DigitermOverlay.js similarity index 100% rename from static/js/overlays/DigitermOverlay.js rename to static/js/map/overlays/DigitermOverlay.js diff --git a/static/js/overlays/LabelOverlay.js b/static/js/map/overlays/LabelOverlay.js similarity index 100% rename from static/js/overlays/LabelOverlay.js rename to static/js/map/overlays/LabelOverlay.js diff --git a/static/js/overlays/LcdOverlay.js b/static/js/map/overlays/LcdOverlay.js similarity index 100% rename from static/js/overlays/LcdOverlay.js rename to static/js/map/overlays/LcdOverlay.js diff --git a/static/js/overlays/LocatorOverlay.js b/static/js/map/overlays/LocatorOverlay.js similarity index 100% rename from static/js/overlays/LocatorOverlay.js rename to static/js/map/overlays/LocatorOverlay.js diff --git a/static/js/overlays/LuacontrollerOverlay.js b/static/js/map/overlays/LuacontrollerOverlay.js similarity index 100% rename from static/js/overlays/LuacontrollerOverlay.js rename to static/js/map/overlays/LuacontrollerOverlay.js diff --git a/static/js/overlays/MinecartOverlay.js b/static/js/map/overlays/MinecartOverlay.js similarity index 100% rename from static/js/overlays/MinecartOverlay.js rename to static/js/map/overlays/MinecartOverlay.js diff --git a/static/js/overlays/MissionOverlay.js b/static/js/map/overlays/MissionOverlay.js similarity index 100% rename from static/js/overlays/MissionOverlay.js rename to static/js/map/overlays/MissionOverlay.js diff --git a/static/js/overlays/PlayerOverlay.js b/static/js/map/overlays/PlayerOverlay.js similarity index 100% rename from static/js/overlays/PlayerOverlay.js rename to static/js/map/overlays/PlayerOverlay.js diff --git a/static/js/overlays/PoiOverlay.js b/static/js/map/overlays/PoiOverlay.js similarity index 100% rename from static/js/overlays/PoiOverlay.js rename to static/js/map/overlays/PoiOverlay.js diff --git a/static/js/overlays/PrivProtectorOverlay.js b/static/js/map/overlays/PrivProtectorOverlay.js similarity index 100% rename from static/js/overlays/PrivProtectorOverlay.js rename to static/js/map/overlays/PrivProtectorOverlay.js diff --git a/static/js/overlays/ProtectorOverlay.js b/static/js/map/overlays/ProtectorOverlay.js similarity index 100% rename from static/js/overlays/ProtectorOverlay.js rename to static/js/map/overlays/ProtectorOverlay.js diff --git a/static/js/overlays/ShopOverlay.js b/static/js/map/overlays/ShopOverlay.js similarity index 100% rename from static/js/overlays/ShopOverlay.js rename to static/js/map/overlays/ShopOverlay.js diff --git a/static/js/overlays/TechnicAnchorOverlay.js b/static/js/map/overlays/TechnicAnchorOverlay.js similarity index 100% rename from static/js/overlays/TechnicAnchorOverlay.js rename to static/js/map/overlays/TechnicAnchorOverlay.js diff --git a/static/js/overlays/TechnicQuarryOverlay.js b/static/js/map/overlays/TechnicQuarryOverlay.js similarity index 100% rename from static/js/overlays/TechnicQuarryOverlay.js rename to static/js/map/overlays/TechnicQuarryOverlay.js diff --git a/static/js/overlays/TechnicSwitchOverlay.js b/static/js/map/overlays/TechnicSwitchOverlay.js similarity index 100% rename from static/js/overlays/TechnicSwitchOverlay.js rename to static/js/map/overlays/TechnicSwitchOverlay.js diff --git a/static/js/overlays/TrainOverlay.js b/static/js/map/overlays/TrainOverlay.js similarity index 100% rename from static/js/overlays/TrainOverlay.js rename to static/js/map/overlays/TrainOverlay.js diff --git a/static/js/overlays/TrainlineOverlay.js b/static/js/map/overlays/TrainlineOverlay.js similarity index 100% rename from static/js/overlays/TrainlineOverlay.js rename to static/js/map/overlays/TrainlineOverlay.js diff --git a/static/js/overlays/TrainsignalOverlay.js b/static/js/map/overlays/TrainsignalOverlay.js similarity index 100% rename from static/js/overlays/TrainsignalOverlay.js rename to static/js/map/overlays/TrainsignalOverlay.js diff --git a/static/js/overlays/TravelnetOverlay.js b/static/js/map/overlays/TravelnetOverlay.js similarity index 100% rename from static/js/overlays/TravelnetOverlay.js rename to static/js/map/overlays/TravelnetOverlay.js diff --git a/static/js/overlays/XPProtectorOverlay.js b/static/js/map/overlays/XPProtectorOverlay.js similarity index 100% rename from static/js/overlays/XPProtectorOverlay.js rename to static/js/map/overlays/XPProtectorOverlay.js diff --git a/static/js/routes.js b/static/js/routes.js index 376e4b1..bf2128e 100644 --- a/static/js/routes.js +++ b/static/js/routes.js @@ -1,5 +1,5 @@ -import Map from './components/Map.js'; +import MapComponent from './map/MapComponent.js'; var Home = { view: function() { @@ -9,5 +9,5 @@ var Home = { export default { "/": Home, - "/map/:layerId/:zoom/:lon/:lat": Map + "/map/:layerId/:zoom/:lon/:lat": MapComponent } From 0368c398a995cf5e19e0b6124e41c94eb5aac9af Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Fri, 30 Aug 2019 10:59:55 +0200 Subject: [PATCH 03/12] working compat routes --- static/js/compat.js | 15 +++++ static/js/main.js | 9 ++- static/js/map/Hashroute.js | 59 ------------------- static/js/map/MapComponent.js | 29 ++++++--- .../js/map/overlays/AbstractGeoJsonOverlay.js | 4 +- static/js/map/overlays/AbstractIconOverlay.js | 4 +- static/js/search/SearchResult.js | 2 +- 7 files changed, 45 insertions(+), 77 deletions(-) create mode 100644 static/js/compat.js delete mode 100644 static/js/map/Hashroute.js diff --git a/static/js/compat.js b/static/js/compat.js new file mode 100644 index 0000000..00bf0ea --- /dev/null +++ b/static/js/compat.js @@ -0,0 +1,15 @@ + +export function hashCompat(){ + + if (window.location.hash) { + let match = window.location.hash.match(/^#\/(\d*)\/(\d*)\/(\d*)$/m); + if (match) { + window.location.hash = `#!/map/0/${match[1]}/${match[2]}/${match[3]}` + } + + match = window.location.hash.match(/^#\/(\d*)\/(\d*)\/(\d*)\/(\d*)$/m); + if (match) { + window.location.hash = `#!/map/${match[1]}/${match[2]}/${match[3]}/${match[4]}` + } + } +} diff --git a/static/js/main.js b/static/js/main.js index 378adf1..c7f88a0 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1,16 +1,15 @@ import { getConfig } from './api.js'; -//import { setup } from './map.js'; import routes from './routes.js'; import wsChannel from './WebSocketChannel.js'; import config from './config.js'; +import { hashCompat } from './compat.js'; -//TODO: migrate #/layer/zoom/lat/lon to #!/map/... -//TODO: migrate #/zoom/lat/lon to #!/map/... +// hash route compat +hashCompat(); getConfig().then(cfg => { config.set(cfg); wsChannel.connect(); - m.route(document.getElementById("app"), "/map/0/13/0/0", routes); - //setup(cfg); + m.route(document.getElementById("app"), "/map/0/12/0/0", routes); }); diff --git a/static/js/map/Hashroute.js b/static/js/map/Hashroute.js deleted file mode 100644 index f3b3777..0000000 --- a/static/js/map/Hashroute.js +++ /dev/null @@ -1,59 +0,0 @@ - -export default { - - setup: function(map, layerMgr){ - function updateHash(){ - var center = map.getCenter(); - window.location.hash = - layerMgr.getCurrentLayer().id + "/" + - center.lng + "/" + center.lat + "/" + map.getZoom(); - } - - map.on('zoomend', updateHash); - map.on('moveend', updateHash); - map.on('baselayerchange', updateHash); - updateHash(); - }, - - getLayerId: function(){ - var hashParts = window.location.hash.substring(1).split("/"); - if (hashParts.length == 4){ - //new format - return +hashParts[0]; - - } - - return 0; - }, - - getZoom: function(){ - var hashParts = window.location.hash.substring(1).split("/"); - if (hashParts.length == 3){ - //old format - return +hashParts[2]; - - } else if (hashParts.length == 4){ - //new format - return +hashParts[3]; - - } - - return 11; - }, - - getCenter: function(){ - var hashParts = window.location.hash.substring(1).split("/"); - if (hashParts.length == 3){ - //old format - return [+hashParts[1], +hashParts[0]]; - - } else if (hashParts.length == 4){ - //new format - return [+hashParts[2], +hashParts[1]]; - - } - - return [0, 0]; - } - -}; diff --git a/static/js/map/MapComponent.js b/static/js/map/MapComponent.js index 4458d54..7b3f8e1 100644 --- a/static/js/map/MapComponent.js +++ b/static/js/map/MapComponent.js @@ -1,4 +1,4 @@ -import wsChannel from './WebSocketChannel.js'; +import wsChannel from '../WebSocketChannel.js'; import SimpleCRS from './SimpleCRS.js'; import CoordinatesDisplay from './CoordinatesDisplay.js'; import WorldInfoDisplay from './WorldInfoDisplay.js'; @@ -13,7 +13,6 @@ export default { }, oncreate(vnode){ - console.log("oncreate", vnode); const cfg = config.get(); var map = L.map(vnode.dom, { @@ -45,22 +44,36 @@ export default { //layer control L.control.layers(layerManager.layerObjects, overlays, { position: "topright" }).addTo(map); + function updateHash(){ + const center = map.getCenter(); + const layerId = layerManager.getCurrentLayer().id; + + m.route.set(`/map/${layerId}/${map.getZoom()}/${center.lng}/${center.lat}`); + } + + map.on('zoomend', updateHash); + map.on('moveend', updateHash); + map.on('baselayerchange', updateHash); + //TODO: overlay persistence (state, localstorage) - //TODO: update hash }, onbeforeupdate(newVnode, oldVnode) { - return false; + const center = newVnode.state.map.getCenter(); + const newAattrs = newVnode.attrs; + + return newAattrs.layerId != layerManager.getCurrentLayer().id || + newAattrs.zoom != newVnode.state.map.getZoom() || + Math.abs(newAattrs.lat - center.lat) > 0.1 || + Math.abs(newAattrs.lat - center.lat) > 0.1; }, onupdate(vnode){ - console.log("onupdate", vnode); - - //TODO: compare and update center,zoom,layer + layerManager.switchLayer(+vnode.attrs.layerId); + vnode.state.map.setView([+vnode.attrs.lat, +vnode.attrs.lon], +vnode.attrs.zoom); }, onremove(vnode){ - console.log("onremove", vnode); vnode.state.map.remove(); } } diff --git a/static/js/map/overlays/AbstractGeoJsonOverlay.js b/static/js/map/overlays/AbstractGeoJsonOverlay.js index 1827d32..2be845a 100644 --- a/static/js/map/overlays/AbstractGeoJsonOverlay.js +++ b/static/js/map/overlays/AbstractGeoJsonOverlay.js @@ -1,5 +1,5 @@ -import debounce from '../util/debounce.js'; -import { getMapObjects } from '../api.js'; +import debounce from '../../util/debounce.js'; +import { getMapObjects } from '../../api.js'; export default L.LayerGroup.extend({ initialize: function(wsChannel, layerMgr, type) { diff --git a/static/js/map/overlays/AbstractIconOverlay.js b/static/js/map/overlays/AbstractIconOverlay.js index dc5aa12..560486b 100644 --- a/static/js/map/overlays/AbstractIconOverlay.js +++ b/static/js/map/overlays/AbstractIconOverlay.js @@ -1,5 +1,5 @@ -import debounce from '../util/debounce.js'; -import { getMapObjects } from '../api.js'; +import debounce from '../../util/debounce.js'; +import { getMapObjects } from '../../api.js'; export default L.LayerGroup.extend({ initialize: function(wsChannel, layerMgr, type, icon) { diff --git a/static/js/search/SearchResult.js b/static/js/search/SearchResult.js index 88de72e..8364668 100644 --- a/static/js/search/SearchResult.js +++ b/static/js/search/SearchResult.js @@ -1,5 +1,5 @@ import SearchStore from './SearchStore.js'; -import layerMgr from '../LayerManager.js'; +import layerMgr from '../map/LayerManager.js'; export default { view: function(vnode){ From a2b042c98c6be500e4d374bd038f823be444b2e5 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Fri, 30 Aug 2019 11:21:34 +0200 Subject: [PATCH 04/12] persistent overlays per client --- static/js/map/CustomOverlay.js | 40 ++++++++++++++++++++++++++++++++++ static/js/map/MapComponent.js | 4 ++-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 static/js/map/CustomOverlay.js diff --git a/static/js/map/CustomOverlay.js b/static/js/map/CustomOverlay.js new file mode 100644 index 0000000..dfe96f9 --- /dev/null +++ b/static/js/map/CustomOverlay.js @@ -0,0 +1,40 @@ + +var customOverlays = {}; + +try { + customOverlays = JSON.parse(localStorage["mapserver-customOverlays"]) +} catch (e){} + +function save(){ + localStorage["mapserver-customOverlays"] = JSON.stringify(customOverlays); +} + +export default function(map, overlays){ + + Object.keys(customOverlays) + .filter(name => overlays[name]) + .forEach(name => { + const layer = overlays[name]; + + if (customOverlays[name] && !map.hasLayer(layer)){ + //Add + map.addLayer(layer); + } + + if (!customOverlays[name] && map.hasLayer(layer)){ + //Remove + map.removeLayer(layer); + } + }); + + map.on('overlayadd', e => { + customOverlays[e.name] = true; + save(); + }); + + map.on('overlayremove', e => { + customOverlays[e.name] = false; + save(); + }); + +} diff --git a/static/js/map/MapComponent.js b/static/js/map/MapComponent.js index 7b3f8e1..46c1c75 100644 --- a/static/js/map/MapComponent.js +++ b/static/js/map/MapComponent.js @@ -4,6 +4,7 @@ import CoordinatesDisplay from './CoordinatesDisplay.js'; import WorldInfoDisplay from './WorldInfoDisplay.js'; import SearchControl from './SearchControl.js'; import Overlaysetup from './Overlaysetup.js'; +import CustomOverlay from './CustomOverlay.js'; import layerManager from './LayerManager.js'; import config from '../config.js'; @@ -33,6 +34,7 @@ export default { //All overlays Overlaysetup(cfg, map, overlays, wsChannel, layerManager); + CustomOverlay(map, overlays); new CoordinatesDisplay({ position: 'bottomleft' }).addTo(map); new WorldInfoDisplay(wsChannel, { position: 'bottomright' }).addTo(map); @@ -54,8 +56,6 @@ export default { map.on('zoomend', updateHash); map.on('moveend', updateHash); map.on('baselayerchange', updateHash); - - //TODO: overlay persistence (state, localstorage) }, onbeforeupdate(newVnode, oldVnode) { From 03757becfde658d74c2e0c891ca181ddd19eed71 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Fri, 30 Aug 2019 14:30:12 +0200 Subject: [PATCH 05/12] search route / separated map factory and component --- static/css/custom.css | 9 --- static/js/components/Map.js | 52 ++++++++++++++ static/js/components/Search.js | 6 ++ static/js/components/SearchInput.js | 38 +++++++++++ static/js/map/MapComponent.js | 79 ---------------------- static/js/map/MapFactory.js | 45 ++++++++++++ static/js/map/SearchControl.js | 7 +- static/js/{search => old}/SearchInput.js | 0 static/js/{search => old}/SearchMenu.js | 0 static/js/{search => old}/SearchResult.js | 0 static/js/{search => old}/SearchService.js | 0 static/js/{search => old}/SearchStore.js | 0 static/js/routes.js | 6 +- 13 files changed, 146 insertions(+), 96 deletions(-) create mode 100644 static/js/components/Map.js create mode 100644 static/js/components/Search.js create mode 100644 static/js/components/SearchInput.js delete mode 100644 static/js/map/MapComponent.js create mode 100644 static/js/map/MapFactory.js rename static/js/{search => old}/SearchInput.js (100%) rename static/js/{search => old}/SearchMenu.js (100%) rename static/js/{search => old}/SearchResult.js (100%) rename static/js/{search => old}/SearchService.js (100%) rename static/js/{search => old}/SearchStore.js (100%) diff --git a/static/css/custom.css b/static/css/custom.css index 0fa2fcc..b719fac 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -20,15 +20,6 @@ body { padding: 5px; } -#search-menu { - position: absolute; - top: 5%; - bottom: 5%; - left: 5%; - right: 5%; - z-index: 99999; -} - .mapserver-label-icon { margin-left: -100px !important; margin-top: -100px !important; diff --git a/static/js/components/Map.js b/static/js/components/Map.js new file mode 100644 index 0000000..f175ec4 --- /dev/null +++ b/static/js/components/Map.js @@ -0,0 +1,52 @@ +import wsChannel from '../WebSocketChannel.js'; +import layerManager from '../map/LayerManager.js'; +import { createMap } from '../map/MapFactory.js'; + +export default { + view(vnode){ + return m("div", { class: "full-screen" }); + }, + + oncreate(vnode){ + + const map = createMap( + vnode.dom, + +vnode.attrs.layerId, + +vnode.attrs.zoom, + +vnode.attrs.lat, + +vnode.attrs.lon + ); + + vnode.state.map = map; + + function updateHash(){ + const center = map.getCenter(); + const layerId = layerManager.getCurrentLayer().id; + + m.route.set(`/map/${layerId}/${map.getZoom()}/${center.lng}/${center.lat}`); + } + + map.on('zoomend', updateHash); + map.on('moveend', updateHash); + map.on('baselayerchange', updateHash); + }, + + onbeforeupdate(newVnode, oldVnode) { + const center = newVnode.state.map.getCenter(); + const newAattrs = newVnode.attrs; + + return newAattrs.layerId != layerManager.getCurrentLayer().id || + newAattrs.zoom != newVnode.state.map.getZoom() || + Math.abs(newAattrs.lat - center.lat) > 0.1 || + Math.abs(newAattrs.lat - center.lat) > 0.1; + }, + + onupdate(vnode){ + layerManager.switchLayer(+vnode.attrs.layerId); + vnode.state.map.setView([+vnode.attrs.lat, +vnode.attrs.lon], +vnode.attrs.zoom); + }, + + onremove(vnode){ + vnode.state.map.remove(); + } +} diff --git a/static/js/components/Search.js b/static/js/components/Search.js new file mode 100644 index 0000000..2448828 --- /dev/null +++ b/static/js/components/Search.js @@ -0,0 +1,6 @@ + +export default { + view(vnode){ + return m("div", vnode.attrs.query) + } +} diff --git a/static/js/components/SearchInput.js b/static/js/components/SearchInput.js new file mode 100644 index 0000000..0f4a320 --- /dev/null +++ b/static/js/components/SearchInput.js @@ -0,0 +1,38 @@ + +const state = { + query: "" +} + +function doSearch(){ + m.route.set(`/search/${state.query}`); +} + +export default { + view: function(){ + + function handleInput(e){ + state.query = e.target.value; + } + + function handleKeyDown(e){ + if (e.keyCode == 13){ + doSearch(); + } + } + + return m("div", { class: "input-group mb-3" }, [ + m("input[type=text]", { + placeholder: "Search", + class: "form-control", + oninput: handleInput, + onkeydown: handleKeyDown, + value: state.query + }), + m("div", { class: "input-group-append", onclick: doSearch }, [ + m("span", { class: "input-group-text" }, [ + m("i", { class: "fa fa-search"}) + ]) + ]) + ]); + } +}; diff --git a/static/js/map/MapComponent.js b/static/js/map/MapComponent.js deleted file mode 100644 index 46c1c75..0000000 --- a/static/js/map/MapComponent.js +++ /dev/null @@ -1,79 +0,0 @@ -import wsChannel from '../WebSocketChannel.js'; -import SimpleCRS from './SimpleCRS.js'; -import CoordinatesDisplay from './CoordinatesDisplay.js'; -import WorldInfoDisplay from './WorldInfoDisplay.js'; -import SearchControl from './SearchControl.js'; -import Overlaysetup from './Overlaysetup.js'; -import CustomOverlay from './CustomOverlay.js'; -import layerManager from './LayerManager.js'; -import config from '../config.js'; - -export default { - view(vnode){ - return m("div", { class: "full-screen" }); - }, - - oncreate(vnode){ - const cfg = config.get(); - - var map = L.map(vnode.dom, { - minZoom: 2, - maxZoom: 12, - center: [+vnode.attrs.lat, +vnode.attrs.lon], - zoom: +vnode.attrs.zoom, - crs: SimpleCRS - }); - - vnode.state.map = map; - - map.attributionControl.addAttribution('Minetest Mapserver'); - - var overlays = {}; - - layerManager.setup(wsChannel, cfg.layers, map, +vnode.attrs.layerId); - - //All overlays - Overlaysetup(cfg, map, overlays, wsChannel, layerManager); - CustomOverlay(map, overlays); - - new CoordinatesDisplay({ position: 'bottomleft' }).addTo(map); - new WorldInfoDisplay(wsChannel, { position: 'bottomright' }).addTo(map); - - if (cfg.enablesearch){ - new SearchControl(wsChannel, { position: 'topright' }).addTo(map); - } - - //layer control - L.control.layers(layerManager.layerObjects, overlays, { position: "topright" }).addTo(map); - - function updateHash(){ - const center = map.getCenter(); - const layerId = layerManager.getCurrentLayer().id; - - m.route.set(`/map/${layerId}/${map.getZoom()}/${center.lng}/${center.lat}`); - } - - map.on('zoomend', updateHash); - map.on('moveend', updateHash); - map.on('baselayerchange', updateHash); - }, - - onbeforeupdate(newVnode, oldVnode) { - const center = newVnode.state.map.getCenter(); - const newAattrs = newVnode.attrs; - - return newAattrs.layerId != layerManager.getCurrentLayer().id || - newAattrs.zoom != newVnode.state.map.getZoom() || - Math.abs(newAattrs.lat - center.lat) > 0.1 || - Math.abs(newAattrs.lat - center.lat) > 0.1; - }, - - onupdate(vnode){ - layerManager.switchLayer(+vnode.attrs.layerId); - vnode.state.map.setView([+vnode.attrs.lat, +vnode.attrs.lon], +vnode.attrs.zoom); - }, - - onremove(vnode){ - vnode.state.map.remove(); - } -} diff --git a/static/js/map/MapFactory.js b/static/js/map/MapFactory.js new file mode 100644 index 0000000..c49478f --- /dev/null +++ b/static/js/map/MapFactory.js @@ -0,0 +1,45 @@ +import wsChannel from '../WebSocketChannel.js'; +import SimpleCRS from './SimpleCRS.js'; +import CoordinatesDisplay from './CoordinatesDisplay.js'; +import WorldInfoDisplay from './WorldInfoDisplay.js'; +import SearchControl from './SearchControl.js'; +import Overlaysetup from './Overlaysetup.js'; +import CustomOverlay from './CustomOverlay.js'; +import layerManager from './LayerManager.js'; +import config from '../config.js'; + + +export function createMap(node, layerId, zoom, lat, lon){ + + const cfg = config.get(); + + const map = L.map(node, { + minZoom: 2, + maxZoom: 12, + center: [lat, lon], + zoom: zoom, + crs: SimpleCRS + }); + + map.attributionControl.addAttribution('Minetest Mapserver'); + + var overlays = {}; + + layerManager.setup(wsChannel, cfg.layers, map, layerId); + + //All overlays + Overlaysetup(cfg, map, overlays, wsChannel, layerManager); + CustomOverlay(map, overlays); + + new CoordinatesDisplay({ position: 'bottomleft' }).addTo(map); + new WorldInfoDisplay(wsChannel, { position: 'bottomright' }).addTo(map); + + if (cfg.enablesearch){ + new SearchControl(wsChannel, { position: 'topright' }).addTo(map); + } + + //layer control + L.control.layers(layerManager.layerObjects, overlays, { position: "topright" }).addTo(map); + + return map; +} diff --git a/static/js/map/SearchControl.js b/static/js/map/SearchControl.js index 8aefdf0..701cbf7 100644 --- a/static/js/map/SearchControl.js +++ b/static/js/map/SearchControl.js @@ -1,5 +1,4 @@ -import SearchMenu from '../search/SearchMenu.js'; -import SearchInput from '../search/SearchInput.js'; +import SearchInput from '../components/SearchInput.js'; export default L.Control.extend({ initialize: function(wsChannel, opts) { @@ -9,10 +8,6 @@ export default L.Control.extend({ onAdd: function(map) { var div = L.DomUtil.create('div'); m.mount(div, SearchInput); - m.mount(document.getElementById("search-content"), { - view: () => m(SearchMenu, {map: map}) - }); - return div; } }); diff --git a/static/js/search/SearchInput.js b/static/js/old/SearchInput.js similarity index 100% rename from static/js/search/SearchInput.js rename to static/js/old/SearchInput.js diff --git a/static/js/search/SearchMenu.js b/static/js/old/SearchMenu.js similarity index 100% rename from static/js/search/SearchMenu.js rename to static/js/old/SearchMenu.js diff --git a/static/js/search/SearchResult.js b/static/js/old/SearchResult.js similarity index 100% rename from static/js/search/SearchResult.js rename to static/js/old/SearchResult.js diff --git a/static/js/search/SearchService.js b/static/js/old/SearchService.js similarity index 100% rename from static/js/search/SearchService.js rename to static/js/old/SearchService.js diff --git a/static/js/search/SearchStore.js b/static/js/old/SearchStore.js similarity index 100% rename from static/js/search/SearchStore.js rename to static/js/old/SearchStore.js diff --git a/static/js/routes.js b/static/js/routes.js index bf2128e..6ae3f1a 100644 --- a/static/js/routes.js +++ b/static/js/routes.js @@ -1,5 +1,6 @@ -import MapComponent from './map/MapComponent.js'; +import Map from './components/Map.js'; +import Search from './components/Search.js'; var Home = { view: function() { @@ -9,5 +10,6 @@ var Home = { export default { "/": Home, - "/map/:layerId/:zoom/:lon/:lat": MapComponent + "/map/:layerId/:zoom/:lon/:lat": Map, + "/search/:query": Search } From 539e187475911c3b585ff82ca0d6cc60f7e25724 Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Sun, 1 Sep 2019 11:10:56 +0200 Subject: [PATCH 06/12] unregister on/remove-layer hook on 'unload' --- static/js/map/CustomOverlay.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/static/js/map/CustomOverlay.js b/static/js/map/CustomOverlay.js index dfe96f9..494b577 100644 --- a/static/js/map/CustomOverlay.js +++ b/static/js/map/CustomOverlay.js @@ -9,6 +9,16 @@ function save(){ localStorage["mapserver-customOverlays"] = JSON.stringify(customOverlays); } +function onAddLayer(e){ + customOverlays[e.name] = true; + save(); +} + +function onRemoveLayer(e){ + customOverlays[e.name] = false; + save(); +} + export default function(map, overlays){ Object.keys(customOverlays) @@ -27,14 +37,12 @@ export default function(map, overlays){ } }); - map.on('overlayadd', e => { - customOverlays[e.name] = true; - save(); + map.on('unload', () => { + map.off('overlayadd', onAddLayer); + map.off('overlayremove', onRemoveLayer); }); - map.on('overlayremove', e => { - customOverlays[e.name] = false; - save(); - }); + map.on('overlayadd', onAddLayer); + map.on('overlayremove', onRemoveLayer); } From 7525c9c25f8e44b1dd69cf6fd4ed47f7f646e340 Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Sun, 1 Sep 2019 11:14:11 +0200 Subject: [PATCH 07/12] oncreate hook in search component --- static/js/components/Search.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/static/js/components/Search.js b/static/js/components/Search.js index 2448828..228c02f 100644 --- a/static/js/components/Search.js +++ b/static/js/components/Search.js @@ -1,5 +1,9 @@ export default { + oncreate(vnode){ + console.log("oncreate", vnode); + }, + view(vnode){ return m("div", vnode.attrs.query) } From e98e85ec8a6523523fb02c2b43312f2a91abcadc Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Sun, 1 Sep 2019 11:56:45 +0200 Subject: [PATCH 08/12] search form --- go.mod | 2 +- go.sum | 5 + static/js/components/Search.js | 55 +++++++++- static/js/components/SearchResult.js | 152 +++++++++++++++++++++++++++ static/js/main.js | 3 + static/js/map/LayerManager.js | 9 +- static/js/map/MapFactory.js | 2 +- static/js/old/SearchService.js | 34 ------ 8 files changed, 222 insertions(+), 40 deletions(-) create mode 100644 static/js/components/SearchResult.js diff --git a/go.mod b/go.mod index a051edc..3c01001 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/patrickmn/go-cache v2.1.0+incompatible github.com/prometheus/client_golang v0.9.4 github.com/sirupsen/logrus v1.3.0 - github.com/stretchr/testify v1.2.2 + github.com/stretchr/testify v1.3.0 github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583 golang.org/x/image v0.0.0-20190118043309-183bebdce1b2 // indirect ) diff --git a/go.sum b/go.sum index bb38522..db86b92 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -19,6 +20,7 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= @@ -57,13 +59,16 @@ github.com/prometheus/client_golang v0.9.4/go.mod h1:oCXIBxdI62A4cR6aTRJCgetEjec github.com/prometheus/client_golang v1.1.0 h1:BQ53HtBmfOitExawJ6LokA4x8ov/z0SYYb0+HxJfRI8= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jOqq0gIVUe6Yk0/QMZ640k6NvkxcBf+8= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME= diff --git a/static/js/components/Search.js b/static/js/components/Search.js index 228c02f..83dbd6b 100644 --- a/static/js/components/Search.js +++ b/static/js/components/Search.js @@ -1,10 +1,63 @@ +import SearchResult from './SearchResult.js'; +import { getMapObjects } from '../api.js'; + +const state = { + busy: false, + result: [] +} + +function searchFor(type, key, valuelike){ + return getMapObjects({ + pos1: { x:-2048, y:-2048, z:-2048 }, + pos2: { x:2048, y:2048, z:2048 }, + type: type, + attributelike: { + key: key, + value: "%" + valuelike +"%" + } + }); +} + +function search(query){ + state.result = []; + + var prom_list = [ + searchFor("shop", "out_item", query), + searchFor("poi", "name", query), + searchFor("train", "station", query), + searchFor("travelnet", "station_name", query), + searchFor("bones", "owner", query), + searchFor("locator", "name", query), + searchFor("label", "text", query), + searchFor("digiterm", "display_text", query), + searchFor("digilinelcd", "text", query) + ]; + + Promise.all(prom_list) + .then(function(results){ + + var arr = []; + results.forEach(function(r) { + arr = arr.concat(r); + }); + + state.result = arr; + state.busy = false; + }); + +} export default { oncreate(vnode){ console.log("oncreate", vnode); + search(vnode.attrs.query); }, view(vnode){ - return m("div", vnode.attrs.query) + if (state.result.length == 0) { + return m("div", vnode.attrs.query); + } else { + return m(SearchResult, { result: state.result }) + } } } diff --git a/static/js/components/SearchResult.js b/static/js/components/SearchResult.js new file mode 100644 index 0000000..2618fca --- /dev/null +++ b/static/js/components/SearchResult.js @@ -0,0 +1,152 @@ +import layerMgr from '../map/LayerManager.js'; + +export default { + view: function(vnode){ + var result = vnode.attrs.result; + + function getLayer(obj){ + var layer = layerMgr.getLayerByY(obj.y); + return layer ? layer.name : ""; + } + + function getPos(obj){ + var text = obj.x + "/" + obj.y + "/" + obj.z; + + return m("span", {class:"badge badge-success"}, text); + } + + var rows = result.map(function(obj){ + + var row_classes = ""; + var description = obj.type; + var type = obj.type; + + // train-line result + if (obj.type == "train"){ + description = [ + m("span", obj.attributes.station), + " ", + m("span", {class:"badge badge-info"}, obj.attributes.line) + ]; + + type = m("i", { class: "fa fa-subway" }); + } + + // travelnet + if (obj.type == "travelnet"){ + description = m("span", obj.attributes.station_name); + type = m("img", { src: "pics/travelnet_inv.png" }); + } + + // bones + if (obj.type == "bones"){ + description = m("span", obj.attributes.owner); + type = m("img", { src: "pics/bones_top.png" }); + } + + // label + if (obj.type == "label"){ + description = m("span", obj.attributes.text); + type = m("img", { src: "pics/mapserver_label.png" }); + } + + // digiterm + if (obj.type == "digiterm"){ + description = m("span", obj.attributes.display_text); + type = m("img", { src: "pics/digiterms_beige_front.png" }); + } + + // digiline lcd + if (obj.type == "digilinelcd"){ + description = m("span", obj.attributes.text); + type = m("img", { src: "pics/lcd_lcd.png" }); + } + + // locator + if (obj.type == "locator"){ + description = m("span", obj.attributes.name); + + var img = "pics/locator_beacon_level1.png"; + + if (obj.attributes.level == "2") + img = "pics/locator_beacon_level2.png"; + else if (obj.attributes.level == "3") + img = "pics/locator_beacon_level3.png"; + + type = m("img", { src: img }); + } + + // poi marker + if (obj.type == "poi"){ + description = m("span", obj.attributes.name); + + var color = obj.attributes.color || "blue"; + var icon = obj.attributes.icon || "home"; + + type = m("div", { style: "position: relative", class: "awesome-marker awesome-marker-icon-" + color }, [ + m("i", { class: "fa fa-" + icon }) + ]); + } + + //shop + if (obj.type == "shop") { + if (obj.attributes.stock == 0){ + row_classes += "table-warning"; + type = m("img", { src: "pics/shop_empty.png" }); + } else { + type = m("img", { src: "pics/shop.png" }); + } + + description = m("span", [ + "Shop, trading ", + m("span", {class:"badge badge-primary"}, + obj.attributes.out_count, + "x", + m("i", {class:"fa fa-cart-arrow-down"}) + ), + m("span", {class:"badge badge-info"}, obj.attributes.out_item), + " for ", + m("span", {class:"badge badge-primary"}, + obj.attributes.in_count, + "x", + m("i", {class:"fa fa-money-bill"}) + ), + m("span", {class:"badge badge-info"}, obj.attributes.in_item), + " Stock: ", + m("span", {class:"badge badge-info"}, obj.attributes.stock) + ]); + } + + function onclick(){ + var layer = layerMgr.getLayerByY(obj.y); + m.route.set(`/map/${layer.id}/${12}/${obj.x}/${obj.z}`); + } + + return m("tr", {"class": row_classes}, [ + m("td", type), + m("td", obj.attributes.owner), + m("td", getLayer(obj)), + m("td", getPos(obj)), + m("td", description), + m("button[type=button]", {class: "btn btn-secondary", onclick: onclick }, [ + "Goto ", + m("i", { class: "fas fa-play" }) + ]) + ]); + }); + + return m("table", {class:"table table-striped"}, [ + m("thead", [ + m("tr", [ + m("th", "Type"), + m("th", "Owner"), + m("th", "Layer"), + m("th", "Position"), + m("th", "Description"), + m("th", "Action") + ]) + ]), + m("tbody", rows) + ]); + } +}; diff --git a/static/js/main.js b/static/js/main.js index c7f88a0..3835a8f 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -4,11 +4,14 @@ import routes from './routes.js'; import wsChannel from './WebSocketChannel.js'; import config from './config.js'; import { hashCompat } from './compat.js'; +import layerManager from './map/LayerManager.js'; // hash route compat hashCompat(); getConfig().then(cfg => { + + layerManager.setup(cfg.layers); config.set(cfg); wsChannel.connect(); m.route(document.getElementById("app"), "/map/0/12/0/0", routes); diff --git a/static/js/map/LayerManager.js b/static/js/map/LayerManager.js index 6d0d395..7d4e2f4 100644 --- a/static/js/map/LayerManager.js +++ b/static/js/map/LayerManager.js @@ -2,17 +2,20 @@ import RealtimeTileLayer from './RealtimeTileLayer.js'; class LayerManager { - setup(wsChannel, layers, map, currentLayerId){ + setup(layers){ this.listeners = []; - this.currentLayer = layers[0]; this.layers = layers; + this.currentLayer = this.layers[0]; + } + + setupMap(wsChannel, map, currentLayerId){ this.map = map; this.layerObjects = {}; var self = this; //All layers - layers.forEach(function(layer){ + this.layers.forEach(function(layer){ var tileLayer = new RealtimeTileLayer(wsChannel, layer.id, map); self.layerObjects[layer.name] = tileLayer; if (layer.id == currentLayerId){ diff --git a/static/js/map/MapFactory.js b/static/js/map/MapFactory.js index c49478f..789f81c 100644 --- a/static/js/map/MapFactory.js +++ b/static/js/map/MapFactory.js @@ -25,7 +25,7 @@ export function createMap(node, layerId, zoom, lat, lon){ var overlays = {}; - layerManager.setup(wsChannel, cfg.layers, map, layerId); + layerManager.setupMap(wsChannel, map, layerId); //All overlays Overlaysetup(cfg, map, overlays, wsChannel, layerManager); diff --git a/static/js/old/SearchService.js b/static/js/old/SearchService.js index fe521a8..bc19717 100644 --- a/static/js/old/SearchService.js +++ b/static/js/old/SearchService.js @@ -17,41 +17,7 @@ export default { SearchStore.busy = true; - function searchFor(type, key, valuelike){ - return getMapObjects({ - pos1: { x:-2048, y:-2048, z:-2048 }, - pos2: { x:2048, y:2048, z:2048 }, - type: type, - attributelike: { - key: key, - value: "%" + valuelike +"%" - } - }); - } - var prom_list = [ - searchFor("shop", "out_item", SearchStore.query), - searchFor("poi", "name", SearchStore.query), - searchFor("train", "station", SearchStore.query), - searchFor("travelnet", "station_name", SearchStore.query), - searchFor("bones", "owner", SearchStore.query), - searchFor("locator", "name", SearchStore.query), - searchFor("label", "text", SearchStore.query), - searchFor("digiterm", "display_text", SearchStore.query), - searchFor("digilinelcd", "text", SearchStore.query) - ]; - - Promise.all(prom_list) - .then(function(results){ - - var arr = []; - results.forEach(function(r) { - arr = arr.concat(r); - }); - - SearchStore.result = arr; - SearchStore.busy = false; - }); }, From 3bde44da929afaed9d27f2ad49b6e52caacb2ee3 Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Sun, 1 Sep 2019 12:01:33 +0200 Subject: [PATCH 09/12] overflow settings --- static/css/custom.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/static/css/custom.css b/static/css/custom.css index b719fac..108c255 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -1,7 +1,6 @@ body { - height: 100%; + height: 98%; margin: 0; - overflow: hidden; } #app { From b21cda248f687f88b9bd5b6fbc51ffe638f05a2b Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Sun, 1 Sep 2019 12:06:47 +0200 Subject: [PATCH 10/12] jshint + cleanup --- Makefile | 2 +- static/js/compat.js | 4 +- static/js/components/Map.js | 7 +- static/js/components/Search.js | 7 +- static/js/components/SearchInput.js | 2 +- static/js/config.js | 2 +- static/js/map/CustomOverlay.js | 2 +- static/js/map/SearchControl.js | 2 +- static/js/old/SearchInput.js | 35 ------- static/js/old/SearchMenu.js | 36 ------- static/js/old/SearchResult.js | 157 ---------------------------- static/js/old/SearchService.js | 28 ----- static/js/old/SearchStore.js | 7 -- static/js/routes.js | 6 +- 14 files changed, 16 insertions(+), 281 deletions(-) delete mode 100644 static/js/old/SearchInput.js delete mode 100644 static/js/old/SearchMenu.js delete mode 100644 static/js/old/SearchResult.js delete mode 100644 static/js/old/SearchService.js delete mode 100644 static/js/old/SearchStore.js diff --git a/Makefile b/Makefile index d7f2c00..529bf21 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ clean: rm -rf $(OUT_DIR) jshint: - jshint static/js/*.js static/js/util static/js/overlays static/js/search + jshint static/js/*.js static/js/components static/js/map static/js/util $(STATIC_VFS): go generate diff --git a/static/js/compat.js b/static/js/compat.js index 00bf0ea..ad4c44b 100644 --- a/static/js/compat.js +++ b/static/js/compat.js @@ -4,12 +4,12 @@ export function hashCompat(){ if (window.location.hash) { let match = window.location.hash.match(/^#\/(\d*)\/(\d*)\/(\d*)$/m); if (match) { - window.location.hash = `#!/map/0/${match[1]}/${match[2]}/${match[3]}` + window.location.hash = `#!/map/0/${match[1]}/${match[2]}/${match[3]}`; } match = window.location.hash.match(/^#\/(\d*)\/(\d*)\/(\d*)\/(\d*)$/m); if (match) { - window.location.hash = `#!/map/${match[1]}/${match[2]}/${match[3]}/${match[4]}` + window.location.hash = `#!/map/${match[1]}/${match[2]}/${match[3]}/${match[4]}`; } } } diff --git a/static/js/components/Map.js b/static/js/components/Map.js index f175ec4..6329b0c 100644 --- a/static/js/components/Map.js +++ b/static/js/components/Map.js @@ -1,9 +1,8 @@ -import wsChannel from '../WebSocketChannel.js'; import layerManager from '../map/LayerManager.js'; import { createMap } from '../map/MapFactory.js'; export default { - view(vnode){ + view(){ return m("div", { class: "full-screen" }); }, @@ -31,7 +30,7 @@ export default { map.on('baselayerchange', updateHash); }, - onbeforeupdate(newVnode, oldVnode) { + onbeforeupdate(newVnode) { const center = newVnode.state.map.getCenter(); const newAattrs = newVnode.attrs; @@ -49,4 +48,4 @@ export default { onremove(vnode){ vnode.state.map.remove(); } -} +}; diff --git a/static/js/components/Search.js b/static/js/components/Search.js index 83dbd6b..668db86 100644 --- a/static/js/components/Search.js +++ b/static/js/components/Search.js @@ -4,7 +4,7 @@ import { getMapObjects } from '../api.js'; const state = { busy: false, result: [] -} +}; function searchFor(type, key, valuelike){ return getMapObjects({ @@ -49,7 +49,6 @@ function search(query){ export default { oncreate(vnode){ - console.log("oncreate", vnode); search(vnode.attrs.query); }, @@ -57,7 +56,7 @@ export default { if (state.result.length == 0) { return m("div", vnode.attrs.query); } else { - return m(SearchResult, { result: state.result }) + return m(SearchResult, { result: state.result }); } } -} +}; diff --git a/static/js/components/SearchInput.js b/static/js/components/SearchInput.js index 0f4a320..be43df3 100644 --- a/static/js/components/SearchInput.js +++ b/static/js/components/SearchInput.js @@ -1,7 +1,7 @@ const state = { query: "" -} +}; function doSearch(){ m.route.set(`/search/${state.query}`); diff --git a/static/js/config.js b/static/js/config.js index 16cc3d5..b348712 100644 --- a/static/js/config.js +++ b/static/js/config.js @@ -9,4 +9,4 @@ export default { set(cfg){ config = cfg; } -} +}; diff --git a/static/js/map/CustomOverlay.js b/static/js/map/CustomOverlay.js index 494b577..b59a95f 100644 --- a/static/js/map/CustomOverlay.js +++ b/static/js/map/CustomOverlay.js @@ -2,7 +2,7 @@ var customOverlays = {}; try { - customOverlays = JSON.parse(localStorage["mapserver-customOverlays"]) + customOverlays = JSON.parse(localStorage["mapserver-customOverlays"]); } catch (e){} function save(){ diff --git a/static/js/map/SearchControl.js b/static/js/map/SearchControl.js index 701cbf7..34a5fcf 100644 --- a/static/js/map/SearchControl.js +++ b/static/js/map/SearchControl.js @@ -5,7 +5,7 @@ export default L.Control.extend({ L.Control.prototype.initialize.call(this, opts); }, - onAdd: function(map) { + onAdd: function() { var div = L.DomUtil.create('div'); m.mount(div, SearchInput); return div; diff --git a/static/js/old/SearchInput.js b/static/js/old/SearchInput.js deleted file mode 100644 index b584f03..0000000 --- a/static/js/old/SearchInput.js +++ /dev/null @@ -1,35 +0,0 @@ -import SearchStore from './SearchStore.js'; -import SearchService from './SearchService.js'; - -export default { - view: function(){ - function handleInput(e){ - SearchStore.query = e.target.value; - } - - function handleKeyDown(e){ - if (e.keyCode == 13){ - SearchService.search(); - } - } - - function handleDoSearch(){ - SearchService.search(); - } - - return m("div", { class: "input-group mb-3" }, [ - m("input[type=text]", { - placeholder: "Search", - class: "form-control", - oninput: handleInput, - onkeydown: handleKeyDown, - value: SearchStore.query - }), - m("div", { class: "input-group-append", onclick: handleDoSearch }, [ - m("span", { class: "input-group-text" }, [ - m("i", { class: "fa fa-search"}) - ]) - ]) - ]); - } -}; diff --git a/static/js/old/SearchMenu.js b/static/js/old/SearchMenu.js deleted file mode 100644 index 66dcc21..0000000 --- a/static/js/old/SearchMenu.js +++ /dev/null @@ -1,36 +0,0 @@ - -import SearchService from './SearchService.js'; -import SearchStore from './SearchStore.js'; -import SearchResult from './SearchResult.js'; - -export default { - view: function(vnode){ - - var style = {}; - - if (!SearchStore.show) { - style.display = "none"; - } - - function close(){ - SearchService.clear(); - } - - function getContent(){ - if (SearchStore.busy){ - return m("div", m("i", { class: "fa fa-spinner"})); - } else { - return m(SearchResult, { map: vnode.attrs.map }); - } - } - - return m("div", { class: "card", id: "search-menu", style: style }, [ - m("div", { class: "card-header" }, [ - m("i", { class: "fa fa-search"}), - "Search", - m("i", { class: "fa fa-times float-right", onclick: close }), - ]), - m("div", { class: "card-body", style: {overflow: "auto"} }, getContent()) - ]); - } -}; diff --git a/static/js/old/SearchResult.js b/static/js/old/SearchResult.js deleted file mode 100644 index 8364668..0000000 --- a/static/js/old/SearchResult.js +++ /dev/null @@ -1,157 +0,0 @@ -import SearchStore from './SearchStore.js'; -import layerMgr from '../map/LayerManager.js'; - -export default { - view: function(vnode){ - var map = vnode.attrs.map; - - function getLayer(obj){ - var layer = layerMgr.getLayerByY(obj.y); - return layer ? layer.name : ""; - } - - function getPos(obj){ - var text = obj.x + "/" + obj.y + "/" + obj.z; - - return m("span", {class:"badge badge-success"}, text); - } - - var rows = SearchStore.result.map(function(obj){ - - var row_classes = ""; - var description = obj.type; - var type = obj.type; - - // train-line result - if (obj.type == "train"){ - description = [ - m("span", obj.attributes.station), - " ", - m("span", {class:"badge badge-info"}, obj.attributes.line) - ]; - - type = m("i", { class: "fa fa-subway" }); - } - - // travelnet - if (obj.type == "travelnet"){ - description = m("span", obj.attributes.station_name); - type = m("img", { src: "pics/travelnet_inv.png" }); - } - - // bones - if (obj.type == "bones"){ - description = m("span", obj.attributes.owner); - type = m("img", { src: "pics/bones_top.png" }); - } - - // label - if (obj.type == "label"){ - description = m("span", obj.attributes.text); - type = m("img", { src: "pics/mapserver_label.png" }); - } - - // digiterm - if (obj.type == "digiterm"){ - description = m("span", obj.attributes.display_text); - type = m("img", { src: "pics/digiterms_beige_front.png" }); - } - - // digiline lcd - if (obj.type == "digilinelcd"){ - description = m("span", obj.attributes.text); - type = m("img", { src: "pics/lcd_lcd.png" }); - } - - // locator - if (obj.type == "locator"){ - description = m("span", obj.attributes.name); - - var img = "pics/locator_beacon_level1.png"; - - if (obj.attributes.level == "2") - img = "pics/locator_beacon_level2.png"; - else if (obj.attributes.level == "3") - img = "pics/locator_beacon_level3.png"; - - type = m("img", { src: img }); - } - - // poi marker - if (obj.type == "poi"){ - description = m("span", obj.attributes.name); - - var color = obj.attributes.color || "blue"; - var icon = obj.attributes.icon || "home"; - - type = m("div", { style: "position: relative", class: "awesome-marker awesome-marker-icon-" + color }, [ - m("i", { class: "fa fa-" + icon }) - ]); - } - - //shop - if (obj.type == "shop") { - if (obj.attributes.stock == 0){ - row_classes += "table-warning"; - type = m("img", { src: "pics/shop_empty.png" }); - } else { - type = m("img", { src: "pics/shop.png" }); - } - - description = m("span", [ - "Shop, trading ", - m("span", {class:"badge badge-primary"}, - obj.attributes.out_count, - "x", - m("i", {class:"fa fa-cart-arrow-down"}) - ), - m("span", {class:"badge badge-info"}, obj.attributes.out_item), - " for ", - m("span", {class:"badge badge-primary"}, - obj.attributes.in_count, - "x", - m("i", {class:"fa fa-money-bill"}) - ), - m("span", {class:"badge badge-info"}, obj.attributes.in_item), - " Stock: ", - m("span", {class:"badge badge-info"}, obj.attributes.stock) - ]); - } - - function onclick(){ - var layer = layerMgr.getLayerByY(obj.y); - - layerMgr.switchLayer(layer.id); - - map.setView([obj.z, obj.x], 12); - SearchStore.show = false; - } - - return m("tr", {"class": row_classes}, [ - m("td", type), - m("td", obj.attributes.owner), - m("td", getLayer(obj)), - m("td", getPos(obj)), - m("td", description), - m("button[type=button]", {class: "btn btn-secondary", onclick: onclick }, [ - "Goto ", - m("i", { class: "fas fa-play" }) - ]) - ]); - }); - - return m("table", {class:"table table-striped"}, [ - m("thead", [ - m("tr", [ - m("th", "Type"), - m("th", "Owner"), - m("th", "Layer"), - m("th", "Position"), - m("th", "Description"), - m("th", "Action") - ]) - ]), - m("tbody", rows) - ]); - } -}; diff --git a/static/js/old/SearchService.js b/static/js/old/SearchService.js deleted file mode 100644 index bc19717..0000000 --- a/static/js/old/SearchService.js +++ /dev/null @@ -1,28 +0,0 @@ -import SearchStore from './SearchStore.js'; -import { getMapObjects } from '../api.js'; - -export default { - - search: function(){ - SearchStore.show = true; - this.fetchData(); - }, - - fetchData: function(){ - SearchStore.result = []; - - if (!SearchStore.query){ - return; - } - - SearchStore.busy = true; - - - - }, - - clear: function(){ - SearchStore.result = []; - SearchStore.show = false; - } -}; diff --git a/static/js/old/SearchStore.js b/static/js/old/SearchStore.js deleted file mode 100644 index a154484..0000000 --- a/static/js/old/SearchStore.js +++ /dev/null @@ -1,7 +0,0 @@ - -export default { - query: "", - show: false, - busy: false, - result: [] -}; diff --git a/static/js/routes.js b/static/js/routes.js index 6ae3f1a..b715183 100644 --- a/static/js/routes.js +++ b/static/js/routes.js @@ -4,12 +4,12 @@ import Search from './components/Search.js'; var Home = { view: function() { - return "Home" + return "Home"; } -} +}; export default { "/": Home, "/map/:layerId/:zoom/:lon/:lat": Map, "/search/:query": Search -} +}; From c1421c9daf8124a96289174b36bc39ab8cd9c2d8 Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Sun, 1 Sep 2019 12:09:21 +0200 Subject: [PATCH 11/12] deps --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index b868d56..03377a8 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,8 @@ require ( github.com/mjibson/esc v0.1.0 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible github.com/prometheus/client_golang v0.9.4 - github.com/stretchr/testify v1.3.0 github.com/sirupsen/logrus v1.4.2 + github.com/stretchr/testify v1.3.0 github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583 golang.org/x/image v0.0.0-20190118043309-183bebdce1b2 // indirect ) From 16fb3bf92f8d67294357fd2dca53ee7ab65c1f62 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2019 10:11:12 +0000 Subject: [PATCH 12/12] Bump github.com/stretchr/testify from 1.2.2 to 1.4.0 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.2.2 to 1.4.0. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.2.2...v1.4.0) Signed-off-by: dependabot-preview[bot] --- go.mod | 2 +- go.sum | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 03377a8..3a87658 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/patrickmn/go-cache v2.1.0+incompatible github.com/prometheus/client_golang v0.9.4 github.com/sirupsen/logrus v1.4.2 - github.com/stretchr/testify v1.3.0 + github.com/stretchr/testify v1.4.0 github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583 golang.org/x/image v0.0.0-20190118043309-183bebdce1b2 // indirect ) diff --git a/go.sum b/go.sum index aa06331..27b948d 100644 --- a/go.sum +++ b/go.sum @@ -76,10 +76,13 @@ github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583 h1:SZPG5w7Qxq7bMcMVl6e3Ht2X7f+AAGQdzjkbyOnNNZ8= github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I= @@ -103,3 +106,5 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=