From 710b3ea7ad6e26d567516e8eb3291b5c2601cf97 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Mon, 3 Jan 2022 12:32:00 +0000 Subject: [PATCH] :sparkles: Adds crypto wallet balance widget --- docs/widgets.md | 33 ++++ src/components/Widgets/WalletBalance.vue | 228 +++++++++++++++++++++++ src/components/Widgets/WidgetBase.vue | 12 +- src/mixins/WidgetMixin.js | 6 +- src/utils/defaults.js | 2 + 5 files changed, 277 insertions(+), 4 deletions(-) create mode 100644 src/components/Widgets/WalletBalance.vue diff --git a/docs/widgets.md b/docs/widgets.md index b35c23c6..4dbddaa3 100644 --- a/docs/widgets.md +++ b/docs/widgets.md @@ -13,6 +13,7 @@ Dashy has support for displaying dynamic content in the form of widgets. There a - [Weather Forecast](#weather-forecast) - [Crypto Watch List](#crypto-watch-list) - [Crypto Price History](#crypto-token-price-history) + - [Crypto Wallet Balance](#wallet-balance) - [RSS Feed](#rss-feed) - [Code Stats](#code-stats) - [Vulnerability Feed](#vulnerability-feed) @@ -238,6 +239,38 @@ Shows recent price history for a given crypto asset, using price data fetched fr --- +### Wallet Balance + +Keep track of your crypto balances and see recent transactions. Data is fetched from [BlockCypher](https://www.blockcypher.com/dev/) + +

+ +##### Options + +**Field** | **Type** | **Required** | **Description** +--- | --- | --- | --- +**`coin`** | `string` | Required | Symbol of coin or asset, e.g. `btc`, `eth` or `doge` +**`address`** | `string` | Required | Address to monitor. This is your wallet's **public** / receiving address +**`network`** | `string` | _Optional_ | To use a different network, other than mainnet. Defaults to `main` +**`limit`** | `number` | _Optional_ | Limit the number of transactions to display. Defaults to `10`, set to large number to show all + +##### Example + +```yaml +- type: wallet-balance + options: + coin: btc + address: 3853bSxupMjvxEYfwGDGAaLZhTKxB2vEVC +``` + +##### Info +- **CORS**: 🟢 Enabled +- **Auth**: 🟢 Not Required +- **Price**: 🟢 Free +- **Privacy**: _See [BlockCypher Privacy Policy](https://www.blockcypher.com/privacy.html)_ + +--- + ### RSS Feed Display news and updates from any RSS-enabled service. diff --git a/src/components/Widgets/WalletBalance.vue b/src/components/Widgets/WalletBalance.vue new file mode 100644 index 00000000..09ba466c --- /dev/null +++ b/src/components/Widgets/WalletBalance.vue @@ -0,0 +1,228 @@ + + + + + diff --git a/src/components/Widgets/WidgetBase.vue b/src/components/Widgets/WidgetBase.vue index 65610814..707602e6 100644 --- a/src/components/Widgets/WidgetBase.vue +++ b/src/components/Widgets/WidgetBase.vue @@ -228,8 +228,8 @@ @error="handleError" :ref="widgetRef" /> - +
{{ handleError('Widget type was not found') }}
@@ -302,6 +309,7 @@ export default { StockPriceChart: () => import('@/components/Widgets/StockPriceChart.vue'), SystemInfo: () => import('@/components/Widgets/SystemInfo.vue'), TflStatus: () => import('@/components/Widgets/TflStatus.vue'), + WalletBalance: () => import('@/components/Widgets/WalletBalance.vue'), Weather: () => import('@/components/Widgets/Weather.vue'), WeatherForecast: () => import('@/components/Widgets/WeatherForecast.vue'), XkcdComic: () => import('@/components/Widgets/XkcdComic.vue'), diff --git a/src/mixins/WidgetMixin.js b/src/mixins/WidgetMixin.js index 8ae161a8..4636b93c 100644 --- a/src/mixins/WidgetMixin.js +++ b/src/mixins/WidgetMixin.js @@ -57,8 +57,10 @@ const WidgetMixin = { this.finishLoading(); }, /* Used as v-tooltip, pass text content in, and will show on hover */ - tooltip(content) { - return { content, trigger: 'hover focus', delay: 250 }; + tooltip(content, html = false) { + return { + content, html, trigger: 'hover focus', delay: 250, + }; }, /* Makes data request, returns promise */ makeRequest(endpoint, options) { diff --git a/src/utils/defaults.js b/src/utils/defaults.js index c353a5bb..30b3e752 100644 --- a/src/utils/defaults.js +++ b/src/utils/defaults.js @@ -228,6 +228,8 @@ module.exports = { sportsScores: 'https://www.thesportsdb.com/api/v1/json', stockPriceChart: 'https://www.alphavantage.co/query', tflStatus: 'https://api.tfl.gov.uk/line/mode/tube/status', + walletBalance: 'https://api.blockcypher.com/v1', + walletQrCode: 'https://www.bitcoinqrcodemaker.com/api', weather: 'https://api.openweathermap.org/data/2.5/weather', weatherForecast: 'https://api.openweathermap.org/data/2.5/forecast/daily', xkcdComic: 'https://xkcd.vercel.app/',