import { Component } from '@angular/core' ; import { MatDialog , MatDialogConfig , MatDialogRef } from '@angular/material' ; import { ActivatedRoute } from '@angular/router' ; import { map , take } from 'rxjs/operators' ; import { TokenService } from '@core/services/index.service' ; import { DialogConfirmationComponent } from '@shared/dialog/confirmation/dialog-confirmation.component' ; import { BreadCrumbModel , ProjectModel , TokenModel } from '@shared/models/index.model' ; /**
 * Token list component
 */ @ Component ( { selector : 'dashboard-project-tokens-list' , templateUrl : './tokens-list.component.html' , styleUrls : [ './tokens-list.component.scss' ] , } ) export class TokensListComponent { private dialogRef : MatDialogRef < DialogConfirmationComponent > ; public projectUid : string ; public project : ProjectModel ; public tokenList : TokenModel [ ] ; public typeIcon : string ; public displayedColumns : string [ ] = [ 'name' , 'action' ] ; public breadCrumb : BreadCrumbModel [ ] ; param dialog param tokenService param route constructor ( private dialog , private tokenService , private route ) { this . projectUid = this . route . snapshot . paramMap . get ( 'projectUid' ) ; this . route . data . pipe ( map ( ( data ) => data ) , take ( 1 ) ) . subscribe ( ( data ) => { this . tokenList = data . tokens ; this . project = data . project ; this . breadCrumb = [ { link : `/projects/${ this . project . uid }` , title : this . project . title } ] ; } ) ; } param tokenUid delete ( tokenUid ) { let dialogConfig = new MatDialogConfig ( ) ; dialogConfig = { width : '500px' , data : { title : 'Delete Token' , content : 'Are you sure you want to delete?' , } , } ; this . dialogRef = this . dialog . open ( DialogConfirmationComponent , dialogConfig ) ; this . dialogRef . afterClosed ( ) . subscribe ( ( result ) => { if ( result === true ) { this . tokenService . delete ( this . projectUid , tokenUid ) . subscribe ( ( tokens ) => this . tokenList = tokens ) ; } } ) ; } }