import { Component , OnInit } from '@angular/core' ; import { ClipboardService } from 'ngx-clipboard' ; import { NgbModal } from '@ng-bootstrap/ng-bootstrap' ; import { AddNewAddressComponent } from './modals/add-new-address/add-new-address.component' ; import { AddressLabel } from '@shared/models/address-label' ; import { Observable } from 'rxjs' ; import { GlobalService } from '@shared/services/global.service' ; import { SnackbarService } from 'ngx-snackbar' ; import { AddressBookService } from '@shared/services/address-book-service' ; import { ConfirmationModalComponent } from '@shared/components/confirmation-modal/confirmation-modal.component' ; import { Router } from '@angular/router' ; import { Animations } from '@shared/animations/animations' ; @ Component ( { selector : 'app-address-book' , templateUrl : './address-book.component.html' , styleUrls : [ './address-book.component.scss' ] , animations : Animations . fadeIn } ) export class AddressBookComponent implements OnInit { constructor ( private router , private globalService , private snackbarService , private addressBookService , private clipboardService , private modalService ) { } public addresses : Observable < AddressLabel [ ] > ; public ngOnInit ( ) { this . getAddressBookAddresses ( ) ; } private getAddressBookAddresses ( ) { this . addresses = this . addressBookService . contacts ; } public sendClicked ( address ) { this . router . navigateByUrl ( `wallet/send/${ address . address }` ) ; } public removeClicked ( address ) { const modal = this . modalService . open ( ConfirmationModalComponent , { backdrop : 'static' , } ) ; const instance = modal . componentInstance ; instance . title = 'Remove Contact' ; instance . body = `Are you sure you want to remove the contact ${ address . label }` ; instance . confirmSnackBarMessage = `Contact ${ address . label } has been removed.` ; modal . result . then ( confirmed => { if ( confirmed ) { this . addressBookService . removeAddressBookAddress ( address ) ; } } ) ; } public addNewAddressClicked ( ) { const addressLabel = this . modalService . open ( AddNewAddressComponent , { backdrop : 'static' } ) ; } }