aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+plugin-pages/plugin-pages.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-10 15:01:12 +0100
committerChocobozzz <me@florianbigard.com>2021-12-10 15:01:12 +0100
commitd63e6d4604dfbe4938c7d66832c9202364c5bb64 (patch)
tree6bd444be722276ff214d911284a400e374bdddc8 /client/src/app/+plugin-pages/plugin-pages.component.ts
parent03a65456f44a6152bb68975e29e076c8c5754cd6 (diff)
downloadPeerTube-d63e6d4604dfbe4938c7d66832c9202364c5bb64.tar.gz
PeerTube-d63e6d4604dfbe4938c7d66832c9202364c5bb64.tar.zst
PeerTube-d63e6d4604dfbe4938c7d66832c9202364c5bb64.zip
Add ability for plugins to register client routes
Diffstat (limited to 'client/src/app/+plugin-pages/plugin-pages.component.ts')
-rw-r--r--client/src/app/+plugin-pages/plugin-pages.component.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/client/src/app/+plugin-pages/plugin-pages.component.ts b/client/src/app/+plugin-pages/plugin-pages.component.ts
new file mode 100644
index 000000000..5f294ee13
--- /dev/null
+++ b/client/src/app/+plugin-pages/plugin-pages.component.ts
@@ -0,0 +1,31 @@
1import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
3import { PluginService } from '@app/core'
4
5@Component({
6 templateUrl: './plugin-pages.component.html'
7})
8export class PluginPagesComponent implements AfterViewInit {
9 @ViewChild('root') root: ElementRef
10
11 constructor (
12 private route: ActivatedRoute,
13 private router: Router,
14 private pluginService: PluginService
15 ) {
16
17 }
18
19 ngAfterViewInit () {
20 const path = '/' + this.route.snapshot.url.map(u => u.path).join('/')
21
22 const registered = this.pluginService.getRegisteredClientRoute(path)
23 if (!registered) {
24 console.log('Could not find registered route %s.', path, this.pluginService.getAllRegisteredClientRoutes())
25
26 return this.router.navigate([ '/404' ], { skipLocationChange: true })
27 }
28
29 registered.onMount({ rootEl: this.root.nativeElement })
30 }
31}