Skip to content

Commit

Permalink
all: smoother profile toolbar (fixes #7627) (#7642)
Browse files Browse the repository at this point in the history
Co-authored-by: mutugiii <[email protected]>
Co-authored-by: dogi <[email protected]>
  • Loading branch information
3 people authored Nov 1, 2024
1 parent 3eb6f14 commit a063656
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.15.22",
"version": "0.15.23",
"myplanet": {
"latest": "v0.20.75",
"min": "v0.19.75"
"latest": "v0.20.76",
"min": "v0.19.76"
},
"scripts": {
"ng": "ng",
Expand Down
28 changes: 22 additions & 6 deletions src/app/users/users-profile/users-profile.component.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
<mat-toolbar *ngIf="!isDialog">
<button mat-icon-button (click)="goBack()"><mat-icon>arrow_back</mat-icon></button>
<span i18n>Member Profile</span>
<span class="toolbar-fill"></span>
<mat-toolbar-row>
<button mat-icon-button (click)="goBack()">
<mat-icon>arrow_back</mat-icon>
</button>
<span i18n>Member Profile</span>
<span class="toolbar-fill"></span>
</mat-toolbar-row>
</mat-toolbar>

<div class="space-container">
<mat-toolbar class="primary-color font-size-1">
<span>{{userDetail.name}}</span>
<mat-icon class="margin-lr-5" *ngIf="userDetail.gender" svgIcon="{{userDetail.gender.toLowerCase()}}"></mat-icon>
<span class="toolbar-fill"></span>
<button mat-icon-button [matMenuTriggerFor]="menu" *ngIf="isMobile; else actionButtons">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #menu="matMenu" class="actions-menu">
<ng-container *ngTemplateOutlet="actionButtons"></ng-container>
</mat-menu>
</mat-toolbar>
<ng-template #actionButtons>
<button mat-stroked-button class="margin-lr-3" *ngIf="hasAchievement && (user.name === urlName || user.isUserAdmin) && !isDialog" [routerLink]="['achievements', { planet: userDetail.planetCode }]">
<mat-icon class="margin-lr-3">visibility</mat-icon><span i18n>View Achievements</span>
</button>
<button mat-raised-button color="accent" class="margin-lr-3" *ngIf="editable && !isDialog" [routerLink]="['../../update/', urlName]"><mat-icon>mode_edit</mat-icon><span i18n>Edit Profile</span></button>
<a mat-raised-button color="accent" class="margin-lr-3" *ngIf="editable && !isDialog" i18n [planetChangePassword]="userDetail">Change Password</a>
</mat-toolbar>
<button mat-raised-button color="accent" class="margin-lr-3" *ngIf="editable && !isDialog" [routerLink]="['../../update/', urlName]">
<mat-icon>mode_edit</mat-icon><span i18n>Edit Profile</span>
</button>
<a mat-raised-button color="accent" class="margin-lr-3" *ngIf="editable && !isDialog" i18n [planetChangePassword]="userDetail">
Change Password
</a>
</ng-template>
<div class="view-container">
<div class="profile-container">
<div class="profile-image-section">
Expand Down
19 changes: 16 additions & 3 deletions src/app/users/users-profile/users-profile.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
import { Component, OnInit, OnDestroy, Input, HostListener } from '@angular/core';
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
Expand All @@ -9,6 +9,7 @@ import { UsersAchievementsService } from '../users-achievements/users-achievemen
import { findDocuments } from '../../shared/mangoQueries';
import { StateService } from '../../shared/state.service';
import { educationLevel } from '../user-constants';
import { DeviceInfoService, DeviceType } from '../../shared/device-info.service';

@Component({
selector: 'planet-users-profile',
Expand All @@ -27,6 +28,8 @@ export class UsersProfileComponent implements OnInit, OnDestroy {
totalLogins = 0;
lastLogin = 0;
educationLevel = educationLevel;
deviceType: DeviceType;
isMobile: boolean;
private onDestroy$ = new Subject<void>();
@Input() planetCode: string | null = null;
@Input() isDialog: boolean;
Expand All @@ -38,8 +41,12 @@ export class UsersProfileComponent implements OnInit, OnDestroy {
private userService: UserService,
private router: Router,
private usersAchievementsService: UsersAchievementsService,
private stateService: StateService
) { }
private stateService: StateService,
private deviceInfoService: DeviceInfoService
) {
this.deviceType = this.deviceInfoService.getDeviceType();
this.isMobile = this.deviceType === DeviceType.MOBILE;
}

ngOnInit() {
this.user = this.userService.get();
Expand All @@ -56,6 +63,12 @@ export class UsersProfileComponent implements OnInit, OnDestroy {
});
}

@HostListener('window:resize')
onResize() {
this.deviceType = this.deviceInfoService.getDeviceType();
this.isMobile = this.deviceType === DeviceType.MOBILE;
}

ngOnDestroy() {
this.onDestroy$.next();
this.onDestroy$.complete();
Expand Down

0 comments on commit a063656

Please sign in to comment.