forked from evergreen-ci/evergreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.go
44 lines (40 loc) · 1.24 KB
/
admin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package service
import (
"net/http"
"time"
"github.com/evergreen-ci/evergreen/rest/data"
"github.com/evergreen-ci/evergreen/rest/model"
"github.com/evergreen-ci/gimlet"
"github.com/mongodb/grip"
"github.com/pkg/errors"
)
func (uis *UIServer) adminSettings(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
template := "not_admin.html"
DBUser := gimlet.GetUser(ctx)
if DBUser != nil && uis.isSuperUser(DBUser) {
template = "admin.html"
}
data := struct {
ViewData
}{uis.GetCommonViewData(w, r, true, true)}
uis.render.WriteResponse(w, http.StatusOK, data, "base", template, "base_angular.html", "menu.html")
}
func (uis *UIServer) adminEvents(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
DBUser := gimlet.GetUser(ctx)
template := "not_admin.html"
if DBUser != nil && uis.isSuperUser(DBUser) {
template = "admin_events.html"
}
dc := &data.DBAdminConnector{}
events, err := dc.GetAdminEventLog(time.Now(), 15)
if err != nil {
grip.Error(errors.Wrap(err, "unable to retrieve admin events"))
}
data := struct {
Data []model.APIAdminEvent
ViewData
}{events, uis.GetCommonViewData(w, r, true, true)}
uis.render.WriteResponse(w, http.StatusOK, data, "base", template, "base_angular.html", "menu.html")
}