2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 //app.controller('DCAE_Ctrl_KPI',
22 var DCAE_Ctrl_KPI = function($scope, $http, $log, $uibModal, $modal, KpiDashboardService) {
23 $scope.Math = window.Math;
24 $scope.activeToplevelTabId = 'DCAE';
25 $scope.activeTabId = 'KPI';
26 var TabIdforState = 'DCAE';
27 $scope.toplevelgTabs1 = KpiDashboardService.getToplevelgTabs1();
28 $scope.toplevelgTabs2 = KpiDashboardService.getToplevelgTabs2();
29 $scope.toplevelgTabs3 = KpiDashboardService.getToplevelgTabs3();
30 $scope.gTabs = KpiDashboardService.getGenericTabs(TabIdforState);
32 $scope.progressReadinessMap = {
40 $scope.progressReadinessColorMap = {
48 $scope.selectedIST = null;
49 $scope.progressReadinessList = [];
51 $scope.progressReadinessListIndexMap = {};
53 for ( var key in $scope.progressReadinessMap) {
54 if ($scope.progressReadinessMap.hasOwnProperty(key)) {
55 $scope.progressReadinessList.push({
58 'title' : $scope.progressReadinessMap[key]
60 $scope.progressReadinessListIndexMap[key] = counter
62 counter = counter + 1;
64 $scope.selectedProgressReadiness1 = $scope.progressReadinessList[0];
66 // restAPI calls to retrieve all user stories
67 KpiDashboardService.getKpiUserStoriesStats().then(
69 $scope.userStories = response.data;
72 if ($scope.userStories) {
73 $scope.userStories.forEach(function(item,
75 $scope.releases.push({
77 'value' : item.releaseKey,
78 'title' : item.releaseKey
81 $scope.selectedRelease = $scope.releases[0];
85 KpiDashboardService.getKpiLocStats()
88 $scope.locStats = response.data;
89 var arr = $scope.locStats;
91 $.each(arr, function() {
92 $scope.totalLOC += this;
94 var sorted = arr.slice().sort(
98 $scope.LOCranks = arr.slice().map(
100 return sorted.indexOf(v)
102 $scope.sortedLOC = []
103 KpiDashboardService.getKpiLocStatsCat()
106 $scope.locStatsCat = response.data;
107 $scope.locStatsCatRanked = [];
108 var OtherPutLast = false
109 for (i = 0; i < $scope.LOCranks.length; i++) {
110 $scope.locStatsCatRanked[$scope.LOCranks[i]] = $scope.locStatsCat[i];
111 $scope.sortedLOC[$scope.LOCranks[i]] = $scope.locStats[i];
114 $scope.sortedLocArray = [];
115 var OthersLoC = null;
117 for (i = 0; i < $scope.sortedLOC.length; i++) {
118 if ($scope.locStatsCatRanked[i]
119 .toLowerCase() !== "others") {
120 $scope.sortedLocArray
122 'category' : $scope.locStatsCatRanked[i],
123 'LOC' : $scope.sortedLOC[i]
126 OthersLoC = $scope.sortedLOC[i]
129 $scope.sortedLocArray
131 'category' : 'Others',
137 KpiDashboardService.getKpiServiceSupported()
140 $scope.kpiServiceSupported = response.data;
143 KpiDashboardService.getKpiPublishedDelivered()
144 .then(function(response) {
145 $scope.kpiTrafficStatsArray = response.data;
146 $scope.kpiTrafficStats = [];
147 $scope.kpiTrafficStats.push({
148 'title' : 'Published',
149 'count' : $scope.kpiTrafficStatsArray[0]
151 $scope.kpiTrafficStats.push({
152 'title' : 'Delivered',
153 'count' : $scope.kpiTrafficStatsArray[1]
157 KpiDashboardService.getKpiFeedStats()
160 $scope.kpiFeedStatsArray = response.data;
161 $scope.kpiFeedStats = [];
162 $scope.kpiFeedStats.push({
163 'title' : 'Total Feeds',
164 'count' : $scope.kpiFeedStatsArray[0]
166 $scope.kpiFeedStats.push({
167 'title' : 'Active Feeds',
168 'count' : $scope.kpiFeedStatsArray[1]
170 $scope.kpiFeedStats.push({
171 'title' : 'Active Subs',
172 'count' : $scope.kpiFeedStatsArray[2]
176 KpiDashboardService.getKpiUserApiStats()
179 $scope.userApis = response.data;
180 $scope.userApiTypes = [];
181 if ($scope.userApis) {
182 $scope.userApis.forEach(function(
184 $scope.userApiTypes.push({
186 'value' : item.apiType,
187 'title' : item.apiType
190 $scope.selectedUserApiType = $scope.userApiTypes[0]
194 $scope.linesOfCode = {
195 "TotalLOC" : "2.068M",
196 "OpenSource" : "63%",
201 $scope.updateUserStory = function(releases, userStories,
202 progressReadinessList,
203 progressReadinessListIndexMap) {
204 var modalInstance = $uibModal
206 animation : $scope.animationsEnabled,
207 templateUrl : 'kpi-dashboard/app/fusion/scripts/view-models/kpidash-page/userstory-edit.html',
213 function($scope, $uibModalInstance,
216 $scope.AngChangeCalled = function() {
218 .log('change called');
220 .log($scope.selectedRelease.releaseKey);
221 $scope.selectedIST = $scope.progressReadinessList[progressReadinessListIndexMap[$scope.userStories[$scope.selectedRelease.index].istprogressReadiness]];
222 $scope.selectedETE = $scope.progressReadinessList[progressReadinessListIndexMap[$scope.userStories[$scope.selectedRelease.index].e2EProgressReadiness]];
224 .log("$scope.selectedIST");
226 .log($scope.selectedIST);
228 .log("$scope.selectedETE");
230 .log($scope.selectedETE);
232 $scope.releases = releases;
233 $scope.userStories = userStories;
234 $scope.progressReadinessList = progressReadinessList;
235 $scope.progressReadinessListIndexMap = progressReadinessListIndexMap;
236 $scope.ok = function() {
237 $scope.userStories[$scope.selectedRelease.index].istprogressReadiness = $scope.selectedIST.value;
238 $scope.userStories[$scope.selectedRelease.index].e2EProgressReadiness = $scope.selectedETE.value;
241 'portalApi/update_user_stories_stats',
242 $scope.userStories[$scope.selectedRelease.index])
246 $scope.userStories = response.data;
247 $scope.releases = [];
248 if ($scope.userStories) {
256 'value' : item.releaseKey,
257 'title' : item.releaseKey
266 $scope.cancel = function() {
267 $uibModalInstance.dismiss();
270 // End of inner controller
275 $scope.updateUserApi = function(userApiTypes, userApis) {
276 // workflowToEdit.active='true';
277 var modalInstance = $uibModal
279 animation : $scope.animationsEnabled,
280 templateUrl : 'kpi-dashboard/app/fusion/scripts/view-models/kpidash-page/userapi-edit.html',
286 function($scope, $uibModalInstance,
288 $scope.userApiTypes = userApiTypes;
289 $scope.userApis = userApis;
290 $scope.ok = function() {
293 * {"id":null,"created":null,"modified":null,"createdId":null,"modifiedId":null,"rowNum":null,"auditUserId":null,"auditTrail":null,"apiType":"Physical
294 * APIs","totalApi":2000,"comment":null};
296 var temp = $scope.userApis[$scope.selectedUserApiType.apiType.index]
299 'portalApi/update_user_api_stats',
307 * $http.post('update_user_stories_stats',$scope.userStories[$scope.selectedRelease.releaseKey.index])
308 * .then(function(response){
309 * $scope.userStories =
313 * if($scope.userStories){
314 * $scope.userStories.forEach(function(item,
316 * $scope.releases.push({'index':
320 * 'title':item.releaseKey});
322 * $uibModalInstance.close();
328 $scope.cancel = function() {
329 $uibModalInstance.dismiss();
332 // End of inner controller
338 DCAE_Ctrl_KPI.$inject = ['$scope','$http', '$log', '$uibModal', '$modal', 'KpiDashboardService'];
339 angular.module('ecompApp').controller('DCAE_Ctrl_KPI',DCAE_Ctrl_KPI);
344 app.controller('DCAE_Ctrl_UserDefinedKPI', function($scope, $http, $log, KpiDashboardService) {
345 $scope.activeToplevelTabId = 'DCAE';
346 $scope.activeTabId = 'User Defined KPI';
347 var TabIdforState = 'DCAE';
348 $scope.toplevelgTabs1 = KpiDashboardService.getToplevelgTabs1();
349 $scope.toplevelgTabs2 = KpiDashboardService.getToplevelgTabs2();
350 $scope.toplevelgTabs3 = KpiDashboardService.getToplevelgTabs3();
351 $scope.gTabs = KpiDashboardService.getGenericTabs(TabIdforState);
355 app.controller('DCAE_Ctrl_Metrics', function($scope, $http, $log, $uibModal,
356 $modal, KpiDashboardService) {
357 $scope.activeToplevelTabId = 'DCAE';
358 $scope.activeTabId = 'Metrics';
359 var TabIdforState = 'DCAE';
360 $scope.toplevelgTabs1 = KpiDashboardService.getToplevelgTabs1();
361 $scope.toplevelgTabs2 = KpiDashboardService.getToplevelgTabs2();
362 $scope.toplevelgTabs3 = KpiDashboardService.getToplevelgTabs3();
363 $scope.gTabs = KpiDashboardService.getGenericTabs(TabIdforState);
365 KpiDashboardService.getKpiGeoMapUrl()
366 .then(function(response) {
367 $scope.geoMapUrl = response.data;
370 KpiDashboardService.getKpiRCloudAUrl()
371 .then(function(response) {
372 $scope.rcloudAUrl = response.data;