1 parent
de13d851a8
commit
a28362b82c
34 files changed
+1541
-341
No files matched your search
+69
-12
@@ -30,6 +30,15 @@ func (s *Server) overview(w http.ResponseWriter, r *http.Request) {
|
||||
d.Audit = audits.Items
|
||||
}
|
||||
smp, e, last := s.telemetry.Snapshot()
|
||||
if len(smp) > 0 {
|
||||
d.RecentQueryRate = smp[len(smp)-1].QueryRate
|
||||
}
|
||||
var groups struct {
|
||||
Items []easydns.UpstreamGroup `json:"items"`
|
||||
}
|
||||
if s.get(r.Context(), "/api/v1/upstreams", &groups) == nil {
|
||||
d.Upstreams = groups.Items
|
||||
}
|
||||
d.SamplingCount = len(smp)
|
||||
d.SamplingTime = last
|
||||
d.SamplingError = e
|
||||
@@ -198,23 +207,71 @@ func (s *Server) zoneDetail(w http.ResponseWriter, r *http.Request, name, tab st
|
||||
}
|
||||
if tab == "records" {
|
||||
v := r.URL.Query()
|
||||
query := url.Values{"page": {strconv.Itoa(getInt(v.Get("page"), 1, 1, 100000))}, "per_page": {"50"}}
|
||||
page := getInt(v.Get("page"), 1, 1, 100000)
|
||||
d.HideDNSSEC = v.Get("hide_dnssec") == "1"
|
||||
d.Filter = map[string]string{"name": v.Get("name"), "type": v.Get("type")}
|
||||
for _, k := range []string{"name", "type"} {
|
||||
if v := strings.TrimSpace(d.Filter[k]); v != "" {
|
||||
query.Set(k, v)
|
||||
query := url.Values{"page": {strconv.Itoa(page)}, "per_page": {"50"}}
|
||||
for _, key := range []string{"name", "type"} {
|
||||
if filter := strings.TrimSpace(d.Filter[key]); filter != "" {
|
||||
query.Set(key, filter)
|
||||
}
|
||||
}
|
||||
var p easydns.Page[easydns.Record]
|
||||
if e, er := s.api.Get(r.Context(), "/api/v1/zones/"+easydns.Escape(name)+"/records?"+query.Encode(), &p); er != nil {
|
||||
if d.Error == "" {
|
||||
d.Error = er.Error()
|
||||
d.Pagination = easydns.Pagination{Page: page, PerPage: zoneRecordPageSize}
|
||||
if d.HideDNSSEC {
|
||||
cursor := parseRecordCursor(v.Get("cursor"))
|
||||
// A type included by the user but excluded by the checkbox
|
||||
// yields no visible rows. Still fetch the API metadata so the
|
||||
// total count is not misleadingly reported as zero.
|
||||
if isDNSSECRecordType(v.Get("type")) {
|
||||
var meta easydns.Page[easydns.Record]
|
||||
q := url.Values{"per_page": {"1"}, "page": {"1"}}
|
||||
if text := strings.TrimSpace(v.Get("name")); text != "" {
|
||||
q.Set("name", text)
|
||||
}
|
||||
q.Set("type", strings.TrimSpace(v.Get("type")))
|
||||
if _, er := s.api.Get(r.Context(), "/api/v1/zones/"+easydns.Escape(name)+"/records?"+q.Encode(), &meta); er != nil {
|
||||
if d.Error == "" {
|
||||
d.Error = er.Error()
|
||||
}
|
||||
} else {
|
||||
d.Pagination.Total = meta.Pagination.Total
|
||||
}
|
||||
} else {
|
||||
listed, er := s.listVisibleZoneRecords(r.Context(), name, query, cursor, page)
|
||||
if er != nil {
|
||||
if d.Error == "" {
|
||||
d.Error = er.Error()
|
||||
}
|
||||
} else {
|
||||
d.Records, d.Pagination.Total = listed.records, listed.rawTotal
|
||||
if listed.etag != "" {
|
||||
d.ETag = listed.etag
|
||||
}
|
||||
if listed.hasNext {
|
||||
d.RecordsNextURL = recordPageURL(name, v, page+1, listed.nextCursor, true)
|
||||
}
|
||||
if listed.hasPrev {
|
||||
d.RecordsPrevURL = recordPageURL(name, v, page-1, listed.prevCursor, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
d.Records = p.Items
|
||||
d.Pagination = p.Pagination
|
||||
if e != "" {
|
||||
d.ETag = e
|
||||
var p easydns.Page[easydns.Record]
|
||||
if e, er := s.api.Get(r.Context(), "/api/v1/zones/"+easydns.Escape(name)+"/records?"+query.Encode(), &p); er != nil {
|
||||
if d.Error == "" {
|
||||
d.Error = er.Error()
|
||||
}
|
||||
} else {
|
||||
d.Records, d.Pagination = p.Items, p.Pagination
|
||||
if e != "" {
|
||||
d.ETag = e
|
||||
}
|
||||
if page > 1 {
|
||||
d.RecordsPrevURL = recordPageURL(name, v, page-1, 0, false)
|
||||
}
|
||||
if page*p.Pagination.PerPage < p.Pagination.Total {
|
||||
d.RecordsNextURL = recordPageURL(name, v, page+1, 0, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user