diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 67bce1a3a..be81d8057 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -36,6 +36,7 @@ import { UsersModule } from './users/users.module'; import { ReportsModule } from './reports/reports.module'; import { NotificationsModule } from './notifications/notifications.module'; import { CollectionsModule } from './collections/collections.module'; +import { ProfileModule } from './profile/profile.module'; /** Main Routing Module */ import { AppRoutingModule } from './app-routing.module'; @@ -55,6 +56,7 @@ import { AppRoutingModule } from './app-routing.module'; CoreModule, HomeModule, LoginModule, + ProfileModule, SettingsModule, NavigationModule, ClientsModule, diff --git a/src/app/core/shell/sidenav/sidenav.component.ts b/src/app/core/shell/sidenav/sidenav.component.ts index 3f55f0ae0..10866d60a 100644 --- a/src/app/core/shell/sidenav/sidenav.component.ts +++ b/src/app/core/shell/sidenav/sidenav.component.ts @@ -43,6 +43,9 @@ export class SidenavComponent implements OnInit { .subscribe(() => this.router.navigate(['/login'], { replaceUrl: true })); } + /** + * Opens Mifos JIRA Wiki page. + */ help() { window.open('https://mifosforge.jira.com/wiki/spaces/docs/pages/52035622/User+Manual', '_blank'); } diff --git a/src/app/core/shell/toolbar/toolbar.component.html b/src/app/core/shell/toolbar/toolbar.component.html index f947bf1ad..744a045c6 100644 --- a/src/app/core/shell/toolbar/toolbar.component.html +++ b/src/app/core/shell/toolbar/toolbar.component.html @@ -98,6 +98,18 @@ + + diff --git a/src/app/core/shell/toolbar/toolbar.component.ts b/src/app/core/shell/toolbar/toolbar.component.ts index 3d164d5c4..11019774d 100644 --- a/src/app/core/shell/toolbar/toolbar.component.ts +++ b/src/app/core/shell/toolbar/toolbar.component.ts @@ -80,6 +80,16 @@ export class ToolbarComponent implements OnInit { .subscribe(() => this.router.navigate(['/login'], { replaceUrl: true })); } + /** + * Opens Mifos JIRA Wiki page. + */ + help() { + window.open('https://mifosforge.jira.com/wiki/spaces/docs/pages/52035622/User+Manual', '_blank'); + } + + /** + * Opens Keyboard shortcuts dialog. + */ showKeyboardShortcuts() { const dialogRef = this.dialog.open(KeyboardShortcutsDialogComponent); dialogRef.afterClosed().subscribe((response: any) => {}); diff --git a/src/app/profile/profile-routing.module.ts b/src/app/profile/profile-routing.module.ts new file mode 100644 index 000000000..e17ba9e62 --- /dev/null +++ b/src/app/profile/profile-routing.module.ts @@ -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 { } diff --git a/src/app/profile/profile.component.html b/src/app/profile/profile.component.html new file mode 100644 index 000000000..a7f30f643 --- /dev/null +++ b/src/app/profile/profile.component.html @@ -0,0 +1,84 @@ +
+ + +
+ + +
+ + + +
+ +
+ User Id +
+ +
+ {{ profileData.userId }} +
+ +
+ User Name +
+ +
+ {{ profileData.username }} +
+ +
+ Office +
+ +
+ {{ profileData.officeName }} +
+ +
+ Status +
+ +
+ {{ profileData.authenticated ? 'Authenticated' : 'Not Authenticated' }} +
+ +
+ Language +
+ +
+ {{ language }} +
+ +
+ +
+ + + + + + + + + + + + + + + + + + +
Role {{ role.name }} Description {{ role.description }}
+ +
+ +
\ No newline at end of file diff --git a/src/app/profile/profile.component.scss b/src/app/profile/profile.component.scss new file mode 100644 index 000000000..a4541ccaf --- /dev/null +++ b/src/app/profile/profile.component.scss @@ -0,0 +1,14 @@ +.container { + max-width: 37rem; + + .content { + div { + margin: 1rem 0; + word-wrap: break-word; + + &.header { + font-weight: 500; + } + } + } +} diff --git a/src/app/profile/profile.component.spec.ts b/src/app/profile/profile.component.spec.ts new file mode 100644 index 000000000..692b2340e --- /dev/null +++ b/src/app/profile/profile.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ProfileComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ProfileComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts new file mode 100644 index 000000000..5480e3b42 --- /dev/null +++ b/src/app/profile/profile.component.ts @@ -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']); + }); + } + }); + } + +} diff --git a/src/app/profile/profile.module.ts b/src/app/profile/profile.module.ts new file mode 100644 index 000000000..bb5c18de0 --- /dev/null +++ b/src/app/profile/profile.module.ts @@ -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 { }