Files
fnx_web/res/template/admin.html

125 lines
3.1 KiB
HTML
Raw Normal View History

2019-04-10 20:33:14 +02:00
{{define "admin_panel"}}
<!DOCTYPE html>
<html>
<head>
{{template "meta_tags" "Administrator panel"}}
{{template "user_style" .}}
<script type="text/javascript">var apiEndpoint = '{{.APIEndpoint}}';</script>
</head>
<body>
2019-07-07 10:11:18 +02:00
{{$isAdmin := .PixelAPI.UserIsAdmin}}
<div id="body" class="body" style="max-width: 100%">
{{template "menu" .}}
2019-07-07 10:11:18 +02:00
{{if $isAdmin.IsAdmin}}
2019-07-07 10:11:18 +02:00
<h3>Bandwidth and views</h3>
<div id="chart_container" class="chart-container" style="position: relative; width: 100%; height: auto;">
<canvas id="bandwidth_chart"></canvas>
</div>
2019-07-07 10:11:18 +02:00
<script src="/res/script/jquery.js"></script>
<script src="/res/misc/chartjs/Chart.min.js"></script>
<script>
2019-07-07 22:43:49 +02:00
$.get(apiEndpoint+"/admin/files/timeseries/14?interval=60", function(response){
2019-07-07 10:11:18 +02:00
console.log(response);
if (response.success) {
var ctx = document.getElementById('bandwidth_chart');
Chart.defaults.global.defaultFontColor = "#b3b3b3";
Chart.defaults.global.defaultFontSize = 16;
Chart.defaults.global.defaultFontFamily = "Ubuntu";
new Chart(
document.getElementById('bandwidth_chart'),
{
type: 'line',
data: {
labels: response.labels,
datasets: [
{
2019-07-07 22:34:20 +02:00
label: "Bandwidth",
2019-07-07 12:18:26 +02:00
backgroundColor: "rgba(100, 255, 100, .1)",
2019-07-07 10:11:18 +02:00
borderColor: "rgba(100, 255, 100, .8)",
borderWidth: 2,
2019-07-07 12:18:26 +02:00
fill: true,
2019-07-07 10:11:18 +02:00
yAxisID: "y_bandwidth",
data: response.downloads
}, {
label: "Views",
2019-07-07 22:34:20 +02:00
backgroundColor: "rgba(128, 128, 255, .2)",
2019-07-07 10:11:18 +02:00
borderColor: "rgba(128, 128, 255, .8)",
borderWidth: 2,
2019-07-07 12:18:26 +02:00
fill: true,
2019-07-07 10:11:18 +02:00
yAxisID: "y_views",
data: response.views
}
]
},
options: {
stacked: false,
aspectRatio: 3,
tooltips: {
mode: "index",
intersect: false,
axis: "x"
},
scales: {
yAxes: [
{
type: "linear",
display: true,
position: "left",
id: "y_bandwidth",
scaleLabel: {
display: true,
2019-07-07 13:00:14 +02:00
labelString: "Bandwidth"
2019-07-07 22:34:20 +02:00
},
ticks: {
callback: function(value, index, values) {
return (value/1e9) + " GB";
}
},
gridLines: {
color: "rgba(100, 255, 100, .1)"
2019-07-07 10:11:18 +02:00
}
}, {
type: "linear",
2019-07-07 10:29:41 +02:00
display: true,
2019-07-07 10:11:18 +02:00
position: "right",
id: "y_views",
scaleLabel: {
display: true,
labelString: "Views"
2019-07-07 10:29:41 +02:00
},
gridLines: {
2019-07-07 22:34:20 +02:00
color: "rgba(128, 128, 255, .2)"
}
}
],
xAxes: [
{
gridLines: {
display: false
2019-07-07 10:11:18 +02:00
}
}
]
},
elements: {
point: {
radius: 0
}
}
}
}
);
}
});
</script>
2019-07-07 13:00:14 +02:00
{{else}}
<h1 style="text-align: center;">;)</h1>
2019-07-07 10:11:18 +02:00
{{end}}
{{template "footer"}}
</div>
</body>
</html>
{{end}}