Make stage views use the 12 hour time setting

This commit is contained in:
Daniel 2021-02-19 19:09:28 +13:00
parent e6366ce12e
commit 86c602b41b
3 changed files with 9 additions and 3 deletions

View File

@ -11,7 +11,7 @@
</div> </div>
</div> </div>
<div class="sidebar"> <div class="sidebar">
<div class="time">{{ time|date:'HH:mm' }}</div> <div class="time">{{ (openlpService.getIsTwelveHourTime()) ? (time|date:'h:mm a') : (time|date:'HH:mm') }}</div>
<div class="transpose"> <div class="transpose">
<button mat-icon-button (click)="transposeUp()"> <button mat-icon-button (click)="transposeUp()">
<mat-icon>keyboard_arrow_up</mat-icon> <mat-icon>keyboard_arrow_up</mat-icon>

View File

@ -16,7 +16,7 @@
</div> </div>
<div class="sidebar"> <div class="sidebar">
<div class="top"> <div class="top">
<div class="time">{{ time|date:'HH:mm' }}</div> <div class="time">{{ (openlpService.getIsTwelveHourTime()) ? (time|date:'h:mm a') : (time|date:'HH:mm') }}</div>
<div class="notes" [innerHTML]="notes|nl2br"></div> <div class="notes" [innerHTML]="notes|nl2br"></div>
</div> </div>
<div class="close"><button mat-raised-button class="closeButton" routerLink="/">Close</button></div> <div class="close"><button mat-raised-button class="closeButton" routerLink="/">Close</button></div>

View File

@ -39,6 +39,7 @@ const httpOptions = {
export class OpenLPService { export class OpenLPService {
private apiURL: string; private apiURL: string;
public stateChanged$: EventEmitter<State>; public stateChanged$: EventEmitter<State>;
private isTwelveHourTime: boolean = true;
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
const host = window.location.hostname; const host = window.location.hostname;
@ -53,11 +54,12 @@ export class OpenLPService {
this.stateChanged$ = new EventEmitter<State>(); this.stateChanged$ = new EventEmitter<State>();
this.retrieveSystemInformation().subscribe(info => { this.retrieveSystemInformation().subscribe(info => {
const ws = new WebSocket(`ws://${host}:${info.websocket_port}`); const ws = new WebSocket(`ws://${host}:${info.websocket_port}`);
ws.onmessage = (event) => { ws.onmessage = (event) => {
const reader = new FileReader(); const reader = new FileReader();
reader.onload = () => { reader.onload = () => {
const state = deserialize(JSON.parse(reader.result as string).results, State); const state = deserialize(JSON.parse(reader.result as string).results, State);
this.isTwelveHourTime = state.twelve;
this.stateChanged$.emit(state); this.stateChanged$.emit(state);
}; };
reader.readAsText(event.data); reader.readAsText(event.data);
@ -69,6 +71,10 @@ export class OpenLPService {
httpOptions.headers = httpOptions.headers.set('Authorization', token); httpOptions.headers = httpOptions.headers.set('Authorization', token);
} }
getIsTwelveHourTime(): boolean {
return this.isTwelveHourTime;
}
retrieveSystemInformation(): Observable<SystemInformation> { retrieveSystemInformation(): Observable<SystemInformation> {
return this.http.get<SystemInformation>(`${this.apiURL}/core/system`, httpOptions); return this.http.get<SystemInformation>(`${this.apiURL}/core/system`, httpOptions);
} }