diff options
Diffstat (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/modals/new-test-environment')
2 files changed, 115 insertions, 0 deletions
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-test-environment/new-test-environment.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-test-environment/new-test-environment.controller.js new file mode 100644 index 00000000..daec9b2e --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-test-environment/new-test-environment.controller.js @@ -0,0 +1,65 @@ +(function () { + 'use strict'; + + appDS2.controller("newTestEnvironmentModalController", ["$uibModalInstance", "$uibModal", "AaiService", "TestEnvironmentsService","OwningEntityService", + "$log", "$scope", "_", "COMPONENT","$rootScope", newTestEnvironmentsModalController]); + + function newTestEnvironmentsModalController($uibModalInstance, $uibModal, AaiService, TestEnvironmentsService,OwningEntityService, $log, $scope, _, COMPONENT, $rootScope) { + var vm = this; + vm.newEnvironment = {}; + + var init = function () { + vm.newEnvironment.operationalEnvironmentType = "VNF"; + loadCategoryParameters(); + loadEcompEnvironmentsList(); + }; + + var loadEcompEnvironmentsList = function () { + TestEnvironmentsService.loadAAIestEnvironments("ECOMP") + .then(function(response) { + vm.environments = response.operationalEnvironment; + }) + .catch(function (error) { + vm.aaiConnectError = error.message; + $log.error(error); + }); + }; + + var loadCategoryParameters = function () { + OwningEntityService.getOwningEntityProperties(function(response){ + vm.environmentsTypesList = response["operational-environment-type"].map(function (x){ + return x.name;}); + vm.workloadContextList = response["workload-context"].map(function (x){ + return x.name;}); + },COMPONENT.TENANT_ISOLATION_FAMILY); + } + + + vm.setEcompEnvironment = function (selectedIndex) { + var ecompEnvironment = vm.environments[selectedIndex]; + vm.newEnvironment.ecompInstanceId = ecompEnvironment.operationalEnvironmentId; + vm.newEnvironment.ecompInstanceName = ecompEnvironment.operationalEnvironmentName; + vm.newEnvironment.tenantContext = ecompEnvironment.tenantContext; + }; + + vm.close = function () { + $uibModalInstance.close(); + }; + + vm.createEnvironment = function () { + if($scope.newTestEnvironment.$valid) { + vm.newEnvironment.workloadContext = vm.newEnvironment.operationalEnvironmentType + '_' + vm.newEnvironment.workloadContext; + var requestDetails = vm.newEnvironment; + $rootScope.$broadcast(COMPONENT.MSO_CREATE_ENVIRONMENT, { + url : COMPONENT.OPERATIONAL_ENVIRONMENT_CREATE, + requestDetails : requestDetails + }); + vm.close(); + } + }; + + + + init(); + } +})();
\ No newline at end of file diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-test-environment/new-test-environment.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-test-environment/new-test-environment.html new file mode 100644 index 00000000..cd14a76c --- /dev/null +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-test-environment/new-test-environment.html @@ -0,0 +1,50 @@ +<link rel="stylesheet" type="text/css" href="app/vid/styles/modal-create-new.css" /> +<div class="modal-header"> + <h3 class="modal-title" id="modal-title">New Test Environment</h3> + <span ng-click="vm.close()" class="pull-right modal-close" aria-hidden="true">×</span> +</div> +<form class="form-create" data-tests-id="test-new-environment-form" name="newTestEnvironment" ng-submit="vm.createEnvironment()"> + <div class="modal-body"> + <div class="form-group"> + <label class="control-label" for="environmentName">Environment Name</label> + <input id="environmentName" class="form-control" ng-model="vm.newEnvironment.instanceName" name="instanceName" data-tests-id="environment-name" placeholder="Enter environment name" required> + </div> + <div class="form-group"> + <label class="control-label" for="ecompInstanceId">ECOMP Environment ID</label> + <select class="form-control" ng-class="{'grayedOut': !selectedIndex, 'connect-error': vm.aaiConnectError}" ng-model="selectedIndex" name="ecompInstanceId" id="ecompInstanceId" data-tests-id="ecomp-instance-id" required ng-change="vm.setEcompEnvironment(selectedIndex)"> + <option value="" disabled selected hidden>Select environment ID</option> + <option data-tests-id="environment-id-option" class="environmentIdOption" ng-repeat="item in vm.environments" ng-value="$index">{{item.operationalEnvironmentId}}</option> + </select> + </div> + <div class="form-group"> + <label class="control-label" for="ecompInstanceName">ECOMP Environment Name</label> + <input id="ecompInstanceName" class="form-control" ng-model="vm.newEnvironment.ecompInstanceName" name="ecompInstanceName" data-tests-id="ecomp-instance-name" required disabled> + </div> + <div class="form-group"> + <label class="control-label" for="tenantContext">Select VSP</label> + <input id="tenantContext" class="form-control" ng-model="vm.newEnvironment.tenantContext" name="tenantContext" data-tests-id="tenant-context" required disabled> + </div> + <div class="form-group"> + <label class="control-label" for="operationalEnvironmentType">Environment Type</label> + <select class="form-control" ng-class="{'grayedOut': !vm.newEnvironment.operationalEnvironmentType}" ng-model="vm.newEnvironment.operationalEnvironmentType" name="operationalEnvironmentType" id="operationalEnvironmentType" data-tests-id="operational-environment-type" required> + <option value="" disabled selected hidden>Enter environment type</option> + <option data-tests-id="environment-type-option" class="environmentTypeOption" ng-repeat="item in vm.environmentsTypesList" ng-value="item">{{item}}</option> + </select> + </div> + <div class="form-group"> + <label class="control-label" for="workloadContext">Workload Context</label> + <select class="form-control" ng-class="{'grayedOut': !vm.newEnvironment.workloadContext}" ng-model="vm.newEnvironment.workloadContext" name="workloadContext" id="workloadContext" data-tests-id="workload-context" required> + <option value="" disabled selected hidden>Select workload context</option> + <option data-tests-id="workload-context-option" class="workloadContextOption" ng-repeat="item in vm.workloadContextList" ng-value="item">{{vm.newEnvironment.operationalEnvironmentType + '_' + item}}</option> + </select> + </div> + <div data-tests-id="test-new-environment-error" class="connect-error" ng-if="vm.aaiConnectError">{{vm.aaiConnectError}}</div> + </div> + <div class="modal-footer"> + <div class="pull-right"> + <button data-tests-id="submit-button" type="submit" id="submit" name="submit" class="btn btn-primary" data-ng-disabled="newTestEnvironment.$invalid">Create</button> + <button data-tests-id="cancel-button" type="button" id="cancel" name="cancel" class="btn btn-white" ng-click="vm.close()">Cancel</button> + </div> + </div> +</form> + |