aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/app/public_json_api.go
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2023-06-16 12:29:10 +0200
committerTaras Madan <tarasmadan@google.com>2023-06-19 16:42:56 +0200
commit4b9f2f7e29d6f5c2e47ee1de4cd5d8f5c4e1d7e4 (patch)
tree41f82050bbab36f739e6e6ae44811c136003429f /dashboard/app/public_json_api.go
parentf1f9726ad56cc48e47cc0fdef249052883d7d7ee (diff)
dashboard/app: add bugGroup json reporting
Diffstat (limited to 'dashboard/app/public_json_api.go')
-rw-r--r--dashboard/app/public_json_api.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/dashboard/app/public_json_api.go b/dashboard/app/public_json_api.go
index a4b630257..2adc1f7e7 100644
--- a/dashboard/app/public_json_api.go
+++ b/dashboard/app/public_json_api.go
@@ -52,11 +52,44 @@ func getExtAPIDescrForBugPage(bugPage *uiBugPage) *publicAPIBugDescription {
}
}
+type publicAPIBugGroup struct {
+ Version int `json:"version"`
+ Bugs []publicAPIBug
+}
+
+type publicAPIBug struct {
+ Title string `json:"title,omitempty"`
+ Link string `json:"link"`
+ LastUpdated string `json:"last-updated,omitempty"`
+}
+
+func getExtAPIDescrForBugGroups(bugGroups []*uiBugGroup) *publicAPIBugGroup {
+ return &publicAPIBugGroup{
+ Version: 1,
+ Bugs: func() []publicAPIBug {
+ var res []publicAPIBug
+ for _, group := range bugGroups {
+ for _, bug := range group.Bugs {
+ res = append(res, publicAPIBug{
+ Title: bug.Title,
+ Link: bug.Link,
+ })
+ }
+ }
+ return res
+ }(),
+ }
+}
+
func GetJSONDescrFor(page interface{}) ([]byte, error) {
var res interface{}
switch i := page.(type) {
case *uiBugPage:
res = getExtAPIDescrForBugPage(i)
+ case *uiTerminalPage:
+ res = getExtAPIDescrForBugGroups([]*uiBugGroup{i.Bugs})
+ case *uiMainPage:
+ res = getExtAPIDescrForBugGroups(i.Groups)
default:
return nil, ErrClientNotFound
}