mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Simplify the inclusion of the Common config settings into each module
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
@@ -41,13 +41,13 @@ func (widget *Widget) getSystemInfo() string {
|
||||
}{
|
||||
{
|
||||
name: "name:",
|
||||
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.Name),
|
||||
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, info.Name),
|
||||
}, {
|
||||
name: "version:",
|
||||
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.ServerVersion),
|
||||
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, info.ServerVersion),
|
||||
}, {
|
||||
name: "root:",
|
||||
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, info.DockerRootDir),
|
||||
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, info.DockerRootDir),
|
||||
},
|
||||
{
|
||||
name: "containers:",
|
||||
@@ -57,15 +57,15 @@ func (widget *Widget) getSystemInfo() string {
|
||||
},
|
||||
{
|
||||
name: "images:",
|
||||
value: fmt.Sprintf("[%s]%d", widget.settings.common.Colors.RowTheme.EvenForeground, info.Images),
|
||||
value: fmt.Sprintf("[%s]%d", widget.settings.Colors.RowTheme.EvenForeground, info.Images),
|
||||
},
|
||||
{
|
||||
name: "volumes:",
|
||||
value: fmt.Sprintf("[%s]%v", widget.settings.common.Colors.RowTheme.EvenForeground, len(diskUsage.Volumes)),
|
||||
value: fmt.Sprintf("[%s]%v", widget.settings.Colors.RowTheme.EvenForeground, len(diskUsage.Volumes)),
|
||||
},
|
||||
{
|
||||
name: "memory limit:",
|
||||
value: fmt.Sprintf("[%s]%s", widget.settings.common.Colors.RowTheme.EvenForeground, humanize.Bytes(uint64(info.MemTotal))),
|
||||
value: fmt.Sprintf("[%s]%s", widget.settings.Colors.RowTheme.EvenForeground, humanize.Bytes(uint64(info.MemTotal))),
|
||||
},
|
||||
{
|
||||
name: "disk usage:",
|
||||
@@ -76,19 +76,19 @@ func (widget *Widget) getSystemInfo() string {
|
||||
[%s]* [::b]total: [%s]%s[::-]
|
||||
`,
|
||||
widget.settings.labelColor,
|
||||
widget.settings.common.Colors.RowTheme.EvenForeground,
|
||||
widget.settings.Colors.RowTheme.EvenForeground,
|
||||
humanize.Bytes(uint64(duContainer)),
|
||||
|
||||
widget.settings.labelColor,
|
||||
widget.settings.common.Colors.RowTheme.EvenForeground,
|
||||
widget.settings.Colors.RowTheme.EvenForeground,
|
||||
humanize.Bytes(uint64(duImg)),
|
||||
|
||||
widget.settings.labelColor,
|
||||
widget.settings.common.Colors.RowTheme.EvenForeground,
|
||||
widget.settings.Colors.RowTheme.EvenForeground,
|
||||
humanize.Bytes(uint64(duVol)),
|
||||
|
||||
widget.settings.labelColor,
|
||||
widget.settings.common.Colors.RowTheme.EvenForeground,
|
||||
widget.settings.Colors.RowTheme.EvenForeground,
|
||||
humanize.Bytes(uint64(duContainer+duImg+duVol))),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -12,14 +12,15 @@ const (
|
||||
|
||||
// Settings defines the configuration options for this module
|
||||
type Settings struct {
|
||||
common *cfg.Common
|
||||
*cfg.Common
|
||||
|
||||
labelColor string
|
||||
}
|
||||
|
||||
// NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||
labelColor: ymlConfig.UString("labelColor", "white"),
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: view.NewTextWidget(app, pages, settings.common),
|
||||
TextWidget: view.NewTextWidget(app, pages, settings.Common),
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ func (widget *Widget) refreshDisplayBuffer() {
|
||||
|
||||
widget.displayBuffer = ""
|
||||
|
||||
widget.displayBuffer += fmt.Sprintf("[%s] System[white]\n", widget.settings.common.Colors.Subheading)
|
||||
widget.displayBuffer += fmt.Sprintf("[%s] System[white]\n", widget.settings.Colors.Subheading)
|
||||
widget.displayBuffer += widget.getSystemInfo()
|
||||
|
||||
widget.displayBuffer += "\n"
|
||||
|
||||
widget.displayBuffer += fmt.Sprintf("[%s] Containers[white]\n", widget.settings.common.Colors.Subheading)
|
||||
widget.displayBuffer += fmt.Sprintf("[%s] Containers[white]\n", widget.settings.Colors.Subheading)
|
||||
widget.displayBuffer += widget.getContainerStates()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user