Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ₯… Catches errors if caused by undefined options

Alicia Sykes37954eaeb097
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;