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, ViewChild, Input} from '@angular/core';
40 import { MatTableDataSource } from '@angular/material';
41 import { MatSort, MatPaginator } from '@angular/material';
42 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
43 import { BasicAuthAccountService } from '../../shared/services/index';
44 import { IAccountOnboarding } from 'src/app/shared/model/account-onboarding/accountOnboarding';
45 import { AccountAddDetailsComponent } from './account-add-details/account-add-details.component';
46 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
47 import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
50 selector: 'app-account-onboarding',
51 templateUrl: './account-onboarding.component.html',
52 styleUrls: ['./account-onboarding.component.scss']
54 export class AccountOnboardingComponent implements OnInit {
56 accountList: Array<IAccountOnboarding> = [];
58 isEditMode: boolean = false;
59 displayedColumns: string[] = ['accountName', 'userName','delete'];
60 dataSource = new MatTableDataSource(this.accountList);
61 @ViewChild(MatSort) sort: MatSort;
62 @ViewChild(MatPaginator) paginator: MatPaginator;
64 constructor(public basicAuthAccountService: BasicAuthAccountService, public ngbModal: NgbModal) { }
67 this.getOnboardingAccounts();
70 populateTableData(wigetList: Array<IAccountOnboarding>){
71 this.dataSource = new MatTableDataSource(wigetList);
72 this.dataSource.sort = this.sort;
73 this.dataSource.paginator = this.paginator;
76 getOnboardingAccounts(){
77 //console.log("getOnboardingAccounts called");
78 this.basicAuthAccountService.getAccountList()
81 //console.log("getOnboardingAccounts Data :: ", _data);
82 if (this.result == null || this.result == 'undefined') {
83 //console.log('BasicAuthAccountService::getOnboardingAccounts Failed: Result or result.data is null');
85 this.accountList = this.result.response;
86 this.populateTableData(this.accountList);
94 openAddNewAccountModal(rowData: any){
95 //console.log("openAddNewAccountModal getting called...");
96 const modalRef = this.ngbModal.open(AccountAddDetailsComponent, { size: 'lg' });
97 modalRef.componentInstance.title = 'Account Details';
98 if(rowData != 'undefined' && rowData){
99 rowData.repassword = rowData.password;
100 modalRef.componentInstance.accountOnboarding = rowData;
101 this.isEditMode = true;
103 modalRef.componentInstance.accountOnboarding = {};
104 this.isEditMode = false;
106 modalRef.componentInstance.passEntry.subscribe((receivedEntry: any) => {
107 //console.log("receivedEntry >>> ",receivedEntry);
109 this.accountList = [];
110 this.getOnboardingAccounts();
115 deleteAccount(selectedAccount : any){
116 let confirmationMsg = 'You are about to delete this account : ' + selectedAccount.applicationName + '. Click OK to continue.';
117 this.openInformationModal("Confirmation",confirmationMsg).result.then((result) => {
118 if (result === 'Ok') {
119 //console.log("deleteAccount called Account Onboarding");
120 if(!selectedAccount || selectedAccount == null || selectedAccount =='undefined'){
121 console.log('AccountOnboardingCtrl::deleteAccount: No Account or ID... cannot delete');
124 //console.log("deleteAccount>>id",selectedAccount.id)
125 this.basicAuthAccountService.deleteAccount(selectedAccount.id)
126 .subscribe( _data => {
128 //console.log("deleteAccount response :: ",this.result);
129 this.accountList.splice(this.accountList.indexOf(selectedAccount), 1);
130 this.getOnboardingAccounts();
140 openConfirmationModal(_title: string, _message: string) {
141 const modalInfoRef = this.ngbModal.open(ConfirmationModalComponent);
142 modalInfoRef.componentInstance.title = _title;
143 modalInfoRef.componentInstance.message = _message;
146 openInformationModal(_title: string, _message: string){
147 const modalInfoRef = this.ngbModal.open(InformationModalComponent);
148 modalInfoRef.componentInstance.title = _title;
149 modalInfoRef.componentInstance.message = _message;