added some map stuff

added a few backend routes
This commit is contained in:
Torben Indorf
2020-02-09 16:00:12 +01:00
parent e2568a1bbe
commit 3770a4111a
20 changed files with 718 additions and 99 deletions
+42
View File
@@ -0,0 +1,42 @@
import { ActionTree, Module } from 'vuex';
import AuthRepository from '@/api/AuthRepository';
import { RepositoryFactory } from '@/api/RepositoryFactory';
import AreaRepository from '@/api/AreaRepository';
import { Area } from '@/models/Area';
const areaRepository: AreaRepository = RepositoryFactory.get('area');
const store = {
geoJson: undefined,
};
const actions: ActionTree<any, any> = {
findAll: async ({ commit }): Promise<Area[]> => {
const response = await areaRepository.findAll();
const areas: Area[] = response.map((areaData: any) =>
new Area(areaData));
return areas;
},
getAreaGeoJson: async ({ commit }, payload: { areaId: string }):
Promise<any> => {
const response = await areaRepository.getGeoJson(payload);
return response;
},
};
const mutations = {
};
const getters = {
geoJson: (state: any) => state.geoJson,
};
const areaStore: Module<any, any> = {
state: store,
actions,
mutations,
getters
};
export default areaStore;
+1 -4
View File
@@ -6,7 +6,6 @@ const authRepository: AuthRepository = RepositoryFactory.get('auth');
const store = {
token: undefined,
isAdmin: false,
lastLogin: undefined
};
@@ -30,14 +29,12 @@ const mutations = {
clearToken: (state: any) => {
state.token = null;
state.lastLogin = null;
},
saveAdminPermission: (state: any, isAdmin: boolean) => state.isAdmin = isAdmin
}
};
const getters = {
token: (state: any) => state.token,
lastLogin: (state: any) => state.lastLogin,
isAdmin: (state: any) => state.isAdmin
};
const authStore: Module<any, any> = {
+27
View File
@@ -0,0 +1,27 @@
import { ActionTree, Module } from 'vuex';
const store = {
selectedArea: undefined,
};
const actions: ActionTree<any, any> = {
};
const mutations = {
saveArea: (state: any, area: any) => {
state.selectedArea = area;
}
};
const getters = {
selectedArea: (state: any) => state.selectedArea,
};
const globalStore: Module<any, any> = {
state: store,
actions,
mutations,
getters
};
export default globalStore;
+14 -9
View File
@@ -1,20 +1,16 @@
import Vue from 'vue';
import Vuex from 'vuex';
import VuexPersistence from 'vuex-persist';
import authStore from "@/store/auth.store";
import authStore from '@/store/auth.store';
import globalStore from '@/store/global.store';
import areaStore from '@/store/area.store';
Vue.use(Vuex);
// set up persistence storage plugin
const vuexPersistence = new VuexPersistence({
key: process.env.VUE_APP_TITLE,
storage: window.localStorage,
reducer: (state: any) => ({
auth: {
token: state.auth.token,
user: state.auth.user
}
}),
filter: (mutation) => ['auth/saveLogin'].includes(mutation.type)
filter: (mutation) => ['auth/saveToken', 'global/saveArea'].includes(mutation.type)
});
export default new Vuex.Store({
@@ -25,6 +21,15 @@ export default new Vuex.Store({
auth: {
namespaced: true,
...authStore
},
global: {
namespaced: true,
...globalStore
},
area: {
namespaced: true,
...areaStore
}
}
},
plugins: [vuexPersistence.plugin]
});