/*- * ============LICENSE_START======================================================= * VID * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ (function () { 'use strict'; appDS2.controller("ServiceModelController", function ($scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService, PropertyService, UtilityService) { $scope.popup = {}; // var baseEndpoint = "vid"; var pathQuery = COMPONENT.SERVICES_DIST_STATUS_PATH + VIDCONFIGURATION.ASDC_MODEL_STATUS; if ( VIDCONFIGURATION.ASDC_MODEL_STATUS === FIELD.STATUS.ALL) { pathQuery = COMPONENT.SERVICES_PATH; } $scope.getServiceModels = function() { $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG_ASDC; $http.get(pathQuery) .then(function successCallback(response) { $scope.services = []; if (response.data && angular.isArray(response.data.services)) { wholeData = response.data.services; $scope.services = $scope.filterDataWithHigerVersion(wholeData); $scope.viewPerPage=10; $scope.totalPage=$scope.services.length/$scope.viewPerPage; $scope.sortBy=COMPONENT.NAME; $scope.scrollViewPerPage=2; $scope.currentPage=1; $scope.searchCategory; $scope.searchString=""; $scope.currentPageNum=1; $scope.isSpinnerVisible = false; $scope.isProgressVisible = false; } else { $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC; $scope.error = true; $scope.isSpinnerVisible = false; } $scope.deployButtonType = response.data.readOnly ? 'disabled' : 'primary'; }, function errorCallback(response) { console.log("Error: " + response); }); } $scope.isFiltered=function(arr,obj){ var filtered = false; if(arr.length>0){ for(var i=0;i=parseFloat(serviceData[i].version.trim()))){ var data = $scope.isThisHigher(fiterDataServices,serviceData[j]); if(data.isHigher){ fiterDataServices[data.index] = serviceData[j]; } } } } } return fiterDataServices; } $scope.isThisHigher = function(arr,obj){ var returnObj = { isHigher:false, index:0 }; if(arr.length>0){ var isNotMatched = true; for(var i=0;i 202) { $scope.showError(FIELD.ERROR.MSO) return; } $scope.customer = response.data.customer; // get data from json $scope.customerList = []; $scope.serviceInstanceToCustomer = []; angular.forEach($scope.customer, function(subVal, subKey) { var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME] }; $scope.customerList.push(cust); if (subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) { angular.forEach(subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) { $scope.serviceInstanceId = []; if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) { $scope.serviceType = serviceSubscription[FIELD.ID.SERVICETYPE]; } else { $scope.serviceType = FIELD.STATUS.NO_SERVICE_SUBSCRIPTION_FOUND; } if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) { angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) { var foo = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID], "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME] }; $scope.serviceInstanceToCustomer.push(foo); }); } }); } }); DataService.setServiceInstanceToCustomer($scope.serviceInstanceToCustomer); var serviceIdList = []; $http.get( FIELD.ID.AAI_GET_SERVICES, { },{ timeout: $scope.responseTimeoutMsec }).then(function(response) { angular.forEach(response.data, function(value, key) { angular.forEach(value, function(subVal, key) { var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] ,"isPermitted" : subVal[FIELD.ID.IS_PERMITTED] }; serviceIdList.push(newVal); DataService.setServiceIdList(serviceIdList); $location.search({ "subscriberId": subscriberId, "serviceType": serviceType, "serviceInstanceId": serviceInstanceId, "isPermitted": newVal.isPermitted.toString() }); $location.path(COMPONENT.INSTANTIATE_PATH); }); }); }); }) ["catch"]($scope.handleServerError); }; }); })();