Skip to content
Snippets Groups Projects
Commit 8b48f4dd authored by paf's avatar paf
Browse files

restores the comparism on local & server clock

parent 854125df
No related branches found
No related tags found
No related merge requests found
......@@ -58,6 +58,16 @@ export class AppComponent implements OnInit, OnDestroy {
return true;
}
private static localTime(date: Date): string {
const year = date.getFullYear();
const month = (`0${date.getMonth() + 1}`).slice(-2);
const day = (`0${date.getDate()}`).slice(-2);
const hours = (`0${date.getHours()}`).slice(-2);
const minutes = (`0${date.getMinutes()}`).slice(-2);
const seconds = (`0${date.getSeconds()}`).slice(-2);
return `${day}.${month}.${year} ${hours}:${minutes}:${seconds}`;
}
closeErrorBox(): void {
this.showError = false;
}
......@@ -86,33 +96,43 @@ export class AppComponent implements OnInit, OnDestroy {
this.setupFocusListeners();
this.bs.getSysConfig().subscribe(sysConfig => {
if (sysConfig) {
this.cts.addCustomTexts(sysConfig.customTexts);
const authData = MainDataService.getAuthData();
if (authData) {
this.cts.addCustomTexts(authData.customTexts);
}
if (sysConfig.broadcastingService && sysConfig.broadcastingService.status) {
this.mds.broadcastingServiceInfo = sysConfig.broadcastingService;
}
this.mds.isApiValid = AppComponent.isValidVersion(this.expectedApiVersion, sysConfig.version);
this.mds.apiVersion = sysConfig.version;
if (!this.mds.isApiValid) {
this.mds.appError$.next({
label: 'Server-Problem: API-Version ungültig',
description: `erwartet: ${this.expectedApiVersion}, gefunden: ${sysConfig.version}`,
category: 'FATAL'
});
}
if (!sysConfig) {
this.mds.isApiValid = false; // push on this.mds.appError$ ?
return;
}
this.cts.addCustomTexts(sysConfig.customTexts);
const authData = MainDataService.getAuthData();
if (authData) {
this.cts.addCustomTexts(authData.customTexts);
}
// TODO implement SysConfig.mainLogo
if (sysConfig.broadcastingService && sysConfig.broadcastingService.status) {
this.mds.broadcastingServiceInfo = sysConfig.broadcastingService;
}
this.mds.isApiValid = AppComponent.isValidVersion(this.expectedApiVersion, sysConfig.version);
this.mds.apiVersion = sysConfig.version;
if (!this.mds.isApiValid) {
this.mds.appError$.next({
label: 'Server-Problem: API-Version ungültig',
description: `erwartet: ${this.expectedApiVersion}, gefunden: ${sysConfig.version}`,
category: 'FATAL'
});
}
this.mds.setTestConfig(sysConfig.testConfig);
} else {
this.mds.isApiValid = false;
// TODO implement SysConfig.mainLogo
const clientTime = new Date();
const serverTime = new Date(sysConfig.serverTimestamp);
if (Math.abs(sysConfig.serverTimestamp - clientTime.getTime()) > 90000) {
this.mds.appError$.next({
label: 'Server- und Client-Uhr stimmen nicht überein.',
description: `Server-Zeit: ${AppComponent.localTime(serverTime)},
Client-Zeit: ${AppComponent.localTime(clientTime)}`,
category: 'FATAL'
});
}
this.mds.setTestConfig(sysConfig.testConfig);
});
this.bs.getSysCheckInfo().subscribe(sysCheckConfigs => {
......
......@@ -7,6 +7,7 @@ export interface SysConfig {
version: string;
mainLogo: string;
testConfig: KeyValuePairs;
serverTimestamp: number;
broadcastingService: BroadCastingServiceInfo;
}
......@@ -22,11 +23,11 @@ export class AppConfig {
) {
}
setDefaultCustomTexts() {
setDefaultCustomTexts(): void {
const ctDefaults = {};
for (const k of Object.keys(customTextsDefault)) {
ctDefaults[k] = customTextsDefault[k].defaultvalue;
}
Object.keys(customTextsDefault).forEach(key => {
ctDefaults[key] = customTextsDefault[key].defaultvalue;
});
this.cts.addCustomTexts(ctDefaults);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment