Sorting certificate table
So far the certificate table was not sorted and it happen that having
multiple certificates they appear on different table position after
machine restart.
That is because the Redfish was used to get the list of certificates
and it does not guarantee any order of elements in returned
collections.
After merging this commit certificates will be always sorted by:
type, issuer name and then by date.
Tested:
Manual tests were made to cofirm that certificates are properly sorted.
Signed-off-by: Zbigniew Kurzynski <zbigniew.kurzynski@intel.com>
Change-Id: Ie8e63d598cd04e2396ed09244a69284e49566f8d
diff --git a/app/access-control/controllers/certificate-controller.js b/app/access-control/controllers/certificate-controller.js
index ad9a060..8a78c05 100644
--- a/app/access-control/controllers/certificate-controller.js
+++ b/app/access-control/controllers/certificate-controller.js
@@ -50,6 +50,24 @@
})
.finally(function() {
$scope.loading = false;
+ $scope.certificates.sort(function(a, b) {
+ if (a.Name > b.Name) {
+ return 1;
+ }
+ if (a.Name < b.Name) {
+ return -1;
+ }
+ if (a.Issuer.CommonName > b.Issuer.CommonName) {
+ return 1;
+ }
+ if (a.Issuer.CommonName < b.Issuer.CommonName) {
+ return -1;
+ }
+ return (Date.parse(a.ValidNotBefore) >
+ Date.parse(b.ValidNotBefore)) ?
+ 1 :
+ -1;
+ });
});
},
function(error) {