Commit 646cc338 authored by Reko Meriö's avatar Reko Meriö

Merge remote-tracking branch 'origin/dev_g2700_2' into dev_reko

parents 2f3f3a7f eb07681c
This diff is collapsed.
......@@ -30,6 +30,7 @@
"vue-pose": "^0.5.0",
"vue-router": "^3.0.2",
"vuetify": "^1.5.7",
"vuex": "^3.1.0"
"vuex": "^3.1.0",
"vuex-persist": "^2.0.0"
}
}
This diff is collapsed.
......@@ -13,9 +13,11 @@ import VueRouter from 'vue-router'
import axios from 'axios';
import Vuex from 'vuex';
import Vuetify from 'vuetify'
import VuexPersist from 'vuex-persist'
import 'vuetify/dist/vuetify.min.css' // Ensure you are using css-loader
import VueMaterial from 'vue-material'
import StoreData from './store'
import vuexPersist from './store'
Vue.use(VueMaterial);
Vue.use(Vuex);
......@@ -27,6 +29,7 @@ import Main from './components/Main'
import Hello from './components/Hello'
import Home from './components/Home'
import Login from './components/auth/Login'
import Profile from './components/Profile'
Vue.component('example-component', require('./components/ExampleComponent.vue').default);
......@@ -40,6 +43,8 @@ Vue.component('favorites', require('./components/Favorites.vue').default);
const store = new Vuex.Store(StoreData);
const router = new VueRouter({
mode: 'history',
routes: [
......@@ -52,9 +57,9 @@ const router = new VueRouter({
}
},
{
path: '/hello',
name: 'hello',
component: Hello
path: '/profile',
name: 'profile',
component: Profile
},
{
......@@ -80,6 +85,8 @@ router.beforeEach((to, from, next) => {
}
});
const app = new Vue({
el: '#app',
components: {
......@@ -87,4 +94,5 @@ const app = new Vue({
},
router,
store,
vuexPersist,
});
......@@ -7,7 +7,7 @@
<v-icon>home</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<router-link :to="{ name: 'home' }">Home</router-link>
<router-link :to="{ name: 'home' }">Etusivu</router-link>
</v-list-tile-content>
</v-list-tile>
<v-list-tile @click="">
......@@ -15,7 +15,7 @@
<v-icon>contact_mail</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<router-link :to="{ name: 'hello', params: { value: 'Hello' } }">Hello</router-link>
<router-link :to="{ name: 'profile'}">Profiili</router-link>
</v-list-tile-content>
</v-list-tile>
</v-list>
......
......@@ -7,7 +7,7 @@
<div>Suosikit</div>
</template>
<v-card color="grey lighten-3" >
<v-card-text v-for="(favorite, index) in favorites" :key="index" @click="pushFavorite(favorite)" class="fav"> {{ favorite }} </v-card-text>
<v-card-text v-for="(favorite, index) in favorites2" :key="index" @click="pushFavorite(favorite)" class="fav"> {{ favorite }} </v-card-text>
</v-card>
</v-expansion-panel-content>
</v-expansion-panel>
......@@ -26,6 +26,11 @@
props: {
favorites: Array,
},
computed: {
favorites2(){
return this.$store.getters.favorites
}
},
methods: {
pushFavorite(location){
this.$emit('pushFavorite', location);
......
......@@ -49,7 +49,8 @@
.get('/api/locations')
.then(response => (this.locationData = response.data))
.catch(error => console.log(error))
.finally(() => this.parse())
.finally(() => this.parse());
this.favorites = this.$store.getters.favorites;
},
parse() {
......@@ -90,6 +91,7 @@
this.favorites.push(this.selectedKunta);
else
console.log("Please");
this.$store.commit("mutateFavorites", this.favorites);
},
createGraph() {
// Init arrays to null
......
<template>
<v-layout row wrap>
<v-flex xs12 offset-md4 md4>
<v-card flat color="transparent">
<v-card-title primary-title>
<h4>Profiili</h4>
</v-card-title>
<v-text-field v-model="age" prepend-icon="accessible" name="age" label="Ikä"> </v-text-field>
<v-select v-model="gender" prepend-icon="usb" :items="items" label="Sukupuoli"></v-select>
<v-card-actions>
<v-btn @click="update" primary large block>Päivitä</v-btn>
</v-card-actions>
</v-card>
</v-flex>
</v-layout>
</div>
</div>
</template>
<script>
import {login} from '../helpers/auth';
export default {
name: "profile",
data: () => ({
items: ['Mies', 'Nainen'],
age: '',
gender: ''
}),
methods: {
update() {
this.$store.commit("mutateAge", this.age);
this.$store.commit("mutateGender", this.gender);
},
getData() {
this.age = this.$store.getters.Age;
this.gender = this.$store.getters.Gender;
console.log(this.$store.getters.Age);
console.log(this.$store.getters.Gender);
}
},
mounted: function() {
this.getData();
},
computed: {
authError() {
return this.$store.getters.authError
}
}
}
</script>
<style scoped>
</styler>
\ No newline at end of file
import { getLocalUser } from "./helpers/auth";
//import { vuexLocal } from "./app";
const user = getLocalUser();
import VuexPersist from 'vuex-persist'
const vuexPersist = new VuexPersist({
key : "my-app",
storage: localStorage
})
export default {
state: {
......@@ -7,8 +14,10 @@ export default {
isLoggedIn: !!user,
loading: false,
auth_error: null,
customers: [],
welcomeMessage: 'Wear Right'
favorites: [],
welcomeMessage: 'Wear Right',
user_age: null,
user_gender: null
},
getters: {
welcome(state) {
......@@ -26,9 +35,16 @@ export default {
authError(state) {
return state.auth_error;
},
customers(state) {
return state.customers;
favorites(state) {
return state.favorites;
},
Age(state) {
return state.user_age;
},
Gender(state) {
return state.user_gender;
}
},
mutations: {
login(state) {
......@@ -51,12 +67,22 @@ export default {
localStorage.removeItem("user");
state.isLoggedIn = false;
state.currentUser = null;
}
},
mutateFavorites: function (state, payload) {
state.favorites = payload;
},
mutateAge: function (state, payload) {
state.user_age = payload;
},
mutateGender: function (state, payload) {
state.user_gender = payload;
}
},
actions: {
login(context) {
context.commit("login");
}
}
},
plugins: [vuexPersist.plugin]
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment