1 import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { PluginService } from '@app/core'
4 import { logger } from '@root-helpers/logger'
7 templateUrl: './plugin-pages.component.html'
9 export class PluginPagesComponent implements AfterViewInit {
10 @ViewChild('root') root: ElementRef
13 private route: ActivatedRoute,
14 private router: Router,
15 private pluginService: PluginService
21 this.pluginService.ensurePluginsAreLoaded('common')
22 .then(() => this.loadRoute())
25 private loadRoute () {
26 const path = '/' + this.route.snapshot.url.map(u => u.path).join('/')
28 const registered = this.pluginService.getRegisteredClientRoute(path)
30 logger.info(`Could not find registered route ${path}`, this.pluginService.getAllRegisteredClientRoutes())
32 return this.router.navigate([ '/404' ], { skipLocationChange: true })
35 registered.onMount({ rootEl: this.root.nativeElement })