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
23 appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER", "DataService", "PropertyService", "$scope", "$http", "$timeout", "$location", "$log", "$route", "VIDCONFIGURATION", "UtilityService", "vidService", "AaiService",
\r
24 function (COMPONENT, FIELD, PARAMETER, DataService, PropertyService, $scope, $http, $timeout, $location, $log, $route, VIDCONFIGURATION, UtilityService, vidService, AaiService) {
\r
26 $scope.showVnfDetails = function (vnf) {
\r
27 console.log("showVnfDetails");
\r
28 DataService.setVnfInstanceId(COMPONENT.VNF_INSTANCE_ID);
\r
30 .setInventoryItem(aaiResult[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM][0]);
\r
32 $scope.$broadcast(COMPONENT.SHOW_COMPONENT_DETAILS, {
\r
33 componentId: COMPONENT.VNF,
\r
34 callbackFunction: callbackFunction
\r
37 $scope.popup = new Object();
\r
40 $scope.isPopupVisible = false;
\r
41 $scope.defaultBaseUrl = "";
\r
42 $scope.responseTimeoutMsec = 60000;
\r
44 $scope.serviceTypes = [FIELD.PROMPT.SELECT_SERVICE, COMPONENT.UCPE_VMS, COMPONENT.SDN_L3_BONDING, COMPONENT.SDN_ETHERNET_INTERNET];
\r
45 $scope.defaultSubscriberName = [FIELD.PROMPT.SELECT_SUB];
\r
47 var callbackFunction = function (response) {
\r
51 $scope.getSubs = function () {
\r
53 $scope.fetchSubs(FIELD.PROMPT.FETCHING_SUBS);
\r
54 $scope.fetchServices();
\r
58 $scope.cancelCreateSI = function () {
\r
60 window.location.href = COMPONENT.WELCOME_PATH;
\r
64 $scope.getServiceTypes = function (globalCustomerId) {
\r
65 DataService.setGlobalCustomerId(globalCustomerId);
\r
66 DataService.setServiceIdList($scope.customerList)
\r
68 if (globalCustomerId !== "" && globalCustomerId !== undefined) {
\r
69 window.location.href = COMPONENT.SERVICE_TYPE_LIST_PATH + $scope.serviceTypeList;
\r
73 $scope.refreshServiceTypes = function (globalCustomerId) {
\r
74 DataService.setGlobalCustomerId(globalCustomerId);
\r
76 $scope.getServiceTypesList();
\r
80 $scope.createSubscriberName = "";
\r
81 $scope.serviceTypeList = {};
\r
82 $scope.custSubList = [];
\r
83 $scope.getServiceTypesList = function () {
\r
84 var notFound = true;
\r
85 var globalCustomerId = DataService.getGlobalCustomerId();
\r
86 $scope.custSubList = DataService.getServiceIdList();
\r
87 if (globalCustomerId !== "" && globalCustomerId !== undefined) {
\r
88 $scope.subId = globalCustomerId;
\r
90 $scope.status = FIELD.PROMPT.FETCHING_SERVICE_TYPES;
\r
91 DataService.setGlobalCustomerId(globalCustomerId);
\r
93 AaiService.getSubscriptionServiceTypeList(DataService
\r
94 .getGlobalCustomerId(), function (response) {
\r
96 $scope.setProgress(100); // done
\r
97 $scope.status = FIELD.STATUS.DONE;
\r
98 $scope.isSpinnerVisible = false;
\r
99 $scope.serviceTypeList = response;
\r
100 for (var i = 0; i < $scope.custSubList.length; i++) {
\r
101 if (globalCustomerId === $scope.custSubList[i].globalCustomerId) {
\r
102 $scope.createSubscriberName = $scope.custSubList[i].subscriberName;
\r
105 }, function (response) { // failure
\r
106 $scope.showError(FIELD.ERROR.AAI);
\r
107 $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICE_TYPES + response.status;
\r
108 $scope.errorDetails = response.data;
\r
111 alert(FIELD.ERROR.SELECT);
\r
116 $scope.subList = [];
\r
117 $scope.getAaiServiceModels = function (selectedServicetype, subName) {
\r
118 DataService.setGlobalCustomerId(selectedServicetype);
\r
119 DataService.setServiceIdList($scope.serviceTypeList)
\r
120 DataService.setSubscriberName(subName);
\r
122 DataService.setSubscribers($scope.custSubList);
\r
124 if (selectedServicetype !== "" && selectedServicetype !== 'undefined') {
\r
125 $location.path(COMPONENT.CREATE_INSTANCE_PATH);
\r
129 $scope.serviceTypeName="";
\r
130 $scope.getAaiServiceModelsList = function(){
\r
131 var globalCustomerId="";
\r
132 var serviceTypeId = DataService.getGlobalCustomerId();
\r
133 $scope.serviceTypeList = DataService.getServiceIdList();
\r
134 $scope.createSubscriberName = DataService.getSubscriberName();
\r
135 $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG;
\r
136 $scope.custSubList = DataService.getSubscribers();
\r
137 for(var i=0; i<$scope.serviceTypeList.length;i++){
\r
138 if(parseInt(serviceTypeId) === i ){
\r
139 $scope.serviceTypeName = $scope.serviceTypeList[i].name;
\r
143 for(var i=0; i<$scope.custSubList.length;i++){
\r
144 if($scope.createSubscriberName === $scope.custSubList[i].subscriberName){
\r
145 globalCustomerId = $scope.custSubList[i].globalCustomerId;
\r
146 globalCustId = globalCustomerId;
\r
152 if(null !== globalCustomerId && "" !== globalCustomerId && undefined !== globalCustomerId
\r
153 && null !== serviceTypeId && "" !== serviceTypeId && undefined !== serviceTypeId){
\r
154 pathQuery = COMPONENT.SERVICES_PATH +globalCustomerId+"/"+$scope.serviceTypeName;
\r
157 var namedQueryId='6e806bc2-8f9b-4534-bb68-be91267ff6c8';
\r
158 AaiService.getServiceModelsByServiceType(namedQueryId,globalCustomerId,$scope.serviceTypeName,function(response) { // success
\r
159 $scope.services = [];
\r
160 if (angular.isArray(response.data['inventory-response-item'])) {
\r
161 wholeData = response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item'];
\r
162 $scope.services = $scope.filterDataWithHigerVersion(response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item']);
\r
163 $scope.serviceType = response.data['inventory-response-item'][0]['service-subscription']['service-type'];
\r
164 $scope.viewPerPage=10;
\r
165 $scope.totalPage=$scope.services.length/$scope.viewPerPage;
\r
166 $scope.sortBy="name";
\r
167 $scope.scrollViewPerPage=2;
\r
168 $scope.currentPage=1;
\r
169 $scope.searchCategory;
\r
170 $scope.searchString="";
\r
171 $scope.currentPageNum=1;
\r
172 $scope.isSpinnerVisible = false;
\r
173 $scope.isProgressVisible = false;
\r
175 $scope.status = "Failed to get service models from ASDC.";
\r
176 $scope.error = true;
\r
177 $scope.isSpinnerVisible = false;
\r
179 DataService.setServiceIdList(response);
\r
180 }, function(response) { // failure
\r
181 $scope.showError(FIELD.ERROR.AAI);
\r
182 $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICES+ response.status;
\r
183 $scope.errorDetails = response.data;
\r
188 var globalCustId;// This value will be assigned only on create new service instance screen-macro
\r
189 $scope.createType = "a la carte";
\r
190 $scope.deployService = function(service,hideServiceFields) {
\r
191 hideServiceFields = hideServiceFields|| false;
\r
192 var temp = service;
\r
193 service.uuid = service['service-instance']['model-version-id'];
\r
195 console.log("Instantiating ASDC service " + service.uuid);
\r
197 $http.get('rest/models/services/' + service.uuid)
\r
198 .then(function successCallback(getServiceResponse) {
\r
199 getServiceResponse.data['service'].serviceTypeName =$scope.serviceTypeName ;
\r
200 getServiceResponse.data['service'].createSubscriberName =$scope.createSubscriberName ;
\r
201 var serviceModel = getServiceResponse.data;
\r
202 DataService.setServiceName(serviceModel.service.name);
\r
204 DataService.setModelInfo(COMPONENT.SERVICE, {
\r
205 "modelInvariantId": serviceModel.service.invariantUuid,
\r
206 "modelVersion": serviceModel.service.version,
\r
207 "modelNameVersionId": serviceModel.service.uuid,
\r
208 "modelName": serviceModel.service.name,
\r
209 "description": serviceModel.service.description,"serviceType": serviceModel.service.serviceType,
\r
210 "serviceRole": serviceModel.service.serviceRole,
\r
211 "category":serviceModel.service.category,
\r
212 "serviceTypeName":serviceModel.service.serviceTypeName,
\r
213 "createSubscriberName":serviceModel.service.createSubscriberName
\r
215 DataService.setHideServiceFields(hideServiceFields);
\r
216 if(hideServiceFields){
\r
217 DataService.setServiceType($scope.serviceTypeName);
\r
218 DataService.setGlobalCustomerId(globalCustId);
\r
221 DataService.setALaCarte (true);
\r
222 $scope.createType = "a la carte";
\r
223 var broadcastType = "createComponent";
\r
225 if (UtilityService.arrayContains (VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid )) {
\r
226 DataService.setALaCarte (false);
\r
227 $scope.createType = "Macro";
\r
228 var convertedAsdcModel = UtilityService.convertModel(serviceModel);
\r
230 //console.log ("display inputs ");
\r
231 //console.log (JSON.stringify ( convertedAsdcModel.completeDisplayInputs));
\r
233 DataService.setModelInfo(COMPONENT.SERVICE, {
\r
234 "modelInvariantId": serviceModel.service.invariantUuid,
\r
235 "modelVersion": serviceModel.service.version,
\r
236 "modelNameVersionId": serviceModel.service.uuid,
\r
237 "modelName": serviceModel.service.name,
\r
238 "description": serviceModel.service.description,
\r
239 "category":serviceModel.service.category,
\r
240 "serviceEcompNaming": serviceModel.service.serviceEcompNaming,
\r
241 "inputs": serviceModel.service.inputs,
\r
242 "displayInputs": convertedAsdcModel.completeDisplayInputs,
\r
243 "serviceTypeName":serviceModel.service.serviceTypeName,
\r
244 "createSubscriberName":serviceModel.service.createSubscriberName,
\r
245 "serviceType": serviceModel.service.serviceType,
\r
246 "serviceRole": serviceModel.service.serviceRole
\r
250 $scope.$broadcast(broadcastType, {
\r
251 componentId : COMPONENT.SERVICE,
\r
252 callbackFunction : function(response) {
\r
253 if (response.isSuccessful) {
\r
254 vidService.setModel(serviceModel);
\r
256 var subscriberId = "Not Found";
\r
257 var serviceType = "Not Found";
\r
259 var serviceInstanceId = response.instanceId;
\r
261 for (var i = 0; i < response.control.length; i++) {
\r
262 if (response.control[i].id == "subscriberName") {
\r
263 subscriberId = response.control[i].value;
\r
264 } else if (response.control[i].id == "serviceType") {
\r
265 serviceType = response.control[i].value;
\r
270 $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId);
\r
276 }, function errorCallback(response) {
\r
277 console.log("Error: " + response);
\r
280 $scope.isFiltered=function(arr,obj){
\r
281 var filtered = false;
\r
283 for(var i=0;i<arr.length;i++){
\r
284 if(obj['extra-properties']['extra-property'] && (obj['extra-properties']['extra-property'][2]['property-value'] == arr[i]['extra-properties']['extra-property'][2]['property-value'])
\r
285 && (obj['extra-properties']['extra-property'][4]['property-value'] == arr[i]['extra-properties']['extra-property'][4]['property-value'])){
\r
293 $scope.filterDataWithHigerVersion = function(serviceData){
\r
294 var fiterDataServices = [];
\r
295 for(var i=0;i<serviceData.length;i++){
\r
296 var higherVersion = serviceData[i];
\r
297 if(!$scope.isFiltered(fiterDataServices,serviceData[i])){
\r
298 for(var j=i;j<serviceData.length;j++){
\r
299 if(serviceData[i]['extra-properties']['extra-property'] && serviceData[j]['extra-properties']['extra-property'] && (serviceData[i]['extra-properties']['extra-property'][4]['property-value'] == serviceData[j]['extra-properties']['extra-property'][4]['property-value'])
\r
300 && (serviceData[i]['extra-properties']['extra-property'][2]['property-value'] == serviceData[j]['extra-properties']['extra-property'][2]['property-value'])
\r
301 && (parseFloat(serviceData[j]['extra-properties']['extra-property'][6]['property-value'])>=parseFloat(serviceData[i]['extra-properties']['extra-property'][6]['property-value']))){
\r
302 var data = $scope.isThisHigher(fiterDataServices,serviceData[j]);
\r
304 fiterDataServices[data.index] = serviceData[j];
\r
310 return fiterDataServices;
\r
313 $scope.isThisHigher = function(arr,obj){
\r
319 var isNotMatched = true;
\r
320 for(var i=0;i<arr.length;i++){
\r
321 if(arr[i]['extra-properties']['extra-property'] && (arr[i]['extra-properties']['extra-property'][2]['property-value'] == obj['extra-properties']['extra-property'][2]['property-value'])
\r
322 && (arr[i]['extra-properties']['extra-property'][4]['property-value'] == obj['extra-properties']['extra-property'][4]['property-value'] )
\r
323 && (arr[i]['extra-properties']['extra-property'][6]['property-value'] < obj['extra-properties']['extra-property'][6]['property-value']) ){
\r
324 isNotMatched = false;
\r
331 if(isNotMatched && !$scope.isFiltered(arr,obj)){
\r
346 $scope.tableData=[];
\r
348 $scope.loadPreviousVersionData=function(version,invariantUUID){
\r
349 $scope.tableData =[];
\r
351 for(var i=0;i<wholeData.length;i++){
\r
352 if(wholeData[i]['extra-properties']['extra-property'] && wholeData[i]['extra-properties']['extra-property'][4]['property-value'] == invariantUUID && version!=wholeData[i]['extra-properties']['extra-property'][6]['property-value']){
\r
353 oldData.push(wholeData[i]);
\r
356 $scope.tableData = oldData;
\r
357 $scope.createType = "Previous Version";
\r
358 var broadcastType = "createTableComponent";
\r
359 $scope.componentName = invariantUUID;
\r
360 $scope.$broadcast(broadcastType, {
\r
361 componentId : COMPONENT.OLDVERSION,
\r
362 callbackFunction : function(response) {
\r
366 $scope.cancelCreateSIType = function(){
\r
368 window.location.href = COMPONENT.SERVICE_MODLES_INSTANCES_SUBSCRIBERS_PATH;
\r
372 $scope.fetchServices = function () {
\r
373 var serviceIdList = [];
\r
375 AaiService.getServices2(function (response) { // success
\r
376 DataService.setServiceIdList(response);
\r
377 }, function (response) { // failure
\r
378 $scope.showError(FIELD.ERROR.AAI);
\r
379 $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICES + response.status;
\r
380 $scope.errorDetails = response.data;
\r
384 $scope.refreshSubs = function () {
\r
386 $scope.fetchSubs(FIELD.PROMPT.REFRESH_SUB_LIST);
\r
387 $scope.fetchServices();
\r
390 $scope.fetchSubs = function (status) {
\r
391 $scope.status = status;
\r
393 AaiService.getSubList(function (response) { // sucesss
\r
394 $scope.setProgress(100); // done
\r
395 $scope.status = FIELD.STATUS.DONE;
\r
396 $scope.isSpinnerVisible = false;
\r
397 $scope.customerList = response;
\r
398 }, function (response) { // failure
\r
399 $scope.showError(FIELD.ERROR.AAI);
\r
400 $scope.errorMsg = FIELD.ERROR.AAI_FETCHING_CUST_DATA + response.status;
\r
401 $scope.errorDetails = response.data;
\r
405 $scope.getPermitted = function (item) {
\r
406 return item.isPermitted || item[FIELD.ID.IS_PERMITTED];
\r
411 $scope.getSubDetails = function (request) {
\r
414 $scope.selectedSubscriber = $location.search().selectedSubscriber;
\r
415 $scope.selectedServiceInstance = $location.search().selectedServiceInstance;
\r
416 $scope.status = FIELD.STATUS.FETCHING_SUB_DETAILS + $scope.selectedSubscriber;
\r
418 $scope.displayData = [];
\r
419 AaiService.getSubDetails($scope.selectedSubscriber, $scope.selectedServiceInstance, function (displayData, subscriberName) {
\r
420 $scope.displayData = displayData;
\r
421 $scope.viewPerPage = 10;
\r
422 $scope.totalPage = $scope.displayData.length / $scope.viewPerPage;
\r
423 $scope.scrollViewPerPage = 2;
\r
424 $scope.currentPage = 1;
\r
425 $scope.searchCategory;
\r
426 $scope.searchString = "";
\r
427 $scope.currentPageNum = 1;
\r
428 $scope.defaultSort = COMPONENT.SUBSCRIBER_NAME;
\r
429 $scope.setProgress(100); // done
\r
430 $scope.status = FIELD.STATUS.DONE;
\r
431 $scope.isSpinnerVisible = false;
\r
432 $scope.subscriberName = subscriberName;
\r
433 }, function (response) {
\r
434 $scope.showError(FIELD.ERROR.AAI);
\r
435 $scope.errorMsg = FIELD.ERROR.AAI_FETCHING_CUST_DATA + response.status;
\r
436 $scope.errorDetails = response.data;
\r
441 $scope.$on(COMPONENT.MSO_DELETE_REQ, function (event, request) {
\r
442 // $log.debug("deleteInstance: request:");
\r
443 // $log.debug(request);
\r
446 $http.post($scope.baseUrl + request.url, {
\r
447 requestDetails: request.requestDetails
\r
449 timeout: $scope.responseTimeoutMsec
\r
450 }).then($scope.handleInitialResponse)
\r
451 ["catch"]($scope.handleServerError);
\r
454 $scope.init = function () {
\r
456 //PropertyService.setAaiBaseUrl("testaai");
\r
457 //PropertyService.setAsdcBaseUrl("testasdc");
\r
459 // takes a default value, retrieves the prop value from the file system and sets it
\r
460 var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec();
\r
461 PropertyService.setMsoMaxPollingIntervalMsec(msecs);
\r
463 // takes a default value, retrieves the prop value from the file system and sets it
\r
464 var polls = PropertyService.retrieveMsoMaxPolls();
\r
465 PropertyService.setMsoMaxPolls(polls);
\r
467 //PropertyService.setMsoBaseUrl("testmso");
\r
468 PropertyService.setServerResponseTimeoutMsec();
\r
471 * Common parameters that would typically be set when the page is
\r
472 * displayed for a specific service instance id.
\r
475 $scope.baseUrl = $scope.defaultBaseUrl;
\r
477 $scope.isSpinnerVisible = true;
\r
478 $scope.isProgressVisible = true;
\r
479 $scope.isPopupVisible = true;
\r
480 $scope.requestId = "";
\r
482 $scope.pollAttempts = 0;
\r
484 $scope.enableCloseButton(false);
\r
485 $scope.resetProgress();
\r
486 $scope.setProgress(2); // Show "a little" progress
\r
489 $scope.getComponentList = function (event, request) {
\r
491 $scope.isSpinnerVisible = true;
\r
492 $scope.isProgressVisible = true;
\r
493 $scope.isPopupVisible = true;
\r
494 $scope.requestId = "";
\r
496 $scope.pollAttempts = 0;
\r
499 $scope.resetProgress();
\r
500 $scope.setProgress(2); // Show "a little" progress
\r
502 $scope.globalCustomerId = $location.search().subscriberId;
\r
503 $scope.serviceType = $location.search().serviceType;
\r
504 $scope.serviceInstanceId = $location.search().serviceInstanceId;
\r
505 $scope.subscriberName = $location.search().subscriberName;
\r
507 //$scope.getAsdcModel($location.search().modelUuid);
\r
509 $scope.namedQueryId = VIDCONFIGURATION.COMPONENT_LIST_NAMED_QUERY_ID;
\r
510 $scope.status = FIELD.STATUS.FETCHING_SERVICE_INST_DATA + $scope.serviceInstanceId;
\r
512 AaiService.runNamedQuery($scope.namedQueryId, $scope.globalCustomerId, $scope.serviceType, $scope.serviceInstanceId,
\r
513 function (response) { //success
\r
514 $scope.handleInitialResponseInventoryItems(response);
\r
515 $scope.setProgress(100); // done
\r
516 $scope.status = FIELD.STATUS.DONE;
\r
517 $scope.isSpinnerVisible = false;
\r
519 function (response) { //failure
\r
520 $scope.showError(FIELD.ERROR.AAI);
\r
521 $scope.errorMsg = FIELD.ERROR.FETCHING_SERVICE_INSTANCE_DATA + response.status;
\r
522 $scope.errorDetails = response.data;
\r
528 $scope.handleServerError = function (response, status) {
\r
529 alert(response.statusText);
\r
532 $scope.getAsdcModel = function (disData) {
\r
534 console.log("disData");
\r
535 console.log(JSON.stringify(disData, null, 4));
\r
537 // if ( !(UtilityService.hasContents (disData.aaiModelVersionId)) ) {
\r
538 // $scope.errorMsg = FIELD.ERROR.MODEL_VERSION_ID_MISSING;
\r
539 // alert($scope.errorMsg);
\r
543 // aaiModelVersionId is the model uuid
\r
544 var pathQuery = COMPONENT.SERVICES_PATH + disData.aaiModelVersionId;
\r
548 }).then(function successCallback(response) {
\r
549 vidService.setModel(response.data);
\r
550 window.location.href =
\r
551 COMPONENT.INSTANTIATE_ROOT_PATH + disData.globalCustomerId +
\r
552 COMPONENT.SUBSCRIBERNAME_SUB_PATH + disData.subscriberName +
\r
553 COMPONENT.SERVICETYPE_SUB_PATH + disData.serviceType +
\r
554 COMPONENT.SERVICEINSTANCEID_SUB_PATH + disData.serviceInstanceId +
\r
555 COMPONENT.IS_PERMITTED_SUB_PATH + disData.isPermitted;
\r
556 console.log("aaiSubscriber getAsdcModel DONE!!!!");
\r
557 }, function errorCallback(response) {
\r
558 console.log("aaiSubscriber getAsdcModel - No matching model found matching the A&AI model version ID = " + disData.aaiModelVersionId);
\r
559 $scope.errorMsg = FIELD.ERROR.NO_MATCHING_MODEL_AAI + disData.aaiModelVersionId;
\r
560 alert($scope.errorMsg);
\r
565 $scope.getTenants = function (globalCustomerId) {
\r
566 $http.get(FIELD.ID.AAI_GET_TENTANTS + globalCustomerId)
\r
567 .then(function successCallback(response) {
\r
568 return response.data;
\r
569 //$location.path("/instantiate");
\r
570 }, function errorCallback(response) {
\r
575 $scope.handleInitialResponseInventoryItems = function (response) {
\r
577 $scope.inventoryResponseItemList = response.data[FIELD.ID.INVENTORY_RESPONSE_ITEM]; // get data from json
\r
578 console.log($scope.inventoryResponseItemList.toString());
\r
580 $scope.displayData = [];
\r
583 $scope.counter = 100;
\r
585 $scope.subscriberName = "";
\r
586 // just look up the subscriber name in A&AI here...
\r
587 AaiService.getSubscriberName($scope.globalCustomerId, function (response) {
\r
588 $scope.subscriberName = response;
\r
589 DataService.setSubscriberName($scope.subscriberName);
\r
591 angular.forEach($scope.inventoryResponseItemList, function (inventoryResponseItem, key) {
\r
593 $scope.inventoryResponseItem = inventoryResponseItem;
\r
595 $scope.service.instance = {
\r
596 "name": $scope.inventoryResponseItem[FIELD.ID.SERVICE_INSTANCE][FIELD.ID.SERVICE_INSTANCE_NAME],
\r
597 "serviceInstanceId": $scope.serviceInstanceId,
\r
598 "serviceType": $scope.serviceType,
\r
599 "globalCustomerId": $scope.globalCustomerId,
\r
600 "subscriberName": $scope.subscriberName,
\r
601 "id": $scope.serviceInstanceId,
\r
604 "type": PARAMETER.STRING,
\r
605 "description": FIELD.PROMPT.VAR_DESCRIPTION_A,
\r
606 "default": FIELD.PROMPT.DEFAULT_A
\r
609 "type": PARAMETER.STRING,
\r
610 "description": FIELD.PROMPT.VAR_DESCRIPTION_B,
\r
611 "default": FIELD.PROMPT.DEFAULT_B
\r
614 "object": $scope.inventoryResponseItem[FIELD.ID.SERVICE_INSTANCE],
\r
619 if (inventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {
\r
621 angular.forEach(inventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (subInventoryResponseItem, key) {
\r
622 // i expect to find vnfs now
\r
624 if (subInventoryResponseItem[FIELD.ID.L3_NETWORK] != null) {
\r
625 var l3NetworkObject = subInventoryResponseItem[FIELD.ID.L3_NETWORK];
\r
627 "id": $scope.counter++,
\r
628 "name": l3NetworkObject[FIELD.ID.NETWORK_NAME],
\r
629 "itemType": FIELD.ID.L3_NETWORK,
\r
630 "nodeId": l3NetworkObject[FIELD.ID.NETWORK_ID],
\r
631 "nodeType": l3NetworkObject[FIELD.ID.NETWORK_TYPE],
\r
632 "nodeStatus": l3NetworkObject[FIELD.ID.ORCHESTRATION_STATUS],
\r
633 "object": l3NetworkObject,
\r
637 if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {
\r
638 //console.log ("subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS]=");
\r
639 //console.log (JSON.stringify (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS], null, 4 ));
\r
640 angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (subSubInventoryResponseItem, key) {
\r
641 //console.log (JSON.stringify (subSubInventoryResponseItem, null, 4 ));
\r
644 if (subSubInventoryResponseItem[FIELD.ID.SUB_NET] != null) {
\r
645 subnetObject = subSubInventoryResponseItem[FIELD.ID.SUB_NET];
\r
647 "subnet-id": subnetObject[FIELD.ID.SUBNET_ID],
\r
648 "subnet-name": subnetObject[FIELD.ID.SUBNET_NAME],
\r
649 "gateway-address": subnetObject[FIELD.ID.GATEWAY_ADDRESS],
\r
650 "network-start-address": subnetObject[FIELD.ID.NETWORK_START_ADDRESS],
\r
651 "cidr-mask": subnetObject[FIELD.ID.CIDR_MASK]
\r
653 l3Network.subnets.push(subnet);
\r
657 $scope.service.instance[FIELD.ID.NETWORKS].push(l3Network);
\r
660 if (subInventoryResponseItem[FIELD.ID.GENERIC_VNF] != null) {
\r
661 var genericVnfObject = subInventoryResponseItem[FIELD.ID.GENERIC_VNF];
\r
664 "name": genericVnfObject[FIELD.ID.VNF_NAME],
\r
665 "id": $scope.counter++,
\r
666 "itemType": COMPONENT.VNF,
\r
667 "nodeType": genericVnfObject[FIELD.ID.VNF_TYPE],
\r
668 "nodeId": genericVnfObject[FIELD.ID.VNF_ID],
\r
669 "nodeStatus": genericVnfObject[FIELD.ID.ORCHESTRATION_STATUS],
\r
670 "object": genericVnfObject,
\r
672 "volumeGroups": [],
\r
673 "availableVolumeGroups": []
\r
675 $scope.service.instance[FIELD.ID.VNFS].push(genericVnf);
\r
677 // look for volume-groups
\r
678 if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {
\r
679 angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (vfmodules, key) {
\r
681 if (vfmodules[FIELD.ID.VOLUME_GROUP] != null) {
\r
682 var volumeGroupObject = vfmodules[FIELD.ID.VOLUME_GROUP];
\r
683 var volumeGroup = {
\r
684 "id": $scope.counter++,
\r
685 "name": volumeGroupObject[FIELD.ID.VOLUME_GROUP_NAME],
\r
686 "itemType": FIELD.ID.VOLUME_GROUP,
\r
687 "nodeId": volumeGroupObject[FIELD.ID.VOLUME_GROUP_ID],
\r
688 "nodeType": volumeGroupObject[FIELD.ID.VNF_TYPE],
\r
689 "nodeStatus": volumeGroupObject[FIELD.ID.ORCHESTRATION_STATUS],
\r
690 "object": volumeGroupObject,
\r
693 genericVnf[FIELD.ID.VOLUMEGROUPS].push(volumeGroup);
\r
694 genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS].push(volumeGroup);
\r
698 // now we've loaded up the availableVolumeGroups, we can use it
\r
699 if (subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {
\r
700 angular.forEach(subInventoryResponseItem[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (vfmodules, key) {
\r
702 if (vfmodules[FIELD.ID.VF_MODULE] != null) {
\r
703 var vfModuleObject = vfmodules[FIELD.ID.VF_MODULE];
\r
705 "id": $scope.counter++,
\r
706 "name": vfModuleObject[FIELD.ID.VF_MODULE_NAME],
\r
707 "itemType": FIELD.ID.VF_MODULE,
\r
708 "nodeType": FIELD.ID.VF_MODULE,
\r
709 "nodeStatus": vfModuleObject[FIELD.ID.ORCHESTRATION_STATUS],
\r
710 "volumeGroups": [],
\r
711 "object": vfModuleObject,
\r
714 genericVnf[FIELD.ID.VF_MODULES].push(vfModule);
\r
715 if (vfmodules[FIELD.ID.INVENTORY_RESPONSE_ITEMS] != null) {
\r
716 angular.forEach(vfmodules[FIELD.ID.INVENTORY_RESPONSE_ITEMS][FIELD.ID.INVENTORY_RESPONSE_ITEM], function (networks, key) {
\r
717 if (networks[FIELD.ID.L3_NETWORK] != null) {
\r
718 var l3NetworkObject = networks[FIELD.ID.L3_NETWORK];
\r
720 "id": $scope.counter++,
\r
721 "name": l3NetworkObject[FIELD.ID.NETWORK_NAME],
\r
722 "itemType": FIELD.ID.L3_NETWORK,
\r
723 "nodeId": l3NetworkObject[FIELD.ID.NETWORK_ID],
\r
724 "nodeType": l3NetworkObject[FIELD.ID.NETWORK_TYPE],
\r
725 "nodeStatus": l3NetworkObject[FIELD.ID.ORCHESTRATION_STATUS],
\r
726 "object": l3NetworkObject,
\r
729 vfModule[FIELD.ID.NETWORKS].push(l3Network);
\r
731 if (networks[FIELD.ID.VOLUME_GROUP] != null) {
\r
732 var volumeGroupObject = networks[FIELD.ID.VOLUME_GROUP];
\r
734 var volumeGroup = {
\r
735 "id": $scope.counter++,
\r
736 "name": volumeGroupObject[FIELD.ID.VOLUME_GROUP_NAME],
\r
737 "itemType": FIELD.ID.VOLUME_GROUP,
\r
738 "nodeId": volumeGroupObject[FIELD.ID.VOLUME_GROUP_ID],
\r
739 "nodeType": volumeGroupObject[FIELD.ID.VNF_TYPE],
\r
740 "nodeStatus": volumeGroupObject[FIELD.ID.ORCHESTRATION_STATUS],
\r
741 "object": volumeGroupObject,
\r
744 var tmpVolGroup = [];
\r
746 angular.forEach(genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS], function (avgroup, key) {
\r
747 if (avgroup.name != volumeGroup.name) {
\r
748 tmpVolGroup.push(avgroup);
\r
752 genericVnf[FIELD.ID.AVAILABLEVOLUMEGROUPS] = tmpVolGroup;
\r
754 vfModule[FIELD.ID.VOLUMEGROUPS].push(volumeGroup);
\r
769 $scope.handleInitialResponse = function (response) {
\r
771 $scope.enableCloseButton(true);
\r
772 $scope.updateLog(response);
\r
773 if (response.data.status < 200 || response.data.status > 202) {
\r
774 $scope.showError(FIELD.ERROR.MSO);
\r
775 $scope.status = FIELD.ERROR.AAI_FETCHING_CUST_DATA + response.data.status;
\r
780 $scope.setProgress(100); // done
\r
781 $scope.status = FIELD.STATUS.DONE;
\r
782 $scope.isSpinnerVisible = false;
\r
784 $scope.customer = response.data.customer; // get data from json
\r
786 $scope.customerList = [];
\r
788 angular.forEach($scope.customer, function (subVal, subKey) {
\r
790 "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID],
\r
791 "subscriberName": subVal[FIELD.ID.SUBNAME],
\r
792 "isPermitted": subVal[FIELD.ID.IS_PERMITTED]
\r
795 $scope.customerList.push(cust);
\r
799 $scope.showContentError(error);
\r
803 $scope.autoGetSubs = function () {
\r
805 * Optionally comment in / out one of these method calls (or add a similar
\r
806 * entry) to auto-invoke an entry when the test screen is redrawn.
\r
812 $scope.updateLog = function (response) {
\r
813 // $scope.log = UtilityService.getCurrentTime() + " HTTP Status: " +
\r
814 // UtilityService.getHttpStatusText(response.data.status) + "\n" +
\r
815 // angular.toJson(response.data.entity, true) + "\n\n" + $scope.log;
\r
816 // UtilityService.checkUndefined("entity", response.data.entity);
\r
817 // UtilityService.checkUndefined("status", response.data.status);
\r
820 $scope.handleServerError = function (response, status) {
\r
821 $scope.enableCloseButton(true);
\r
822 var message = UtilityService.getHttpErrorMessage(response);
\r
823 if (message != "") {
\r
824 message = " (" + message + ")";
\r
826 $scope.showError(FIELD.ERROR.SYSTEM_ERROR + message);
\r
829 $scope.showContentError = function (message) {
\r
830 // $log.debug(message);
\r
831 console.log(message);
\r
832 if (UtilityService.hasContents(message)) {
\r
833 $scope.showError("System failure (" + message + ")");
\r
835 $scope.showError(FIELD.ERROR.SYSTEM_ERROR);
\r
839 $scope.showError = function (message) {
\r
840 $scope.isSpinnerVisible = false;
\r
841 $scope.isProgressVisible = false;
\r
842 $scope.error = message;
\r
843 $scope.status = FIELD.STATUS.ERROR;
\r
846 $scope.close = function () {
\r
847 if ($scope.timer != undefined) {
\r
848 $timeout.cancel($scope.timer);
\r
850 $scope.isPopupVisible = false;
\r
855 * Consider converting the progress bar mechanism, the disabled button handling
\r
856 * and the following methods to generic Angular directive(s) and/or approach.
\r
859 $scope.enableCloseButton = function (isEnabled) {
\r
860 var selector = FIELD.STYLE.MSO_CTRL_BTN;
\r
862 $scope.isCloseEnabled = isEnabled;
\r
865 $(selector).addClass(FIELD.STYLE.BTN_PRIMARY).removeClass(FIELD.STYLE.BTN_INACTIVE).attr(FIELD.STYLE.BTN_TYPE, FIELD.STYLE.PRIMARY);
\r
867 $(selector).removeClass(FIELD.STYLE.BTN_PRIMARY).addClass(FIELD.STYLE.BTN_INACTIVE).attr(FIELD.STYLE.BTN_TYPE, FIELD.STYLE.DISABLED);
\r
871 $scope.resetProgress = function () {
\r
872 $scope.percentProgress = 0;
\r
873 $scope.progressClass = FIELD.STYLE.PROGRESS_BAR_INFO;
\r
876 $scope.setProgress = function (percentProgress) {
\r
877 percentProgress = parseInt(percentProgress);
\r
878 if (percentProgress >= 100) {
\r
879 $scope.progressClass = FIELD.STYLE.PROGRESS_BAR_SUCCESS;
\r
882 if (percentProgress < $scope.percentProgress) {
\r
886 $scope.percentProgress = percentProgress;
\r
887 $scope.progressWidth = {width: percentProgress + "%"};
\r
888 if (percentProgress >= 5) {
\r
889 $scope.progressText = percentProgress + " %";
\r
891 // Hidden since color combination is barely visible when progress portion is narrow.
\r
892 $scope.progressText = "";
\r
896 $scope.reloadRoute = function () {
\r
900 $scope.prevPage = function () {
\r
901 $scope.currentPage--;
\r
904 $scope.nextPage = function () {
\r
905 $scope.currentPage++;
\r
907 $scope.serviceInstanceses = [{"sinstance": FIELD.NAME.SERVICE_INSTANCE_Id}, {"sinstance": FIELD.NAME.SERVICE_INSTANCE_NAME}]
\r
908 $scope.getSubscriberDet = function (selectedCustomer, selectedserviceinstancetype, selectedServiceInstance) {
\r
910 var sintype = selectedserviceinstancetype;
\r
911 if (selectedServiceInstance != "" && selectedServiceInstance != undefined) {
\r
912 selectedServiceInstance.trim();
\r
915 $http.get(COMPONENT.AAI_GET_SERVICE_INSTANCE_PATH + selectedServiceInstance + "/" + sintype + "?r=" + Math.random(), {}, {
\r
916 timeout: $scope.responseTimeoutMsec
\r
917 }).then(function (response) {
\r
918 var notFound = true;
\r
919 if (angular.isArray(response.data[FIELD.ID.RESULT_DATA])) {
\r
922 item = response.data[FIELD.ID.RESULT_DATA][0];
\r
923 var url = item[FIELD.ID.RESOURCE_LINK];
\r
924 var globalCustomerId = "";
\r
925 var serviceSubscription = "";
\r
926 // split it and find the customer Id and service-subscription
\r
927 urlParts = url.split("/");
\r
928 if (urlParts[7] === FIELD.ID.CUSTOMER) {
\r
929 globalCustomerId = urlParts[8];
\r
931 if (urlParts[10] === FIELD.ID.SERVICE_SUBSCRIPTION) {
\r
932 serviceSubscription = urlParts[11];
\r
935 if (globalCustomerId !== "") {
\r
937 window.location.href = COMPONENT.SELECTED_SERVICE_SUB_PATH + serviceSubscription + COMPONENT.SELECTEDSUBSCRIBER_SUB_PATH + globalCustomerId + COMPONENT.SELECTEDSERVICEINSTANCE_SUB_PATH + selectedServiceInstance;
\r
941 alert(FIELD.ERROR.SERVICE_INST_DNE);
\r
943 }); // add a failure callback...
\r
944 } else if (selectedCustomer != null) {
\r
945 window.location.href = COMPONENT.SELECTED_SUB_PATH + selectedCustomer;
\r
947 alert(FIELD.ERROR.SELECT);
\r
950 }]).directive('restrictInput', function () {
\r
955 require: 'ngModel',
\r
956 link: function ($scope, element, attr, ctrl) {
\r
957 ctrl.$parsers.unshift(function (viewValue) {
\r
959 var types = $scope.$eval(attr.restrictInput);
\r
960 if (!types.regex && types.type) {
\r
962 switch (types.type) {
\r
963 case 'Service Instance Name' :
\r
964 types.regex = '^[a-zA-Z0-9-_]*$';
\r
970 var reg = new RegExp(types.regex);
\r
971 if (reg.test(viewValue)) {
\r
974 var overrideValue = (reg.test(viewValue) ? viewValue : '');
\r
975 element.val(overrideValue);
\r
976 return overrideValue;
\r
983 appDS2.controller('TreeCtrl', ['$scope', function ($scope) {
\r
984 $scope.remove = function (scope) {
\r
988 $scope.toggle = function (scope) {
\r
992 $scope.moveLastToTheBeginning = function () {
\r
993 var a = $scope.data.pop();
\r
994 $scope.data.splice(0, 0, a);
\r
997 $scope.newSubItem = function (scope) {
\r
998 var nodeData = scope.$modelValue;
\r
999 nodeData.nodes.push({
\r
1000 id: nodeData.id * 10 + nodeData.nodes.length,
\r
1001 title: nodeData.title + '.' + (nodeData.nodes.length + 1),
\r
1006 $scope.collapseAll = function () {
\r
1007 $scope.$broadcast(FIELD.ID.ANGULAR_UI_TREE_COLLAPSEALL);
\r
1010 $scope.expandAll = function () {
\r
1011 $scope.$broadcast(FIELD.ID.ANGULAR_UI_TREE_EXPANDALL);
\r