Skip to content

Commit

Permalink
username displayed on dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
ChauhanAbhinav committed Aug 22, 2019
1 parent a3a7043 commit b1b7e6b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/app/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<mat-sidenav-container>
<mat-sidenav mode="side" opened>
<mat-nav-list >
<mat-nav-list style="text-align: center;font-size:20px;font-weight:100;">
{{user}}
<a mat-list-item >
<button mat-raised-button color="primary" (click) = "logout()">
<mat-icon aria-hidden="false" aria-label="icon" style="padding-right: 10px">power_settings_new</mat-icon> Logout
</button>
</a>

<mat-divider ></mat-divider>

<a mat-list-item [routerLink]="'public'">
<mat-icon aria-hidden="false" aria-label="icon" style="padding-right: 10px">public</mat-icon> Public </a>
Expand All @@ -13,12 +21,7 @@
<a mat-list-item [routerLink]="'userlist'">
<mat-icon aria-hidden="false" aria-label="icon" style="padding-right: 10px">group</mat-icon>All Users </a>

<mat-divider ></mat-divider>

<a mat-list-item >
<button mat-raised-button color="primary" (click) = "logout()">
<mat-icon aria-hidden="false" aria-label="icon" style="padding-right: 10px">power_settings_new</mat-icon> Logout</button>
</a>

</mat-nav-list>
</mat-sidenav>
Expand Down
2 changes: 2 additions & 0 deletions src/app/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {Router} from '@angular/router';
styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements OnInit {
private user;
constructor(private loginService: LoginService, private router: Router) {
loginService.authenticate();
this.user = loginService.getLoggedUser();
}
logout() {
this.loginService.logout();
Expand Down
3 changes: 2 additions & 1 deletion src/app/top-bar/top-bar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<mat-toolbar-row>
<mat-icon aria-hidden="false" aria-label="icon" style="padding-right: 0px">home</mat-icon>
<button mat-button routerLink="/dashboard" style="font-size:20px">
Dashboard</button>
{{user}}
</button>
<span class="spacer"></span>

<button mat-button routerLink="/login">Login</button>
Expand Down
4 changes: 3 additions & 1 deletion src/app/top-bar/top-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import { LoginService } from '../services/login.service';
styleUrls: ['./top-bar.component.css']
})
export class TopBarComponent implements OnInit {

private user;
constructor(private loginService: LoginService) {
this.user = 'Dashboard';
}


ngOnInit() {
}

Expand Down

0 comments on commit b1b7e6b

Please sign in to comment.