This commit is contained in:
Eugene Pankov
2021-06-27 16:28:49 +02:00
parent 0689c984ff
commit df108d9071
24 changed files with 404 additions and 63 deletions

View File

@@ -10,6 +10,7 @@ import { ConfigModalComponent } from './configModal.component'
import { ConfigService } from '../services/config.service'
import { combineLatest } from 'rxjs'
import { Config, Version } from '../api'
import { Router } from '@angular/router'
@Component({
selector: 'main',
@@ -35,16 +36,25 @@ export class MainComponent {
public loginService: LoginService,
private ngbModal: NgbModal,
private config: ConfigService,
private router: Router,
) {
window.addEventListener('message', event => {
if (event.data === 'request-connector') {
this.iframe.nativeElement.contentWindow['__connector__'] = this.appConnector
this.iframe.nativeElement.contentWindow.postMessage('connector-ready', '*')
}
})
window.addEventListener('message', this.connectorRequestHandler)
}
connectorRequestHandler = event => {
if (event.data === 'request-connector') {
this.iframe.nativeElement.contentWindow['__connector__'] = this.appConnector
this.iframe.nativeElement.contentWindow.postMessage('connector-ready', '*')
}
}
async ngAfterViewInit () {
await this.loginService.ready$.toPromise()
if (!this.loginService.user) {
this.router.navigate(['/login'])
return
}
combineLatest(
this.config.activeConfig$,
this.config.activeVersion$
@@ -58,6 +68,10 @@ export class MainComponent {
await this.config.selectDefaultConfig()
}
ngOnDestroy () {
window.removeEventListener('message', this.connectorRequestHandler)
}
unloadApp () {
this.showApp = false
this.iframe.nativeElement.src = 'about:blank'