internal/httpd/admin.go

03fe6e44370f8129c9ac68f13fe674cc271f5ffa
gitbay/internal/httpd/admin.go

34 lines · 870 bytes

 1package httpd
 2
 3import (
 4	"net/http"
 5
 6	"gitbay.org/gitbay/internal/store"
 7)
 8
 9// adminPage is the operator's view: the running build and every worker
10// queue, read through the dashboard command's admin-only block. A
11// non-admin gets the same 404 a missing page would, so the URL confirms
12// nothing.
13func (s *Server) adminPage(w http.ResponseWriter, r *http.Request, viewer store.User) {
14	if !viewer.IsAdmin {
15		s.notFound(w, r)
16		return
17	}
18	var d struct {
19		Server struct {
20			Commit string `json:"commit"`
21		} `json:"server"`
22		Queues store.Queues `json:"queues"`
23	}
24	if msg, ok := s.runControlInto(viewer, []string{"dashboard"}, &d); !ok {
25		http.Error(w, msg, http.StatusInternalServerError)
26		return
27	}
28	s.render(w, "admin.html", struct {
29		basePage
30		Tab    string
31		Commit string
32		Queues store.Queues
33	}{s.baseFor(viewer), "admin", d.Server.Commit, d.Queues})
34}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form