From c42764c90c8e99aa9d3aa2b3c7a0e9e41d50d805 Mon Sep 17 00:00:00 2001 From: hrushikesh07 Date: Mon, 2 Jan 2017 17:34:32 +0530 Subject: [PATCH 1/2] single search added for ui grid --- .../controller/discoveryResourcesCtrl.js | 32 +++++++++++++++++-- .../analytics/view/discoveryResources.html | 6 ++-- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/client/cat3/src/partials/sections/dashboard/analytics/controller/discoveryResourcesCtrl.js b/client/cat3/src/partials/sections/dashboard/analytics/controller/discoveryResourcesCtrl.js index c44f1b07c..59a643f6e 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/controller/discoveryResourcesCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/analytics/controller/discoveryResourcesCtrl.js @@ -3,6 +3,9 @@ angular.module('dashboard.analytics') .controller('discoveryResourcesCtrl', ['$scope', '$rootScope', '$state','analyticsServices', 'genericServices','$timeout','toastr','$modal', function ($scope,$rootScope,$state,analyticsServices,genSevs,$timeout,toastr,$modal){ var disResrc=this; + $scope.gridApi=null; + disResrc.filterValue=''; + $scope.colArray=[]; $scope.instanceType=null; $scope.selectInstanceRow=[]; $scope.TagName={ @@ -71,6 +74,8 @@ paginationPageSize:25, columnDefs: [], onRegisterApi: function (gridApi) { + gridApi.grid.registerRowsProcessor( $scope.singleFilter, 200 ); + $scope.gridApi=gridApi; gridApi.edit.on.afterCellEdit($scope, function (rowEntity, colDefa, newValue, oldValue) { console.log( colDefa.name,'---',colDefa.name.substring(0, colDefa.name.length-3)); var tagna=colDefa.name.substring(0, colDefa.name.length-3); @@ -109,10 +114,12 @@ }; disResrc.gridOptionInstances.data = []; if($rootScope.organNewEnt.instanceType === 'Managed') { + $scope.colArray=['platformId','privateIpAddress','os','state']; + disResrc.gridOptionInstances.enableFiltering=true; disResrc.gridOptionInstances.columnDefs=[ {name: 'InstanceId', field: 'platformId',enableCellEditOnFocus: false, enableCellEdit: false,enableFiltering: true}, - {name: 'os', enableFiltering: true,displayName: 'OS', enableCellEdit: false, type: 'number',enableCellEditOnFocus: false}, + {name: 'os', enableFiltering: true,displayName: 'OS', enableCellEdit: false,enableCellEditOnFocus: false}, {name: 'privateIpAddress',enableFiltering: true, displayName: 'IP Address',enableCellEditOnFocus: false, enableCellEdit: false}, {name: 'state',enableFiltering: true, displayName: 'Status',enableCellEditOnFocus: false, @@ -147,7 +154,7 @@ ]; $scope.instanceType= 'managedInstances'; } else if($rootScope.organNewEnt.instanceType === 'Assigned'){ - disResrc.gridOptionInstances.enableFiltering=true; + $scope.colArray=['platformId','privateIpAddress','os','state']; disResrc.gridOptionInstances.columnDefs=[ {name: 'InstanceId', field: 'platformId',enableCellEditOnFocus: false, enableCellEdit: false,enableFiltering: true}, @@ -186,7 +193,7 @@ ]; $scope.instanceType= 'unmanagedInstances'; } else if($rootScope.organNewEnt.instanceType === 'Unassigned'){ - disResrc.gridOptionInstances.enableFiltering=false; + $scope.colArray=['platformId','privateIpAddress','os','state']; disResrc.gridOptionInstances.columnDefs= [ {name: 'InstanceId', field: 'platformId',enableCellEditOnFocus: false, enableCellEdit: false}, @@ -244,6 +251,7 @@ editDropdownValueLabel: 'id' } ]; + $scope.instanceType= 'unassigned-instances'; } var param = { @@ -307,6 +315,24 @@ analyticsServices.applyFilter(true,null); disResrc.init(); }; + $scope.filterInst = function() { + $scope.gridApi.grid.refresh(); + }; + $scope.singleFilter = function( renderableRows ){ + var matcher = new RegExp(disResrc.filterValue); + renderableRows.forEach( function( row ) { + var match = false; + angular.forEach($scope.colArray,function( field ){ + if ( row.entity[field] && row.entity[field].match(matcher) ){ + match = true; + } + }); + if ( !match ){ + row.visible = false; + } + }); + return renderableRows; + }; disResrc.init(); }]).controller('instanceManageCtrl',['$scope','$rootScope','items','$modalInstance','genericServices',function ($scope,$rootScope,items,$modalInstance,genericServices) { diff --git a/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryResources.html b/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryResources.html index 4fedf8987..e4118ea44 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryResources.html +++ b/client/cat3/src/partials/sections/dashboard/analytics/view/discoveryResources.html @@ -11,8 +11,10 @@ -
-
No Data Found!
+ + +
+
No Data Found!
From 65427f5a8aac2d025deecdda55a6419451c851e6 Mon Sep 17 00:00:00 2001 From: hrushikesh07 Date: Mon, 2 Jan 2017 17:37:15 +0530 Subject: [PATCH 2/2] inline search remove --- .../dashboard/analytics/controller/discoveryResourcesCtrl.js | 1 - 1 file changed, 1 deletion(-) diff --git a/client/cat3/src/partials/sections/dashboard/analytics/controller/discoveryResourcesCtrl.js b/client/cat3/src/partials/sections/dashboard/analytics/controller/discoveryResourcesCtrl.js index 59a643f6e..032d19fa5 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/controller/discoveryResourcesCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/analytics/controller/discoveryResourcesCtrl.js @@ -115,7 +115,6 @@ disResrc.gridOptionInstances.data = []; if($rootScope.organNewEnt.instanceType === 'Managed') { $scope.colArray=['platformId','privateIpAddress','os','state']; - disResrc.gridOptionInstances.enableFiltering=true; disResrc.gridOptionInstances.columnDefs=[ {name: 'InstanceId', field: 'platformId',enableCellEditOnFocus: false, enableCellEdit: false,enableFiltering: true},