From cf093be1b5829fa160eb82827e60816a1f5d6efd Mon Sep 17 00:00:00 2001 From: David Poindexter Date: Sat, 27 Jan 2024 15:08:14 -0500 Subject: [PATCH] Implement Rolling Year for dashboard and user activity list default views --- app/controllers/dashboard.js | 19 ++++++++++++++++++- .../user-activity/user-activity-list.js | 19 +++++++++++++------ app/views/dashboard.html | 1 + 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/app/controllers/dashboard.js b/app/controllers/dashboard.js index 37884a7..034d44e 100644 --- a/app/controllers/dashboard.js +++ b/app/controllers/dashboard.js @@ -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(); @@ -149,7 +166,7 @@ }; init(); - $scope.thisYear(); + $scope.rollingYear(); }]); diff --git a/app/controllers/user-activity/user-activity-list.js b/app/controllers/user-activity/user-activity-list.js index 87871c2..e41bba4 100644 --- a/app/controllers/user-activity/user-activity-list.js +++ b/app/controllers/user-activity/user-activity-list.js @@ -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 () { diff --git a/app/views/dashboard.html b/app/views/dashboard.html index b80f786..4c978b8 100644 --- a/app/views/dashboard.html +++ b/app/views/dashboard.html @@ -39,6 +39,7 @@
+