Improved the "user area"

This commit is contained in:
tidusjar 2020-11-04 09:00:24 +00:00
commit 2fe5297f34
5 changed files with 64 additions and 13 deletions

View file

@ -56,6 +56,7 @@ export class AppComponent implements OnInit {
if (this.authService.loggedIn()) { if (this.authService.loggedIn()) {
this.identity.getUser().subscribe(u => { this.identity.getUser().subscribe(u => {
this.username = u.userName;
if (u.language) { if (u.language) {
this.translate.use(u.language); this.translate.use(u.language);
} }
@ -106,9 +107,7 @@ export class AppComponent implements OnInit {
this.currentUrl = event.url; this.currentUrl = event.url;
if (event instanceof NavigationStart) { if (event instanceof NavigationStart) {
this.user = this.authService.claims(); this.user = this.authService.claims();
if (this.user && this.user.username) {
this.username = this.user.username;
}
this.isAdmin = this.authService.hasRole("admin"); this.isAdmin = this.authService.hasRole("admin");
this.showNav = this.authService.loggedIn(); this.showNav = this.authService.loggedIn();

View file

@ -4,7 +4,13 @@
[opened]="!(isHandset$ | async)"> [opened]="!(isHandset$ | async)">
<mat-toolbar>{{applicationName}}</mat-toolbar> <mat-toolbar>{{applicationName}}</mat-toolbar>
<div class="profile-img-container"> <div class="profile-img-container">
<img class="profile-img" src="https://www.gravatar.com/avatar/{{emailHash}}?d=https://raw.githubusercontent.com/tidusjar/Ombi/gh-pages/img/android-chrome-512x512.png" /> <div class="profile-img">
<img src="https://www.gravatar.com/avatar/{{emailHash}}?d=https://raw.githubusercontent.com/tidusjar/Ombi/gh-pages/img/android-chrome-512x512.png" />
</div>
<div class="profile-info">
<h3>{{username}}</h3>
<p>{{welcomeText | translate}}</p>
</div>
</div> </div>
<mat-nav-list> <mat-nav-list>
<span *ngFor="let nav of navItems"> <span *ngFor="let nav of navItems">

View file

@ -90,9 +90,34 @@
}*/ }*/
.profile-img-container { .profile-img-container {
text-align: center;padding-bottom: 15px; margin: 20px auto 10px;
overflow: hidden;
text-align: center;
width: 80%;
} }
.profile-img { .profile-img {
width: 100px; float: left;
border-radius: 100%; height: 40px;
margin-right: 15px;
}
.profile-info {
overflow: hidden;
text-align: left;
}
.profile-info > h3 {
font-size: 15px;
text-transform: capitalize;
// color: #333;
margin-bottom: 2px;
}
.profile-info > p {
// color: #333;
font-size: 11px;
margin-top: 5px;
}
.profile-img img {
border-radius: 6px;
box-shadow: 4px 3px 6px 0 rgba(0,0,0,.2);
width: 45px;
} }

View file

@ -7,7 +7,8 @@ import { StorageService } from '../shared/storage/storage-service';
import { SettingsService } from '../services'; import { SettingsService } from '../services';
import { MatSlideToggleChange } from '@angular/material/slide-toggle'; import { MatSlideToggleChange } from '@angular/material/slide-toggle';
import { SearchFilter } from './SearchFilter'; import { SearchFilter } from './SearchFilter';
import {Md5} from 'ts-md5/dist/md5'; import { Md5 } from 'ts-md5/dist/md5';
import { TranslateService } from '@ngx-translate/core';
export enum SearchFilterType { export enum SearchFilterType {
Movie = 1, Movie = 1,
@ -40,11 +41,13 @@ export class MyNavComponent implements OnInit {
public navItems: INavBar[]; public navItems: INavBar[];
public searchFilter: SearchFilter; public searchFilter: SearchFilter;
public SearchFilterType = SearchFilterType; public SearchFilterType = SearchFilterType;
public emailHash: string|Int32Array; public emailHash: string | Int32Array;
public welcomeText: string;
constructor(private breakpointObserver: BreakpointObserver, constructor(private breakpointObserver: BreakpointObserver,
private settingsService: SettingsService, private settingsService: SettingsService,
private store: StorageService) { private store: StorageService,
private translate: TranslateService) {
} }
public async ngOnInit() { public async ngOnInit() {
@ -56,8 +59,8 @@ export class MyNavComponent implements OnInit {
tvShows: true tvShows: true
} }
this.setWelcomeText();
if(this.email) { if (this.email) {
const md5 = new Md5(); const md5 = new Md5();
this.emailHash = md5.appendStr(this.email).end(); this.emailHash = md5.appendStr(this.email).end();
} }
@ -122,4 +125,19 @@ export class MyNavComponent implements OnInit {
} }
this.store.save("searchFilter", JSON.stringify(this.searchFilter)); this.store.save("searchFilter", JSON.stringify(this.searchFilter));
} }
private setWelcomeText() {
var d = new Date();
var hour = d.getHours();
if (hour >= 0 && hour < 12) {
this.welcomeText = 'NavigationBar.MorningWelcome';
}
if (hour >= 12 && hour < 18) {
this.welcomeText = 'NavigationBar.AfternoonWelcome';
}
if (hour >= 18 && hour < 23) {
this.welcomeText = 'NavigationBar.EveningWelcome';
}
}
} }

View file

@ -75,7 +75,10 @@
"TvShows":"TV Shows", "TvShows":"TV Shows",
"Music":"Music", "Music":"Music",
"People":"People" "People":"People"
} },
"MorningWelcome":"Good morning!",
"AfternoonWelcome":"Good afternoon!",
"EveningWelcome":"Good evening!"
}, },
"Search": { "Search": {
"Title": "Search", "Title": "Search",