feat(ui): Make logo link and header configurable

Closes #213
This commit is contained in:
TwiN
2022-01-08 14:55:40 -05:00
parent 0e586e4152
commit fc016bd682
9 changed files with 53 additions and 20 deletions

View File

@ -6,8 +6,10 @@ import (
)
const (
defaultTitle = "Health Dashboard | Gatus"
defaultLogo = ""
defaultTitle = "Health Dashboard | Gatus"
defaultHeader = "Health Status"
defaultLogo = ""
defaultLink = ""
)
var (
@ -18,15 +20,19 @@ var (
// Config is the configuration for the UI of Gatus
type Config struct {
Title string `yaml:"title"` // Title of the page
Logo string `yaml:"logo"` // Logo to display on the page
Title string `yaml:"title,omitempty"` // Title 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
}
// GetDefaultConfig returns a Config struct with the default values
func GetDefaultConfig() *Config {
return &Config{
Title: defaultTitle,
Logo: defaultLogo,
Title: defaultTitle,
Header: defaultHeader,
Logo: defaultLogo,
Link: defaultLink,
}
}
@ -35,6 +41,12 @@ func (cfg *Config) ValidateAndSetDefaults() error {
if len(cfg.Title) == 0 {
cfg.Title = defaultTitle
}
if len(cfg.Header) == 0 {
cfg.Header = defaultHeader
}
if len(cfg.Header) == 0 {
cfg.Header = defaultLink
}
t, err := template.ParseFiles(StaticFolder + "/index.html")
if err != nil {
return err