diff --git a/pixelapi/admin.go b/pixelapi/admin.go new file mode 100644 index 0000000..5367d52 --- /dev/null +++ b/pixelapi/admin.go @@ -0,0 +1,16 @@ +package pixelapi + +// IsAdmin is the response to the /admin/is_admin API +type IsAdmin struct { + Success bool `json:"success"` + IsAdmin bool `json:"is_admin"` +} + +// UserIsAdmin returns if the logged in user is an admin user +func (p *PixelAPI) UserIsAdmin() (resp IsAdmin, err error) { + err = p.jsonRequest("GET", p.apiEndpoint+"/admin/is_admin", &resp) + if err != nil { + return resp, err + } + return resp, nil +} diff --git a/res/static/script/Toolbar.js b/res/static/script/Toolbar.js index 33b5032..b9b6890 100644 --- a/res/static/script/Toolbar.js +++ b/res/static/script/Toolbar.js @@ -249,7 +249,28 @@ var DetailsWindow = { document.getElementById('bandwidth_chart'), { type: 'line', - data: response, + data: { + labels: response.labels, + datasets: [ + { + label: "Downloads", + backgroundColor: "rgba(100, 255, 100, .4)", + borderColor: "rgba(100, 255, 100, .8)", + borderWidth: 2, + fill: false, + yAxisID: "y_bandwidth", + data: response.downloads + }, { + label: "Views", + backgroundColor: "rgba(128, 128, 255, .4)", + borderColor: "rgba(128, 128, 255, .8)", + borderWidth: 2, + fill: false, + yAxisID: "y_views", + data: response.views + } + ] + }, options: { stacked: false, aspectRatio: 2.5, @@ -271,7 +292,7 @@ var DetailsWindow = { } }, { type: "linear", - display: true, + display: false, position: "right", id: "y_views", scaleLabel: { diff --git a/res/template/admin.html b/res/template/admin.html index 6ef85d7..f36e38f 100644 --- a/res/template/admin.html +++ b/res/template/admin.html @@ -7,13 +7,96 @@
-