Commit 0a8093fb authored by Reko Meriö's avatar Reko Meriö

Merge

parents 5ad35738 2238e50e
......@@ -29,7 +29,7 @@ class LocationController extends Controller
return $locations;
}
public function pullclothes(Request $request){
/* public function pullclothes(Request $request){
$age = $request->input('age');
$temperature = $request->input('temperature');
if(!empty($request->input('gender'))){
......@@ -41,6 +41,26 @@ class LocationController extends Controller
$vaatteet = DB::select( DB::raw("select vaate.vaate,tyyppi.tyyppi from vaate inner join tyyppi on tyyppi.id=vaate.tyyppi_id where vaate.id in (select vaatecomp.vaate_id from vaatecomp where vaatecomp.age_id = (select id from age where minage<= :age and maxage >= :age2 and gender = :gender) and vaatecomp.temperature_id = (select id from temperature where mintemperature <= :temperature and maxtemperature >= :temperature2))"),array('age' => $age, 'age2' => $age, 'gender' => $gender, 'temperature' => $temperature, 'temperature2' => $temperature));
return $vaatteet;
}*/
public function pullclothes(Request $request){
$age = $request->input('age');
$temperature = $request->input('temperature');
if(!empty($request->input('gender')) && $age >= 18 && $age <= 70){
$gender = $request->input('gender');
}
else {
$gender = "B";
}
$a =array([]);
for($i=1; $i <=6; $i++) {
$vaatteet = DB::select( DB::raw("select vaate.vaate,tyyppi.tyyppi from vaate inner join tyyppi on tyyppi.id=vaate.tyyppi_id where vaate.id in (select vaatecomp.vaate_id from vaatecomp where vaatecomp.age_id = (select id from age where minage<= :age and maxage >= :age2 and gender = :gender) and vaatecomp.temperature_id = :tempid)"),array('age' => $age, 'age2' => $age, 'gender' => $gender, 'tempid' => $i));
array_push($a,$vaatteet);
}
//return json_encode($a);
return $a;
// return $vaatteet;
}
public function populatedb(){
......
......@@ -1892,6 +1892,11 @@
"safe-buffer": "5.1.2"
}
},
"circular-json": {
"version": "0.5.9",
"resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.9.tgz",
"integrity": "sha512-4ivwqHpIFJZBuhN3g/pEcdbnGUywkBblloGbkglyloVjjR3uT6tieI89MVOfbP2tHX5sgb01FuLgAOzebNlJNQ=="
},
"class-utils": {
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz",
......@@ -5567,6 +5572,11 @@
"integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=",
"dev": true
},
"lodash.merge": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz",
"integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ=="
},
"lodash.restparam": {
"version": "3.6.1",
"resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz",
......@@ -8899,6 +8909,15 @@
"resolved": "https://registry.npmjs.org/vuex/-/vuex-3.1.0.tgz",
"integrity": "sha512-mdHeHT/7u4BncpUZMlxNaIdcN/HIt1GsGG5LKByArvYG/v6DvHcOxvDCts+7SRdCoIRGllK8IMZvQtQXLppDYg=="
},
"vuex-persist": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/vuex-persist/-/vuex-persist-2.0.0.tgz",
"integrity": "sha512-BG5iOlthnXBCMp1tZpUTc/pvn+81fyEwx+1sYar1ktEZukbGHEsB5yIAydXeoWxUW416oj4/2Qfjrd/noqkoxQ==",
"requires": {
"circular-json": "0.5.9",
"lodash.merge": "4.6.1"
}
},
"watchpack": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz",
......
......@@ -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 source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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>
......
......@@ -8,11 +8,9 @@
</v-btn>
</v-flex>
<v-flex xs8 v-if="cloth[index]" >
{{ label }}:
{{ cloth[index] }}
</v-flex>
<v-flex v-else xs8>
{{ label }}:
Valitse vapaasti
</v-flex>
......@@ -36,7 +34,6 @@
}),
props:{
cloth: Array,
label: String
},
watch:{
cloth: function() {
......
<template>
<div id="cloth-picker">
<ClothSlider :cloth="hats" label="Hatut"/>
<ClothSlider :cloth="upperBody" label="Ylävartalo"/>
<ClothSlider :cloth="lowerBody" label="Housut"/>
<ClothSlider :cloth="shoes" label="Kengät"/>
</div>
<v-flex xs12 md6 pa-2>
<ClothSlider :cloth="hats" />
<ClothSlider :cloth="upperBody" />
<ClothSlider :cloth="lowerBody" />
<ClothSlider :cloth="shoes" />
</v-flex>
</template>
<script>
......@@ -18,70 +20,90 @@
lowerBody: [],
hats: [],
shoes: [],
age: 60,
gender: "N",
age: null,
gender: null,
}),
props:{
weatherData: Array,
props: {
weatherData: Array,
temperature: Number,
},
components: {
components: {
ClothSlider
},
methods: {
getClothes() {
axios
.get('/api/clothes?age='+this.age+'&temperature='+this.temperature+"&gender="+this.gender)
.get('/api/clothes?age=' + this.age + '&temperature=' + this.temperature + "&gender=" + this.gender)
.then(response => (this.clothes = response.data))
.catch(error => console.log(error))
.finally(() => this.clothesToArrays())
},
clothesToArrays(){
clothesToArrays() {
// 0 is empty
var j = this.getTemperatureIndex();
console.table(this.clothes[j]);
console.log(j);
this.resetVariables();
for (var i = 0; i < this.clothes.length; i++){
if(this.clothes[i].tyyppi == 'hattu'){
this.hats.push(this.clothes[i].vaate);
for (var i = 0; i < this.clothes[j].length; i++) {
if (this.clothes[j][i].tyyppi == 'hattu') {
this.hats.push(this.clothes[j][i].vaate);
}
if(this.clothes[i].tyyppi == 'paita' || this.clothes[i].tyyppi == 'takki' ){
this.upperBody.push(this.clothes[i].vaate);
if (this.clothes[j][i].tyyppi == 'paita' || this.clothes[j][i].tyyppi == 'takki') {
this.upperBody.push(this.clothes[j][i].vaate);
}
if(this.clothes[i].tyyppi == 'housut'){
this.lowerBody.push(this.clothes[i].vaate);
if (this.clothes[j][i].tyyppi == 'housut') {
this.lowerBody.push(this.clothes[j][i].vaate);
}
if(this.clothes[i].tyyppi == 'kengät'){
this.shoes.push(this.clothes[i].vaate);
if (this.clothes[j][i].tyyppi == 'kengät') {
this.shoes.push(this.clothes[j][i].vaate);
}
}
},
getTemperatureIndex() {
if (this.temperature >= 20) return 1;
else if (this.temperature >= 10 && this.temperature <= 19) return 2;
else if (this.temperature >= 0 && this.temperature <= 9) return 3;
else if (this.temperature >= -10 && this.temperature <= 0) return 4;
else if (this.temperature >= -29 && this.temperature <= -20) return 5;
else if (this.temperature >= -100 && this.temperature <= -30) return 6;
},
resetVariables(){
resetVariables() {
this.hats = [];
this.upperBody = [];
this.lowerBody = [];
this.shoes = [];
this.hatIndex = 0;
this.upperBodyIndex = 0;
this.lowerBodyIndex = 0;
this.shoeIndex = 0;
this.upperBodyIndex = 0;
this.lowerBodyIndex = 0;
this.shoeIndex = 0;
},
getProfile() {
this.age = this.$store.getters.Age;
this.gender = this.$store.getters.Gender;
switch(this.gender){
case "Mies" : this.gender = "M";
break;
case "Nainen" : this.gender = "N";
break;
}
console.log(this.gender);
}
},
watch: {
temperature: function() {
this.clothesToArrays();
}
},
watch: {
temperature: function() {
this.getClothes();
}
}
mounted: function() {
this.getProfile();
this.getClothes();
},
}
</script>
<style>
#cloth-picker{
width: 100%;
font-size: 30px;
background-color: #ffffff;
padding: 10px;
border-radius: 5px;
text-align: center;
margin:auto;
font-family: inherit;
}
</style>
<template>
<div>
<div class="text-xs-center mb-3"></div>
<v-expansion-panel v-model="panel" expand: false>
<v-expansion-panel-content v-if="favorites != null">
<template v-slot:header>
<div>Suosikit</div>
</template>
<v-card color="grey lighten-3">
<v-card-text v-for="(favorite, index) in favorites" :key="index" @click="pushFavorite(favorite)"> {{ favorite }}</v-card-text>
</v-card>
</v-expansion-panel-content>
</v-expansion-panel>
</div>
<div>
<div class="text-xs-center mb-3"></div>
<v-expansion-panel v-model="panel" expand: false>
<v-expansion-panel-content v-if="favorites != null">
<template v-slot:header>
<div>Suosikit</div>
</template>
<v-card color="grey lighten-3">
<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>
</div>
</template>
<script>
export default {
name: 'FavoriteTab',
data: () => ({
panel: [
false
],
test: null,
panel: [
true
],
}),
props: {
favorites: Array,
},
props: {
favorites: Array,
},
computed: {
favorites2() {
return this.$store.getters.favorites
}
},
methods: {
pushFavorite(location){
this.$emit('pushFavorite', location);
}
pushFavorite(location) {
this.$emit('pushFavorite', location);
this.panel = 1;
}
}
}
</script>
<style>
.fav:hover {
color: rgb(9, 173, 0);
}
.fav:active {
color: rgb(100, 221, 23);
}
</style>
<template>
<v-flex xs12 md6 pa-2>
<v-flex xs12 md12 pa-2>
<v-card color="transparent" flat>
<v-card-text>
<v-autocomplete color="light-green accent-4" v-model="selectedKunta" :items="kunnat" hide-no-data hide-selected item-text="Description" item-value="API" label="Paikkakunta" placeholder="" prepend-icon="mdi-database-search" clearable return-object></v-autocomplete>
......@@ -11,14 +11,10 @@
Lisää suosikiksi
<v-icon right>mdi-close-circle</v-icon>
</v-btn>
<v-btn :disabled="!selectedKunta" color="light-green accent-4" @click="getCoords">
Hae sää
<v-icon right>mdi-close-circle</v-icon>
</v-btn>
</v-card-actions>
<favorites @pushFavorite="pullFavorite" :favorites="favorites"></favorites>
</v-card>
</v-flex>
</v-flex>
</template>
<script>
......@@ -53,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() {
......@@ -94,6 +91,7 @@
this.favorites.push(this.selectedKunta);
else
console.log("Please");
this.$store.commit("mutateFavorites", this.favorites);
},
createGraph() {
// Init arrays to null
......@@ -114,7 +112,12 @@
},
mounted: function() {
this.getLocations();
}
}
},
watch: {
selectedKunta: function(){
if(this.selectedKunta)
this.getCoords();
}
}}
</script>
<template>
<div>
<v-layout row wrap>
<v-flex xs12 md6>
<Locations id="locations" @pushWeatherData="pushData" />
<Weather id="weather" @pushTemperature="pullTemperature" :values="values" :weatherData="weatherData" :kunta="selectedKunta"/>
<Clothes :temperature="temperature" />
</v-flex>
<Clothes :temperature="temperature" />
</v-layout>
</div>
</template>
......
<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>
</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;
}
},
mounted: function() {
this.getData();
},
computed: {
authError() {
return this.$store.getters.authError
}
}
}
</script>
<style scoped>
</styler>
\ No newline at end of file
<template>
<v-flex xs12 md6 pa-2>
<v-flex xs12 md12 pa-2>
<v-card flat>
<div id="top">
<img id="icon" :src="icon">
<WeatherChart id="chart" :values="temperatures" :labels="temperaturesWithC" />
</div>
<v-card-title>
<div id="location" class="left">{{ kunta }}</div>
<div class="label">Lämpötila</div>
<div class="left">{{ currentTemp }}°C</div>
<div class="label">Feels like</div>
<div id="feels-like" class="left">{{ feelsLike }}°C</div>
<div id="summary">{{ summary }}</div>
</v-card-title>
<v-card-text>
<div class="label">Päivä</div>
<v-slider v-model="date" :tick-labels="dateLabels" :max="96" step="24" ticks="always" tick-size="4" color="light-blue accent-4" thumb-color="light-blue accent-4" track-color="light-blue accent-1"></v-slider>
<div class="label">Tunti</div>
<v-slider v-model="hour" :tick-labels="hourLabels" :max="max" :step="interval" ticks="always" tick-size="4" color="light-blue accent-4" thumb-color="light-blue accent-4" track-color="light-blue accent-1"></v-slider>
</v-card-text>
<v-layout row wrap>
<v-card-title>
<div id="location" class="left">{{ kunta }}</div>
<v-flex xs3>
<div class="label">Lämpötila</div>
<div class="left">{{ currentTemp }}°C</div>
<div class="label">Feels like</div>
<div id="feels-like" class="left">{{ feelsLike }}°C</div>
</v-flex>
<v-flex xs9>
<WeatherChart id="chart" :hours="hours" :values="temperatures" :labels="temperaturesWithC" />
</v-flex>
<div id="summary">{{ summary }}</div>
<div id="wind">Tuuli: {{ wind }} m/s</div>
</v-card-title>
<v-card-text>
<div class="label">Päivä</div>
<v-slider v-model="date" :tick-labels="dateLabels" :max="96" step="24" ticks="always" tick-size="1" color="light-blue accent-4" thumb-color="light-blue accent-4" track-color="light-blue accent-1"></v-slider>
<div class="label">Tunti</div>
<v-slider v-model="hour" :tick-labels="hourLabels" :max="max" :step="interval" ticks="always" tick-size="1" color="light-blue accent-4" thumb-color="light-blue accent-4" track-color="light-blue accent-1"></v-slider>
<v-layout row wrap justify-space-between>
<v-flex class="time-stamp" xs1 v-for="(icon,index) in icons" :key="index"><img class="icon" :src="icon"></v-flex>
</v-layout>
</v-card-text>
</v-layout>
</v-card>
</v-flex>
</template>
......@@ -36,7 +43,8 @@
temperatures: [0, 0],
currentTemp: '-',
temperaturesWithC: ['-', '-', '-', '-', '-', '-', '-'],
icon: '/images/icons/clear-day.png',
icon_src: '/images/icons/',
icons: [],
feelsLike: '-',
summary: null,
hourLabels: [],
......@@ -46,7 +54,9 @@
interval: 3,
ticks: 1,
time: 0,
max: 18
max: 18,
wind: 0,
hours: [],
}),
props: {
weatherData: Array,
......@@ -62,39 +72,38 @@
var month = d.getMonth() + 1;