diff options
| author | Taras Madan <tarasmadan@google.com> | 2025-01-29 10:06:00 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-01-31 14:06:26 +0000 |
| commit | aa47157c8ec3df5a6d16e3866b095c8f91026465 (patch) | |
| tree | ba6846ab62f0863d4e1b3294577563e4fffd35a3 /dashboard/app | |
| parent | 4c6ac32f33aa00c680c8f4656d1fbf2887f390f1 (diff) | |
dashboard/app: change coverage links
It will simplify the json API links.
Diffstat (limited to 'dashboard/app')
| -rw-r--r-- | dashboard/app/coverage_test.go | 6 | ||||
| -rw-r--r-- | dashboard/app/main.go | 15 | ||||
| -rw-r--r-- | dashboard/app/templates/templates.html | 8 |
3 files changed, 19 insertions, 10 deletions
diff --git a/dashboard/app/coverage_test.go b/dashboard/app/coverage_test.go index ef8321c9f..c4945ab09 100644 --- a/dashboard/app/coverage_test.go +++ b/dashboard/app/coverage_test.go @@ -29,7 +29,7 @@ func TestFileCoverage(t *testing.T) { name: "empty db", covDB: func(t *testing.T) spannerclient.SpannerClient { return emptyCoverageDBFixture(t, 1) }, fileProv: func(t *testing.T) covermerger.FileVersProvider { return staticFileProvider(t) }, - url: "/test2/graph/coverage/file?dateto=2025-01-31&period=month" + + url: "/test2/coverage/file?dateto=2025-01-31&period=month" + "&commit=c0e75905caf368e19aab585d20151500e750de89&filepath=virt/kvm/kvm_main.c", wantInRes: []string{"1 line1"}, }, @@ -37,7 +37,7 @@ func TestFileCoverage(t *testing.T) { name: "regular db", covDB: func(t *testing.T) spannerclient.SpannerClient { return coverageDBFixture(t) }, fileProv: func(t *testing.T) covermerger.FileVersProvider { return staticFileProvider(t) }, - url: "/test2/graph/coverage/file?dateto=2025-01-31&period=month" + + url: "/test2/coverage/file?dateto=2025-01-31&period=month" + "&commit=c0e75905caf368e19aab585d20151500e750de89&filepath=virt/kvm/kvm_main.c", wantInRes: []string{ "4 1 line1", @@ -48,7 +48,7 @@ func TestFileCoverage(t *testing.T) { name: "multimanager db", covDB: func(t *testing.T) spannerclient.SpannerClient { return multiManagerCovDBFixture(t) }, fileProv: func(t *testing.T) covermerger.FileVersProvider { return staticFileProvider(t) }, - url: "/test2/graph/coverage/file?dateto=2025-01-31&period=month" + + url: "/test2/coverage/file?dateto=2025-01-31&period=month" + "&commit=c0e75905caf368e19aab585d20151500e750de89&filepath=virt/kvm/kvm_main.c" + "&manager=special-cc-manager&unique-only=1", wantInRes: []string{ diff --git a/dashboard/app/main.go b/dashboard/app/main.go index 071dc8544..93ee73c00 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -65,11 +65,14 @@ func initHTTPHandlers() { http.Handle("/"+ns+"/graph/fuzzing", handlerWrapper(handleGraphFuzzing)) http.Handle("/"+ns+"/graph/crashes", handlerWrapper(handleGraphCrashes)) http.Handle("/"+ns+"/graph/found-bugs", handlerWrapper(handleFoundBugsGraph)) - http.Handle("/"+ns+"/graph/coverage/file", handlerWrapper(handleFileCoverage)) http.Handle("/"+ns+"/graph/coverage", handlerWrapper(handleCoverageGraph)) - http.Handle("/"+ns+"/graph/coverage_heatmap", handlerWrapper(handleCoverageHeatmap)) + http.Handle("/"+ns+"/coverage/file", handlerWrapper(handleFileCoverage)) + http.Handle("/"+ns+"/coverage", handlerWrapper(handleCoverageHeatmap)) + http.Handle("/"+ns+"/graph/coverage_heatmap", handleMovedPermanently("/"+ns+"/coverage")) if nsConfig.Subsystems.Service != nil { - http.Handle("/"+ns+"/graph/coverage_subsystems_heatmap", handlerWrapper(handleSubsystemsCoverageHeatmap)) + http.Handle("/"+ns+"/graph/coverage_subsystems_heatmap", + handleMovedPermanently("/"+ns+"/coverage/subsystems")) + http.Handle("/"+ns+"/coverage/subsystems", handlerWrapper(handleSubsystemsCoverageHeatmap)) } http.Handle("/"+ns+"/repos", handlerWrapper(handleRepos)) http.Handle("/"+ns+"/bug-summaries", handlerWrapper(handleBugSummaries)) @@ -85,6 +88,12 @@ func initHTTPHandlers() { http.HandleFunc("/cron/subsystem_reports", handleSubsystemReports) } +func handleMovedPermanently(dest string) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, dest, http.StatusMovedPermanently) + } +} + type uiMainPage struct { Header *uiHeader Now time.Time diff --git a/dashboard/app/templates/templates.html b/dashboard/app/templates/templates.html index 0f859f715..bcf1551fa 100644 --- a/dashboard/app/templates/templates.html +++ b/dashboard/app/templates/templates.html @@ -106,11 +106,11 @@ Use of this source code is governed by Apache 2 LICENSE that can be found in the <div class="dropdown-content"> <a class="navigation_tab{{if eq .URLPath (printf "/%v/graph/coverage" $.Namespace)}}_selected{{end}}" href="/{{$.Namespace}}/graph/coverage?period=quarter">Total</a> - <a class="navigation_tab{{if eq .URLPath (printf "/%v/graph/coverage_heatmap" $.Namespace)}}_selected{{end}}" - href="/{{$.Namespace}}/graph/coverage_heatmap?period=month">Repo Heatmap</a> + <a class="navigation_tab{{if eq .URLPath (printf "/%v/coverage" $.Namespace)}}_selected{{end}}" + href="/{{$.Namespace}}/coverage?period=month">Repo Heatmap</a> {{if .ShowSubsystems}} - <a class="navigation_tab{{if eq .URLPath (printf "/%v/graph/coverage_subsystems_heatmap" $.Namespace)}}_selected{{end}}" - href="/{{$.Namespace}}/graph/coverage_subsystems_heatmap?period=month">Subsystems Heatmap</a> + <a class="navigation_tab{{if eq .URLPath (printf "/%v/coverage/subsystems" $.Namespace)}}_selected{{end}}" + href="/{{$.Namespace}}/coverage/subsystems?period=month">Subsystems Heatmap</a> {{end}} </div> </div> |
