mirror of
https://github.com/Foltik/Shimapan
synced 2024-11-10 07:38:59 -05:00
Cleanup + work on dash ctrl
This commit is contained in:
parent
f892b5676c
commit
1139ff7f10
@ -1,18 +1,34 @@
|
|||||||
var angular = require('angular');
|
var angular = require('angular');
|
||||||
|
|
||||||
angular.module('DashCtrl', ['chart.js']).controller('DashController', ['$scope', $scope => {
|
angular.module('DashCtrl', ['chart.js', 'StatSvc']).controller('DashController', ['$scope', 'StatService', async ($scope, StatService) => {
|
||||||
const colorScheme = ['#2a9fd6'];
|
const colorScheme = ['#2a9fd6'];
|
||||||
|
// Calculate and format descending dates back one week to use for x-axis labels
|
||||||
// Calculate and format descending dates back one week
|
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
const oneDay = 1000 * 60 * 60 * 24;
|
const oneDay = 1000 * 60 * 60 * 24;
|
||||||
let dates = Array.from({length: 7}, (date, i) => new Date(currentDate - oneDay * (6 - i)));
|
let labels = Array.from({length: 7}, (date, i) =>
|
||||||
let labels = dates.map(date => date.toISOString().substr(5, 5));
|
(new Date(currentDate - oneDay * (6 - i))).toISOString().substr(5, 5));
|
||||||
|
|
||||||
|
StatService.getWeek((err, stats) => {
|
||||||
|
$scope.uploadData = [Array.from({length: 7}, (val, i) => stats[labels[i]] ? stats[labels[i]].uploads : 0)];
|
||||||
|
$scope.viewData = [Array.from({length: 7}, (val, i) => stats[labels[i]] ? stats[labels[i]].views : 0)];
|
||||||
|
|
||||||
|
$scope.stats = stats;
|
||||||
|
|
||||||
|
$scope.statUploads = Object.keys(stats).reduce((acc, key) => acc + stats[key].uploads);
|
||||||
|
$scope.statUploadSize = Object.keys(stats).reduce((acc, key) => acc + stats[key].size);
|
||||||
|
$scope.statViews = Object.keys(stats).reduce((acc, key) => acc + stats[key].views);
|
||||||
|
});
|
||||||
|
|
||||||
|
StatService.getAll((err, stats) => {
|
||||||
|
$scope.statTotalUploads = stats.count;
|
||||||
|
$scope.statTotalUploadSize = stats.size;
|
||||||
|
$scope.statTotalViews = stats.views;
|
||||||
|
});
|
||||||
|
|
||||||
$scope.uploadColors = colorScheme;
|
$scope.uploadColors = colorScheme;
|
||||||
$scope.uploadLabels = labels;
|
$scope.uploadLabels = labels;
|
||||||
$scope.uploadSeries = ['Uploads'];
|
$scope.uploadSeries = ['Uploads'];
|
||||||
$scope.uploadData = [[10, 20, 30, 20, 15, 20, 45]];
|
//$scope.uploadData = [[5, 11, 4, 3, 7, 9, 21]];
|
||||||
$scope.uploadOptions = {
|
$scope.uploadOptions = {
|
||||||
title: {
|
title: {
|
||||||
display: true,
|
display: true,
|
||||||
@ -23,13 +39,11 @@ angular.module('DashCtrl', ['chart.js']).controller('DashController', ['$scope',
|
|||||||
$scope.viewColors = colorScheme;
|
$scope.viewColors = colorScheme;
|
||||||
$scope.viewLabels = labels;
|
$scope.viewLabels = labels;
|
||||||
$scope.viewSeries = ['Views'];
|
$scope.viewSeries = ['Views'];
|
||||||
$scope.viewData = [[5, 11, 4, 3, 7, 9, 21]];
|
//$scope.viewData = [[5, 11, 4, 3, 7, 9, 21]];
|
||||||
$scope.viewOptions = {
|
$scope.viewOptions = {
|
||||||
title: {
|
title: {
|
||||||
display: true,
|
display: true,
|
||||||
text: 'Historical Views'
|
text: 'Historical Views'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
{
|
|
||||||
}
|
|
@ -38,7 +38,7 @@
|
|||||||
<i class="dash-stat-icon fa fa-eye fa-3x"></i>
|
<i class="dash-stat-icon fa fa-eye fa-3x"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="dash-singlestats-totals" class="dash-row" ng-init="statTotalUploads=0;statTotalUploadSize=0;statTotalViews=0;">
|
<div id="dash-singlestats-totals" class="dash-row">
|
||||||
<div class="dash-card dash-card-singlestat">
|
<div class="dash-card dash-card-singlestat">
|
||||||
<div class="dash-stat">
|
<div class="dash-stat">
|
||||||
<span class="dash-stat-title">Total Uploads</span>
|
<span class="dash-stat-title">Total Uploads</span>
|
||||||
|
@ -8,4 +8,7 @@ file
|
|||||||
|
|
||||||
api
|
api
|
||||||
create
|
create
|
||||||
delete
|
delete
|
||||||
|
|
||||||
|
stats
|
||||||
|
get
|
Loading…
Reference in New Issue
Block a user