From ad9df7a67cc653caef48f6f2bfd1cb6290c044a0 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 23 Jul 2022 14:33:23 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=9A=A8=20Fix=20lint=20errors=20in=20G?= =?UTF-8?q?luetun=20widget?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Widgets/GluetunStatus.vue | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/Widgets/GluetunStatus.vue b/src/components/Widgets/GluetunStatus.vue index 381265e6..99cd6e06 100644 --- a/src/components/Widgets/GluetunStatus.vue +++ b/src/components/Widgets/GluetunStatus.vue @@ -55,20 +55,20 @@ export default { methods: { /* Make GET request to Gluetun publicip API endpoint */ fetchData() { - this.makeRequest(this.options.hostname + "/v1/publicip/ip").then(this.processData); + this.makeRequest(`${this.options.hostname}/v1/publicip/ip`).then(this.processData); }, /* Assign data variables to the returned data */ processData(ipInfo) { - var fields = this.options.visibleFields.split(","); - this.public_ip = fields.includes("public_ip") ? ipInfo.public_ip : null; - this.country = fields.includes("country") ? ipInfo.country : null; - this.region = fields.includes("region") ? ipInfo.region : null; - this.city = fields.includes("city") ? ipInfo.city : null; - this.location = fields.includes("location") ? ipInfo.location : null; - this.organization = fields.includes("organization") ? ipInfo.organization : null; - this.postal_code = fields.includes("postal_code") ? ipInfo.postal_code : null; - this.timezone = fields.includes("timezone") ? ipInfo.timezone : null; - } + const fields = this.options.visibleFields.split(','); + this.public_ip = fields.includes('public_ip') ? ipInfo.public_ip : null; + this.country = fields.includes('country') ? ipInfo.country : null; + this.region = fields.includes('region') ? ipInfo.region : null; + this.city = fields.includes('city') ? ipInfo.city : null; + this.location = fields.includes('location') ? ipInfo.location : null; + this.organization = fields.includes('organization') ? ipInfo.organization : null; + this.postal_code = fields.includes('postal_code') ? ipInfo.postal_code : null; + this.timezone = fields.includes('timezone') ? ipInfo.timezone : null; + }, }, }; From 37954eaeb097056ec1046386e794c42249ce5fa3 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 23 Jul 2022 14:42:26 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A5=85=20Catches=20errors=20if=20caus?= =?UTF-8?q?ed=20by=20undefined=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/widgets.md | 2 +- src/components/Widgets/GluetunStatus.vue | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/widgets.md b/docs/widgets.md index a45a2591..7a31041c 100644 --- a/docs/widgets.md +++ b/docs/widgets.md @@ -1838,7 +1838,7 @@ Display info from the Gluetun VPN container public IP API. This can show the IP **Field** | **Type** | **Required** | **Description** --- | --- | --- | --- -**`visibleFields`** | `string` | Required | A comma separated list of the fields you want visible in the widget. You can have any number of the following : `public_ip`, `region`, `country`, `city`, `location`, `organisation`, `postal_code`, `timezone` +**`visibleFields`** | `string` | Required | A comma separated list of the fields you want visible in the widget. You can have any number of the following : `public_ip`, `region`, `country`, `city`, `location`, `organisation`, `postal_code`, `timezone`. Defaults to just `public_ip` **`host`** | `string` | Required | The url to the gluetun HTTP control server. E.g. `http://gluetun:8000` diff --git a/src/components/Widgets/GluetunStatus.vue b/src/components/Widgets/GluetunStatus.vue index 99cd6e06..3a51c636 100644 --- a/src/components/Widgets/GluetunStatus.vue +++ b/src/components/Widgets/GluetunStatus.vue @@ -52,14 +52,23 @@ export default { timezone: null, }; }, + computed: { + visibleFields() { + return this.options.visibleFields || 'public_ip'; + }, + hostname() { + if (!this.options.hostname) this.error('`hostname` is required'); + return this.options.hostname; + }, + }, methods: { /* Make GET request to Gluetun publicip API endpoint */ fetchData() { - this.makeRequest(`${this.options.hostname}/v1/publicip/ip`).then(this.processData); + this.makeRequest(`${this.hostname}/v1/publicip/ip`).then(this.processData); }, /* Assign data variables to the returned data */ processData(ipInfo) { - const fields = this.options.visibleFields.split(','); + const fields = this.visibleFields.split(','); this.public_ip = fields.includes('public_ip') ? ipInfo.public_ip : null; this.country = fields.includes('country') ? ipInfo.country : null; this.region = fields.includes('region') ? ipInfo.region : null; From ac9d585a17a222377782b4a8fd4075b37a397801 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 23 Jul 2022 14:50:48 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=92=AC=20Makes=20hard-coded=20text=20?= =?UTF-8?q?translatable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/locales/en.json | 10 ++++++++++ src/components/Widgets/GluetunStatus.vue | 16 ++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index efdaf631..404e3da8 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -304,6 +304,16 @@ "up": "Up", "down": "Down" }, + "gluetun-status": { + "vpn-ip": "VPN IP", + "country": "Country", + "region": "Region", + "city": "City", + "post-code": "Post Code", + "location": "Location", + "timezone": "Timezone", + "organization": "Organization" + }, "nextcloud": { "active": "active", "and": "and", diff --git a/src/components/Widgets/GluetunStatus.vue b/src/components/Widgets/GluetunStatus.vue index 3a51c636..c07e96e2 100644 --- a/src/components/Widgets/GluetunStatus.vue +++ b/src/components/Widgets/GluetunStatus.vue @@ -1,35 +1,35 @@