Skip to content

Commit 5cdb1cf

Browse files
committed
dashboard/app: add dropdown with subsystems
1 parent f3558db commit 5cdb1cf

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

dashboard/app/main.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ 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
}
@@ -1423,6 +1424,14 @@ func findBugByID(c context.Context, r *http.Request) (*Bug, error) {
14231424
return nil, fmt.Errorf("mandatory parameter id/extid is missing")
14241425
}
14251426

1427+
func ssListJSON(service *subsystem.Service, w http.ResponseWriter) error {
1428+
res := []string{}
1429+
for _, subsystem := range service.List() {
1430+
res = append(res, subsystem.Name)
1431+
}
1432+
return json.NewEncoder(w).Encode(res)
1433+
}
1434+
14261435
func handleSubsystemsList(c context.Context, w http.ResponseWriter, r *http.Request) error {
14271436
hdr, err := commonHeader(c, r, w, "")
14281437
if err != nil {
@@ -1436,6 +1445,13 @@ func handleSubsystemsList(c context.Context, w http.ResponseWriter, r *http.Requ
14361445
if service == nil {
14371446
return fmt.Errorf("%w: the namespace does not have subsystems", ErrClientBadRequest)
14381447
}
1448+
if r.FormValue("json") == "1" {
1449+
w.Header().Set("Content-Type", "application/json")
1450+
if err := ssListJSON(service, w); err != nil {
1451+
return fmt.Errorf("ssListJSON: %w", err)
1452+
}
1453+
return nil
1454+
}
14391455
nonEmpty := r.FormValue("all") != "true"
14401456
list := []*uiSubsystem{}
14411457
someHidden := false

dashboard/app/static/coverage.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ 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 subsystem names.');
25+
}
26+
});
27+
}
28+
29+
$(document).ready(initDropdowns);
30+
1431
// This handler is called when user clicks on the coverage percentage.
1532
// It downloads the kernel file coverage html block and adjust page to show it.
1633
// "#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)