summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/ui/app.js
diff options
context:
space:
mode:
authorthuva4 <tharma.thuva@gmail.com>2018-03-10 00:10:46 +0530
committerthuva4 <tharma.thuva@gmail.com>2018-03-10 00:13:38 +0530
commit0f4b6dd80c7e2d4468025486e7b0dc58505125d4 (patch)
treee349ee280a129d4edf5c0623532bc831737597c2 /testapi/opnfv_testapi/ui/app.js
parentbc5a216764b93ad9551830f2459194a4cea9d754 (diff)
Add sorting service to module
Show the results in sorted order Provide options to sort the results by fields in pods and project page Change-Id: I9b73fbe98146d4bdf9edbb4a3ef3b3e0717500a7 qSigned-off-by: thuva4 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/opnfv_testapi/ui/app.js')
-rw-r--r--testapi/opnfv_testapi/ui/app.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/testapi/opnfv_testapi/ui/app.js b/testapi/opnfv_testapi/ui/app.js
index a64bfcc..ada7577 100644
--- a/testapi/opnfv_testapi/ui/app.js
+++ b/testapi/opnfv_testapi/ui/app.js
@@ -34,6 +34,36 @@
angular
.module('testapiApp')
+ .service('sortService', function(){
+
+ this.sortFunction = function(data, field, ascending){
+ if(ascending){
+ data.sort(function(a,b) {
+ if (a[field].toLowerCase() > b[field].toLowerCase()) {
+ return -1;
+ }
+ if (a[field].toLowerCase() < b[field].toLowerCase()) {
+ return 1;
+ }
+ return 0;
+ });
+ }else{
+ data.sort(function(a,b) {
+ if (a[field].toLowerCase() < b[field].toLowerCase()) {
+ return -1;
+ }
+ if (a[field].toLowerCase() > b[field].toLowerCase()) {
+ return 1;
+ }
+ return 0;
+ });
+ }
+ return data
+ }
+ });
+
+ angular
+ .module('testapiApp')
.directive('dynamicModel', ['$compile', '$parse', function ($compile, $parse) {
return {
restrict: 'A',