Korrektur UserLogo, #12 Easy interal must be greater than good interval

This commit is contained in:
Your Name
2025-01-27 20:17:45 +01:00
parent 9638feacb9
commit 47b393e134
3 changed files with 63 additions and 35 deletions

View File

@@ -30,10 +30,16 @@ import { ClickOutsideDirective } from './service/click-outside.directive';
<div class="flex justify-center items-center mb-8">
<h1 class="text-3xl font-bold mx-auto">Vocabulary Training</h1>
<div class="relative" appClickOutside (clickOutside)="showDropdown = false">
<img [src]="photoURL" alt="User Photo" class="w-10 h-10 rounded-full cursor-pointer" (click)="toggleDropdown()" />
<div *ngIf="showDropdown" class="absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg">
@if(photoURL){
<img [src]="photoURL" alt="User Photo" class="w-10 h-10 rounded-full cursor-pointer" (click)="toggleDropdown()" referrerpolicy="no-referrer" crossorigin="anonymous"/>
} @else {
<div class="image-placeholder w-10 h-10 rounded-full cursor-pointer">Image</div>
}
@if(showDropdown){
<div class="absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg">
<button (click)="logout()" class="block w-full text-left px-4 py-2 text-gray-700 hover:bg-gray-100">Abmelden</button>
</div>
}
</div>
</div>
<app-deck-list></app-deck-list>
@@ -72,6 +78,7 @@ img:hover {
.dropdown button:hover {
background-color: #f7fafc;
}
`,
imports: [CommonModule, DeckListComponent, ClickOutsideDirective],
})
@@ -79,7 +86,7 @@ export class AppComponent {
isLoggedIn = false;
private auth: Auth = inject(Auth);
showDropdown = false;
photoURL: string = 'https://via.placeholder.com/40';
photoURL: string = 'https://placehold.co/40';
// user: User | null = null;
ngOnInit() {
@@ -88,7 +95,7 @@ export class AppComponent {
const accessToken = localStorage.getItem('accessToken');
const refreshToken = localStorage.getItem('refreshToken');
this.photoURL = localStorage.getItem('photoURL');
this.showDropdown = false;
if (isLoggedIn && accessToken && refreshToken) {
this.isLoggedIn = true;
}
@@ -106,7 +113,9 @@ export class AppComponent {
localStorage.setItem('accessToken', await result.user.getIdToken());
localStorage.setItem('refreshToken', result.user.refreshToken);
localStorage.setItem('photoURL', result.user.photoURL);
this.showDropdown = false;
console.log('Logged in with Google', result.user);
} catch (error) {
console.error('Google Login failed', error);