mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-31 17:57:43 +01:00
paging
This commit is contained in:
parent
de3a9b9903
commit
8a3fb92bbe
@ -6,6 +6,7 @@
|
|||||||
$scope.events = [];
|
$scope.events = [];
|
||||||
$scope.orgUsers = [];
|
$scope.orgUsers = [];
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
|
$scope.continuationToken = null;
|
||||||
|
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
$scope.filterEnd = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59);
|
$scope.filterEnd = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59);
|
||||||
@ -17,7 +18,11 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$scope.refresh = function () {
|
$scope.refresh = function () {
|
||||||
loadEvents();
|
loadEvents(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.next = function () {
|
||||||
|
loadEvents(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
var i = 0,
|
var i = 0,
|
||||||
@ -44,13 +49,11 @@
|
|||||||
|
|
||||||
$scope.orgUsers = users;
|
$scope.orgUsers = users;
|
||||||
|
|
||||||
return loadEvents();
|
return loadEvents(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadEvents() {
|
function loadEvents(clearExisting) {
|
||||||
$scope.loading = true;
|
|
||||||
|
|
||||||
var start = null, end = null;
|
var start = null, end = null;
|
||||||
try {
|
try {
|
||||||
var format = 'yyyy-MM-ddTHH:mm';
|
var format = 'yyyy-MM-ddTHH:mm';
|
||||||
@ -59,16 +62,24 @@
|
|||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
|
|
||||||
if (!start || !end || end < start) {
|
if (!start || !end || end < start) {
|
||||||
$scope.loading = false;
|
|
||||||
alert('Invalid date range.');
|
alert('Invalid date range.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (clearExisting) {
|
||||||
|
$scope.continuationToken = null;
|
||||||
|
$scope.events = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.loading = true;
|
||||||
return apiService.events.listOrganization({
|
return apiService.events.listOrganization({
|
||||||
orgId: $state.params.orgId,
|
orgId: $state.params.orgId,
|
||||||
start: start,
|
start: start,
|
||||||
end: end
|
end: end,
|
||||||
|
continuationToken: $scope.continuationToken
|
||||||
}).$promise.then(function (list) {
|
}).$promise.then(function (list) {
|
||||||
|
$scope.continuationToken = list.ContinuationToken;
|
||||||
|
|
||||||
var events = [];
|
var events = [];
|
||||||
for (i = 0; i < list.Data.length; i++) {
|
for (i = 0; i < list.Data.length; i++) {
|
||||||
var userId = list.Data[i].ActingUserId || list.Data[i].UserId;
|
var userId = list.Data[i].ActingUserId || list.Data[i].UserId;
|
||||||
@ -81,7 +92,12 @@
|
|||||||
date: list.Data[i].Date
|
date: list.Data[i].Date
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$scope.events = events;
|
if ($scope.events && $scope.events.length > 0) {
|
||||||
|
$scope.events = $scope.events.concat(events);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$scope.events = events;
|
||||||
|
}
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="event in filteredEvents = (events | orderBy: ['-date'])">
|
<tr ng-repeat="event in filteredEvents = (events)">
|
||||||
<td style="width: 210px; min-width: 100px;">
|
<td style="width: 210px; min-width: 100px;">
|
||||||
{{event.date | date:'medium'}}
|
{{event.date | date:'medium'}}
|
||||||
</td>
|
</td>
|
||||||
@ -57,5 +57,11 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="box-footer text-center" ng-show="continuationToken">
|
||||||
|
<button class="btn btn-link btn-block" ng-click="next()" ng-if="!loading">
|
||||||
|
Load more...
|
||||||
|
</button>
|
||||||
|
<i class="fa fa-fw fa-refresh fa-spin text-muted" ng-if="loading"></i>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
Loading…
Reference in New Issue
Block a user