diff --git a/assets/svgload.svg b/assets/svgload.svg new file mode 100644 index 0000000..22ebe15 --- /dev/null +++ b/assets/svgload.svg @@ -0,0 +1,13 @@ + diff --git a/assets/websocket.js b/assets/websocket.js new file mode 100644 index 0000000..30d26b0 --- /dev/null +++ b/assets/websocket.js @@ -0,0 +1,16 @@ +window.addEventListener("load", function(evt) { + var ws; + var loc = window.location, new_uri; + if (loc.protocol === "https:") { + new_uri = "wss:"; + } else { + new_uri = "ws:"; + } + new_uri += "//" + loc.host + "/ws"; + ws = new WebSocket(new_uri); + ws.onmessage = function(evt) { + // there should be a check for the message + // content, but it is not needed for now + location.reload(); + } +}); diff --git a/cmd/ginvalid/main.go b/cmd/ginvalid/main.go index 2fce12e..c20c0e7 100644 --- a/cmd/ginvalid/main.go +++ b/cmd/ginvalid/main.go @@ -46,6 +46,7 @@ func registerRoutes(r *mux.Router) { r.HandleFunc("/results/{validator}/{user}/{repo}", web.Results).Methods("GET") r.HandleFunc("/results/{validator}/{user}/{repo}/{id}", web.Results).Methods("GET") r.HandleFunc("/login", web.LoginGet).Methods("GET") + r.HandleFunc("/ws", web.WebSocket) r.HandleFunc("/login", web.LoginPost).Methods("POST") r.HandleFunc("/logout", web.Logout).Methods("GET") r.HandleFunc("/repos", web.ListRepos).Methods("GET") diff --git a/go.mod b/go.mod index 0cedd60..9ce8abc 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/google/uuid v1.1.1 github.com/gorilla/handlers v1.4.2 github.com/gorilla/mux v1.7.3 + github.com/gorilla/websocket v1.5.0 // indirect github.com/magiconair/properties v1.8.1 // indirect github.com/mattn/go-colorable v0.1.4 // indirect github.com/mattn/go-isatty v0.0.10 // indirect diff --git a/go.sum b/go.sum index ce3b556..4ac9826 100644 --- a/go.sum +++ b/go.sum @@ -60,6 +60,8 @@ github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/ github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= diff --git a/internal/resources/templates/generic_results.go b/internal/resources/templates/generic_results.go index fefaefd..c160840 100644 --- a/internal/resources/templates/generic_results.go +++ b/internal/resources/templates/generic_results.go @@ -37,6 +37,11 @@ const GenericResults = ` {{ end }}
{{.Content}}diff --git a/internal/resources/templates/layout.go b/internal/resources/templates/layout.go index 86a0d91..66a128b 100644 --- a/internal/resources/templates/layout.go +++ b/internal/resources/templates/layout.go @@ -15,6 +15,7 @@ var Layout = ` +