diff --git a/web/landing_page.css b/web/landing_page.css index cc939eaf..748c821a 100644 --- a/web/landing_page.css +++ b/web/landing_page.css @@ -5,9 +5,13 @@ body { header { background-color: {{.HeaderColor}}; color: #fff; - font-size: 2rem; + font-size: 1rem; padding: 1rem; } main { padding: 1rem; } +label { + display: inline-block; + width: {{.Form.Width}}em; +} diff --git a/web/landing_page.go b/web/landing_page.go index 61e21283..c755372c 100644 --- a/web/landing_page.go +++ b/web/landing_page.go @@ -31,10 +31,27 @@ type LandingConfig struct { CSS string // CSS style tag for the landing page. Name string // The name of the exporter, generally suffixed by _exporter. Description string // A short description about the exporter. + Form LandingForm // A POST form. Links []LandingLinks // Links displayed on the landing page. Version string // The version displayed. } +// LandingForm provides a configuration struct for creating a POST form on the landing page. +type LandingForm struct { + Action string + Inputs []LandingFormInput + Width float64 +} + +// LandingFormInput represents a single form input field. +type LandingFormInput struct { + Label string + Type string + Name string + Placeholder string + Value string +} + type LandingLinks struct { Address string // The URL the link points to. Text string // The text of the link. @@ -54,6 +71,15 @@ var ( func NewLandingPage(c LandingConfig) (*LandingPageHandler, error) { var buf bytes.Buffer + + length := 0 + for _, input := range c.Form.Inputs { + inputLength := len(input.Label) + if inputLength > length { + length = inputLength + } + } + c.Form.Width = (float64(length) + 1) / 2 if c.CSS == "" { if c.HeaderColor == "" { // Default to Prometheus orange. diff --git a/web/landing_page.html b/web/landing_page.html index 68c40170..bc67d759 100644 --- a/web/landing_page.html +++ b/web/landing_page.html @@ -19,6 +19,16 @@