From 381269d18e7a09abb81bc21966a4a8d6b4b37e39 Mon Sep 17 00:00:00 2001 From: Divakar Konakalla Date: Tue, 27 Sep 2016 19:20:23 +0530 Subject: [PATCH] Integrated API's to get list of managed, assigned & unassigned instance list, implemented search of instances through key words, multiselect component to select more than 1 resources at a time. --- client/cat3/src/factory/workzoneServices.js | 12 ++ .../dashboard/analytics/analytics.html | 166 +++++++++--------- .../sections/dashboard/analytics/analytics.js | 63 +++++-- .../dashboard/analytics/analytics.scss | 8 +- 4 files changed, 152 insertions(+), 97 deletions(-) diff --git a/client/cat3/src/factory/workzoneServices.js b/client/cat3/src/factory/workzoneServices.js index d42205a56..342f856b8 100644 --- a/client/cat3/src/factory/workzoneServices.js +++ b/client/cat3/src/factory/workzoneServices.js @@ -515,6 +515,18 @@ }; var url ='/aws/providers/describe/vpcs'; return $http.post(fullUrl(url),reqBody, Auth.getHeaderObject()); + }, + getManagedInstances:function (providerId) { + var url ='/providers/'+providerId+'/managedInstances'; + return $http.get(fullUrl(url),Auth.getHeaderObject()); + }, + getAssignedInstances:function (providerId) { + var url ='/providers/'+providerId+'/unmanagedInstances'; + return $http.get(fullUrl(url),Auth.getHeaderObject()); + }, + getUnassignedInstances:function (providerId) { + var url ='/providers/'+providerId+'/unassigned-instances'; + return $http.get(fullUrl(url),Auth.getHeaderObject()); } }; return serviceInterface; diff --git a/client/cat3/src/partials/sections/dashboard/analytics/analytics.html b/client/cat3/src/partials/sections/dashboard/analytics/analytics.html index 86f795f6f..599a15e81 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/analytics.html +++ b/client/cat3/src/partials/sections/dashboard/analytics/analytics.html @@ -17,80 +17,85 @@ Provider -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-
-
- -
-
-
    -
  • First itemitemitemitem
  • -
  • Second item
  • -
  • Third item
  • -
-
-
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+ +
+
+
    +
  • {{resource.platformId}}
  • +
+
- - -
- -
+
+
+ + +

@@ -108,22 +113,21 @@
-
- - - - - -
+
+ + + + + +
{{filt.title}} :{{filt.name}}
-
diff --git a/client/cat3/src/partials/sections/dashboard/analytics/analytics.js b/client/cat3/src/partials/sections/dashboard/analytics/analytics.js index 12f865892..9c64d1f66 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/analytics.js +++ b/client/cat3/src/partials/sections/dashboard/analytics/analytics.js @@ -19,7 +19,6 @@ deferred.reject({redirectTo: 'dashboard'}); } return deferred.promise; - }] } }).state('dashboard.analytics.capacity', { @@ -38,14 +37,13 @@ deferred.reject({redirectTo: 'dashboard'}); } return deferred.promise; - }] } }).state('dashboard.analytics.usage', { url: "usage/", templateUrl: "src/partials/sections/dashboard/analytics/view/usage.html", controller: "usageCtrl as usage", - params:{filterView:{org:true,provi:true,region:true,resources:true}}, + params:{filterView:{org:true,provi:true,region:false,instanceType:true,resources:true}}, resolve: { auth: ["$q", function ($q) { var deferred = $q.defer(); @@ -57,7 +55,6 @@ deferred.reject({redirectTo: 'dashboard'}); } return deferred.promise; - }] } }) @@ -79,16 +76,17 @@ $rootScope.organNewEnt.org = '0'; $rootScope.filterNewEnt.period='month'; $rootScope.splitUpCosts=[]; + $scope.selectedResources = []; analytic.viewByFilter='orgView'; $scope.$watch(function() { return analytic.viewByFilter}, function(newVal, oldVal) { - if(newVal === 'ProviderView'){ - $rootScope.viewType='ProviderView'; - $state.params.filterView.provi=true; - } else { - $rootScope.organNewEnt.provider='' - $rootScope.viewType='orgView'; - $state.params.filterView.provi=false; - } + if(newVal === 'ProviderView'){ + $rootScope.viewType='ProviderView'; + $state.params.filterView.provi=true; + } else { + $rootScope.organNewEnt.provider='' + $rootScope.viewType='orgView'; + $state.params.filterView.provi=false; + } $rootScope.stateItems = $state.params; }, true); $scope.$on('CHANGE_splitUp', function (event, data) { @@ -131,7 +129,7 @@ analytic.splitUp=$rootScope.splitUpCosts[0]; } }; - // // get organigetion + //get organisation genericServices.getTreeNew().then(function (orgs) { $rootScope.organObject = orgs; analytic.applyFilter(true); @@ -165,6 +163,8 @@ $scope.getProviders = function() { workzoneServices.getProviders().then(function(response) { $scope.providers = response.data; + $scope.filter = []; + $scope.filter.providerId = response.data[0]._id; }, function(error) { toastr.error(error); }); @@ -209,5 +209,40 @@ $scope.getProviderRegions(); } }; + $scope.getResourse = function(instType) { + if(instType === 'Managed') { + workzoneServices.getManagedInstances($scope.filter.providerId).then(function(response) { + $scope.resourceList = response.data; + }, function(error) { + toastr.error(error); + }); + } + if(instType === 'Assigned') { + workzoneServices.getAssignedInstances($scope.filter.providerId).then(function(response) { + $scope.resourceList = response.data.unmanagedInstances; + }, function(error) { + toastr.error(error); + }); + } + if(instType === 'Unassigned') { + workzoneServices.getUnassignedInstances($scope.filter.providerId).then(function(response) { + $scope.resourceList = response.data.data; + }, function(error) { + toastr.error(error); + }); + } + }; + $scope.toggleResourceSelection = function(resourceId) { + var idx = $scope.selectedResources.indexOf(resourceId); + if(idx > -1) { + $scope.selectedResources.splice(idx, 1); + } else { + if($scope.selectedResources.length === 5){ + toastr.error('Maximum 5 resources allowed.'); + }else{ + $scope.selectedResources.push(resourceId); + } + } + }; }]); -})(angular); +})(angular); \ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/analytics/analytics.scss b/client/cat3/src/partials/sections/dashboard/analytics/analytics.scss index ec22e0e14..f05b6671a 100644 --- a/client/cat3/src/partials/sections/dashboard/analytics/analytics.scss +++ b/client/cat3/src/partials/sections/dashboard/analytics/analytics.scss @@ -227,8 +227,8 @@ } .bp-panel-body { - max-height:150px; - min-height: 100px; + max-height: 105px; + min-height: 80px; overflow-y: auto; } @@ -264,4 +264,8 @@ .filter-name { margin-top: -21px; } + + .selected { + background: #ddd; + } } \ No newline at end of file