Commit c7d2ece6 authored by Tom Käsler's avatar Tom Käsler

Merge branch '246-show-local-time-in-header' into 'master'

Resolve "Show local time in header"

Closes #246 and #245

See merge request !240
parents c6cc206b 7d72871c
Pipeline #27417 passed with stages
in 7 minutes and 51 seconds
......@@ -5,6 +5,16 @@
<mat-icon class="header-icons" aria-label="Go back">keyboard_arrow_left</mat-icon>
</button>
<span class="fill-remaining-space"></span>
<h3 *ngIf="router.url.includes('comments') && user.role === 1" fxLayoutAlign="center center">
<mat-icon>access_time</mat-icon>
{{cTime}}
</h3>
<span class="fill-remaining-space"
*ngIf="router.url.includes('comments') && user.role === 1 && deviceType === 'desktop'"></span>
<h3 *ngIf="router.url.includes('comments') && user.role === 1 && deviceType === 'desktop'" fxLayoutAlign="center center">
{{'header.id' | translate}}: {{ roomId.slice(0,4) }} {{ roomId.slice(4,8) }}
</h3>
<span class="fill-remaining-space"></span>
<mat-menu class="color-menu" #themeMenu="matMenu" [overlapTrigger]="false">
<mat-grid-list cols="2">
......
......@@ -59,3 +59,7 @@ mat-toolbar {
.sessions {
color: var(--primary);
}
h3 {
color: var(--on-surface);
}
......@@ -19,6 +19,9 @@ import { ThemeService } from '../../../../theme/theme.service';
export class HeaderComponent implements OnInit {
user: User;
themeClass = localStorage.getItem('theme');
cTime: string;
roomId: string;
deviceType = localStorage.getItem('deviceType');
constructor(public location: Location,
private authenticationService: AuthenticationService,
......@@ -41,6 +44,24 @@ export class HeaderComponent implements OnInit {
this.translationService.setDefaultLang(localStorage.getItem('currentLang'));
}
this.authenticationService.watchUser.subscribe(newUser => this.user = newUser);
this.getRoomId();
let time = new Date();
this.getTime(time);
setInterval(() => {
time = new Date();
this.getTime(time);
this.getRoomId();
}, 1000);
}
public getRoomId() {
this.roomId = localStorage.getItem('shortId');
}
getTime(time: Date) {
const hh = ('0' + time.getHours()).substr(-2);
const mm = ('0' + time.getMinutes()).substr(-2);
this.cTime = hh + ':' + mm;
}
logout() {
......@@ -55,10 +76,6 @@ export class HeaderComponent implements OnInit {
this.location.back();
}
goToHomepage() {
this.router.navigate(['/home']);
}
useLanguage(language: string) {
this.translationService.use(language);
localStorage.setItem('currentLang', language);
......
......@@ -13,7 +13,7 @@
</mat-expansion-panel>
<mat-expansion-panel *ngFor="let room of rooms" class="matPanel">
<mat-expansion-panel-header class="matPanelListHeader">
<button mat-button routerLink="/{{ baseUrl }}/room/{{ room.shortId }}">
<button mat-button routerLink="/{{ baseUrl }}/room/{{ room.shortId }}" (click)="setCurrentRoom(room.shortId)">
<mat-icon>input</mat-icon>
</button>
<mat-panel-title class="panelTitle">
......
......@@ -51,4 +51,8 @@ export class RoomListComponent implements OnInit {
this.closedRooms = this.rooms.filter(room => room.closed);
this.isLoading = false;
}
setCurrentRoom(shortId: string) {
localStorage.setItem('shortId', shortId);
}
}
......@@ -11,7 +11,8 @@
"change-theme": "Stil ändern",
"change-language": "Sprache ändern",
"login": "Login",
"my-account": "Mein Account"
"my-account": "Mein Account",
"id": "ID"
},
"login-page": {
"creator": "Referent/in",
......
......@@ -11,7 +11,8 @@
"change-theme": "Change theme",
"change-language": "Change language",
"login": "Login",
"my-account": "My account"
"my-account": "My account",
"id": "ID"
},
"login-page": {
"creator": "Speaker",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment