aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorBastien Wirtz <bastien.wirtz@gmail.com>2022-10-30 14:48:45 +0100
committerBastien Wirtz <bastien.wirtz@gmail.com>2022-10-30 14:48:45 +0100
commit5bb84dcefbafab8d80313771854c1d982560ee1a (patch)
tree6ff5d53d35b2fc3ce90daa59a02d9475af98d49b /src
parentde814b9e04ee3cda0f14d99119e06308245dee29 (diff)
downloadhomer-5bb84dcefbafab8d80313771854c1d982560ee1a.tar.gz
homer-5bb84dcefbafab8d80313771854c1d982560ee1a.tar.zst
homer-5bb84dcefbafab8d80313771854c1d982560ee1a.zip
Fix openweather service
Diffstat (limited to 'src')
-rw-r--r--src/components/services/OpenWeather.vue16
-rw-r--r--src/components/services/Ping.vue7
2 files changed, 14 insertions, 9 deletions
diff --git a/src/components/services/OpenWeather.vue b/src/components/services/OpenWeather.vue
index 3169866..649e8e5 100644
--- a/src/components/services/OpenWeather.vue
+++ b/src/components/services/OpenWeather.vue
@@ -23,7 +23,7 @@
23 <p class="title is-4">{{ name }}</p> 23 <p class="title is-4">{{ name }}</p>
24 <p class="subtitle is-6"> 24 <p class="subtitle is-6">
25 <span> 25 <span>
26 {{ temp | tempSuffix(this.item.units) }} 26 {{ temperature }}
27 </span> 27 </span>
28 <span class="location-time"> 28 <span class="location-time">
29 {{ locationTime }} 29 {{ locationTime }}
@@ -68,15 +68,13 @@ export default {
68 } 68 }
69 return `${this.temp} ${unit}`; 69 return `${this.temp} ${unit}`;
70 }, 70 },
71 },
72 created() {
73 this.fetchWeather();
74 },
75 computed: {
76 locationTime: function () { 71 locationTime: function () {
77 return this.calcTime(this.timezoneOffset); 72 return this.calcTime(this.timezoneOffset);
78 }, 73 },
79 }, 74 },
75 created() {
76 this.fetchWeather();
77 },
80 methods: { 78 methods: {
81 fetchWeather: async function () { 79 fetchWeather: async function () {
82 let locationQuery; 80 let locationQuery;
@@ -89,7 +87,11 @@ export default {
89 } 87 }
90 88
91 const apiKey = this.item.apikey || this.item.apiKey; 89 const apiKey = this.item.apikey || this.item.apiKey;
92 const url = `https://api.openweathermap.org/data/2.5/weather?${locationQuery}&appid=${apiKey}&units=${this.item.units}`; 90
91 let url = `https://api.openweathermap.org/data/2.5/weather?${locationQuery}&appid=${apiKey}&units=${this.item.units}`;
92 if (this.item.endpoint) {
93 url = this.item.endpoint;
94 }
93 fetch(url) 95 fetch(url)
94 .then((response) => { 96 .then((response) => {
95 if (!response.ok) { 97 if (!response.ok) {
diff --git a/src/components/services/Ping.vue b/src/components/services/Ping.vue
index 07bc053..e2db050 100644
--- a/src/components/services/Ping.vue
+++ b/src/components/services/Ping.vue
@@ -29,9 +29,12 @@ export default {
29 }, 29 },
30 methods: { 30 methods: {
31 fetchStatus: async function () { 31 fetchStatus: async function () {
32 const method = typeof this.item.method === 'string' ? this.item.method.toUpperCase() : 'HEAD'; 32 const method =
33 typeof this.item.method === "string"
34 ? this.item.method.toUpperCase()
35 : "HEAD";
33 36
34 if (!['GET', 'HEAD', 'OPTION'].includes(method)) { 37 if (!["GET", "HEAD", "OPTION"].includes(method)) {
35 console.error(`Ping: ${method} is not a supported HTTP method`); 38 console.error(`Ping: ${method} is not a supported HTTP method`);
36 return; 39 return;
37 } 40 }