diff --git a/client/cat3/src/partials/sections/dashboard/analytics/analytics.html b/client/cat3/src/partials/sections/dashboard/analytics/analytics.html
index ef0330037..905edc8be 100644
--- a/client/cat3/src/partials/sections/dashboard/analytics/analytics.html
+++ b/client/cat3/src/partials/sections/dashboard/analytics/analytics.html
@@ -45,7 +45,7 @@
-
@@ -105,7 +105,7 @@
- Dashboard
- - Reports
+ - Reports
-
diff --git a/client/cat3/src/partials/sections/dashboard/analytics/analytics.js b/client/cat3/src/partials/sections/dashboard/analytics/analytics.js
index 1194d88db..92d6ff7d0 100644
--- a/client/cat3/src/partials/sections/dashboard/analytics/analytics.js
+++ b/client/cat3/src/partials/sections/dashboard/analytics/analytics.js
@@ -43,7 +43,7 @@
url: "usage/",
templateUrl: "src/partials/sections/dashboard/analytics/view/usage.html",
controller: "usageCtrl as usage",
- params:{filterView:{org:true,provi:true,region:false,instanceType:true,resources:true}},
+ params:{filterView:{org:true,provi:true,instanceType:true,resources:true,report:true}},
resolve: {
auth: ["$q", function ($q) {
var deferred = $q.defer();
@@ -77,11 +77,15 @@
$scope.$watch(function() { return analytic.viewByFilter}, function(newVal, oldVal) {
if(newVal === 'ProviderView'){
$rootScope.viewType='ProviderView';
- $state.params.filterView.provi=true;
+ if($state.params && $state.params.filterView){
+ analytic.ViewproviFilter=true;
+ }
} else {
$rootScope.organNewEnt.provider=''
$rootScope.viewType='orgView';
- $state.params.filterView.provi=false;
+ if($state.params && $state.params.filterView){
+ analytic.ViewproviFilter=false;
+ }
}
$rootScope.stateItems = $state.params;
}, true);
@@ -167,41 +171,68 @@
}
};
$scope.getResourse = function(instType) {
+ $rootScope.filterNewEnt.resources=[];
+ $scope.selectedResources=[];
if(instType === 'Managed') {
workzoneServices.getManagedInstances($scope.filter.providerId).then(function(response) {
- $scope.resourceList = response.data;
+ if(response.data && response.data.managedInstances && response.data.managedInstances.length >0){
+ $scope.resourceList = response.data.managedInstances;
+ } else{
+ $scope.resourceList=[];
+ }
}, function(error) {
toastr.error(error);
});
}
if(instType === 'Assigned') {
workzoneServices.getAssignedInstances($scope.filter.providerId).then(function(response) {
- $scope.resourceList = response.data.unmanagedInstances;
+ if(response.data && response.data.unmanagedInstances.length >0){
+ $scope.resourceList = response.data.unmanagedInstances;
+ } else{
+ $scope.resourceList = [];
+ }
+
}, function(error) {
toastr.error(error);
});
}
if(instType === 'Unassigned') {
workzoneServices.getUnassignedInstances($scope.filter.providerId).then(function(response) {
- $scope.resourceList = response.data.data;
+ if(response.data && response.data.data && response.data.data.length >0){
+ $scope.resourceList = response.data.data;
+ $scope.selectedResources.push(response.data.data[0]._id);
+ $rootScope.filterNewEnt.resources=$scope.selectedResources;
+ } else {
+ $scope.resourceList = [];
+ }
}, function(error) {
toastr.error(error);
});
}
};
+ $scope.$on('INI_usage', function (event, id) {
+ $scope.getResourse(id);
+ });
$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);
- }
- }
+ // 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);
+ // }
+ // }
+ if($scope.selectedResources === resourceId){
+ $scope.selectedResources='';
+ } else{
+ $scope.selectedResources=resourceId;
+ }
+
+ $rootScope.filterNewEnt.resources=$scope.selectedResources;
};
- if (!$rootScope.stateParams.view) {
+ if (!$rootScope.stateParams.view && $rootScope.organObject) {
$state.go('dashboard.analytics.cost');
}
}]);
diff --git a/client/cat3/src/partials/sections/dashboard/analytics/analyticsServices.js b/client/cat3/src/partials/sections/dashboard/analytics/analyticsServices.js
index bd370c6a8..cb52c0c98 100644
--- a/client/cat3/src/partials/sections/dashboard/analytics/analyticsServices.js
+++ b/client/cat3/src/partials/sections/dashboard/analytics/analyticsServices.js
@@ -20,8 +20,10 @@
$rootScope.filterNewEnt.period = period;
if (or) {
- $rootScope.filterNewEnt.org = {name: obj[or].name, id: obj[or].rowid, title: 'Org'};
+ $rootScope.filterNewEnt.org = {name: obj[or].name, id: obj[or].rowid, title: 'ORG'};
$rootScope.filterNewEnt.provider = '';
+ } else{
+ $rootScope.filterNewEnt.org = {id: obj[or].rowid, title: 'ORG'};
}
if (filterApp) {
if (bu) {
@@ -38,7 +40,13 @@
title: 'Project'
};
}
-
+ if($rootScope.organNewEnt.instanceType) {
+ $rootScope.filterNewEnt.instanceType = {
+ name: $rootScope.organNewEnt.instanceType,
+ id: $rootScope.organNewEnt.instanceType,
+ title: 'Instance'
+ };
+ }
if ($rootScope.organNewEnt.provider) {
$rootScope.filterNewEnt.provider = {
name: $rootScope.providers[$rootScope.organNewEnt.provider].providerName,
@@ -53,7 +61,7 @@
$rootScope.organNewEnt.org = or;
}
}
-
+ return 1;
}
};
}]);
diff --git a/client/cat3/src/partials/sections/dashboard/analytics/controller/costCtrl.js b/client/cat3/src/partials/sections/dashboard/analytics/controller/costCtrl.js
index 4a31b6da5..76f5a39a3 100644
--- a/client/cat3/src/partials/sections/dashboard/analytics/controller/costCtrl.js
+++ b/client/cat3/src/partials/sections/dashboard/analytics/controller/costCtrl.js
@@ -1,12 +1,11 @@
(function (angular) {
"use strict";
angular.module('dashboard.analytics')
- .controller('costCtrl', ['$scope', '$rootScope', '$state','analyticsServices', 'genericServices', function ($scope,$rootScope,$state,analyticsServices,genSevs){
+ .controller('costCtrl', ['$scope', '$rootScope', '$state','analyticsServices', 'genericServices','$timeout', function ($scope,$rootScope,$state,analyticsServices,genSevs,$timeout){
$rootScope.stateItems = $state.params;
//analyticsServices.initFilter();
// var treeNames = ['Analytics','Cost'];
// $rootScope.$emit('treeNameUpdate', treeNames);
- analyticsServices.initFilter();
var costObj =this;
costObj.chartData=[];
costObj.splitUp=null;
@@ -267,7 +266,6 @@
}
});
};
- costObj.createChart();
$scope.$on('CHANGE_VIEW', function (event, data) {
costObj.splitUp=data.replace(/([A-Z])/g, ' $1').replace(/^./, function(str) {
return str.toUpperCase();
@@ -280,8 +278,15 @@
costObj.getCostData($rootScope.filterNewEnt);
}
};
- $rootScope.applyFilter(true,'month');
- costObj.trendsChart($rootScope.filterNewEnt);
+ costObj.init =function(){
+ analyticsServices.initFilter();
+ costObj.createChart();
+ $timeout(function () {
+ $rootScope.applyFilter(true,'month');
+ costObj.trendsChart($rootScope.filterNewEnt);
+ },200);
+ };
+ costObj.init();
- }]);
+ }]);
})(angular);
diff --git a/client/cat3/src/partials/sections/dashboard/analytics/controller/usageCtrl.js b/client/cat3/src/partials/sections/dashboard/analytics/controller/usageCtrl.js
index f740ee3d7..04b66b4c0 100644
--- a/client/cat3/src/partials/sections/dashboard/analytics/controller/usageCtrl.js
+++ b/client/cat3/src/partials/sections/dashboard/analytics/controller/usageCtrl.js
@@ -1,9 +1,8 @@
(function (angular) {
"use strict";
angular.module('dashboard.analytics')
- .controller('usageCtrl', ['$scope', '$rootScope', '$state','analyticsServices', 'genericServices', function ($scope,$rootScope,$state,analyticsServices,genSevs){
+ .controller('usageCtrl', ['$scope', '$rootScope', '$state','analyticsServices', 'genericServices','$timeout', function ($scope,$rootScope,$state,analyticsServices,genSevs,$timeout){
$rootScope.stateItems = $state.params;
- console.log($state.params);
var usage =this;
usage.trendsChart=function(fltObj){
usage.trendLineChart={};
@@ -65,31 +64,42 @@
};
usage.trendLineChart.data = [];
usage.costGridOptions.columnDefs = [];
- var param = {
- url: 'http://neocatalyst.rlcatalyst.com/analytics/trend/usage?resource=57da3fecbddbbdf876981be5&fromTimeStamp=2016-09-27T07:07:17&toTimeStamp=2016-09-28T07:07:17&interval=3600'
- };
- genSevs.promiseGet(param).then(function (result) {
- angular.forEach(result, function (valu, keyChild) {
- var va = [];
- angular.forEach(valu.dataPoints, function (value) {
- va.push([Date.parse(value.fromTime), value.average]);
+ var $today = new Date();
+ var $yesterday = new Date($today);
+ $yesterday.setDate($today.getDate() - 1);
+ // if(fltObj && fltObj.resources && fltObj.resources.length >0) {
+ //angular.forEach(fltObj.resources, function (resId) {
+ var param = {
+ url: '/analytics/trend/usage?resource='+fltObj.resources+'&fromTimeStamp='+$yesterday+'&toTimeStamp='+ $today+'&interval=3600'
+ };
+ genSevs.promiseGet(param).then(function (result) {
+ angular.forEach(result, function (valu, keyChild) {
+ var va = [];
+ angular.forEach(valu.dataPoints, function (value) {
+ va.push([Date.parse(value.fromTime), value.average]);
+ });
+ usage.trendLineChart.data.push({
+ "key": keyChild,
+ "values": va
+ });
+ });
});
- usage.trendLineChart.data.push({
- "key": keyChild,
- "values": va
- });
- });
- });
+ ///});
+ /// }
};
- $rootScope.applyFilter =function(filterApp,period){
- analyticsServices.applyFilter(filterApp,period);
- if($state.current.name === "dashboard.analytics.usage") {
- usage.trendsChart($rootScope.filterNewEnt);
- }
- };
- if($state.current.name === "dashboard.analytics.usage") {
- usage.trendsChart($rootScope.filterNewEnt);
- }
+ $rootScope.applyFilter =function(filterApp,period){
+ analyticsServices.applyFilter(filterApp,period);
+ if($state.current.name === "dashboard.analytics.usage") {
+ usage.trendsChart($rootScope.filterNewEnt);
+ }
+ };
+ usage.init =function(){
+ $rootScope.organNewEnt.instanceType='Unassigned';
+ $rootScope.organNewEnt.provider='0';
+ $scope.$emit('INI_usage', 'Unassigned');
+ $timeout(function(){$rootScope.applyFilter(true,'month')},200);
+ };
+ usage.init();
- }]);
+ }]);
})(angular);
diff --git a/client/cat3/src/partials/sections/dashboard/analytics/view/cost.html b/client/cat3/src/partials/sections/dashboard/analytics/view/cost.html
index 00b70c483..6ca4728fd 100644
--- a/client/cat3/src/partials/sections/dashboard/analytics/view/cost.html
+++ b/client/cat3/src/partials/sections/dashboard/analytics/view/cost.html
@@ -31,9 +31,9 @@ Aggregate cost