mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-400 Move name and configKey values from widget to settings
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"github.com/wtfutil/wtf/cfg"
|
||||
)
|
||||
|
||||
const configKey = "bittrex"
|
||||
|
||||
type colors struct {
|
||||
base struct {
|
||||
name string
|
||||
@@ -24,11 +26,11 @@ type Settings struct {
|
||||
summary map[string]interface{}
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods.bittrex")
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods." + configKey)
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
|
||||
common: cfg.NewCommonSettingsFromYAML(name, configKey, ymlConfig),
|
||||
}
|
||||
|
||||
settings.colors.base.name = localConfig.UString("colors.base.name")
|
||||
|
||||
@@ -27,7 +27,7 @@ type Widget struct {
|
||||
// NewWidget Make new instance of widget
|
||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, "Bittrex", "bittrex", false),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common.Name, settings.common.ConfigKey, false),
|
||||
|
||||
settings: settings,
|
||||
summaryList: summaryList{},
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"github.com/wtfutil/wtf/cfg"
|
||||
)
|
||||
|
||||
const configKey = "blockfolio"
|
||||
|
||||
type colors struct {
|
||||
name string
|
||||
grows string
|
||||
@@ -19,11 +21,11 @@ type Settings struct {
|
||||
displayHoldings bool
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods.blockfolio")
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods." + configKey)
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
|
||||
common: cfg.NewCommonSettingsFromYAML(name, configKey, ymlConfig),
|
||||
|
||||
deviceToken: localConfig.UString("device_token"),
|
||||
displayHoldings: localConfig.UBool("displayHoldings", true),
|
||||
|
||||
@@ -20,7 +20,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, "Blockfolio", "blockfolio", false),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common.Name, settings.common.ConfigKey, false),
|
||||
|
||||
device_token: settings.deviceToken,
|
||||
settings: settings,
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"github.com/wtfutil/wtf/cfg"
|
||||
)
|
||||
|
||||
const configKey = "price"
|
||||
|
||||
type colors struct {
|
||||
from struct {
|
||||
name string
|
||||
@@ -34,14 +36,14 @@ type Settings struct {
|
||||
top map[string]interface{}
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods.cryptolive")
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods." + configKey)
|
||||
|
||||
currencies, _ := localConfig.Map("currencies")
|
||||
top, _ := localConfig.Map("top")
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
|
||||
common: cfg.NewCommonSettingsFromYAML(name, configKey, ymlConfig),
|
||||
currencies: currencies,
|
||||
top: top,
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"github.com/wtfutil/wtf/modules/cryptoexchanges/cryptolive/toplist"
|
||||
)
|
||||
|
||||
const configKey = "cryptolive"
|
||||
|
||||
type colors struct {
|
||||
from struct {
|
||||
name string
|
||||
@@ -31,7 +33,8 @@ type colors struct {
|
||||
|
||||
type Settings struct {
|
||||
colors
|
||||
common *cfg.Common
|
||||
common *cfg.Common
|
||||
|
||||
currencies map[string]interface{}
|
||||
top map[string]interface{}
|
||||
|
||||
@@ -39,19 +42,20 @@ type Settings struct {
|
||||
toplistSettings *toplist.Settings
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods.cryptolive")
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods." + configKey)
|
||||
|
||||
currencies, _ := localConfig.Map("currencies")
|
||||
top, _ := localConfig.Map("top")
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
|
||||
common: cfg.NewCommonSettingsFromYAML(name, configKey, ymlConfig),
|
||||
|
||||
currencies: currencies,
|
||||
top: top,
|
||||
|
||||
priceSettings: price.NewSettingsFromYAML(ymlConfig),
|
||||
toplistSettings: toplist.NewSettingsFromYAML(ymlConfig),
|
||||
priceSettings: price.NewSettingsFromYAML(name, ymlConfig),
|
||||
toplistSettings: toplist.NewSettingsFromYAML(name, ymlConfig),
|
||||
}
|
||||
|
||||
settings.colors.from.name = localConfig.UString("colors.from.name")
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"github.com/wtfutil/wtf/cfg"
|
||||
)
|
||||
|
||||
const configKey = "toplist"
|
||||
|
||||
type colors struct {
|
||||
from struct {
|
||||
name string
|
||||
@@ -34,14 +36,14 @@ type Settings struct {
|
||||
top map[string]interface{}
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods.cryptolive")
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
|
||||
localConfig, _ := ymlConfig.Get("wtf.mods." + configKey)
|
||||
|
||||
currencies, _ := localConfig.Map("currencies")
|
||||
top, _ := localConfig.Map("top")
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
|
||||
common: cfg.NewCommonSettingsFromYAML(name, configKey, ymlConfig),
|
||||
currencies: currencies,
|
||||
top: top,
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ type Widget struct {
|
||||
// NewWidget Make new instance of widget
|
||||
func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(app, "CryptoLive", "cryptolive", false),
|
||||
TextWidget: wtf.NewTextWidget(app, settings.common.Name, settings.common.ConfigKey, false),
|
||||
|
||||
priceWidget: price.NewWidget(settings.priceSettings),
|
||||
toplistWidget: toplist.NewWidget(settings.toplistSettings),
|
||||
|
||||
Reference in New Issue
Block a user