Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<option ng-repeat="env in organObject[organNewEnt.org].environments" value="{{organObject[organNewEnt.org].environments.indexOf(env)}}" >{{env.name}}</option>
</select>
</div>
<div class="col-lg-12 col-md-12 form-group" ng-show="stateItems.filterView.provi">
<div class="col-lg-12 col-md-12 form-group" ng-show="stateItems.filterView.provi || analytic.ViewproviFilter">
<label for="">Provider</label>
<select class="form-control select2 select2-hidden-accessible" id="selectProvider" ng-model="organNewEnt.provider" >
<option value=''>Select</option>
Expand All @@ -66,7 +66,7 @@
</div>
<div class="col-lg-12 col-md-12 form-group" ng-show="stateItems.filterView.instanceType">
<label for="">Type of Instance</label>
<select class="form-control select2 select2-hidden-accessible" ng-model="filter.instanceType" ng-change="getResourse(filter.instanceType)">
<select class="form-control select2 select2-hidden-accessible" ng-model="organNewEnt.instanceType" ng-change="getResourse(organNewEnt.instanceType)">
<option value=''>Select</option>
<option value='Managed'>Managed</option>
<option value='Assigned'>Assigned</option>
Expand All @@ -86,7 +86,7 @@
</div>
<div class="panel-body bp-panel-body list-resources">
<ul class="list-group">
<li class="list-group-item cursor" ng-repeat="resource in resourceList | filter:searchText.name | filter:{platformId: filters.platformId}" ng-class="{'selected':selectedResources.indexOf(resource.platformId)>-1}" ng-click="toggleResourceSelection(resource.platformId);">{{resource.platformId}}</li>
<li class="list-group-item cursor" ng-repeat="resource in resourceList | filter:searchText.name | filter:{platformId: filters.platformId}" ng-class="{'selected':selectedResources.indexOf(resource._id)>-1}" ng-click="toggleResourceSelection(resource._id);">{{resource.platformId}}</li>
</ul>
</div>
</div>
Expand All @@ -105,7 +105,7 @@
<div id='rightPanel' class='container-fluid'>
<ul class="nav nav-tabs" >
<li ng-class="{'active':analytic.tabShowChat === true}"><a ng-click="analytic.tabShow(true,false)" ><i class="fa fa-area-chart fa-2" aria-hidden="true"></i> Dashboard</a></li>
<li ng-class="{'active':analytic.tabShowReport === true}"><a ng-click="analytic.tabShow(false,true)" ><i class="fa fa-file-text fa-2" aria-hidden="true"></i> Reports</a></li>
<li ng-show="!stateItems.filterView.report" ng-class="{'active':analytic.tabShowReport === true}"><a ng-click="analytic.tabShow(false,true)" ><i class="fa fa-file-text fa-2" aria-hidden="true"></i> Reports</a></li>
<li class="form-group pull-right filter-btn" >
<button type="button" class="btn btn-xs cat-btn-update ng-scope pull-right margin-left6" ng-click="isOpenSidebar = !isOpenSidebar">
<i class="fa fa-filter fa-2 white" aria-hidden="true"></i>&nbsp;Filter
Expand All @@ -125,7 +125,8 @@
<div class="col-lg-7 col-md-7 col-sm-12 pull-right" >
<span ng-repeat="filt in filterNewEnt" ng-if="filt !== '' && filt.title">
<!--data-toggle="tooltip" onmouseenter="$(this).tooltip('show')"-->
<span class="label label-success " title="{{filt.title}}">{{filt.title}} :{{filt.name}} </span>
<span class="label label-success " title="{{filt.title}}">{{filt.title}} :{{filt.name}}
</span>
</span>
</div>
</div>
Expand Down
65 changes: 48 additions & 17 deletions client/cat3/src/partials/sections/dashboard/analytics/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
}
}]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand All @@ -53,7 +61,7 @@
$rootScope.organNewEnt.org = or;
}
}

return 1;
}
};
}]);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Original file line number Diff line number Diff line change
@@ -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={};
Expand Down Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ <h3 class="box-title">Aggregate cost</h3>
</div>
<div class="col-lg-12 col-md-12 col-sm-12" >
<div class="box box-infobox box-info">
<div class="box-header with-border"><h3 class="box-title">Monthly trends of cost across organization</h3>
<div class="box-header with-border"><h3 class="box-title">Daily trends of cost across organization</h3>
<div class="box-tools pull-right" ng-show="cost.trendLineChart.data.length >0">
<span data-toggle="tooltip" title="3 New Messages" class="badge bg-yellow" >Total Cost - ${{cost.trendLineChart.totalCost}}</span>
<span data-toggle="tooltip" title="3 New Messages" class="badge bg-yellow" >Total Cost ${{cost.trendLineChart.totalCost}}</span>
</div>
</div>
<div class="box-body" ><nvd3 options="cost.trendLineChart.options" data="cost.trendLineChart.data" class="with-3d-shadow with-transitions"></nvd3></div>
Expand Down