Skip to content

Commit

Permalink
Merge pull request #37 from david-poindexter/dashboard-default-rollin…
Browse files Browse the repository at this point in the history
…g-year

Implement `Rolling Year` for dashboard and user activity list default views
  • Loading branch information
david-poindexter authored Jan 27, 2024
2 parents ecbf0af + cf093be commit 2f91b9d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
19 changes: 18 additions & 1 deletion app/controllers/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@
return deferred.promise;
};

$scope.getCurrentDate = function () {
return new Date();
};

$scope.getDateOneYearAgo = function () {
var date = new Date();
date.setDate(date.getDate() - 365);
return date;
};

$scope.rollingYear = function () {
$scope.period_start = $scope.getDateOneYearAgo();
$scope.period_end = $scope.getCurrentDate();

$scope.getUserActivity();
};

$scope.thisYear = function () {
var now = new Date();
var year = now.getFullYear();
Expand Down Expand Up @@ -149,7 +166,7 @@
};

init();
$scope.thisYear();
$scope.rollingYear();

}]);

19 changes: 13 additions & 6 deletions app/controllers/user-activity/user-activity-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,20 @@
return deferred.promise;
};

$scope.rollingYear = function () {
var now = new Date();
var yearAgo = now;
yearAgo.setDate(now.getDate() - 365);
$scope.getCurrentDate = function () {
return new Date();
};

$scope.period_end = now;
$scope.period_start = yearAgo;
$scope.getDateOneYearAgo = function () {
var date = new Date();
date.setDate(date.getDate() - 365);
return date;
};

$scope.rollingYear = function () {
$scope.period_start = $scope.getDateOneYearAgo();
$scope.period_end = $scope.getCurrentDate();
$scope.getUserActivity();
};

init = function () {
Expand Down
1 change: 1 addition & 0 deletions app/views/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

<div class="row">
<div class="col">
<button type="button" class="btn btn-sm btn-light" ng-click="rollingYear()">Rolling Year</button>
<button type="button" class="btn btn-sm btn-light" ng-click="thisYear()">This Year</button>
<button type="button" class="btn btn-sm btn-light" ng-click="thisMonth()">This Month</button>
<button type="button" class="btn btn-sm btn-light" ng-click="lastYear()">Last Year</button>
Expand Down

0 comments on commit 2f91b9d

Please sign in to comment.