mirror of
https://github.com/Lissy93/dashy.git
synced 2024-11-24 05:56:49 +03:00
⚡ IP address widget used ipapi.co by default (#437)
This commit is contained in:
parent
5b6e75766d
commit
edbd770a2d
@ -210,16 +210,17 @@ Display news and updates from any RSS-enabled service.
|
|||||||
|
|
||||||
### Public IP
|
### Public IP
|
||||||
|
|
||||||
Often find yourself searching "What's my IP", just so you can check your VPN is still connected? This widget displays your public IP address, along with ISP name and approx location. Data can be fetched from either [IP-API.com](https://ip-api.com/) or [ipgeolocation.io](https://ipgeolocation.io/).
|
Often find yourself searching "What's my IP", just so you can check your VPN is still connected? This widget displays your public IP address, along with ISP name and approx location. Data can be fetched from either [IpApi.co](https://ipapi.co/), [IP-API.com](https://ip-api.com/) or [IpGeolocation.io](https://ipgeolocation.io/).
|
||||||
|
|
||||||
<p align="center"><img width="400" src="https://i.ibb.co/vc3c8zN/public-ip.png" /></p>
|
<p align="center"><img width="400" src="https://i.ibb.co/vc3c8zN/public-ip.png" /></p>
|
||||||
|
|
||||||
##### Options
|
##### Options
|
||||||
|
_All fields are optional_
|
||||||
|
|
||||||
**Field** | **Type** | **Required** | **Description**
|
**Field** | **Type** | **Required** | **Description**
|
||||||
--- | --- | --- | ---
|
--- | --- | --- | ---
|
||||||
**`provider`** | `string` | Required | The name of the service to fetch IP address from. Can be either `ip-api` or `ipgeolocation`. Defaults to `ip-api` which only works via HTTP, if you set to `ipgeolocation` then you must also provide an API key
|
**`provider`** | `string` | _Optional_ | The name of the service to fetch IP address from. Can be either `ipapi.co`, `ip-api` or `ipgeolocation`. Defaults to `ipapi.co`. Note, `ip-api` doesn't work on HTTPS, and if you set to `ipgeolocation` then you must also provide an API key
|
||||||
**`apiKey`** | `string` | Required | Only required if provider is set to `ipgeolocation`. You can get a free API key [here](https://ipgeolocation.io/signup.html)
|
**`apiKey`** | `string` | _Optional_ | Only required if provider is set to `ipgeolocation`. You can get a free API key [here](https://ipgeolocation.io/signup.html)
|
||||||
|
|
||||||
##### Example
|
##### Example
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ export default {
|
|||||||
endpoint() {
|
endpoint() {
|
||||||
if (this.provider === 'ipgeolocation') {
|
if (this.provider === 'ipgeolocation') {
|
||||||
return `${widgetApiEndpoints.publicIp2}?apiKey=${this.apiKey}`;
|
return `${widgetApiEndpoints.publicIp2}?apiKey=${this.apiKey}`;
|
||||||
|
} else if (this.provider === 'ipapi') {
|
||||||
|
return widgetApiEndpoints.publicIp3;
|
||||||
}
|
}
|
||||||
return widgetApiEndpoints.publicIp;
|
return widgetApiEndpoints.publicIp;
|
||||||
},
|
},
|
||||||
@ -32,8 +34,8 @@ export default {
|
|||||||
return this.options.apiKey;
|
return this.options.apiKey;
|
||||||
},
|
},
|
||||||
provider() {
|
provider() {
|
||||||
// Can be either `ip-api` or `ipgeolocation`
|
// Can be either `ip-api`, `ipapi.co` or `ipgeolocation`
|
||||||
return this.options.provider || 'ip-api';
|
return this.options.provider || 'ipapi.co';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -52,18 +54,26 @@ export default {
|
|||||||
},
|
},
|
||||||
/* Assign data variables to the returned data */
|
/* Assign data variables to the returned data */
|
||||||
processData(ipInfo) {
|
processData(ipInfo) {
|
||||||
if (this.provider === 'ip-api') {
|
if (this.provider === 'ipapi.co') {
|
||||||
|
this.ipAddr = ipInfo.ip;
|
||||||
|
this.ispName = ipInfo.org;
|
||||||
|
this.location = `${ipInfo.city}, ${ipInfo.region}`;
|
||||||
|
this.flagImg = getCountryFlag(ipInfo.country_code);
|
||||||
|
this.mapsUrl = getMapUrl({ lat: ipInfo.latitude, lon: ipInfo.longitude });
|
||||||
|
} else if (this.provider === 'ipgeolocation') {
|
||||||
|
this.ipAddr = ipInfo.ip;
|
||||||
|
this.ispName = ipInfo.organization || ipInfo.isp;
|
||||||
|
this.location = `${ipInfo.city}, ${ipInfo.country_name}`;
|
||||||
|
this.flagImg = ipInfo.country_flag;
|
||||||
|
this.mapsUrl = getMapUrl({ lat: ipInfo.latitude, lon: ipInfo.longitude });
|
||||||
|
} else if (this.provider === 'ip-api') {
|
||||||
this.ipAddr = ipInfo.query;
|
this.ipAddr = ipInfo.query;
|
||||||
this.ispName = ipInfo.isp;
|
this.ispName = ipInfo.isp;
|
||||||
this.location = `${ipInfo.city}, ${ipInfo.regionName}`;
|
this.location = `${ipInfo.city}, ${ipInfo.regionName}`;
|
||||||
this.flagImg = getCountryFlag(ipInfo.countryCode);
|
this.flagImg = getCountryFlag(ipInfo.countryCode);
|
||||||
this.mapsUrl = getMapUrl({ lat: ipInfo.lat, lon: ipInfo.lon });
|
this.mapsUrl = getMapUrl({ lat: ipInfo.lat, lon: ipInfo.lon });
|
||||||
} else if (this.provider === 'ipgeolocation') {
|
} else {
|
||||||
this.ipAddr = ipInfo.ip;
|
this.error('Unknown API provider fo IP address');
|
||||||
this.ispName = ipInfo.organization || ipInfo.isp;
|
|
||||||
this.flagImg = ipInfo.country_flag;
|
|
||||||
this.location = `${ipInfo.city}, ${ipInfo.country_name}`;
|
|
||||||
this.mapsUrl = getMapUrl({ lat: ipInfo.latitude, lon: ipInfo.longitude });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -222,8 +222,9 @@ module.exports = {
|
|||||||
holidays: 'https://kayaposoft.com/enrico/json/v2.0/?action=getHolidaysForDateRange',
|
holidays: 'https://kayaposoft.com/enrico/json/v2.0/?action=getHolidaysForDateRange',
|
||||||
jokes: 'https://v2.jokeapi.dev/joke/',
|
jokes: 'https://v2.jokeapi.dev/joke/',
|
||||||
news: 'https://api.currentsapi.services/v1/latest-news',
|
news: 'https://api.currentsapi.services/v1/latest-news',
|
||||||
publicIp: 'http://ip-api.com/json',
|
publicIp: 'https://ipapi.co/json',
|
||||||
publicIp2: 'https://api.ipgeolocation.io/ipgeo',
|
publicIp2: 'https://api.ipgeolocation.io/ipgeo',
|
||||||
|
publicIp3: 'http://ip-api.com/json',
|
||||||
readMeStats: 'https://github-readme-stats.vercel.app/api',
|
readMeStats: 'https://github-readme-stats.vercel.app/api',
|
||||||
rssToJson: 'https://api.rss2json.com/v1/api.json',
|
rssToJson: 'https://api.rss2json.com/v1/api.json',
|
||||||
sportsScores: 'https://www.thesportsdb.com/api/v1/json',
|
sportsScores: 'https://www.thesportsdb.com/api/v1/json',
|
||||||
|
Loading…
Reference in New Issue
Block a user