aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+remote-interaction
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+remote-interaction')
-rw-r--r--client/src/app/+remote-interaction/remote-interaction-routing.module.ts23
-rw-r--r--client/src/app/+remote-interaction/remote-interaction.component.html7
-rw-r--r--client/src/app/+remote-interaction/remote-interaction.component.scss2
-rw-r--r--client/src/app/+remote-interaction/remote-interaction.component.ts56
-rw-r--r--client/src/app/+remote-interaction/remote-interaction.module.ts26
5 files changed, 114 insertions, 0 deletions
diff --git a/client/src/app/+remote-interaction/remote-interaction-routing.module.ts b/client/src/app/+remote-interaction/remote-interaction-routing.module.ts
new file mode 100644
index 000000000..1dddfb3ba
--- /dev/null
+++ b/client/src/app/+remote-interaction/remote-interaction-routing.module.ts
@@ -0,0 +1,23 @@
1import { NgModule } from '@angular/core'
2import { RouterModule, Routes } from '@angular/router'
3import { LoginGuard } from '@app/core'
4import { RemoteInteractionComponent } from './remote-interaction.component'
5
6const remoteInteractionRoutes: Routes = [
7 {
8 path: '',
9 component: RemoteInteractionComponent,
10 canActivate: [ LoginGuard ],
11 data: {
12 meta: {
13 title: $localize`Remote interaction`
14 }
15 }
16 }
17]
18
19@NgModule({
20 imports: [ RouterModule.forChild(remoteInteractionRoutes) ],
21 exports: [ RouterModule ]
22})
23export class RemoteInteractionRoutingModule {}
diff --git a/client/src/app/+remote-interaction/remote-interaction.component.html b/client/src/app/+remote-interaction/remote-interaction.component.html
new file mode 100644
index 000000000..e59783b9a
--- /dev/null
+++ b/client/src/app/+remote-interaction/remote-interaction.component.html
@@ -0,0 +1,7 @@
1<div class="root">
2
3 <div class="alert alert-error" *ngIf="error">
4 {{ error }}
5 </div>
6
7</div>
diff --git a/client/src/app/+remote-interaction/remote-interaction.component.scss b/client/src/app/+remote-interaction/remote-interaction.component.scss
new file mode 100644
index 000000000..5e6774739
--- /dev/null
+++ b/client/src/app/+remote-interaction/remote-interaction.component.scss
@@ -0,0 +1,2 @@
1@import '_variables';
2@import '_mixins';
diff --git a/client/src/app/+remote-interaction/remote-interaction.component.ts b/client/src/app/+remote-interaction/remote-interaction.component.ts
new file mode 100644
index 000000000..e24607b24
--- /dev/null
+++ b/client/src/app/+remote-interaction/remote-interaction.component.ts
@@ -0,0 +1,56 @@
1import { forkJoin } from 'rxjs'
2import { Component, OnInit } from '@angular/core'
3import { ActivatedRoute, Router } from '@angular/router'
4import { VideoChannel } from '@app/shared/shared-main'
5import { SearchService } from '@app/shared/shared-search'
6
7@Component({
8 selector: 'my-remote-interaction',
9 templateUrl: './remote-interaction.component.html',
10 styleUrls: ['./remote-interaction.component.scss']
11})
12export class RemoteInteractionComponent implements OnInit {
13 error = ''
14
15 constructor (
16 private route: ActivatedRoute,
17 private router: Router,
18 private search: SearchService
19 ) { }
20
21 ngOnInit () {
22 const uri = this.route.snapshot.queryParams['uri']
23
24 if (!uri) {
25 this.error = $localize`URL parameter is missing in URL parameters`
26 return
27 }
28
29 this.loadUrl(uri)
30 }
31
32 private loadUrl (uri: string) {
33 forkJoin([
34 this.search.searchVideos({ search: uri }),
35 this.search.searchVideoChannels({ search: uri })
36 ]).subscribe(([ videoResult, channelResult ]) => {
37 let redirectUrl: string
38
39 if (videoResult.data.length !== 0) {
40 const video = videoResult.data[0]
41
42 redirectUrl = '/videos/watch/' + video.uuid
43 } else if (channelResult.data.length !== 0) {
44 const channel = new VideoChannel(channelResult.data[0])
45
46 redirectUrl = '/video-channels/' + channel.nameWithHost
47 } else {
48 this.error = $localize`Cannot access to the remote resource`
49 return
50 }
51
52 this.router.navigateByUrl(redirectUrl)
53 })
54 }
55
56}
diff --git a/client/src/app/+remote-interaction/remote-interaction.module.ts b/client/src/app/+remote-interaction/remote-interaction.module.ts
new file mode 100644
index 000000000..9f9f1cdfd
--- /dev/null
+++ b/client/src/app/+remote-interaction/remote-interaction.module.ts
@@ -0,0 +1,26 @@
1import { CommonModule } from '@angular/common'
2import { NgModule } from '@angular/core'
3import { SharedSearchModule } from '@app/shared/shared-search'
4import { RemoteInteractionRoutingModule } from './remote-interaction-routing.module'
5import { RemoteInteractionComponent } from './remote-interaction.component'
6
7@NgModule({
8 imports: [
9 CommonModule,
10
11 SharedSearchModule,
12
13 RemoteInteractionRoutingModule
14 ],
15
16 declarations: [
17 RemoteInteractionComponent
18 ],
19
20 exports: [
21 RemoteInteractionComponent
22 ],
23
24 providers: []
25})
26export class RemoteInteractionModule { }