Merge pull request #2807 from kush-bavishi/FasterPermalink

Faster permalink
This commit is contained in:
Hossein Shafagh 2019-06-11 16:16:55 -07:00 committed by GitHub
commit 198abcfe65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 6 deletions

View File

@ -17,7 +17,7 @@ angular.module('lemur')
}); });
}) })
.controller('CertificatesViewController', function ($q, $scope, $uibModal, $stateParams, CertificateApi, CertificateService, MomentService, ngTableParams, toaster) { .controller('CertificatesViewController', function ($q, $scope, $uibModal, $stateParams, $location, CertificateApi, CertificateService, MomentService, ngTableParams, toaster) {
$scope.filter = $stateParams; $scope.filter = $stateParams;
$scope.certificateTable = new ngTableParams({ $scope.certificateTable = new ngTableParams({
page: 1, // show first page page: 1, // show first page
@ -29,11 +29,24 @@ angular.module('lemur')
}, { }, {
total: 0, // length of data total: 0, // length of data
getData: function ($defer, params) { getData: function ($defer, params) {
CertificateApi.getList(params.url()) $scope.path = $location.path();
.then(function (data) { // Handle Permalink clicks through a separate API
params.total(data.total); // Clicking on Permalink adds the certificate name to the URL after "certificates/", which is used to identify the click
$defer.resolve(data); if ($scope.path.indexOf('certificates/') > -1 && $scope.path.split('/')[2].length > 0) {
}); $scope.certificateName = $scope.path.split('/')[2];
CertificateApi.one('name').one($scope.certificateName).getList()
.then(function (data) {
params.total(data.total);
$defer.resolve(data);
});
}
else {
CertificateApi.getList(params.url())
.then(function (data) {
params.total(data.total);
$defer.resolve(data);
});
}
} }
}); });