]>
Commit | Line | Data |
---|---|---|
d63e6d46 C |
1 | import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | |
3 | import { PluginService } from '@app/core' | |
42b40636 | 4 | import { logger } from '@root-helpers/logger' |
d63e6d46 C |
5 | |
6 | @Component({ | |
7 | templateUrl: './plugin-pages.component.html' | |
8 | }) | |
9 | export class PluginPagesComponent implements AfterViewInit { | |
10 | @ViewChild('root') root: ElementRef | |
11 | ||
12 | constructor ( | |
13 | private route: ActivatedRoute, | |
14 | private router: Router, | |
15 | private pluginService: PluginService | |
16 | ) { | |
17 | ||
18 | } | |
19 | ||
20 | ngAfterViewInit () { | |
9d9a3733 C |
21 | this.pluginService.ensurePluginsAreLoaded('common') |
22 | .then(() => this.loadRoute()) | |
23 | } | |
24 | ||
25 | private loadRoute () { | |
d63e6d46 C |
26 | const path = '/' + this.route.snapshot.url.map(u => u.path).join('/') |
27 | ||
28 | const registered = this.pluginService.getRegisteredClientRoute(path) | |
29 | if (!registered) { | |
42b40636 | 30 | logger.info(`Could not find registered route ${path}`, this.pluginService.getAllRegisteredClientRoutes()) |
d63e6d46 C |
31 | |
32 | return this.router.navigate([ '/404' ], { skipLocationChange: true }) | |
33 | } | |
34 | ||
35 | registered.onMount({ rootEl: this.root.nativeElement }) | |
36 | } | |
37 | } |