mirror of
https://github.com/prometheus/alertmanager
synced 2025-01-31 18:51:53 +00:00
Merge pull request #847 from mxinden/serve-libs
Serve FontAwesome & Bootstrap ourself
This commit is contained in:
commit
d383ab0d91
7
Makefile
7
Makefile
@ -60,7 +60,12 @@ assets:
|
|||||||
-@$(GO) get -u github.com/jteeuwen/go-bindata/...
|
-@$(GO) get -u github.com/jteeuwen/go-bindata/...
|
||||||
# Using "-mode 420" and "-modtime 1" to make assets make target deterministic.
|
# Using "-mode 420" and "-modtime 1" to make assets make target deterministic.
|
||||||
# It sets all file permissions and time stamps to 420 and 1
|
# It sets all file permissions and time stamps to 420 and 1
|
||||||
@go-bindata $(bindata_flags) -mode 420 -modtime 1 -pkg ui -o ui/bindata.go ui/app/script.js ui/app/index.html ui/app/favicon.ico
|
@go-bindata $(bindata_flags) -mode 420 -modtime 1 -pkg ui -o \
|
||||||
|
ui/bindata.go ui/app/script.js \
|
||||||
|
ui/app/index.html \
|
||||||
|
ui/app/favicon.ico \
|
||||||
|
ui/lib/...
|
||||||
|
|
||||||
@go-bindata $(bindata_flags) -mode 420 -modtime 1 -pkg deftmpl -o template/internal/deftmpl/bindata.go template/default.tmpl
|
@go-bindata $(bindata_flags) -mode 420 -modtime 1 -pkg deftmpl -o template/internal/deftmpl/bindata.go template/default.tmpl
|
||||||
|
|
||||||
promu:
|
promu:
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<title>Alertmanager</title>
|
<title>Alertmanager</title>
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
|
|
||||||
<script src="https://use.fontawesome.com/b7508bb100.js"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
|
@ -66,7 +66,13 @@ init flags location =
|
|||||||
if prod then
|
if prod then
|
||||||
Api.makeApiUrl location.pathname
|
Api.makeApiUrl location.pathname
|
||||||
else
|
else
|
||||||
Api.makeApiUrl "http://localhost:9093"
|
Api.makeApiUrl "http://localhost:9093/"
|
||||||
|
|
||||||
|
libUrl =
|
||||||
|
if prod then
|
||||||
|
location.pathname
|
||||||
|
else
|
||||||
|
"http://localhost:9093/"
|
||||||
in
|
in
|
||||||
update (urlUpdate location)
|
update (urlUpdate location)
|
||||||
(Model
|
(Model
|
||||||
@ -79,6 +85,8 @@ init flags location =
|
|||||||
initStatusModel
|
initStatusModel
|
||||||
location.pathname
|
location.pathname
|
||||||
apiUrl
|
apiUrl
|
||||||
|
libUrl
|
||||||
|
Loading
|
||||||
Loading
|
Loading
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +20,9 @@ type alias Model =
|
|||||||
, status : StatusModel
|
, status : StatusModel
|
||||||
, basePath : String
|
, basePath : String
|
||||||
, apiUrl : String
|
, apiUrl : String
|
||||||
|
, libUrl : String
|
||||||
, bootstrapCSS : ApiData String
|
, bootstrapCSS : ApiData String
|
||||||
|
, fontAwesomeCSS : ApiData String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -42,6 +44,7 @@ type Msg
|
|||||||
| RedirectAlerts
|
| RedirectAlerts
|
||||||
| UpdateFilter String
|
| UpdateFilter String
|
||||||
| BootstrapCSSLoaded (ApiData String)
|
| BootstrapCSSLoaded (ApiData String)
|
||||||
|
| FontAwesomeCSSLoaded (ApiData String)
|
||||||
|
|
||||||
|
|
||||||
type Route
|
type Route
|
||||||
|
@ -129,3 +129,6 @@ update msg ({ basePath, apiUrl } as model) =
|
|||||||
|
|
||||||
BootstrapCSSLoaded css ->
|
BootstrapCSSLoaded css ->
|
||||||
( { model | bootstrapCSS = css }, Cmd.none )
|
( { model | bootstrapCSS = css }, Cmd.none )
|
||||||
|
|
||||||
|
FontAwesomeCSSLoaded css ->
|
||||||
|
( { model | fontAwesomeCSS = css }, Cmd.none )
|
||||||
|
@ -4,7 +4,7 @@ import Html exposing (Html, node, text, div)
|
|||||||
import Html.Attributes exposing (class, rel, href, src, style)
|
import Html.Attributes exposing (class, rel, href, src, style)
|
||||||
import Html.Events exposing (on)
|
import Html.Events exposing (on)
|
||||||
import Json.Decode exposing (succeed)
|
import Json.Decode exposing (succeed)
|
||||||
import Types exposing (Msg(MsgForSilenceForm, MsgForSilenceView, BootstrapCSSLoaded), Model, Route(..))
|
import Types exposing (Msg(MsgForSilenceForm, MsgForSilenceView, BootstrapCSSLoaded, FontAwesomeCSSLoaded), Model, Route(..))
|
||||||
import Utils.Views exposing (error, loading)
|
import Utils.Views exposing (error, loading)
|
||||||
import Utils.Types exposing (ApiData(Failure, Success))
|
import Utils.Types exposing (ApiData(Failure, Success))
|
||||||
import Views.SilenceList.Views as SilenceList
|
import Views.SilenceList.Views as SilenceList
|
||||||
@ -19,42 +19,49 @@ import Views.NavBar.Views exposing (navBar)
|
|||||||
view : Model -> Html Msg
|
view : Model -> Html Msg
|
||||||
view model =
|
view model =
|
||||||
div []
|
div []
|
||||||
[ renderLink "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"
|
[ renderCSS model.libUrl
|
||||||
, fontAwesome
|
, case ( model.bootstrapCSS, model.fontAwesomeCSS ) of
|
||||||
, case model.bootstrapCSS of
|
( Success _, Success _ ) ->
|
||||||
Success _ ->
|
|
||||||
div []
|
div []
|
||||||
[ navBar model.route
|
[ navBar model.route
|
||||||
, div [ class "container pb-4" ] [ currentView model ]
|
, div [ class "container pb-4" ] [ currentView model ]
|
||||||
]
|
]
|
||||||
|
|
||||||
Failure err ->
|
( Failure err, _ ) ->
|
||||||
div []
|
failureView model err
|
||||||
[ div [ style [ ( "padding", "40px" ), ( "color", "red" ) ] ] [ text err ]
|
|
||||||
, navBar model.route
|
( _, Failure err ) ->
|
||||||
, div [ class "container pb-4" ] [ currentView model ]
|
failureView model err
|
||||||
]
|
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
text ""
|
text ""
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
renderLink : String -> Html Msg
|
failureView : Model -> String -> Html Msg
|
||||||
renderLink url =
|
failureView model err =
|
||||||
|
div []
|
||||||
|
[ div [ style [ ( "padding", "40px" ), ( "color", "red" ) ] ] [ text err ]
|
||||||
|
, navBar model.route
|
||||||
|
, div [ class "container pb-4" ] [ currentView model ]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
renderCSS : String -> Html Msg
|
||||||
|
renderCSS assetsUrl =
|
||||||
|
div []
|
||||||
|
[ cssNode (assetsUrl ++ "lib/bootstrap-4.0.0-alpha.6-dist/css/bootstrap.min.css") BootstrapCSSLoaded
|
||||||
|
, cssNode (assetsUrl ++ "lib/font-awesome-4.7.0/css/font-awesome.min.css") FontAwesomeCSSLoaded
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
cssNode : String -> (ApiData String -> Msg) -> Html Msg
|
||||||
|
cssNode url msg =
|
||||||
node "link"
|
node "link"
|
||||||
[ href url
|
[ href url
|
||||||
, rel "stylesheet"
|
, rel "stylesheet"
|
||||||
, on "load" (succeed (BootstrapCSSLoaded (Success url)))
|
, on "load" (succeed (msg (Success url)))
|
||||||
, on "error" (succeed (BootstrapCSSLoaded (Failure ("Failed to load Bootstrap CSS from: " ++ url))))
|
, on "error" (succeed (msg (Failure ("Failed to load CSS from: " ++ url))))
|
||||||
]
|
|
||||||
[]
|
|
||||||
|
|
||||||
|
|
||||||
fontAwesome : Html msg
|
|
||||||
fontAwesome =
|
|
||||||
node "script"
|
|
||||||
[ src "https://use.fontawesome.com/b7508bb100.js"
|
|
||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
|
|
||||||
|
250
ui/bindata.go
250
ui/bindata.go
File diff suppressed because one or more lines are too long
6
ui/lib/bootstrap-4.0.0-alpha.6-dist/css/bootstrap.min.css
vendored
Normal file
6
ui/lib/bootstrap-4.0.0-alpha.6-dist/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2337
ui/lib/font-awesome-4.7.0/css/font-awesome.css
vendored
Normal file
2337
ui/lib/font-awesome-4.7.0/css/font-awesome.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
ui/lib/font-awesome-4.7.0/css/font-awesome.min.css
vendored
Normal file
4
ui/lib/font-awesome-4.7.0/css/font-awesome.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
ui/lib/font-awesome-4.7.0/fonts/FontAwesome.otf
Normal file
BIN
ui/lib/font-awesome-4.7.0/fonts/FontAwesome.otf
Normal file
Binary file not shown.
BIN
ui/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.eot
Normal file
BIN
ui/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.eot
Normal file
Binary file not shown.
2671
ui/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.svg
Normal file
2671
ui/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.svg
Normal file
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 434 KiB |
BIN
ui/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf
Normal file
BIN
ui/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf
Normal file
Binary file not shown.
BIN
ui/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff
Normal file
BIN
ui/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff
Normal file
Binary file not shown.
BIN
ui/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff2
Normal file
BIN
ui/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff2
Normal file
Binary file not shown.
@ -18,6 +18,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof" // Comment this line to disable pprof endpoint.
|
_ "net/http/pprof" // Comment this line to disable pprof endpoint.
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/common/log"
|
"github.com/prometheus/common/log"
|
||||||
@ -62,6 +63,13 @@ func Register(r *route.Router, reloadCh chan<- struct{}) {
|
|||||||
serveAsset(w, req, "ui/app/favicon.ico")
|
serveAsset(w, req, "ui/app/favicon.ico")
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
r.Get("/lib/*filepath", ihf("lib_files",
|
||||||
|
func(w http.ResponseWriter, req *http.Request) {
|
||||||
|
fp := route.Param(req.Context(), "filepath")
|
||||||
|
serveAsset(w, req, filepath.Join("ui/lib", fp))
|
||||||
|
},
|
||||||
|
))
|
||||||
|
|
||||||
r.Post("/-/reload", func(w http.ResponseWriter, req *http.Request) {
|
r.Post("/-/reload", func(w http.ResponseWriter, req *http.Request) {
|
||||||
w.Write([]byte("Reloading configuration file..."))
|
w.Write([]byte("Reloading configuration file..."))
|
||||||
reloadCh <- struct{}{}
|
reloadCh <- struct{}{}
|
||||||
|
Loading…
Reference in New Issue
Block a user