2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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 * ============LICENSE_END=========================================================
22 * The Instantiation (or View/Edit) Controller controls the instantiation/removal of
23 * deployable objects (Services, VNFs, VF-Modules, Networks, and Volume-Groups)
28 appDS2.controller("pnfSearchAssociationController", ["COMPONENT", "$log", "FIELD", "PARAMETER", "DataService", "CreationService", "$scope", "$window", "$location", "AaiService", "$uibModal", "UtilityService", "vidService", "$timeout",
29 function (COMPONENT, $log, FIELD, PARAMETER, DataService, CreationService, $scope, $window, $location, AaiService, $uibModal, UtilityService, vidService, $timeout) {
31 var requestParams = {};
33 $scope.selectedMetadata = {};
35 $scope.serviceMetadataFields = [];
36 $scope.nodeTemplateFields = {};
38 $scope.pnfInstance= false;
39 $scope.notFound= false;
41 $scope.pnfMetadata = [];
43 $scope.errorMsg = FIELD.ERROR.INSTANCE_NAME_VALIDATE;
45 $scope.modelName = DataService.getModelInfo(COMPONENT.VNF).modelCustomizationName;
47 var handleGetParametersResponse = function(parameters) {
48 $scope.serviceMetadataFields = parameters.summaryList;
49 $scope.serviceMetadataFields.forEach(function (t, number) {
50 $scope.serviceMetadataFields[number].key = $scope.serviceMetadataFields[number].name.split(' ').join('')
52 $scope.nodeTemplateFields = _.keyBy(parameters.userProvidedList, 'id');
55 CreationService.initializeComponent(COMPONENT.VNF);
57 CreationService.getParameters(handleGetParametersResponse);
59 $scope.back = function() {
60 $window.history.back();
63 $scope.searchPnf = function(pnfName) {
64 $scope.pnfInstance= false;
65 $scope.notFound=false;
67 AaiService.getPnfByName(pnfName)
68 .then(function (response) {
69 $scope.pnfInstance = response.data;
70 requestParams.pnf = response.data.pnfName;
72 .catch(function (error) {
73 $scope.pnfNameNotFound= pnfName;
74 $scope.notFound= true;
80 $scope.associate = function() {
82 requestParams.serviceModelInfo = vidService.getModel().service;
83 requestParams.attuuid = DataService.getLoggedInUserId();
84 requestParams.instanceId = DataService.getServiceInstanceId();
86 modalInstance = $uibModal.open({
87 templateUrl: 'app/vid/scripts/modals/mso-commit/mso-commit.html',
88 controller: "msoCommitModalController",
91 msoType: function () {
92 return COMPONENT.MSO_CREATE_REALATIONSHIP;
94 requestParams: function () {
95 requestParams.callbackFunction = updateViewCallbackFunction;
98 configuration: function () {
107 var updateViewCallbackFunction = function(response) {
108 $scope.callbackResults = "";
109 var color = FIELD.ID.COLOR_NONE;
110 $scope.callbackStyle = {
111 "background-color" : color
115 * This 1/2 delay was only added to visually highlight the status
116 * change. Probably not needed in the real application code.
118 $timeout(function() {
119 $scope.callbackResults = UtilityService.getCurrentTime()
120 + FIELD.STATUS.IS_SUCCESSFUL + response.isSuccessful;
121 if (response.isSuccessful) {
122 color = FIELD.ID.COLOR_8F8;
125 color = FIELD.ID.COLOR_F88;
127 $scope.callbackStyle = {
128 "background-color" : color
134 $scope.cancel = function() {
135 modalInstance.dismiss('cancel');