2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
24 appDS2.controller("ServiceModelController", function ($scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService,
\r
25 PropertyService, UtilityService) {
\r
29 // var baseEndpoint = "vid";
\r
30 var pathQuery = COMPONENT.SERVICES_DIST_STATUS_PATH + VIDCONFIGURATION.ASDC_MODEL_STATUS;
\r
32 if ( VIDCONFIGURATION.ASDC_MODEL_STATUS === FIELD.STATUS.ALL) {
\r
33 pathQuery = COMPONENT.SERVICES_PATH;
\r
36 $scope.getServiceModels = function() {
\r
37 $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG_ASDC;
\r
39 $http.get(pathQuery)
\r
40 .then(function successCallback(response) {
\r
41 $scope.services = [];
\r
42 if (angular.isArray(response.data)) {
\r
43 $scope.services = response.data;
\r
44 $scope.viewPerPage=10;
\r
45 $scope.totalPage=$scope.services.length/$scope.viewPerPage;
\r
46 $scope.sortBy=COMPONENT.NAME;
\r
47 $scope.scrollViewPerPage=2;
\r
48 $scope.currentPage=1;
\r
49 $scope.searchCategory;
\r
50 $scope.searchString="";
\r
51 $scope.currentPageNum=1;
\r
52 $scope.isSpinnerVisible = false;
\r
53 $scope.isProgressVisible = false;
\r
55 $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC;
\r
56 $scope.error = true;
\r
57 $scope.isSpinnerVisible = false;
\r
59 }, function errorCallback(response) {
\r
60 console.log("Error: " + response);
\r
64 $scope.init = function() {
\r
65 var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec();
\r
66 PropertyService.setMsoMaxPollingIntervalMsec(msecs);
\r
68 var polls = PropertyService.retrieveMsoMaxPolls();
\r
69 PropertyService.setMsoMaxPolls(polls);
\r
71 //PropertyService.setMsoBaseUrl("testmso");
\r
72 PropertyService.setServerResponseTimeoutMsec(10000);
\r
75 $scope.prevPage = function() {
\r
76 $scope.currentPage--;
\r
79 $scope.nextPage = function() {
\r
80 $scope.currentPage++;
\r
83 $scope.createType = COMPONENT.A_LA_CARTE;
\r
84 $scope.deployService = function(service) {
\r
87 console.log("Instantiating SDC service " + service.uuid);
\r
89 $http.get(COMPONENT.SERVICES_PATH + service.uuid)
\r
90 .then(function successCallback(getServiceResponse) {
\r
92 var serviceModel = getServiceResponse.data;
\r
93 DataService.setServiceName(serviceModel.service.name);
\r
95 DataService.setModelInfo(COMPONENT.SERVICE, {
\r
96 "modelInvariantId": serviceModel.service.invariantUuid,
\r
97 "modelVersion": serviceModel.service.version,
\r
98 "modelNameVersionId": serviceModel.service.uuid,
\r
99 "modelName": serviceModel.service.name,
\r
100 "description": serviceModel.service.description,
\r
101 "category":serviceModel.service.category
\r
103 DataService.setALaCarte (true);
\r
104 $scope.createType = COMPONENT.A_LA_CARTE;
\r
105 var broadcastType = COMPONENT.CREATE_COMPONENT;
\r
107 if (UtilityService.arrayContains (VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid )) {
\r
108 DataService.setALaCarte (false);
\r
109 $scope.createType = COMPONENT.MACRO;
\r
110 var convertedAsdcModel = UtilityService.convertModel(serviceModel);
\r
112 //console.log ("display inputs ");
\r
113 //console.log (JSON.stringify ( convertedAsdcModel.completeDisplayInputs));
\r
115 DataService.setModelInfo(COMPONENT.SERVICE, {
\r
116 "modelInvariantId": serviceModel.service.invariantUuid,
\r
117 "modelVersion": serviceModel.service.version,
\r
118 "modelNameVersionId": serviceModel.service.uuid,
\r
119 "modelName": serviceModel.service.name,
\r
120 "description": serviceModel.service.description,
\r
121 "category":serviceModel.service.category,
\r
122 "serviceEcompNaming": serviceModel.service.serviceEcompNaming,
\r
123 "inputs": serviceModel.service.inputs,
\r
124 "displayInputs": convertedAsdcModel.completeDisplayInputs
\r
128 $scope.$broadcast(broadcastType, {
\r
129 componentId : COMPONENT.SERVICE,
\r
130 callbackFunction : function(response) {
\r
131 if (response.isSuccessful) {
\r
132 vidService.setModel(serviceModel);
\r
134 var subscriberId = FIELD.STATUS.NOT_FOUND;
\r
135 var serviceType = FIELD.STATUS.NOT_FOUND;
\r
137 var serviceInstanceId = response.instanceId;
\r
139 for (var i = 0; i < response.control.length; i++) {
\r
140 if (response.control[i].id == COMPONENT.SUBSCRIBER_NAME) {
\r
141 subscriberId = response.control[i].value;
\r
142 } else if (response.control[i].id == FIELD.ID.SERVICE_TYPE) {
\r
143 serviceType = response.control[i].value;
\r
148 $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId);
\r
154 }, function errorCallback(response) {
\r
155 console.log("Error: " + response);
\r
159 $scope.refreshSubs = function(subscriberId, serviceType, serviceInstanceId) {
\r
160 $scope.status = FIELD.STATUS.FETCHING_SUBSCRIBER_LIST_AAI;
\r
162 $http.get( FIELD.ID.AAI_REFRESH_FULL_SUBSCRIBERS, {
\r
165 timeout: $scope.responseTimeoutMsec
\r
166 }).then(function(response){
\r
168 if (response.data.status < 200 || response.data.status > 202) {
\r
169 $scope.showError(FIELD.ERROR.MSO)
\r
173 $scope.customer = response.data.customer; // get data from json
\r
175 $scope.customerList = [];
\r
177 $scope.serviceInstanceToCustomer = [];
\r
179 angular.forEach($scope.customer, function(subVal, subKey) {
\r
180 var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME] };
\r
181 $scope.customerList.push(cust);
\r
182 if (subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) {
\r
183 angular.forEach(subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) {
\r
184 $scope.serviceInstanceId = [];
\r
185 if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) {
\r
186 $scope.serviceType = serviceSubscription[FIELD.ID.SERVICETYPE];
\r
188 $scope.serviceType = FIELD.STATUS.NO_SERVICE_SUBSCRIPTION_FOUND;
\r
190 if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) {
\r
191 angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) {
\r
192 var foo = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID],
\r
193 "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID],
\r
194 "subscriberName": subVal[FIELD.ID.SUBNAME] };
\r
195 $scope.serviceInstanceToCustomer.push(foo);
\r
201 DataService.setServiceInstanceToCustomer($scope.serviceInstanceToCustomer);
\r
202 var serviceIdList = [];
\r
203 $http.get( FIELD.ID.AAI_GET_SERVICES, {
\r
205 timeout: $scope.responseTimeoutMsec
\r
206 }).then(function(response) {
\r
207 angular.forEach(response.data, function(value, key) {
\r
208 angular.forEach(value, function(subVal, key) {
\r
209 var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] };
\r
210 serviceIdList.push(newVal);
\r
211 DataService.setServiceIdList(serviceIdList);
\r
214 "subscriberId": subscriberId,
\r
215 "serviceType": serviceType,
\r
216 "serviceInstanceId": serviceInstanceId
\r
219 $location.path(COMPONENT.INSTANTIATE_PATH);
\r
224 ["catch"]($scope.handleServerError);
\r