parent
d51cb3957f
commit
b7aeed4321
@ -1,35 +1,59 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, ElementRef, HostListener, Input, OnInit, ViewChild} from '@angular/core';
|
||||||
import { TranslationService } from '../../services/translation.service';
|
import { TranslationService } from '../../services/translation.service';
|
||||||
|
import {ThemeService} from "../../services/theme.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-header',
|
selector: 'app-header',
|
||||||
templateUrl: './header.component.html',
|
templateUrl: './header.component.html',
|
||||||
styleUrls: ['./header.component.scss']
|
styleUrls: ['./header.component.scss']
|
||||||
})
|
})
|
||||||
export class HeaderComponent implements OnInit {
|
export class HeaderComponent implements OnInit {
|
||||||
title!: string;
|
title!: string;
|
||||||
version!: string;
|
version!: string;
|
||||||
sandkasten_logo!: string;
|
sandkasten_logo!: string;
|
||||||
gitea_logo!: string;
|
gitea_logo!: string;
|
||||||
@Input() themeClass!: string;
|
isMenuOpen!: boolean;
|
||||||
|
isCheck!: boolean;
|
||||||
ngOnInit(): void {
|
@ViewChild('menuRef') menuRef!: ElementRef;
|
||||||
this.title = 'Sandkasten';
|
@Input() themeClass!: string;
|
||||||
this.version = '1.0';
|
@Input() themeService!: ThemeService;
|
||||||
this.sandkasten_logo = 'assets/img/logo.png';
|
|
||||||
this.gitea_logo = 'assets/img/gitea.png';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Instanciation du service pour les actions de traduction
|
ngOnInit(): void {
|
||||||
constructor(private translationService: TranslationService) {}
|
this.title = 'Sandkasten';
|
||||||
|
this.version = '1.0';
|
||||||
// Méthode pour changer la langue
|
this.sandkasten_logo = 'assets/img/logo.png';
|
||||||
onLanguageChange(event: any) {
|
this.gitea_logo = 'assets/img/gitea.png';
|
||||||
this.translationService.onLanguageChange(event);
|
this.isMenuOpen = false;
|
||||||
}
|
this.isCheck = false;
|
||||||
|
}
|
||||||
// Méthode pour récupérer le drapeau de la langue courante
|
|
||||||
getFlagImageUrl(): string {
|
// Instanciation du service pour les actions de traduction
|
||||||
return this.translationService.getFlagImageUrl();
|
constructor(private translationService: TranslationService) {}
|
||||||
}
|
|
||||||
|
// Méthode pour changer la langue
|
||||||
|
onLanguageChange(event: any) {
|
||||||
|
this.translationService.onLanguageChange(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleTheme() {
|
||||||
|
this.themeService.toggleDarkTheme();
|
||||||
|
this.themeService.isDarkTheme.subscribe(value => {
|
||||||
|
this.isCheck = value;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
openCloseMenu() {
|
||||||
|
this.isMenuOpen = !this.isMenuOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('document:click', ['$event'])
|
||||||
|
clickout(event: any) {
|
||||||
|
// If the menu is open and click is outside the menu, we close it
|
||||||
|
if (this.isMenuOpen && !this.menuRef.nativeElement.contains(event.target)) {
|
||||||
|
this.isMenuOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue