Skip to content

Commit 11e48dc

Browse files
committed
dashboard/app: add dropdown with subsystems and managers
1 parent f3558db commit 11e48dc

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

dashboard/app/main.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ func initHTTPHandlers() {
7070
http.Handle("/"+ns+"/graph/coverage", handlerWrapper(handleCoverageGraph))
7171
http.Handle("/"+ns+"/graph/coverage_heatmap", handlerWrapper(handleCoverageHeatmap))
7272
if nsConfig.Subsystems.Service != nil {
73+
http.Handle("/"+ns+"/subsystems.json", handlerWrapper(handleSubsystemsCoverageHeatmap))
7374
http.Handle("/"+ns+"/graph/coverage_subsystems_heatmap", handlerWrapper(handleSubsystemsCoverageHeatmap))
7475
}
7576
}
7677
http.Handle("/"+ns+"/repos", handlerWrapper(handleRepos))
7778
http.Handle("/"+ns+"/bug-summaries", handlerWrapper(handleBugSummaries))
7879
http.Handle("/"+ns+"/subsystems", handlerWrapper(handleSubsystemsList))
80+
http.Handle("/"+ns+"/managers", handlerWrapper(handleManagersList))
7981
http.Handle("/"+ns+"/backports", handlerWrapper(handleBackports))
8082
http.Handle("/"+ns+"/s/", handlerWrapper(handleSubsystemPage))
8183
http.Handle("/"+ns+"/manager/", handlerWrapper(handleManagerPage))
@@ -1423,6 +1425,30 @@ func findBugByID(c context.Context, r *http.Request) (*Bug, error) {
14231425
return nil, fmt.Errorf("mandatory parameter id/extid is missing")
14241426
}
14251427

1428+
func ssListJSON(service *subsystem.Service, w http.ResponseWriter) error {
1429+
res := []string{}
1430+
for _, subsystem := range service.List() {
1431+
res = append(res, subsystem.Name)
1432+
}
1433+
return json.NewEncoder(w).Encode(res)
1434+
}
1435+
1436+
func handleManagersList(c context.Context, w http.ResponseWriter, r *http.Request) error {
1437+
if r.FormValue("json") != "1" {
1438+
return http.ErrNotSupported
1439+
}
1440+
hdr, err := commonHeader(c, r, w, "")
1441+
if err != nil {
1442+
return err
1443+
}
1444+
managers, err := CachedManagerList(c, hdr.Namespace)
1445+
if err != nil {
1446+
return err
1447+
}
1448+
w.Header().Set("Content-Type", "application/json")
1449+
return json.NewEncoder(w).Encode(managers)
1450+
}
1451+
14261452
func handleSubsystemsList(c context.Context, w http.ResponseWriter, r *http.Request) error {
14271453
hdr, err := commonHeader(c, r, w, "")
14281454
if err != nil {
@@ -1436,6 +1462,10 @@ func handleSubsystemsList(c context.Context, w http.ResponseWriter, r *http.Requ
14361462
if service == nil {
14371463
return fmt.Errorf("%w: the namespace does not have subsystems", ErrClientBadRequest)
14381464
}
1465+
if r.FormValue("json") == "1" {
1466+
w.Header().Set("Content-Type", "application/json")
1467+
return ssListJSON(service, w)
1468+
}
14391469
nonEmpty := r.FormValue("all") != "true"
14401470
list := []*uiSubsystem{}
14411471
someHidden := false

dashboard/app/static/coverage.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,36 @@ function initTogglers(){
1111
});
1212
}
1313

14+
function initDropdowns(){
15+
$.ajax({
16+
url: '/upstream/subsystems?json=1',
17+
method: 'GET',
18+
success: function(data) {
19+
data.forEach(item => {
20+
$('#target-subsystem').append(new Option(item, item));
21+
});
22+
},
23+
error: function() {
24+
log('failed to load subsystems');
25+
}
26+
});
27+
28+
$.ajax({
29+
url: '/upstream/managers?json=1',
30+
method: 'GET',
31+
success: function(data) {
32+
data.forEach(item => {
33+
$('#target-manager').append(new Option(item, item));
34+
});
35+
},
36+
error: function() {
37+
log('failed to load managers');
38+
}
39+
});
40+
}
41+
42+
$(document).ready(initDropdowns);
43+
1444
// This handler is called when user clicks on the coverage percentage.
1545
// It downloads the kernel file coverage html block and adjust page to show it.
1646
// "#file-content-prev" and "#file-content-curr" are the file content <div>s.

pkg/cover/templates/heatmap.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@
105105

106106
{{ define "body" }}
107107
<div style="white-space: nowrap">
108+
<div>
109+
<select id="target-subsystem">
110+
<option value="*">*</option>
111+
</select>
112+
<select id="target-manager">
113+
<option value="*">*</option>
114+
</select>
115+
</div>
108116
<div style="display:inline-block">
109117
<ul id="collapsible-list">
110118
<li>

0 commit comments

Comments
 (0)