Added details
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
</v-list-item>
|
||||
<v-divider></v-divider>
|
||||
<v-row justify="space-around">
|
||||
<v-col class="text-center pb-0" v-for="i in 5" :key="i">
|
||||
<v-col class="text-center" v-for="i in 5" :key="i">
|
||||
<div>{{ getMoment(data.hourly[i * 3].dt, "HH:mm") }}</div>
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ on }">
|
||||
@@ -49,27 +49,36 @@
|
||||
</template>
|
||||
<span>{{ data.hourly[i * 3].weather[0].description }}</span>
|
||||
</v-tooltip>
|
||||
|
||||
<div>{{ Math.round(data.hourly[i * 3].temp) }} °C</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-divider></v-divider>
|
||||
<v-card-actions>
|
||||
<v-btn block class="primary" @click="details = true">Pokaż szczegóły</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
<v-skeleton-loader type="card" v-else></v-skeleton-loader>
|
||||
<Details v-model="details" :city="city" :wdata="data" v-if="city && data"></Details>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from "vue-property-decorator";
|
||||
import Details from '@/components/Details.vue';
|
||||
import axios from "axios";
|
||||
const moment = require("moment");
|
||||
|
||||
@Component
|
||||
@Component({
|
||||
components: {
|
||||
Details,
|
||||
}
|
||||
})
|
||||
export default class City extends Vue {
|
||||
@Prop({ required: true }) private readonly city!: any;
|
||||
|
||||
private created() {
|
||||
this.getData();
|
||||
setInterval(this.getData, 1000 * 60);
|
||||
//setInterval(this.getData, 1000 * 60);
|
||||
}
|
||||
|
||||
private getData() {
|
||||
@@ -99,6 +108,7 @@ export default class City extends Vue {
|
||||
return {
|
||||
data: undefined,
|
||||
forecast: undefined,
|
||||
details: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
138
src/components/Details.vue
Normal file
138
src/components/Details.vue
Normal file
@@ -0,0 +1,138 @@
|
||||
<template>
|
||||
<v-dialog v-model="overlay">
|
||||
<v-card>
|
||||
<v-card-title class="justify-center text-break"
|
||||
>Szczegółowa prognoza pogody dla {{ city.name }}
|
||||
</v-card-title>
|
||||
<v-card-text class="px-1 pb-1">
|
||||
<apexchart
|
||||
:options="temperatureOptions"
|
||||
:series="temperatureSeries"
|
||||
></apexchart>
|
||||
<apexchart
|
||||
:options="humidityOptions"
|
||||
:series="humiditySeries"
|
||||
></apexchart>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn class="primary" @click="overlay = false">Zamknij</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from "vue-property-decorator";
|
||||
const moment = require("moment");
|
||||
|
||||
@Component
|
||||
export default class Details extends Vue {
|
||||
@Prop({ required: true }) private readonly value!: boolean;
|
||||
@Prop({ required: true }) private readonly city!: any;
|
||||
@Prop({ required: true }) private readonly wdata!: any;
|
||||
|
||||
get overlay() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
set overlay(val: boolean) {
|
||||
this.$emit("input", val);
|
||||
}
|
||||
|
||||
get temperatureSeries() {
|
||||
const ts = this.wdata.hourly
|
||||
.slice(0, this.$vuetify.breakpoint.xsOnly ? 12 : 24)
|
||||
.map((element: any) => {
|
||||
return {
|
||||
x: moment.unix(element.dt).format("HH:mm"),
|
||||
y: Math.round(element.temp),
|
||||
};
|
||||
});
|
||||
return [
|
||||
{
|
||||
name: "temperatura",
|
||||
data: ts,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
get humiditySeries() {
|
||||
const ts = this.wdata.hourly
|
||||
.slice(0, this.$vuetify.breakpoint.xsOnly ? 12 : 24)
|
||||
.map((element: any) => {
|
||||
return {
|
||||
x: moment.unix(element.dt).format("HH:mm"),
|
||||
y: Math.round(element.humidity),
|
||||
};
|
||||
});
|
||||
return [
|
||||
{
|
||||
name: "wilgotność",
|
||||
data: ts,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
private data() {
|
||||
return {
|
||||
temperatureOptions: {
|
||||
chart: {
|
||||
type: "line",
|
||||
toolbar: false,
|
||||
},
|
||||
title: {
|
||||
text: "Prognoza temperatury",
|
||||
align: "center",
|
||||
},
|
||||
xaxis: {
|
||||
labels: {
|
||||
showDuplicates: true,
|
||||
rotateAlways: true,
|
||||
},
|
||||
title: {
|
||||
text: "Godzina",
|
||||
offsetY: -30,
|
||||
},
|
||||
},
|
||||
yaxis: {
|
||||
title: {
|
||||
text: "Temperatura",
|
||||
},
|
||||
},
|
||||
stroke: {
|
||||
curve: "smooth",
|
||||
},
|
||||
},
|
||||
humidityOptions: {
|
||||
chart: {
|
||||
type: "line",
|
||||
toolbar: false,
|
||||
},
|
||||
title: {
|
||||
text: "Prognoza wilgotności",
|
||||
align: "center",
|
||||
},
|
||||
xaxis: {
|
||||
labels: {
|
||||
showDuplicates: true,
|
||||
rotateAlways: true,
|
||||
},
|
||||
title: {
|
||||
text: "Godzina",
|
||||
offsetY: -30,
|
||||
},
|
||||
},
|
||||
yaxis: {
|
||||
title: {
|
||||
text: "Wilgotność",
|
||||
},
|
||||
},
|
||||
stroke: {
|
||||
curve: "smooth",
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -2,11 +2,14 @@ import Vue from "vue";
|
||||
import App from "./App.vue";
|
||||
import store from "./store";
|
||||
import vuetify from "./plugins/vuetify";
|
||||
import VueApexCharts from 'vue-apexcharts'
|
||||
|
||||
import { initializeApp } from "firebase/app";
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
|
||||
Vue.use(VueApexCharts)
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: process.env.VUE_APP_FIREBASE_apiKey,
|
||||
authDomain: process.env.VUE_APP_FIREBASE_authDomain,
|
||||
@@ -24,3 +27,5 @@ new Vue({
|
||||
vuetify,
|
||||
render: (h) => h(App),
|
||||
}).$mount("#app");
|
||||
|
||||
Vue.component('apexchart', VueApexCharts)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<v-card
|
||||
tile
|
||||
outlined
|
||||
height="230"
|
||||
height="283"
|
||||
width="350"
|
||||
:color="hover ? 'grey lighten-2' : ''"
|
||||
class="rounded-xl"
|
||||
|
||||
Reference in New Issue
Block a user