2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 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=========================================================
24 appDS2.controller("testEnvironmentsController", ["$uibModal", "TestEnvironmentsService", "$log", "$rootScope", "$scope", "COMPONENT", testEnvironmentsController]);
26 function testEnvironmentsController($uibModal, TestEnvironmentsService, $log, $rootScope, $scope, COMPONENT) {
31 var init = function() {
32 vm.loadAAIestEnvironments();
35 vm.loadAAIestEnvironments = function() {
36 TestEnvironmentsService.loadAAIestEnvironments("VNF")
37 .then(function(response) {
38 vm.environments = response.operationalEnvironment;
39 vm.connectError = false;
40 if(!vm.environments.length) {
44 .catch(function (error) {
45 vm.connectError = error.message || "Unknown error";
50 function handleEnvActionComplete(result) {
51 if (result.isSuccessful) {
52 vm.loadAAIestEnvironments();
54 $scope.popup.isVisible = false;
57 vm.onTestEnvActivateClick = function(testEnv) {
58 var modalInstance = $uibModal.open({
59 templateUrl: 'app/vid/scripts/modals/attach-test-env-manifest/attach-test-env-manifest.html',
60 controller: 'attachTestEnvManifestController',
65 modalInstance.result.then(function (result) {
68 var relatedEcompEnv = _.find(testEnv.relationshipList.relationship, { relatedTo: "operational-environment" });
70 var manifest = result;
71 var envId = testEnv.operationalEnvironmentId;
72 var relatedInstanceId =
73 _.find(relatedEcompEnv.relationshipData, {"relationshipKey": "operational-environment.operational-environment-id"})
75 var relatedInstanceName =
76 _.find(relatedEcompEnv.relatedToProperty, {"propertyKey": "operational-environment.operational-environment-name"})
78 var workloadContext = testEnv.workloadContext;
80 $rootScope.$broadcast(COMPONENT.MSO_ACTIVATE_ENVIRONMENT, {
81 url: COMPONENT.MSO_ACTIVATE_ENVIRONMENT,
83 relatedInstanceId: relatedInstanceId,
84 relatedInstanceName: relatedInstanceName,
85 workloadContext: workloadContext,
87 callbackFunction: handleEnvActionComplete
94 vm.onTestEnvDeactivateClick = function(testEnv) {
95 var envId = testEnv.operationalEnvironmentId;
96 $rootScope.$broadcast(COMPONENT.MSO_DEACTIVATE_ENVIRONMENT, {
97 url : COMPONENT.MSO_DEACTIVATE_ENVIRONMENT,
99 callbackFunction: handleEnvActionComplete
103 vm.isEnvActive = function(testEnv) {
104 return testEnv.operationalEnvironmentStatus==='ACTIVE';
107 vm.getEnvStatus = function (testEnv) {
108 return testEnv.operationalEnvironmentStatus;
111 vm.createNewTestEnvironment = function() {
112 var modalInstance = $uibModal.open({
113 templateUrl: 'app/vid/scripts/modals/new-test-environment/new-test-environment.html',
114 controller: 'newTestEnvironmentModalController',