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 @@ +import { NgModule } from '@angular/core' +import { RouterModule, Routes } from '@angular/router' +import { LoginGuard } from '@app/core' +import { RemoteInteractionComponent } from './remote-interaction.component' + +const remoteInteractionRoutes: Routes = [ + { + path: '', + component: RemoteInteractionComponent, + canActivate: [ LoginGuard ], + data: { + meta: { + title: $localize`Remote interaction` + } + } + } +] + +@NgModule({ + imports: [ RouterModule.forChild(remoteInteractionRoutes) ], + exports: [ RouterModule ] +}) +export 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 @@ +
+ +
+ {{ error }} +
+ +
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 @@ +@import '_variables'; +@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 @@ +import { forkJoin } from 'rxjs' +import { Component, OnInit } from '@angular/core' +import { ActivatedRoute, Router } from '@angular/router' +import { VideoChannel } from '@app/shared/shared-main' +import { SearchService } from '@app/shared/shared-search' + +@Component({ + selector: 'my-remote-interaction', + templateUrl: './remote-interaction.component.html', + styleUrls: ['./remote-interaction.component.scss'] +}) +export class RemoteInteractionComponent implements OnInit { + error = '' + + constructor ( + private route: ActivatedRoute, + private router: Router, + private search: SearchService + ) { } + + ngOnInit () { + const uri = this.route.snapshot.queryParams['uri'] + + if (!uri) { + this.error = $localize`URL parameter is missing in URL parameters` + return + } + + this.loadUrl(uri) + } + + private loadUrl (uri: string) { + forkJoin([ + this.search.searchVideos({ search: uri }), + this.search.searchVideoChannels({ search: uri }) + ]).subscribe(([ videoResult, channelResult ]) => { + let redirectUrl: string + + if (videoResult.data.length !== 0) { + const video = videoResult.data[0] + + redirectUrl = '/videos/watch/' + video.uuid + } else if (channelResult.data.length !== 0) { + const channel = new VideoChannel(channelResult.data[0]) + + redirectUrl = '/video-channels/' + channel.nameWithHost + } else { + this.error = $localize`Cannot access to the remote resource` + return + } + + this.router.navigateByUrl(redirectUrl) + }) + } + +} 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 @@ +import { CommonModule } from '@angular/common' +import { NgModule } from '@angular/core' +import { SharedSearchModule } from '@app/shared/shared-search' +import { RemoteInteractionRoutingModule } from './remote-interaction-routing.module' +import { RemoteInteractionComponent } from './remote-interaction.component' + +@NgModule({ + imports: [ + CommonModule, + + SharedSearchModule, + + RemoteInteractionRoutingModule + ], + + declarations: [ + RemoteInteractionComponent + ], + + exports: [ + RemoteInteractionComponent + ], + + providers: [] +}) +export class RemoteInteractionModule { } diff --git a/client/src/app/+videos/+video-watch/comment/video-comment-add.component.html b/client/src/app/+videos/+video-watch/comment/video-comment-add.component.html index ca9cd863b..fdefed09a 100644 --- a/client/src/app/+videos/+video-watch/comment/video-comment-add.component.html +++ b/client/src/app/+videos/+video-watch/comment/video-comment-add.component.html @@ -57,13 +57,9 @@