Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard: profile picture, username clickable and link to profile #7792

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/app/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<mat-card class="horizontal">
<img [src]="profileImg">
<a [routerLink]="['/users/profile', user.name]" class="profile-link">
<img [src]="profileImg" class="profile-avatar">
</a>
<div class="dashboard-name">
<h1 class="mat-title">{{displayName}} ({{visits | number}})</h1>
<a [routerLink]="['/users/profile', user.name]" class="profile-link">
<h1 class="mat-title">{{displayName}} ({{visits | number}})</h1>
</a>
<h1 class="mat-title">
<span class="mat-subheading-2"><ng-container *ngFor="let role of roles; last as last">
<planet-role [role]="role"></planet-role><span *ngIf="!last">, </span>
</ng-container></span>
<span class="mat-subheading-2">
<ng-container *ngFor="let role of roles; last as last">
<planet-role [role]="role"></planet-role><span *ngIf="!last">, </span>
</ng-container>
</span>
</h1>
</div>
<div class="date">
Expand Down
11 changes: 10 additions & 1 deletion src/app/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
badgesCourses: { [key: string]: any[] } = {};
badgeGroups = [ ...foundations, 'none' ];
badgeIcons = foundationIcons;
user: any;

dateNow: any;
visits = 0;
Expand Down Expand Up @@ -76,14 +77,22 @@ export class DashboardComponent implements OnInit, OnDestroy {

ngOnInit() {
const user = this.userService.get();
this.displayName = user.firstName !== undefined ? user.firstName + ' ' + user.lastName : user.name;

if (user) {
this.user = user;
this.displayName = user.firstName ? `${user.firstName} ${user.lastName}` : user.name;
} else {
console.warn('User data is missing or not initialized properly.');
}

this.planetName = this.stateService.configuration.name;
this.getSurveys();
this.getExams();
this.initDashboard();
this.couchService.findAll('login_activities', findDocuments({ 'user': this.userService.get().name }, [ 'user' ], [], 1000))
.pipe(
catchError(() => {
console.warn('Error fetching login activities');
return of([]);
})
).subscribe((res: any) => {
Expand Down
Loading