/** Angular Imports */ import { Component , OnInit } from '@angular/core' ; import { ActivatedRoute , Router } from '@angular/router' ; import { MatDialog } from '@angular/material/dialog' ; /** Custom Services */ import { UsersService } from '../users.service' ; /** Custom Components */ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component' ; import { ChangePasswordDialogComponent } from 'app/shared/change-password-dialog/change-password-dialog.component' ; /**
 * View user component.
 */ @ Component ( { selector : 'mifosx-view-user' , templateUrl : './view-user.component.html' , styleUrls : [ './view-user.component.scss' ] } ) export class ViewUserComponent implements OnInit { /** User Data. */ userData : any ; param { UsersService } usersService param { ActivatedRoute } route param { Router } router param { MatDialog } dialog constructor ( private usersService , private route , private router , private dialog ) { this . route . data . subscribe ( ( data ) => { this . userData = data . user ; } ) ; } ngOnInit ( ) { } /**
     * Deletes the user and redirects to users.
     */ delete ( ) { const deleteUserDialogRef = this . dialog . open ( DeleteDialogComponent , { data : { deleteContext : `user ${ this . userData . id }` } } ) ; deleteUserDialogRef . afterClosed ( ) . subscribe ( ( response ) => { if ( response . delete ) { this . usersService . deleteUser ( this . userData . id ) . subscribe ( ( ) => { this . router . navigate ( [ '/users' ] ) ; } ) ; } } ) ; } /**
     * Change Password of the Users.
     */ changeUserPassword ( ) { const changeUserPasswordDialogRef = this . dialog . open ( ChangePasswordDialogComponent , { width : '400px' , height : '300px' } ) ; changeUserPasswordDialogRef . afterClosed ( ) . subscribe ( ( response ) => { if ( response . password && response . repeatPassword ) { const password = response . password ; const repeatPassword = response . repeatPassword ; const firstname = this . userData . firstname ; const data = { password : password , repeatPassword : repeatPassword , firstname : firstname } ; this . usersService . changePassword ( this . userData . id , data ) . subscribe ( ( ) => { this . router . navigate ( [ '/users' ] ) ; } ) ; } } ) ; } }