aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/app.component.ts42
1 files changed, 27 insertions, 15 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index fc4d6c6a2..2149768a2 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -4,6 +4,7 @@ import { GuardsCheckStart, NavigationEnd, Router } from '@angular/router'
4import { AuthService, RedirectService, ServerService } from '@app/core' 4import { AuthService, RedirectService, ServerService } from '@app/core'
5import { is18nPath } from '../../../shared/models/i18n' 5import { is18nPath } from '../../../shared/models/i18n'
6import { ScreenService } from '@app/shared/misc/screen.service' 6import { ScreenService } from '@app/shared/misc/screen.service'
7import { skip } from 'rxjs/operators'
7 8
8@Component({ 9@Component({
9 selector: 'my-app', 10 selector: 'my-app',
@@ -89,25 +90,36 @@ export class AppComponent implements OnInit {
89 } 90 }
90 ) 91 )
91 92
93 // Inject JS
92 this.serverService.configLoaded 94 this.serverService.configLoaded
93 .subscribe(() => { 95 .subscribe(() => {
94 const config = this.serverService.getConfig() 96 const config = this.serverService.getConfig()
97
98 if (config.instance.customizations.javascript) {
99 try {
100 // tslint:disable:no-eval
101 eval(config.instance.customizations.javascript)
102 } catch (err) {
103 console.error('Cannot eval custom JavaScript.', err)
104 }
105 }
106 })
95 107
96 // We test customCSS if the admin removed the css 108 // Inject CSS if modified (admin config settings)
97 if (this.customCSS || config.instance.customizations.css) { 109 this.serverService.configLoaded
98 const styleTag = '<style>' + config.instance.customizations.css + '</style>' 110 .pipe(skip(1)) // We only want to subscribe to reloads, because the CSS is already injected by the server
99 this.customCSS = this.domSanitizer.bypassSecurityTrustHtml(styleTag) 111 .subscribe(() => {
100 } 112 const headStyle = document.querySelector('style.custom-css-style')
113 if (headStyle) headStyle.parentNode.removeChild(headStyle)
101 114
102 if (config.instance.customizations.javascript) { 115 const config = this.serverService.getConfig()
103 try { 116
104 // tslint:disable:no-eval 117 // We test customCSS if the admin removed the css
105 eval(config.instance.customizations.javascript) 118 if (this.customCSS || config.instance.customizations.css) {
106 } catch (err) { 119 const styleTag = '<style>' + config.instance.customizations.css + '</style>'
107 console.error('Cannot eval custom JavaScript.', err) 120 this.customCSS = this.domSanitizer.bypassSecurityTrustHtml(styleTag)
108 } 121 }
109 } 122 })
110 })
111 } 123 }
112 124
113 isUserLoggedIn () { 125 isUserLoggedIn () {