2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 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============================================
39 import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
40 import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
41 import { BasicAuthAccountService } from 'src/app/shared/services';
42 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
45 selector: 'app-account-add-details',
46 templateUrl: './account-add-details.component.html',
47 styleUrls: ['./account-add-details.component.scss']
49 export class AccountAddDetailsComponent implements OnInit {
52 isEditMode: boolean = false;
53 dupliateName: boolean = false;
54 emptyAccountName: boolean = false;
55 emptyAccountUsername: boolean = false;
56 passwordMatched: boolean = false;
58 @Input() accountOnboarding: any;
59 @Output() passEntry: EventEmitter<any> = new EventEmitter();
61 constructor(public basicAuthAccountService: BasicAuthAccountService, public activeModal: NgbActiveModal, public ngbModal: NgbModal) { }
64 this.passwordMatched = true;
65 this.dupliateName = false;
66 this.emptyAccountName = false;
67 this.emptyAccountUsername = false;
69 if(this.accountOnboarding.applicationName){
70 this.isEditMode = true;
72 this.isEditMode = false;
73 this.accountOnboarding.isActive = true;
74 this.accountOnboarding.endpointList = [];
76 //console.log("IsEditMode in Add account Dialog :: ",this.isEditMode)
81 const modalRef = this.ngbModal.open(ConfirmationModalComponent);
82 modalRef.componentInstance.title = "";
83 modalRef.componentInstance.message = 'Please add the roles to this Username/MechId through AAF Screen';
84 modalRef.result.then((result) => { }, (resut) => {return;});
86 /*this.accountOnboarding.endpointList.push({
91 //Add Or Update Account.
94 //console.log("saveChanges called Account Onboarding");
96 if(this.accountOnboarding.applicationName == ''
97 || this.accountOnboarding.applicationName == undefined){
98 this.emptyAccountName = true;
102 if(this.accountOnboarding.username == ''
103 || this.accountOnboarding.username == undefined){
104 this.emptyAccountUsername = true;
108 if(this.dupliateName == true){
112 if(this.dupliateName == true){
116 if(this.accountOnboarding.password != this.accountOnboarding.repassword){
117 this.passwordMatched = false;
120 //console.log("isValid....",isValid)
125 if(this.accountOnboarding.isActive == true)
129 applicationName: this.accountOnboarding.applicationName,
130 username: this.accountOnboarding.username,
131 password: this.accountOnboarding.password,
132 endpoints: this.accountOnboarding.endpoints,
137 var message = "Are you sure you want to change '" + this.accountOnboarding.applicationName + "'?"
138 this.basicAuthAccountService.updateAccount(this.accountOnboarding.id, newAccount)
139 .subscribe( _data => {
141 //console.log("updateAccount response :: ",this.result);
142 this.passEntry.emit(this.result);
143 this.ngbModal.dismissAll();
148 this.basicAuthAccountService.createAccount(newAccount)
149 .subscribe( _data => {
151 //console.log("createAccount response :: ",this.result);
152 this.passEntry.emit(this.result);
153 this.ngbModal.dismissAll();