1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-01 16:13:27 +00:00

date range filtering

This commit is contained in:
Kyle Spearrin
2017-12-15 12:42:21 -05:00
parent 9834f3d2aa
commit de3a9b9903
4 changed files with 54 additions and 7 deletions

View File

@@ -6,10 +6,20 @@
$scope.events = [];
$scope.orgUsers = [];
$scope.loading = true;
var d = new Date();
$scope.filterEnd = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59);
d.setDate(d.getDate() - 30);
$scope.filterStart = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0);
$scope.$on('$viewContentLoaded', function () {
load();
});
$scope.refresh = function () {
loadEvents();
};
var i = 0,
orgUsersUserIdDict = {},
orgUsersIdDict = {};
@@ -33,8 +43,32 @@
}
$scope.orgUsers = users;
return apiService.events.listOrganization({ orgId: $state.params.orgId }).$promise;
}).then(function (list) {
return loadEvents();
});
}
function loadEvents() {
$scope.loading = true;
var start = null, end = null;
try {
var format = 'yyyy-MM-ddTHH:mm';
start = $filter('date')($scope.filterStart, format + 'Z', 'UTC');
end = $filter('date')($scope.filterEnd, format + ':59.999Z', 'UTC');
} catch (e) { }
if (!start || !end || end < start) {
$scope.loading = false;
alert('Invalid date range.');
return;
}
return apiService.events.listOrganization({
orgId: $state.params.orgId,
start: start,
end: end
}).$promise.then(function (list) {
var events = [];
for (i = 0; i < list.Data.length; i++) {
var userId = list.Data[i].ActingUserId || list.Data[i].UserId;