mirror of
https://github.com/Lissy93/dashy.git
synced 2025-09-26 03:08:49 +02:00
🥅 Catches errors if caused by undefined options
This commit is contained in:
parent
ad9df7a67c
commit
37954eaeb0
@ -1838,7 +1838,7 @@ Display info from the Gluetun VPN container public IP API. This can show the IP
|
|||||||
|
|
||||||
**Field** | **Type** | **Required** | **Description**
|
**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`
|
**`host`** | `string` | Required | The url to the gluetun HTTP control server. E.g. `http://gluetun:8000`
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,14 +52,23 @@ export default {
|
|||||||
timezone: null,
|
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: {
|
methods: {
|
||||||
/* Make GET request to Gluetun publicip API endpoint */
|
/* Make GET request to Gluetun publicip API endpoint */
|
||||||
fetchData() {
|
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 */
|
/* Assign data variables to the returned data */
|
||||||
processData(ipInfo) {
|
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.public_ip = fields.includes('public_ip') ? ipInfo.public_ip : null;
|
||||||
this.country = fields.includes('country') ? ipInfo.country : null;
|
this.country = fields.includes('country') ? ipInfo.country : null;
|
||||||
this.region = fields.includes('region') ? ipInfo.region : null;
|
this.region = fields.includes('region') ? ipInfo.region : null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user