-
-
Notifications
You must be signed in to change notification settings - Fork 592
feat(config): customizable dashboard texts #1235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,16 @@ import ( | |
) | ||
|
||
const ( | ||
defaultTitle = "Health Dashboard | Gatus" | ||
defaultDescription = "Gatus is an advanced automated status page that lets you monitor your applications and configure alerts to notify you if there's an issue" | ||
defaultHeader = "Gatus" | ||
defaultLogo = "" | ||
defaultLink = "" | ||
defaultCustomCSS = "" | ||
defaultSortBy = "name" | ||
defaultFilterBy = "none" | ||
defaultTitle = "Health Dashboard | Gatus" | ||
defaultDescription = "Gatus is an advanced automated status page that lets you monitor your applications and configure alerts to notify you if there's an issue" | ||
defaultHeader = "Gatus" | ||
defaultDashboardTitle = "Health Dashboard" | ||
defaultDashboardDescription = "Monitor the health of your endpoints in real-time" | ||
defaultLogo = "" | ||
defaultLink = "" | ||
defaultCustomCSS = "" | ||
defaultSortBy = "name" | ||
defaultFilterBy = "none" | ||
) | ||
|
||
var ( | ||
|
@@ -30,17 +32,18 @@ var ( | |
|
||
// Config is the configuration for the UI of Gatus | ||
type Config struct { | ||
Title string `yaml:"title,omitempty"` // Title of the page | ||
Description string `yaml:"description,omitempty"` // Meta description of the page | ||
Header string `yaml:"header,omitempty"` // Header is the text at the top of the page | ||
Logo string `yaml:"logo,omitempty"` // Logo to display on the page | ||
Link string `yaml:"link,omitempty"` // Link to open when clicking on the logo | ||
Buttons []Button `yaml:"buttons,omitempty"` // Buttons to display below the header | ||
CustomCSS string `yaml:"custom-css,omitempty"` // Custom CSS to include in the page | ||
DarkMode *bool `yaml:"dark-mode,omitempty"` // DarkMode is a flag to enable dark mode by default | ||
DefaultSortBy string `yaml:"default-sort-by,omitempty"` // DefaultSortBy is the default sort option ('name', 'group', 'health') | ||
DefaultFilterBy string `yaml:"default-filter-by,omitempty"` // DefaultFilterBy is the default filter option ('none', 'failing', 'unstable') | ||
|
||
Title string `yaml:"title,omitempty"` // Title of the page | ||
Description string `yaml:"description,omitempty"` // Meta description of the page | ||
DashboardTitle string `yaml:"dashboard-title,omitempty"` // Dashboard Title between header and endpoints | ||
DashboardDescription string `yaml:"dashboard-description,omitempty"` // Dashboard Description between header and endpoints | ||
Comment on lines
+37
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume the config should also reflect this naming? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe even creating an object called dashboard:
heading: asdf
subheading: hjkl There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to create a parent |
||
Header string `yaml:"header,omitempty"` // Header is the text at the top of the page | ||
Logo string `yaml:"logo,omitempty"` // Logo to display on the page | ||
Link string `yaml:"link,omitempty"` // Link to open when clicking on the logo | ||
Buttons []Button `yaml:"buttons,omitempty"` // Buttons to display below the header | ||
CustomCSS string `yaml:"custom-css,omitempty"` // Custom CSS to include in the page | ||
DarkMode *bool `yaml:"dark-mode,omitempty"` // DarkMode is a flag to enable dark mode by default | ||
DefaultSortBy string `yaml:"default-sort-by,omitempty"` // DefaultSortBy is the default sort option ('name', 'group', 'health') | ||
DefaultFilterBy string `yaml:"default-filter-by,omitempty"` // DefaultFilterBy is the default filter option ('none', 'failing', 'unstable') | ||
Comment on lines
+35
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same alignment comment here |
||
////////////////////////////////////////////// | ||
// Non-configurable - used for UI rendering // | ||
////////////////////////////////////////////// | ||
|
@@ -73,6 +76,8 @@ func GetDefaultConfig() *Config { | |
return &Config{ | ||
Title: defaultTitle, | ||
Description: defaultDescription, | ||
DashboardTitle: defaultDashboardTitle, | ||
DashboardDescription: defaultDashboardDescription, | ||
Header: defaultHeader, | ||
Logo: defaultLogo, | ||
Link: defaultLink, | ||
|
@@ -92,6 +97,12 @@ func (cfg *Config) ValidateAndSetDefaults() error { | |
if len(cfg.Description) == 0 { | ||
cfg.Description = defaultDescription | ||
} | ||
if len(cfg.DashboardTitle) == 0 { | ||
cfg.DashboardTitle = defaultDashboardTitle | ||
} | ||
if len(cfg.DashboardDescription) == 0 { | ||
cfg.DashboardDescription = defaultDashboardDescription | ||
} | ||
if len(cfg.Header) == 0 { | ||
cfg.Header = defaultHeader | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ func TestConfig_ValidateAndSetDefaults(t *testing.T) { | |
cfg := &Config{ | ||
Title: "", | ||
Description: "", | ||
DashboardTitle: "", | ||
DashboardDescription: "", | ||
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be aligned |
||
Header: "", | ||
Logo: "", | ||
Link: "", | ||
|
@@ -23,6 +25,12 @@ func TestConfig_ValidateAndSetDefaults(t *testing.T) { | |
if cfg.Description != defaultDescription { | ||
t.Errorf("expected description to be %s, got %s", defaultDescription, cfg.Description) | ||
} | ||
if cfg.DashboardTitle != defaultDashboardTitle { | ||
t.Errorf("expected DashboardTitle to be %s, got %s", defaultDashboardTitle, cfg.DashboardTitle) | ||
} | ||
if cfg.DashboardDescription != defaultDashboardDescription { | ||
t.Errorf("expected DashboardDescription to be %s, got %s", defaultDashboardDescription, cfg.DashboardDescription) | ||
} | ||
if cfg.Header != defaultHeader { | ||
t.Errorf("expected header to be %s, got %s", defaultHeader, cfg.Header) | ||
} | ||
|
@@ -78,6 +86,12 @@ func TestGetDefaultConfig(t *testing.T) { | |
if defaultConfig.Title != defaultTitle { | ||
t.Error("expected GetDefaultConfig() to return defaultTitle, got", defaultConfig.Title) | ||
} | ||
if defaultConfig.DashboardTitle != defaultDashboardTitle { | ||
t.Error("expected GetDefaultConfig() to return defaultDashboardTitle, got", defaultConfig.DashboardTitle) | ||
} | ||
if defaultConfig.DashboardDescription != defaultDashboardDescription { | ||
t.Error("expected GetDefaultConfig() to return defaultDashboardDescription, got", defaultConfig.DashboardDescription) | ||
} | ||
if defaultConfig.Logo != defaultLogo { | ||
t.Error("expected GetDefaultConfig() to return defaultLogo, got", defaultConfig.Logo) | ||
} | ||
|
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please align using spaces, not tabs.