@@ -0,0 +1,33 @@
|
||||
/** Angular Imports */
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
/** Routing Imports */
|
||||
import { Route } from '../core/route/route.service';
|
||||
|
||||
/** Translation Imports */
|
||||
import { extract } from '../core/i18n/i18n.service';
|
||||
|
||||
/** Custom Components */
|
||||
import { ProfileComponent } from './profile.component';
|
||||
|
||||
/** Profile Routes */
|
||||
const routes: Routes = [
|
||||
Route.withShell([
|
||||
{
|
||||
path: 'profile',
|
||||
component: ProfileComponent,
|
||||
data: { title: extract('Profile'), breadcrumb: 'Profile' },
|
||||
}
|
||||
])
|
||||
];
|
||||
|
||||
/**
|
||||
* Profile Routing Module
|
||||
*/
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: []
|
||||
})
|
||||
export class ProfileRoutingModule { }
|
||||
@@ -0,0 +1,84 @@
|
||||
<div class="container m-b-20" fxLayout="row" fxLayout.lt-md="column" fxLayoutAlign="end" fxLayoutGap="2%">
|
||||
<button mat-raised-button color="primary" [routerLink]="['/system', 'roles-and-permissions']">
|
||||
<fa-icon icon="check"></fa-icon>
|
||||
Permissions
|
||||
</button>
|
||||
<button mat-raised-button color="primary" (click)="changeUserPassword()">
|
||||
<fa-icon icon="cog"></fa-icon>
|
||||
Change Password
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="container" fxLayout="column" fxLayoutGap="2%">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<div fxLayout="row wrap" class="content">
|
||||
|
||||
<div fxFlex="50%" class="header">
|
||||
User Id
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ profileData.userId }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="header">
|
||||
User Name
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ profileData.username }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="header">
|
||||
Office
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ profileData.officeName }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="header">
|
||||
Status
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ profileData.authenticated ? 'Authenticated' : 'Not Authenticated' }}
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%" class="header">
|
||||
Language
|
||||
</div>
|
||||
|
||||
<div fxFlex="50%">
|
||||
{{ language }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</mat-card>
|
||||
|
||||
<mat-card>
|
||||
|
||||
<table class="mat-elevation-z1" mat-table [dataSource]="dataSource">
|
||||
|
||||
<ng-container matColumnDef="role">
|
||||
<th mat-header-cell *matHeaderCellDef> Role </th>
|
||||
<td mat-cell *matCellDef="let role"> {{ role.name }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="description">
|
||||
<th mat-header-cell *matHeaderCellDef> Description </th>
|
||||
<td mat-cell *matCellDef="let role">{{ role.description }}</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
|
||||
</table>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
|
||||
.content {
|
||||
div {
|
||||
margin: 1rem 0;
|
||||
word-wrap: break-word;
|
||||
|
||||
&.header {
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProfileComponent } from './profile.component';
|
||||
|
||||
describe('ProfileComponent', () => {
|
||||
let component: ProfileComponent;
|
||||
let fixture: ComponentFixture<ProfileComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ProfileComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ProfileComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,68 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { MatTableDataSource, MatDialog } from '@angular/material';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
/** Custom Services */
|
||||
import { AuthenticationService } from 'app/core/authentication/authentication.service';
|
||||
import { ChangePasswordDialogComponent } from 'app/shared/change-password-dialog/change-password-dialog.component';
|
||||
import { UserService } from 'app/self-service/users/user.service';
|
||||
|
||||
/**
|
||||
* Profile Component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-profile',
|
||||
templateUrl: './profile.component.html',
|
||||
styleUrls: ['./profile.component.scss']
|
||||
})
|
||||
export class ProfileComponent implements OnInit {
|
||||
|
||||
/** Profile Data */
|
||||
profileData: any;
|
||||
/** Language, TODO: Update when df, locale settings are setup */
|
||||
language = 'English';
|
||||
|
||||
/** Roles Table Datasource */
|
||||
dataSource = new MatTableDataSource();
|
||||
/** Columns to be displayed in user roles table. */
|
||||
displayedColumns: string[] = ['role', 'description'];
|
||||
|
||||
/**
|
||||
* @param {AuthenticationService} authenticationService Authentication Service
|
||||
* @param {UserService} userService Users Service
|
||||
* @param {Router} router Router
|
||||
* @param {MatDialog} dialog Mat Dialog
|
||||
*/
|
||||
constructor(private authenticationService: AuthenticationService,
|
||||
private userService: UserService,
|
||||
private router: Router,
|
||||
public dialog: MatDialog) {
|
||||
this.profileData = authenticationService.getCredentials();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.dataSource = new MatTableDataSource(this.profileData.roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change Password of the user.
|
||||
*/
|
||||
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.profileData.userId, data).subscribe(() => {
|
||||
this.router.navigate(['/home']);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/** Angular Imports */
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
/** Custom Modules */
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
import { ProfileRoutingModule } from './profile-routing.module';
|
||||
|
||||
/** Custom Components */
|
||||
import { ProfileComponent } from './profile.component';
|
||||
|
||||
/**
|
||||
* Profile Module
|
||||
*/
|
||||
@NgModule({
|
||||
declarations: [ProfileComponent],
|
||||
imports: [
|
||||
SharedModule,
|
||||
ProfileRoutingModule
|
||||
]
|
||||
})
|
||||
export class ProfileModule { }
|
||||
Reference in New Issue
Block a user