@@ -54,4 +54,17 @@ export class UserService {
|
|||||||
return this.http.disableApiPrefix().get('/assets/mock/user.mock.json');
|
return this.http.disableApiPrefix().get('/assets/mock/user.mock.json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change User Password.
|
||||||
|
* @param userId User Id of users
|
||||||
|
* @param password New Password of the user
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*
|
||||||
|
* TODO: update endpoint once API available
|
||||||
|
*/
|
||||||
|
changePassword(userId: string, passwordObj: any) {
|
||||||
|
|
||||||
|
return this.http.put(`/self/user/${userId}`, passwordObj);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['view/1600']"></tr>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['view',row.id]"></tr>
|
||||||
<!-- TODO: Update route once API is setup. -->
|
<!-- TODO: Update route once API is setup. -->
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<fa-icon icon="edit"></fa-icon>
|
<fa-icon icon="edit"></fa-icon>
|
||||||
Edit
|
Edit
|
||||||
</button>
|
</button>
|
||||||
<button mat-raised-button color="primary" (click)="openDialog()">
|
<button mat-raised-button color="primary" (click)="changeUserPassword()">
|
||||||
<fa-icon icon="cog"></fa-icon>
|
<fa-icon icon="cog"></fa-icon>
|
||||||
Change Password
|
Change Password
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
/** Angular Imports */
|
/** Angular Imports */
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { ChangePasswordDialogComponent } from 'app/shared/change-password-dialog/change-password-dialog.component';
|
||||||
|
import { MatDialog } from '@angular/material';
|
||||||
|
|
||||||
|
/** Custom Services. */
|
||||||
|
import { UserService } from '../user.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View self service user component.
|
* View self service user component.
|
||||||
@@ -20,8 +25,15 @@ export class ViewUserComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* Retrieves the user data from `resolve`.
|
* Retrieves the user data from `resolve`.
|
||||||
* @param {ActivatedRoute} route Activated Route.
|
* @param {ActivatedRoute} route Activated Route.
|
||||||
|
* @param {UserService} userService Users Service.
|
||||||
|
* @param {ActivatedRoute} route Activated Route.
|
||||||
|
* @param {Router} router Router for navigation.
|
||||||
|
* @param {MatDialog} dialog Dialog reference.
|
||||||
*/
|
*/
|
||||||
constructor(private route: ActivatedRoute) {
|
constructor(private route: ActivatedRoute,
|
||||||
|
private userService: UserService,
|
||||||
|
private router: Router,
|
||||||
|
private dialog: MatDialog) {
|
||||||
this.route.data.subscribe((data: { user: any }) => {
|
this.route.data.subscribe((data: { user: any }) => {
|
||||||
this.user = data.user;
|
this.user = data.user;
|
||||||
});
|
});
|
||||||
@@ -30,8 +42,24 @@ export class ViewUserComponent implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
openDialog() {
|
/**
|
||||||
// TODO: Open change password dialog.
|
* Open Dialog to Change Password
|
||||||
|
*/
|
||||||
|
changeUserPassword() {
|
||||||
|
const changeUserPasswordDialogRef = this.dialog.open(ChangePasswordDialogComponent, {
|
||||||
|
width: '400px',
|
||||||
|
height: '300px'
|
||||||
|
});
|
||||||
|
changeUserPasswordDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
|
if (response.password && response.repeatPassword) {
|
||||||
|
const password = response.password;
|
||||||
|
const repeatPassword = response.repeatPassword;
|
||||||
|
const data = {password: password, repeatPassword: repeatPassword };
|
||||||
|
this.userService.changePassword(this.user.id, data).subscribe(() => {
|
||||||
|
this.router.navigate(['/..']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,11 @@
|
|||||||
<mat-error *ngIf="changePasswordForm.controls.password.hasError('maxlength')">
|
<mat-error *ngIf="changePasswordForm.controls.password.hasError('maxlength')">
|
||||||
Password should not be more than <strong>50 characters long</strong>
|
Password should not be more than <strong>50 characters long</strong>
|
||||||
</mat-error>
|
</mat-error>
|
||||||
<mat-error *ngIf="changePasswordForm.controls.password.hasError('pattern')">
|
<mat-error *ngIf="changePasswordForm.controls.password.hasError('pattern') && !(changePasswordForm.controls.password.hasError('minlength') || changePasswordForm.controls.password.hasError('maxlength'))">
|
||||||
Password should include a <strong>numeral</strong> and at <strong>least one uppercase</strong> ,<strong>lowercase and special character</strong>
|
Password should include a <strong>numeral</strong> and at <strong>least one uppercase</strong> ,<strong>lowercase and special character</strong>
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div fxLayout="column">
|
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>Repeat Password</mat-label>
|
<mat-label>Repeat Password</mat-label>
|
||||||
<input matInput formControlName="repeatPassword" type="password">
|
<input matInput formControlName="repeatPassword" type="password">
|
||||||
|
|||||||
Reference in New Issue
Block a user