Compare commits
4 Commits
fcdfae85e3
...
475fc7c257
Author | SHA1 | Date | |
---|---|---|---|
475fc7c257 | |||
026e5cc8c9 | |||
61c174dd2b | |||
f41cbf1481 |
10
README.md
10
README.md
@ -30,17 +30,21 @@ the commandline.
|
|||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
Usage of ./taler-dashboard:
|
Usage of taler-dashboard:
|
||||||
|
-fr duration
|
||||||
|
update frequency (default 1m0s)
|
||||||
-min string
|
-min string
|
||||||
minimum version we care for (default "0.9.3")
|
minimum version we care for (default "0.9.3")
|
||||||
-num int
|
-num int
|
||||||
number of issues to retrieve at once (default 100)
|
number of issues to retrieve at once (default 250)
|
||||||
-port string
|
-port string
|
||||||
[ip]:port to serve (default ":8080")
|
[ip]:port to serve (default ":8080")
|
||||||
|
-project int
|
||||||
|
project id to use (default 23)
|
||||||
-token string
|
-token string
|
||||||
API-Token (default "")
|
API-Token (default "")
|
||||||
-url string
|
-url string
|
||||||
URL to the issues (default "https://bugs.gnunet.org/api/rest/issues")
|
URL to the issues (default "https://bugs.gnunet.org/api/rest")
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note**: We assume that this service runs behind a reverse-proxy which deals
|
**Note**: We assume that this service runs behind a reverse-proxy which deals
|
||||||
|
43
data.go
43
data.go
@ -39,12 +39,12 @@ type Data struct {
|
|||||||
token string
|
token string
|
||||||
num int
|
num int
|
||||||
projectId int
|
projectId int
|
||||||
filterId int
|
|
||||||
minimumVersion string
|
minimumVersion string
|
||||||
tmpl *template.Template
|
tmpl *template.Template
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
|
||||||
Issues Issues
|
Issues Issues
|
||||||
|
Projects Projects
|
||||||
Timestamp time.Time
|
Timestamp time.Time
|
||||||
Freq time.Duration
|
Freq time.Duration
|
||||||
Lasterror error
|
Lasterror error
|
||||||
@ -70,9 +70,29 @@ func NewData(ctx context.Context, url, token string, num int) *Data {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const statusFilter = `status%5B%5D=10&status%5B%5D=20&status%5B%5D=30&status%5B%5D=40&status%5B%5D=50&severity%5B%5D=20`
|
||||||
|
|
||||||
|
var fields = []string{"id",
|
||||||
|
"description",
|
||||||
|
"summary",
|
||||||
|
"category",
|
||||||
|
"target_version",
|
||||||
|
"status",
|
||||||
|
"reporter",
|
||||||
|
"handler",
|
||||||
|
"resolution",
|
||||||
|
"priority",
|
||||||
|
"severity",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"relationships",
|
||||||
|
"tags",
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Data) update() {
|
func (d *Data) update() {
|
||||||
url := fmt.Sprintf("%s?project_id=%dfilter_id=%d&page_size=%d",
|
url := fmt.Sprintf("%s/issues?project_id=%d&page_size=%d&%s&select=%s",
|
||||||
d.url, d.projectId, d.filterId, d.num)
|
d.url, d.projectId, d.num, statusFilter,
|
||||||
|
strings.Join(fields, ","))
|
||||||
req, e := http.NewRequestWithContext(d.ctx, "GET", url, nil)
|
req, e := http.NewRequestWithContext(d.ctx, "GET", url, nil)
|
||||||
if nil != e {
|
if nil != e {
|
||||||
d.mux.Lock()
|
d.mux.Lock()
|
||||||
@ -115,6 +135,23 @@ func (d *Data) update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.Issues = issues
|
d.Issues = issues
|
||||||
|
fmt.Println("got", len(issues), "issues")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Data) Loop() {
|
||||||
|
d.update()
|
||||||
|
go func() {
|
||||||
|
var ticker = time.NewTicker(d.Freq)
|
||||||
|
for range ticker.C {
|
||||||
|
select {
|
||||||
|
case <-d.ctx.Done():
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
fmt.Println("updating data")
|
||||||
|
d.update()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Data) printJSON(w io.Writer) {
|
func (d *Data) printJSON(w io.Writer) {
|
||||||
|
15
list.tmpl
15
list.tmpl
@ -2,14 +2,17 @@
|
|||||||
<head><title>GNU Taler Dashboard</title></head>
|
<head><title>GNU Taler Dashboard</title></head>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
margin-left:15%;
|
margin-left:1%;
|
||||||
margin-right:15%;
|
margin-right:1%;
|
||||||
font-family:sans-serif;
|
font-family:sans-serif;
|
||||||
}
|
}
|
||||||
h3 {
|
h3 {
|
||||||
margin-left: -10%;
|
|
||||||
color: brown;
|
color: brown;
|
||||||
}
|
}
|
||||||
|
details {
|
||||||
|
margin-left: 10%;
|
||||||
|
margin-right: 10%;
|
||||||
|
}
|
||||||
pre {
|
pre {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
@ -18,12 +21,10 @@ pre {
|
|||||||
</style>
|
</style>
|
||||||
<body>
|
<body>
|
||||||
<h1>GNU Taler Dashboard</h1>
|
<h1>GNU Taler Dashboard</h1>
|
||||||
<a href="/">Table view</a>
|
<h2><a href="/">Table view</a> | List View </h2>
|
||||||
<h2>List View</h2>
|
Data from {{ .Timestamp.Format "02 Jan 06 15:04 MST"}}, updateting every {{ .Freq }} (no auto-refresh)
|
||||||
Data from {{ .Timestamp.Format "02 Jan 06 15:04 MST"}}, updating every {{.Freq}}
|
|
||||||
{{ with .Lasterror }}, Last error: {{ . }} {{end}}
|
{{ with .Lasterror }}, Last error: {{ . }} {{end}}
|
||||||
|
|
||||||
|
|
||||||
<!-- p>
|
<!-- p>
|
||||||
{{ $issues := .Issues }}
|
{{ $issues := .Issues }}
|
||||||
{{ range $issues.Tags }}
|
{{ range $issues.Tags }}
|
||||||
|
24
main.go
24
main.go
@ -31,12 +31,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
fl_url = flag.String("url", "https://bugs.gnunet.org/api/rest/issues", "URL to the issues")
|
fl_url = flag.String("url", "https://bugs.gnunet.org/api/rest", "URL to the issues")
|
||||||
fl_token = flag.String("token", os.Getenv("MANTIS_API_TOKEN"), "API-Token")
|
fl_token = flag.String("token", os.Getenv("MANTIS_API_TOKEN"), "API-Token")
|
||||||
fl_port = flag.String("port", ":8080", "[ip]:port to serve")
|
fl_port = flag.String("port", ":8080", "[ip]:port to serve")
|
||||||
fl_num = flag.Int("num", 100, "number of issues to retrieve at once")
|
fl_num = flag.Int("num", 250, "number of issues to retrieve at once")
|
||||||
fl_min = flag.String("min", "0.9.3", "minimum version we care for")
|
fl_min = flag.String("min", "0.9.3", "minimum version we care for")
|
||||||
fl_freq = flag.Duration("fr", time.Minute, "update frequency")
|
fl_freq = flag.Duration("fr", time.Minute, "update frequency")
|
||||||
|
fl_proj = flag.Int("project", 23, "project id to use")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -45,24 +46,11 @@ func main() {
|
|||||||
|
|
||||||
var ctx = context.Background()
|
var ctx = context.Background()
|
||||||
var data = NewData(ctx, *fl_url, *fl_token, *fl_num)
|
var data = NewData(ctx, *fl_url, *fl_token, *fl_num)
|
||||||
data.filterId = 230
|
data.projectId = *fl_proj
|
||||||
data.projectId = 23
|
|
||||||
data.minimumVersion = *fl_min
|
data.minimumVersion = *fl_min
|
||||||
data.Freq = *fl_freq
|
data.Freq = *fl_freq
|
||||||
|
|
||||||
data.update()
|
data.Loop()
|
||||||
go func() {
|
|
||||||
var ticker = time.NewTicker(*fl_freq)
|
|
||||||
for range ticker.C {
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return
|
|
||||||
default:
|
|
||||||
fmt.Println("updating data")
|
|
||||||
data.update()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Println("got request for table")
|
log.Println("got request for table")
|
||||||
|
30
projects.go
30
projects.go
@ -1,5 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file is part of taler-dashboard
|
This file is part of taler-dashboard
|
||||||
Copyright (C) 2023 Özgür Kesim
|
Copyright (C) 2023 Özgür Kesim
|
||||||
@ -19,3 +21,31 @@ package main
|
|||||||
|
|
||||||
@author Özgür Kesim <oec-taler@kesim.org>
|
@author Özgür Kesim <oec-taler@kesim.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
type Projects []Project
|
||||||
|
|
||||||
|
type Project struct {
|
||||||
|
Id int
|
||||||
|
Name string
|
||||||
|
Description string
|
||||||
|
Status KeyVal
|
||||||
|
ViewState KeyVal `json:"view_state"`
|
||||||
|
Enabled bool
|
||||||
|
InheritGlobal bool `json:"inherit_global"`
|
||||||
|
AccessLevel KeyVal `json:"AccessLevel"`
|
||||||
|
Versions []Version
|
||||||
|
Categories []Category
|
||||||
|
// CustomFields []any `json:"custom_fields"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Version struct {
|
||||||
|
KeyVal
|
||||||
|
Released bool
|
||||||
|
Obsolete bool
|
||||||
|
Timestamp time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type Category struct {
|
||||||
|
KeyVal
|
||||||
|
Project KeyVal
|
||||||
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head><title>GNU Taler Dashboard</title></head>
|
<head><title>GNU Taler Dashboard</title></head>
|
||||||
<style>
|
<style>
|
||||||
@ -47,9 +46,8 @@ details {
|
|||||||
</style>
|
</style>
|
||||||
<body>
|
<body>
|
||||||
<h1>GNU Taler Dashboard</h1>
|
<h1>GNU Taler Dashboard</h1>
|
||||||
<a href="/list">List view</a>
|
<h2>Table view | <a href="/list">List View</a></h2>
|
||||||
<h2>Table View</h2>
|
Data from {{ .Timestamp.Format "02 Jan 06 15:04 MST"}}, updateting every {{ .Freq }} (no auto-refresh)
|
||||||
Data from {{ .Timestamp.Format "02 Jan 06 15:04 MST"}}, updateting every {{ .Freq }}
|
|
||||||
{{ with .Lasterror }}, Last error: {{ . }} {{end}}
|
{{ with .Lasterror }}, Last error: {{ . }} {{end}}
|
||||||
|
|
||||||
{{ $issues := .Issues }}
|
{{ $issues := .Issues }}
|
||||||
|
Loading…
Reference in New Issue
Block a user