Skip to content

Commit

Permalink
Fixed translation for portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Litzenburger authored and Jan Litzenburger committed Jul 14, 2021
1 parent fad2d4a commit 821b63b
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 97 deletions.
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"endOfLine": "auto"
"endOfLine": "auto",
"printWidth": 120
}
2 changes: 1 addition & 1 deletion MMM-Jast.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Click here for the Magic Mirror [Forum Thread](https://forum.magicmirror.builder
* cryptocurrencies
* No API Key required
* Vertical or horizontal scrolling or static list
* Depot value growth summary
* Share Portfolio value and growth summary
* Very customizable
* Easy to use

Expand Down Expand Up @@ -51,9 +51,9 @@ To use this module, add it to the modules array in the `MagicMirror/config/confi
showChangePercent: true,
showChangeValue: false,
showChangeValueCurrency: false,
showDepot: false,
showDepotGrowthPercent: false,
showDepotGrowth: false,
showPortfolioValue: false,
showPortfolioGrowthPercent: false,
showPortfolioGrowth: false,
numberDecimalsValues: 2,
numberDecimalsPercentages: 1,
virtualHorizontalMultiplier: 2,
Expand Down Expand Up @@ -82,9 +82,9 @@ To use this module, add it to the modules array in the `MagicMirror/config/confi
| showChangePercent | (Boolean) Show stocks change against last close in percent | true |
| showChangeValue | (Boolean) Show stocks change against last close in absolute value | false |
| showChangeValueCurrency | (Boolean) Show currency for change value | false |
| showDepot | (Boolean) Show depot value | false |
| showDepotGrowth | (Boolean) Show depot value growth summary | false |
| showDepotGrowthPercent | (Boolean) Show depot value growth summary in percent | false |
| showPortfolioValue | (Boolean) Show portfolio value | false |
| showPortfolioGrowth | (Boolean) Show portfolio value growth summary | false |
| showPortfolioGrowthPercent | (Boolean) Show portfolio value growth summary in percent | false |
| useGrouping | (Boolean) Add grouping to high value numbers (i.e. BTC 60,000.00 EUR) | false |
| virtualHorizontalMultiplier | (Number) Virtually repeats the stocklist in horizontal mode to avoid whitespaces | 2 |

Expand All @@ -93,7 +93,7 @@ To use this module, add it to the modules array in the `MagicMirror/config/confi
| -------- | -------- | -------- |
| symbol | (String) Stock's symbol/key | "BABA" |
| name | (String) Optional: Stock's display name | "Alibaba" |
| quantity | (Integer) Optional: To calculate depotGrowth | 500 |
| quantity | (Integer) Optional: To calculate portfolio value and growth | 500 |

### Where the hack do I get the symbol for my favorite stocks?!
The easiest way to get the symbol for your stock is to open [finance.yahoo.com](https://finance.yahoo.com) and use the search field on the top. You'll find the symbol either in the search preview or in the result page's URL (i.e. https://finance.yahoo.com/quote/BMW.DE?p=BMW.DE where BMW.DE would be the symbol).
33 changes: 30 additions & 3 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@
"showDepotGrowthPercent": {
"type": "boolean"
},
"showPortfolioValue": {
"type": "boolean"
},
"showPortfolioGrowth": {
"type": "boolean"
},
"showPortfolioGrowthPercent": {
"type": "boolean"
},
"virtualHorizontalMultiplier": {
"type": "integer"
}
Expand Down Expand Up @@ -228,20 +237,35 @@
"key": "MMM-Jast.config.showChangeValueCurrency",
"description": "Show currency for change value"
},
{
"title": "showPortfolioValue",
"key": "MMM-Jast.config.showPortfolioValue",
"description": "Show portfolio value"
},
{
"title": "showPortfolioGrowth",
"key": "MMM-Jast.config.showPortfolioGrowth",
"description": "Show portfolio value growth summary"
},
{
"title": "showPortfolioGrowthPercent",
"key": "MMM-Jast.config.showPortfolioGrowthPercent",
"description": "Show portfolio value growth summary in percent"
},
{
"title": "showDepot",
"key": "MMM-Jast.config.showDepot",
"description": "Show depot value"
"description": "[DEPRECATED] This property was replaced by 'showPortfolio'. This field should be set to false, as it will be removed in laters versions."
},
{
"title": "showDepotGrowth",
"key": "MMM-Jast.config.showDepotGrowth",
"description": "Show depot value growth summary"
"description": "[DEPRECATED] This property was replaced by 'showPortfolioGrowth'. This field should be set to false, as it will be removed in laters versions."
},
{
"title": "showDepotGrowthPercent",
"key": "MMM-Jast.config.showDepotGrowthPercent",
"description": "Show depot value growth summary in percent"
"description": "[DEPRECATED] This property was replaced by 'showPortfolioGrowthPercent'. This field should be set to false, as it will be removed in laters versions."
},
{
"title": "virtualHorizontalMultiplier",
Expand Down Expand Up @@ -303,6 +327,9 @@
"showDepot": false,
"showDepotGrowth": false,
"showDepotGrowthPercent": false,
"showPortfolioValue": false,
"showPortfolioGrowth": false,
"showPortfolioGrowthPercent": false,
"virtualHorizontalMultiplier": 2
}
}
Expand Down
86 changes: 45 additions & 41 deletions src/client/Client.ts
Original file line number Diff line number Diff line change
@@ -1,90 +1,94 @@
import Utils from "./Utils";
import { Config } from "../models/Config";
import Utils from './Utils'
import { Config } from '../models/Config'

Module.register("MMM-Jast", {
Module.register('MMM-Jast', {
defaults: {
locale: config.locale || "en-GB",
locale: config.locale || 'en-GB',
updateIntervalInSeconds: 600,
useGrouping: false,
currencyStyle: "code",
currencyStyle: 'code',
fadeSpeedInSeconds: 3.5, // Higher value: vertical -> faster // horizontal -> slower
stocks: [
{ name: "BASF", symbol: "BAS.DE", quantity: 100 },
{ name: "SAP", symbol: "SAP.DE", quantity: 200 },
{ name: "Henkel", symbol: "HEN3.DE" },
{ name: "AbbVie", symbol: "4AB.DE" },
{ name: "Bitcoin", symbol: "BTC-EUR" },
{ name: "Alibaba", symbol: "BABA" }
{ name: 'BASF', symbol: 'BAS.DE', quantity: 100 },
{ name: 'SAP', symbol: 'SAP.DE', quantity: 200 },
{ name: 'Henkel', symbol: 'HEN3.DE' },
{ name: 'AbbVie', symbol: '4AB.DE' },
{ name: 'Bitcoin', symbol: 'BTC-EUR' },
{ name: 'Alibaba', symbol: 'BABA' }
],
scroll: "vertical",
maxWidth: "100%",
scroll: 'vertical',
maxWidth: '100%',
numberDecimalsValues: 2,
numberDecimalsPercentages: 1,
showColors: true,
showCurrency: true,
showChangePercent: true,
showChangeValue: false,
showChangeValueCurrency: false,
showDepot: false,
showDepotGrowth: false,
showDepotGrowthPercent: false,
showPortfolioValue: false,
showPortfolioGrowth: false,
showPortfolioGrowthPercent: false,
virtualHorizontalMultiplier: 2
} as Config,

getStyles() {
return ["MMM-Jast.css"];
return ['MMM-Jast.css']
},

getTranslations() {
return {
en: "translations/en.json",
de: "translations/de.json"
};
en: 'translations/en.json',
de: 'translations/de.json'
}
},

getTemplate() {
return "templates/MMM-Jast.njk";
return 'templates/MMM-Jast.njk'
},

getTemplateData() {
const utils = new Utils(this.config);
const utils = new Utils(this.config)
return {
config: this.config,
stocks: this.stocks,
utils
};
}
},

start() {
// Config compatibility to older versions
this.config.showPortfolioValue = this.config.showDepot || this.config.showPortfolioValue
this.config.showPortfolioGrowth = this.config.showDepotGrowth || this.config.showPortfolioGrowth
this.config.showPortfolioGrowthPercent =
this.config.showDepotGrowthPercent || this.config.showPortfolioGrowthPercent

// Override defaults
this.nunjucksEnvironment().loaders[0].async = false;
this.nunjucksEnvironment().loaders[0].useCache = true;
this.stocks = [];
this.loadData();
this.scheduleUpdate();
this.updateDom();
this.nunjucksEnvironment().loaders[0].async = false
this.nunjucksEnvironment().loaders[0].useCache = true
this.stocks = []
this.loadData()
this.scheduleUpdate()
this.updateDom()
},

scheduleUpdate() {
const self = this;
const self = this
this.config.updateIntervalInSeconds =
this.config.updateIntervalInSeconds < 120
? 120
: this.config.updateIntervalInSeconds;
this.config.updateIntervalInSeconds < 120 ? 120 : this.config.updateIntervalInSeconds
setInterval(() => {
self.loadData();
}, this.config.updateIntervalInSeconds * 1000);
self.loadData()
}, this.config.updateIntervalInSeconds * 1000)
},

loadData() {
this.sendSocketNotification("GET_STOCKS", this.config);
this.sendSocketNotification('GET_STOCKS', this.config)
},

socketNotificationReceived(notificationIdentifier: string, payload: any) {
if (notificationIdentifier === "STOCKS_RESULT") {
this.stocks = payload;
this.updateDom();
console.debug("Stocks", this.stocks);
if (notificationIdentifier === 'STOCKS_RESULT') {
this.stocks = payload
this.updateDom()
console.debug('Stocks', this.stocks)
}
}
});
})
Loading

0 comments on commit 821b63b

Please sign in to comment.