From 39bbf9a3d7acb611f43fbe90f6996386d06cb0a9 Mon Sep 17 00:00:00 2001 From: Torben Indorf Date: Mon, 17 Feb 2020 07:11:21 +0100 Subject: [PATCH] added the menu controller --- src/App.vue | 27 ++++++- src/components/HelloWorld.vue | 103 -------------------------- src/components/LeftMenu.component.vue | 61 +++++++++++++++ src/router/index.ts | 6 ++ src/store/global.store.ts | 5 ++ src/store/status.store.ts | 2 - src/views/CreateDataSet.view.vue | 18 +++++ src/views/Home.view.vue | 29 +++++++- src/views/MapOverview.view.vue | 51 ++++++------- 9 files changed, 169 insertions(+), 133 deletions(-) delete mode 100644 src/components/HelloWorld.vue create mode 100644 src/components/LeftMenu.component.vue create mode 100644 src/views/CreateDataSet.view.vue diff --git a/src/App.vue b/src/App.vue index 20bed79..b7f5eee 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,14 +1,35 @@ + + diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue deleted file mode 100644 index 4388e9d..0000000 --- a/src/components/HelloWorld.vue +++ /dev/null @@ -1,103 +0,0 @@ - - - - - diff --git a/src/components/LeftMenu.component.vue b/src/components/LeftMenu.component.vue new file mode 100644 index 0000000..20ded20 --- /dev/null +++ b/src/components/LeftMenu.component.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/src/router/index.ts b/src/router/index.ts index c172095..c424493 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -4,6 +4,7 @@ import LoginView from "@/views/Login.view.vue"; import HomeView from "@/views/Home.view.vue"; import AreaSelectionView from "@/views/AreaSelection.view.vue"; import MapOverviewView from "@/views/MapOverview.view.vue"; +import CreateDataSetView from '@/views/CreateDataSet.view.vue'; import AuthGuard from "@/helpers/AuthGuard"; import Router from 'vue-router'; @@ -43,6 +44,11 @@ export default new IonicVueRouter({ path: 'mapOverview', name: 'mapOverview', component: MapOverviewView + }, + { + path: 'createDataSet', + name: 'createDataSet', + component: CreateDataSetView } ] }, diff --git a/src/store/global.store.ts b/src/store/global.store.ts index cf3f733..fffcf90 100644 --- a/src/store/global.store.ts +++ b/src/store/global.store.ts @@ -2,6 +2,7 @@ import { ActionTree, Module } from 'vuex'; const store = { selectedArea: undefined, + headerTitle: undefined }; const actions: ActionTree = { @@ -10,11 +11,15 @@ const actions: ActionTree = { const mutations = { saveArea: (state: any, area: any) => { state.selectedArea = area; + }, + saveHeaderTitle: (state: any, title: string) => { + state.headerTitle = title; } }; const getters = { selectedArea: (state: any) => state.selectedArea, + headerTitle: (state: any) => state.headerTitle }; const globalStore: Module = { diff --git a/src/store/status.store.ts b/src/store/status.store.ts index 7be70c8..ac225ea 100644 --- a/src/store/status.store.ts +++ b/src/store/status.store.ts @@ -26,8 +26,6 @@ const actions: ActionTree = { Promise => { const response = await statusRepository.getIcons(lastUpdate); - console.log(response); - commit('saveIcons', response); return response; diff --git a/src/views/CreateDataSet.view.vue b/src/views/CreateDataSet.view.vue new file mode 100644 index 0000000..065182e --- /dev/null +++ b/src/views/CreateDataSet.view.vue @@ -0,0 +1,18 @@ + + + + + diff --git a/src/views/Home.view.vue b/src/views/Home.view.vue index 4995c1a..9b3ab40 100644 --- a/src/views/Home.view.vue +++ b/src/views/Home.view.vue @@ -1,18 +1,43 @@ diff --git a/src/views/MapOverview.view.vue b/src/views/MapOverview.view.vue index 052e9d9..12b1f78 100644 --- a/src/views/MapOverview.view.vue +++ b/src/views/MapOverview.view.vue @@ -1,19 +1,16 @@ @@ -51,18 +48,22 @@ public map?: Map | null; public async created() { - this.map = null; + // Small timeout before hot reloading the map. Needed for development! + setTimeout(this.initMap, 1000); + } + + public async initMap() { const allIcons = await this.getAllIcons(); const allStates = await this.getAllStates(); const allNests = await this.getAllNests({ areaId: this.selectedArea.id! }); const response = await this.getAreaGeoJson({ areaId: this.selectedArea.id! }); + this.map = new Map('map').setView( [53.15190499781906, 8.827171325683596], 14 ); - const osm = new TileLayer( 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { @@ -79,13 +80,6 @@ this.map.addLayer(osm); - const ccIcon = icon({ - iconUrl: 'cc-logo-black.png', - iconSize: [35, 35], - iconAnchor: [17, 17], - popupAnchor: [0, -28] - }); - const geo = geoJSON(response, { // Style style: (feature: any) => { @@ -120,15 +114,22 @@ const iconData = icon({ iconUrl: base64icon, iconAnchor: [19, 19], - iconSize: [25, 25], + iconSize: [25, 25] }); new Marker([nest.history[0].location.latitude, nest.history[0].location.longitude], { icon: iconData }).addTo(this.map!); }); } + + public destroyed() { + this.map!.off(); + this.map!.remove(); + } } -