From e6ece430f29123cc42bb81b5269ea82f90b88d00 Mon Sep 17 00:00:00 2001 From: SKANKHUNTER <31552675+MrBurrBurr@users.noreply.github.com> Date: Sat, 18 Jul 2020 22:04:56 +0200 Subject: [PATCH 1/5] Basic wallet info --- src/models/Bot.js | 19 +++++++++++++++++++ src/views/modals/Bot.vue | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/models/Bot.js b/src/models/Bot.js index 10de14d63..f6618e2fb 100644 --- a/src/models/Bot.js +++ b/src/models/Bot.js @@ -16,6 +16,8 @@ export class Bot { this.steamid = data.s_SteamID; this.avatarHash = data.AvatarHash || '0b46945851b3d26da93a6ddba3ac961206cc191d'; this.bgrCount = data.GamesToRedeemInBackgroundCount; + this.walletBalance = data.WalletBalance; + this.walletCurrency = data.WalletCurrency; this.active = data.KeepRunning; this.config = data.BotConfig; @@ -86,4 +88,21 @@ export class Bot { if (this.status === BotStatus.FARMING && selectedBots.includes('farming')) return true; return false; } + + get walletInfo() { + if (this.walletCurrency === 0) return; + let currency = this.walletBalance / 100; + + // Resolve ECurrencyCode + switch (this.walletCurrency) { + case 1: + countryCode = 'USD'; + break; + + default: + countryCode = 'EUR'; + } + + return currency.toLocaleString(Vue.i18n.locale, { style: 'currency', currency: countryCode }); + } } diff --git a/src/views/modals/Bot.vue b/src/views/modals/Bot.vue index cc0401900..6d478cd6e 100644 --- a/src/views/modals/Bot.vue +++ b/src/views/modals/Bot.vue @@ -15,6 +15,9 @@

{{ bot.name }}

+
+ {{ bot.walletInfo }} +

{{ bot.statusText }}

@@ -132,9 +135,9 @@ .bot-profile__avatar-wrapper { background: var(--color-status); grid-area: avatar; - height: 75px; + height: 80px; padding: 2px; - width: 75px; + width: 80px; } .bot-profile__avatar { From 9434bb922cb9b01aef93a1062cb7d6d3f3b03ad9 Mon Sep 17 00:00:00 2001 From: SKANKHUNTER <31552675+MrBurrBurr@users.noreply.github.com> Date: Sun, 19 Jul 2020 00:24:56 +0200 Subject: [PATCH 2/5] Misc --- src/models/Bot.js | 9 ++++----- src/views/modals/Bot.vue | 29 +++++++++++++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/models/Bot.js b/src/models/Bot.js index f6618e2fb..abf1d9264 100644 --- a/src/models/Bot.js +++ b/src/models/Bot.js @@ -90,17 +90,16 @@ export class Bot { } get walletInfo() { - if (this.walletCurrency === 0) return; - let currency = this.walletBalance / 100; + if (this.walletCurrency === 0) return null; + const currency = this.walletBalance / 100; + let countryCode = 'EUR'; // Resolve ECurrencyCode switch (this.walletCurrency) { case 1: countryCode = 'USD'; break; - - default: - countryCode = 'EUR'; + //... } return currency.toLocaleString(Vue.i18n.locale, { style: 'currency', currency: countryCode }); diff --git a/src/views/modals/Bot.vue b/src/views/modals/Bot.vue index 6d478cd6e..8c08cf0d3 100644 --- a/src/views/modals/Bot.vue +++ b/src/views/modals/Bot.vue @@ -9,14 +9,18 @@
-

- {{ bot.nickname }} -

-

- {{ bot.name }} -

-
- {{ bot.walletInfo }} +
+
+

+ {{ bot.nickname }} +

+

+ {{ bot.name }} +

+
+
+ {{ bot.walletInfo }} +

{{ bot.statusText }} @@ -135,9 +139,9 @@ .bot-profile__avatar-wrapper { background: var(--color-status); grid-area: avatar; - height: 80px; + height: 75px; padding: 2px; - width: 80px; + width: 75px; } .bot-profile__avatar { @@ -149,6 +153,11 @@ min-width: 0; } + .bot-profile__info { + display: flex; + align-items: center; + } + .bot-profile__name { margin: 0; } From dfa4046e616cfc454d32c16961e3660ac84e205d Mon Sep 17 00:00:00 2001 From: SKANKHUNTER <31552675+MrBurrBurr@users.noreply.github.com> Date: Sun, 19 Jul 2020 20:32:08 +0200 Subject: [PATCH 3/5] Hardcoding is really good --- src/models/Bot.js | 14 +++-------- src/utils/getCountryCode.js | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 src/utils/getCountryCode.js diff --git a/src/models/Bot.js b/src/models/Bot.js index abf1d9264..3cf7f4b5a 100644 --- a/src/models/Bot.js +++ b/src/models/Bot.js @@ -1,4 +1,5 @@ import Vue from 'vue'; +import getCountryCode from '../utils/getCountryCode'; const timeSpanRegex = /(?:(\d+).)?(\d{2}):(\d{2}):(\d{2})(?:.?(\d{7}))?/; @@ -92,16 +93,7 @@ export class Bot { get walletInfo() { if (this.walletCurrency === 0) return null; const currency = this.walletBalance / 100; - let countryCode = 'EUR'; - - // Resolve ECurrencyCode - switch (this.walletCurrency) { - case 1: - countryCode = 'USD'; - break; - //... - } - - return currency.toLocaleString(Vue.i18n.locale, { style: 'currency', currency: countryCode }); + const currencyCode = getCountryCode(this.walletCurrency); + return currency.toLocaleString(Vue.i18n.locale, { style: 'currency', currency: currencyCode }); } } diff --git a/src/utils/getCountryCode.js b/src/utils/getCountryCode.js new file mode 100644 index 000000000..ab26c95d9 --- /dev/null +++ b/src/utils/getCountryCode.js @@ -0,0 +1,48 @@ +// Todo: Read ECurrencyCode from api +export default function getCountryCode(id) { + const codes = { + "Invalid": 0, + "USD": 1, + "GBP": 2, + "EUR": 3, + "CHF": 4, + "RUB": 5, + "PLN": 6, + "BRL": 7, + "JPY": 8, + "NOK": 9, + "IDR": 10, + "MYR": 11, + "PHP": 12, + "SGD": 13, + "THB": 14, + "VND": 15, + "KRW": 16, + "TRY": 17, + "UAH": 18, + "MXN": 19, + "CAD": 20, + "AUD": 21, + "NZD": 22, + "CNY": 23, + "INR": 24, + "CLP": 25, + "PEN": 26, + "COP": 27, + "ZAR": 28, + "HKD": 29, + "TWD": 30, + "SAR": 31, + "AED": 32, + "ARS": 34, + "ILS": 35, + "BYN": 36, + "KZT": 37, + "KWD": 38, + "QAR": 39, + "CRC": 40, + "UYU": 41 + }; + + return Object.keys(codes)[id]; +} \ No newline at end of file From 830b7d2afdaee8747a138196545e9c52828a642b Mon Sep 17 00:00:00 2001 From: SKANKHUNTER <31552675+MrBurrBurr@users.noreply.github.com> Date: Sun, 19 Jul 2020 20:34:35 +0200 Subject: [PATCH 4/5] Misc --- src/utils/getCountryCode.js | 88 ++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/utils/getCountryCode.js b/src/utils/getCountryCode.js index ab26c95d9..bfc741a9d 100644 --- a/src/utils/getCountryCode.js +++ b/src/utils/getCountryCode.js @@ -1,48 +1,48 @@ // Todo: Read ECurrencyCode from api -export default function getCountryCode(id) { - const codes = { - "Invalid": 0, - "USD": 1, - "GBP": 2, - "EUR": 3, - "CHF": 4, - "RUB": 5, - "PLN": 6, - "BRL": 7, - "JPY": 8, - "NOK": 9, - "IDR": 10, - "MYR": 11, - "PHP": 12, - "SGD": 13, - "THB": 14, - "VND": 15, - "KRW": 16, - "TRY": 17, - "UAH": 18, - "MXN": 19, - "CAD": 20, - "AUD": 21, - "NZD": 22, - "CNY": 23, - "INR": 24, - "CLP": 25, - "PEN": 26, - "COP": 27, - "ZAR": 28, - "HKD": 29, - "TWD": 30, - "SAR": 31, - "AED": 32, - "ARS": 34, - "ILS": 35, - "BYN": 36, - "KZT": 37, - "KWD": 38, - "QAR": 39, - "CRC": 40, - "UYU": 41 - }; +const codes = { + "Invalid": 0, + "USD": 1, + "GBP": 2, + "EUR": 3, + "CHF": 4, + "RUB": 5, + "PLN": 6, + "BRL": 7, + "JPY": 8, + "NOK": 9, + "IDR": 10, + "MYR": 11, + "PHP": 12, + "SGD": 13, + "THB": 14, + "VND": 15, + "KRW": 16, + "TRY": 17, + "UAH": 18, + "MXN": 19, + "CAD": 20, + "AUD": 21, + "NZD": 22, + "CNY": 23, + "INR": 24, + "CLP": 25, + "PEN": 26, + "COP": 27, + "ZAR": 28, + "HKD": 29, + "TWD": 30, + "SAR": 31, + "AED": 32, + "ARS": 34, + "ILS": 35, + "BYN": 36, + "KZT": 37, + "KWD": 38, + "QAR": 39, + "CRC": 40, + "UYU": 41 +}; +export default function getCountryCode(id) { return Object.keys(codes)[id]; } \ No newline at end of file From 52cbf6d6acea83a6c24919bfc93011737ed9a1d0 Mon Sep 17 00:00:00 2001 From: SKANKHUNTER <31552675+MrBurrBurr@users.noreply.github.com> Date: Sun, 19 Jul 2020 20:44:26 +0200 Subject: [PATCH 5/5] Misc --- src/models/Bot.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/models/Bot.js b/src/models/Bot.js index 3cf7f4b5a..14b383c55 100644 --- a/src/models/Bot.js +++ b/src/models/Bot.js @@ -94,6 +94,7 @@ export class Bot { if (this.walletCurrency === 0) return null; const currency = this.walletBalance / 100; const currencyCode = getCountryCode(this.walletCurrency); + if (typeof currencyCode === 'undefined') return null; return currency.toLocaleString(Vue.i18n.locale, { style: 'currency', currency: currencyCode }); } }