diff options
author | Dick Wolff <dckwlff@gmail.com> | 2021-01-12 11:39:27 +0100 |
---|---|---|
committer | Dick Wolff <dckwlff@gmail.com> | 2021-01-12 11:39:27 +0100 |
commit | b79561bc9c59d79875a9931d235774333579a363 (patch) | |
tree | 3a8cf41c18b5b4ad4a1a7dec31ef580980bb83be /src/components/services | |
parent | 593f8afc909e166260f32a9e97f8d54d941802e6 (diff) | |
download | homer-b79561bc9c59d79875a9931d235774333579a363.tar.gz homer-b79561bc9c59d79875a9931d235774333579a363.tar.zst homer-b79561bc9c59d79875a9931d235774333579a363.zip |
Format file.
Diffstat (limited to 'src/components/services')
-rw-r--r-- | src/components/services/OpenWeather.vue | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/src/components/services/OpenWeather.vue b/src/components/services/OpenWeather.vue index 30abb2d..a9310ee 100644 --- a/src/components/services/OpenWeather.vue +++ b/src/components/services/OpenWeather.vue | |||
@@ -6,7 +6,11 @@ | |||
6 | <div class="media"> | 6 | <div class="media"> |
7 | <div v-if="image" class="media-left"> | 7 | <div v-if="image" class="media-left"> |
8 | <figure class="image is-48x48"> | 8 | <figure class="image is-48x48"> |
9 | <img :src="`http://openweathermap.org/img/wn/` + image + `@2x.png`" :alt="conditions" :title="conditions" /> | 9 | <img |
10 | :src="`http://openweathermap.org/img/wn/` + image + `@2x.png`" | ||
11 | :alt="conditions" | ||
12 | :title="conditions" | ||
13 | /> | ||
10 | </figure> | 14 | </figure> |
11 | </div> | 15 | </div> |
12 | <div v-if="item.icon" class="media-left"> | 16 | <div v-if="item.icon" class="media-left"> |
@@ -21,10 +25,10 @@ | |||
21 | {{ item.subtitle }} | 25 | {{ item.subtitle }} |
22 | </template> | 26 | </template> |
23 | <template v-else-if="api"> | 27 | <template v-else-if="api"> |
24 | {{ temp }} | 28 | {{ temp }} |
25 | <span v-if="this.item.units == 'metric'">°C</span> | 29 | <span v-if="this.item.units == 'metric'">°C</span> |
26 | <span v-else-if="this.item.units == 'imperial'">°F</span> | 30 | <span v-else-if="this.item.units == 'imperial'">°F</span> |
27 | <span v-else>K</span> | 31 | <span v-else>K</span> |
28 | </template> | 32 | </template> |
29 | </p> | 33 | </p> |
30 | </div> | 34 | </div> |
@@ -47,36 +51,38 @@ export default { | |||
47 | data: () => ({ | 51 | data: () => ({ |
48 | api: { | 52 | api: { |
49 | name: "", | 53 | name: "", |
50 | weather: [{ | 54 | weather: [ |
51 | main: "", | 55 | { |
52 | description: "", | 56 | main: "", |
53 | icon: "" | 57 | description: "", |
54 | }], | 58 | icon: "", |
59 | }, | ||
60 | ], | ||
55 | main: { | 61 | main: { |
56 | temp: "", | 62 | temp: "", |
57 | humidity: "" | 63 | humidity: "", |
58 | } | 64 | }, |
59 | } | 65 | }, |
60 | }), | 66 | }), |
61 | computed: { | 67 | computed: { |
62 | temp: function () { | 68 | temp: function () { |
63 | if (this.api) { | 69 | if (this.api) { |
64 | return parseInt(this.api.main.temp).toFixed(1); | 70 | return parseInt(this.api.main.temp).toFixed(1); |
71 | } | ||
72 | return ""; | ||
73 | }, | ||
74 | image: function () { | ||
75 | if (this.api) { | ||
76 | return this.api.weather[0].icon; | ||
77 | } | ||
78 | return ""; | ||
79 | }, | ||
80 | conditions: function () { | ||
81 | if (this.api) { | ||
82 | return this.api.weather[0].description; | ||
65 | } | 83 | } |
66 | return ""; | 84 | return ""; |
67 | }, | 85 | }, |
68 | image: function () { | ||
69 | if (this.api) { | ||
70 | return this.api.weather[0].icon; | ||
71 | } | ||
72 | return ""; | ||
73 | }, | ||
74 | conditions: function () { | ||
75 | if (this.api) { | ||
76 | return this.api.weather[0].description; | ||
77 | } | ||
78 | return ""; | ||
79 | } | ||
80 | }, | 86 | }, |
81 | created() { | 87 | created() { |
82 | this.fetchStatus(); | 88 | this.fetchStatus(); |
@@ -96,4 +102,4 @@ export default { | |||
96 | .media-left img { | 102 | .media-left img { |
97 | max-height: 100%; | 103 | max-height: 100%; |
98 | } | 104 | } |
99 | </style> \ No newline at end of file | 105 | </style> |