Skip to content

Commit 24282df

Browse files
committed
Customization of background and branding images
1 parent b0131ff commit 24282df

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

cmd/admin/main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,21 @@ func osctrlAdminService() {
356356
adminMux.HandleFunc("GET "+faviconPath, handlersAdmin.FaviconHandler)
357357
// Admin: static
358358
adminMux.Handle("GET /static/", http.StripPrefix("/static", http.FileServer(http.Dir(flagParams.StaticFiles))))
359-
359+
// Admin: background image
360+
adminMux.HandleFunc("GET /background.png", func(w http.ResponseWriter, r *http.Request) {
361+
http.ServeFile(w, r, flagParams.BackgroundImage)
362+
})
360363
// ///////////////////////// AUTHENTICATED CONTENT
364+
// Admin: branding image
365+
adminMux.Handle(
366+
"GET /branding.png",
367+
handlerAuthCheck(
368+
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
369+
http.ServeFile(w, r, flagParams.BrandingImage)
370+
}),
371+
flagParams.ConfigValues.Auth,
372+
),
373+
)
361374
// Admin: JSON data for environments
362375
adminMux.Handle(
363376
"GET /json/environment/{env}/{target}",

cmd/admin/static/css/custom.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717

1818
.navbar-brand {
19-
background-image: url("/static/img/brand.png");
19+
background-image: url("/branding.png");
2020
background-position: 50% 50%;
2121
background-repeat: no-repeat;
2222
background-size: 100%;
@@ -69,7 +69,7 @@ input[type=text]#carve {
6969

7070
body {
7171
font-family: 'Bai Jamjuree', sans-serif;
72-
background-image: url("/static/img/circuit.svg");
72+
background-image: url("/background.png");
7373
background-attachment: fixed;
7474
}
7575

pkg/config/flags.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ const (
3737
defTemplatesFolder string = "./tmpl_admin"
3838
// Default carved files folder
3939
defCarvedFolder string = "./carved_files/"
40+
// Default background image file
41+
defBackgroundImageFile string = defStaticFilesFolder + "/img/circuit.svg"
42+
// Default branding image file
43+
defBrandingImageFile string = defStaticFilesFolder + "/img/brand.png"
4044
// Default DB configuration file
4145
defDBConfigurationFile string = "config/db.json"
4246
// Default redis configuration file
@@ -97,6 +101,10 @@ type ServiceFlagParams struct {
97101
CarvedDir string
98102
// Optimize UI
99103
OptimizeUI bool
104+
// Branding image file
105+
BrandingImage string
106+
// Background image file
107+
BackgroundImage string
100108

101109
// Debug HTTP configuration values
102110
DebugHTTPValues DebugHTTPConfiguration
@@ -818,6 +826,22 @@ func initAdminFlags(params *ServiceFlagParams) []cli.Flag {
818826
EnvVars: []string{"OPTIMIZE_UI"},
819827
Destination: &params.OptimizeUI,
820828
},
829+
&cli.StringFlag{
830+
Name: "background-image",
831+
Aliases: []string{"bg-img", "background"},
832+
Value: defBackgroundImageFile,
833+
Usage: "Background image file for all the pages in the osctrl-admin UI",
834+
EnvVars: []string{"BACKGROUND_IMAGE"},
835+
Destination: &params.BackgroundImage,
836+
},
837+
&cli.StringFlag{
838+
Name: "branding-image",
839+
Aliases: []string{"brand-img", "branding"},
840+
Value: defBrandingImageFile,
841+
Usage: "Branding image file for the osctrl-admin UI. Use an image with 450x130 pixels for best results.",
842+
EnvVars: []string{"BRANDING_IMAGE"},
843+
Destination: &params.BrandingImage,
844+
},
821845
}
822846
}
823847

pkg/config/types.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,13 @@ type YAMLConfigurationCarver struct {
199199

200200
// YAMLConfigurationAdmin to hold admin UI specific configuration values
201201
type YAMLConfigurationAdmin struct {
202-
SessionKey string `yaml:"sessionKey"`
203-
StaticDir string `yaml:"staticDir"`
204-
StaticOffline bool `yaml:"keyFile"`
205-
TemplatesDir string `yaml:"templatesDir"`
206-
OptimizeUI bool `yaml:"optimizeUI"`
202+
SessionKey string `yaml:"sessionKey"`
203+
StaticDir string `yaml:"staticDir"`
204+
StaticOffline bool `yaml:"keyFile"`
205+
TemplatesDir string `yaml:"templatesDir"`
206+
OptimizeUI bool `yaml:"optimizeUI"`
207+
BrandingImage string `yaml:"brandingImage"`
208+
BackgroundImage string `yaml:"backgroundImage"`
207209
}
208210

209211
// YAMLConfigurationDebug to hold the debug configuration values

0 commit comments

Comments
 (0)