2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
40 class AccountAddDetailsCtrl {
41 constructor($scope, $log, $interval, basicAuthAccountService, $modalInstance, errorMessageByCode, ECOMP_URL_REGEX, $window, confirmBoxService, $cookies,items) {
43 this.addEndpoint = () => {
44 confirmBoxService.showInformation('Please add the roles to this Username/MechId through AAF Screen ').then(isConfirmed => {});
46 /* this.account.endpointList.push({
52 this.account.endpointList = [];
53 this.passwordMatched = true;
54 this.dupliateName = false;
55 this.emptyAccountName = false;
56 this.emptyAccountUsername = false;
57 this.accountList = items.list;
59 if (items&& items.account) {
60 this.isEditMode = true;
61 this.account = _.clone(items.account);
62 this.account.repassword = this.account.password;
63 this.account.endpointList = this.account.endpoints;
64 if(this.account.isActive == 'Y')
65 this.account.active = true;
67 this.account.active = false;
69 this.isEditMode = false;
70 this.account.active = true;
72 console.log(this.account);
75 let resetConflict = fieldName => {
76 delete this.conflictMessages[fieldName];
77 if($scope.widgetForm[fieldName]){
78 $scope.widgetForm[fieldName].$setValidity('conflict', true);
83 /* this.closeThisDialog = () => {
84 $scope.closeThisDialog(true);
87 this.removeEndpointItem = (endpoint) => {
88 for(var i = 0; i < this.account.endpointList.length; i++){
89 if(this.account.endpointList[i].name == endpoint.name){
90 this.account.endpointList.splice(i, 1);
96 this.updateUsername = () => {
97 this.emptyAccountUsername = false;
100 this.updateAccountName = () => {
101 this.dupliateName = false;
102 for(var i = 0; i < this.accountList.length; i++){
103 if(this.accountList[i].applicationName == this.account.applicationName){
104 this.dupliateName = true;
110 this.updateAccountEndpoint = (endpoint) => {
111 endpoint.valid = true;
114 this.saveChanges = () => {
119 for(var i = 0; i < this.account.endpointList.length; i++){
120 if(this.account.endpointList[i].name == undefined
121 || this.account.endpointList[i].name == null
122 || this.account.endpointList[i].name == ""){
123 this.account.endpointList.splice(i, 1);
126 if(!this.account.endpointList[i].name.startsWith("/")){
127 this.account.endpointList[i].name = "/" + this.account.endpointList[i].name;
129 if(!r.test(this.account.endpointList[i].name)){
130 this.account.endpointList[i].valid = false;
137 if(this.account.applicationName == ''
138 || this.account.applicationName == undefined){
139 this.emptyAccountName = true;
143 if(this.account.username == ''
144 || this.account.username == undefined){
145 this.emptyAccountUsername = true;
149 if(this.dupliateName == true){
153 if(this.account.password != this.account.repassword){
154 this.passwordMatched = false;
164 if(this.account.active == true)
168 applicationName: this.account.applicationName,
169 username: this.account.username,
170 password: this.account.password,
171 endpoints: this.account.endpointList,
177 var message = "Are you sure you want to change '" + this.account.applicationName + "'?"
178 confirmBoxService.editItem(message).then(isConfirmed => {
180 basicAuthAccountService.updateAccount(this.account.id, newAccount).then(() => {
181 $modalInstance.close("confirmed");
186 basicAuthAccountService.createAccount(newAccount).then(() => {
187 $modalInstance.close("confirmed");
193 $scope.$on('$stateChangeStart', e => {
198 AccountAddDetailsCtrl.$inject = ['$scope', '$log', '$interval', 'basicAuthAccountService', '$modalInstance', 'errorMessageByCode', 'ECOMP_URL_REGEX', '$window', 'confirmBoxService', '$cookies','items'];
199 angular.module('ecompApp').controller('AccountAddDetailsCtrl', AccountAddDetailsCtrl);