Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | 1x | import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; import { CustomtextService } from '../services/customtext/customtext.service'; // eslint-disable-next-line import/no-relative-packages import customTextsDefaultJSON from '../../../../../definitions/custom-texts.json'; import { KeyValuePairs } from '../../app.interfaces'; import { AppSettings, DEFAULT_BACKGROUND_BODY, DEFAULT_BACKGROUND_BOX, DEFAULT_LOGO, SysConfig } from '../interfaces/app-config.interfaces'; const customTextsDefault = customTextsDefaultJSON as { [k: string]: { 'label': string, 'defaultvalue': string } }; export class AppConfig { customTexts: KeyValuePairs = {}; version = ''; veronaPlayerApiVersionMin: number = 0; veronaPlayerApiVersionMax: number = 0; mainLogo = DEFAULT_LOGO; appTitle = 'IQB-Testcenter'; backgroundBody: string = ''; backgroundBox: string = ''; introHtml = ''; trustedIntroHtml: SafeUrl | null = null; legalNoticeHtml = ''; trustedLegalNoticeHtml: SafeUrl | null = null; globalWarningText = ''; globalWarningExpiredDay = ''; globalWarningExpiredHour = ''; sanitizer: DomSanitizer | null = null; cts: CustomtextService | null = null; bugReportAuth: string = ''; bugReportTarget: string = ''; broadcastingServiceUri: string = ''; fileServiceUri: string = ''; get warningMessage(): string { Iif (this.globalWarningExpiredDay) { return AppConfig.isWarningExpired(this.globalWarningExpiredDay, this.globalWarningExpiredHour) ? '' : this.globalWarningText; } return this.globalWarningText; } constructor( sysConfig: SysConfig, cts: CustomtextService, sanitizer: DomSanitizer ) { this.sanitizer = sanitizer; this.cts = cts; if (sysConfig) { this.customTexts = sysConfig.customTexts; this.setCustomTexts(sysConfig.customTexts); this.setAppConfig(sysConfig.appConfig); this.version = sysConfig.version; this.veronaPlayerApiVersionMin = sysConfig.veronaPlayerApiVersionMin; this.veronaPlayerApiVersionMax = sysConfig.veronaPlayerApiVersionMax; this.broadcastingServiceUri = sysConfig.broadcastingServiceUri; this.fileServiceUri = sysConfig.fileServiceUri; } else { this.setCustomTexts({}); this.setAppConfig({}); } this.applyBackgroundColors(); } setCustomTexts(customTexts: KeyValuePairs): void { const ctSettings: { [k: string]: string } = {}; Object.keys(customTextsDefault).forEach(k => { ctSettings[k] = customTextsDefault[k].defaultvalue; }); Iif (customTexts) { Object.keys(customTexts).forEach(k => { ctSettings[k] = customTexts[k]; }); } this.cts?.addCustomTexts(ctSettings); } setAppConfig(appConfig: AppSettings): void { this.appTitle = 'IQB-Testcenter'; this.introHtml = 'Einführungstext nicht definiert'; this.legalNoticeHtml = '<p>Anbieter:<br>Max Mustermann<br>Musterstraße 1<br>13088 Berlin<br>' + '<br>Kontakt:<br>Telefon: 030/1234567-8<br>Telefax: 030/1234567-9<br>E-Mail: mail@mustermann.de' + '<br>Website: www.mustermann.de</p>'; // TODO does this makes sense this.mainLogo = DEFAULT_LOGO; this.backgroundBody = DEFAULT_BACKGROUND_BODY; this.backgroundBox = DEFAULT_BACKGROUND_BOX; this.trustedIntroHtml = null; this.trustedLegalNoticeHtml = null; this.globalWarningText = ''; this.globalWarningExpiredDay = ''; this.globalWarningExpiredHour = ''; this.bugReportAuth = ''; this.bugReportTarget = ''; Iif (appConfig) { Iif (appConfig.appTitle) this.appTitle = appConfig.appTitle; Iif (appConfig.mainLogo) this.mainLogo = appConfig.mainLogo; Iif (appConfig.backgroundBody) this.backgroundBody = appConfig.backgroundBody; Iif (appConfig.backgroundBox) this.backgroundBox = appConfig.backgroundBox; Iif (appConfig.introHtml) this.introHtml = appConfig.introHtml; Iif (appConfig.legalNoticeHtml) this.legalNoticeHtml = appConfig.legalNoticeHtml; Iif (appConfig.globalWarningText) this.globalWarningText = appConfig.globalWarningText; Iif (appConfig.globalWarningExpiredDay) this.globalWarningExpiredDay = appConfig.globalWarningExpiredDay; Iif (appConfig.globalWarningExpiredHour) { this.globalWarningExpiredHour = appConfig.globalWarningExpiredHour; } Iif (appConfig.bugReportAuth) this.bugReportAuth = appConfig.bugReportAuth; Iif (appConfig.bugReportTarget) this.bugReportTarget = appConfig.bugReportTarget; } this.trustedIntroHtml = this.sanitizer?.bypassSecurityTrustHtml(this.introHtml) ?? ''; this.trustedLegalNoticeHtml = this.sanitizer?.bypassSecurityTrustHtml(this.legalNoticeHtml) ?? ''; } applyBackgroundColors(): void { document.documentElement.style.setProperty('--tc-body-background', this.backgroundBody); document.documentElement.style.setProperty('--tc-box-background', this.backgroundBox); } static isWarningExpired(warningDay: string, warningHour: string): boolean { const calcTimePoint = new Date(warningDay); calcTimePoint.setHours(Number(warningHour)); const now = new Date(Date.now()); return calcTimePoint < now; } getAppConfig(): AppSettings { return { appTitle: this.appTitle, mainLogo: this.mainLogo, backgroundBody: this.backgroundBody, backgroundBox: this.backgroundBox, introHtml: this.introHtml, legalNoticeHtml: this.legalNoticeHtml, globalWarningText: this.globalWarningText, globalWarningExpiredDay: this.globalWarningExpiredDay, globalWarningExpiredHour: this.globalWarningExpiredHour, bugReportAuth: this.bugReportAuth, bugReportTarget: this.bugReportTarget }; } } |