diff options
Diffstat (limited to 'client/src/app/videos')
3 files changed, 27 insertions, 8 deletions
diff --git a/client/src/app/videos/+video-edit/video-add-routing.module.ts b/client/src/app/videos/+video-edit/video-add-routing.module.ts index 9541a2bd1..e0fef7158 100644 --- a/client/src/app/videos/+video-edit/video-add-routing.module.ts +++ b/client/src/app/videos/+video-edit/video-add-routing.module.ts | |||
@@ -4,7 +4,7 @@ import { RouterModule, Routes } from '@angular/router' | |||
4 | import { MetaGuard } from '@ngx-meta/core' | 4 | import { MetaGuard } from '@ngx-meta/core' |
5 | 5 | ||
6 | import { LoginGuard } from '../../core' | 6 | import { LoginGuard } from '../../core' |
7 | import { CanDeactivateGuard } from '../../shared/can-deactivate-guard.service' | 7 | import { CanDeactivateGuard } from '../../shared/guards/can-deactivate-guard.service' |
8 | import { VideoAddComponent } from './video-add.component' | 8 | import { VideoAddComponent } from './video-add.component' |
9 | 9 | ||
10 | const videoAddRoutes: Routes = [ | 10 | const videoAddRoutes: Routes = [ |
@@ -12,7 +12,7 @@ const videoAddRoutes: Routes = [ | |||
12 | path: '', | 12 | path: '', |
13 | component: VideoAddComponent, | 13 | component: VideoAddComponent, |
14 | canActivate: [ MetaGuard, LoginGuard ], | 14 | canActivate: [ MetaGuard, LoginGuard ], |
15 | canDeactivate: [CanDeactivateGuard] | 15 | canDeactivate: [ CanDeactivateGuard ] |
16 | } | 16 | } |
17 | ] | 17 | ] |
18 | 18 | ||
diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts index 58eccef48..c6f0525c3 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts | |||
@@ -1,10 +1,12 @@ | |||
1 | import { HttpEventType, HttpResponse } from '@angular/common/http' | 1 | import { HttpEventType, HttpResponse } from '@angular/common/http' |
2 | import { Component, OnInit, ViewChild } from '@angular/core' | 2 | import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' |
3 | import { FormBuilder, FormGroup } from '@angular/forms' | 3 | import { FormBuilder, FormGroup } from '@angular/forms' |
4 | import { Router } from '@angular/router' | 4 | import { Router } from '@angular/router' |
5 | import { UserService } from '@app/shared' | 5 | import { UserService } from '@app/shared' |
6 | import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service' | ||
6 | import { NotificationsService } from 'angular2-notifications' | 7 | import { NotificationsService } from 'angular2-notifications' |
7 | import { BytesPipe } from 'ngx-pipes' | 8 | import { BytesPipe } from 'ngx-pipes' |
9 | import { Subscription } from 'rxjs/Subscription' | ||
8 | import { VideoPrivacy } from '../../../../../shared/models/videos' | 10 | import { VideoPrivacy } from '../../../../../shared/models/videos' |
9 | import { AuthService, ServerService } from '../../core' | 11 | import { AuthService, ServerService } from '../../core' |
10 | import { FormReactive } from '../../shared' | 12 | import { FormReactive } from '../../shared' |
@@ -12,7 +14,6 @@ import { ValidatorMessage } from '../../shared/forms/form-validators/validator-m | |||
12 | import { populateAsyncUserVideoChannels } from '../../shared/misc/utils' | 14 | import { populateAsyncUserVideoChannels } from '../../shared/misc/utils' |
13 | import { VideoEdit } from '../../shared/video/video-edit.model' | 15 | import { VideoEdit } from '../../shared/video/video-edit.model' |
14 | import { VideoService } from '../../shared/video/video.service' | 16 | import { VideoService } from '../../shared/video/video.service' |
15 | import { CanComponentDeactivate } from '@app/shared/can-deactivate-guard.service' | ||
16 | 17 | ||
17 | @Component({ | 18 | @Component({ |
18 | selector: 'my-videos-add', | 19 | selector: 'my-videos-add', |
@@ -23,12 +24,12 @@ import { CanComponentDeactivate } from '@app/shared/can-deactivate-guard.service | |||
23 | ] | 24 | ] |
24 | }) | 25 | }) |
25 | 26 | ||
26 | export class VideoAddComponent extends FormReactive implements OnInit, CanComponentDeactivate { | 27 | export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy, CanComponentDeactivate { |
27 | @ViewChild('videofileInput') videofileInput | 28 | @ViewChild('videofileInput') videofileInput |
28 | 29 | ||
29 | isUploadingVideo = false | 30 | isUploadingVideo = false |
30 | videoUploaded = false | 31 | videoUploaded = false |
31 | videoUploadObservable = null | 32 | videoUploadObservable: Subscription = null |
32 | videoUploadPercents = 0 | 33 | videoUploadPercents = 0 |
33 | videoUploadedIds = { | 34 | videoUploadedIds = { |
34 | id: 0, | 35 | id: 0, |
@@ -85,8 +86,26 @@ export class VideoAddComponent extends FormReactive implements OnInit, CanCompon | |||
85 | }) | 86 | }) |
86 | } | 87 | } |
87 | 88 | ||
89 | ngOnDestroy () { | ||
90 | if (this.videoUploadObservable) { | ||
91 | this.videoUploadObservable.unsubscribe() | ||
92 | } | ||
93 | } | ||
94 | |||
88 | canDeactivate () { | 95 | canDeactivate () { |
89 | return !this.isUploadingVideo | 96 | let text = '' |
97 | |||
98 | if (this.videoUploaded === true) { | ||
99 | text = 'Your video was uploaded in your account and is private.' + | ||
100 | ' But associated data (tags, description...) will be lost, are you sure you want to leave this page?' | ||
101 | } else { | ||
102 | text = 'Your video is not uploaded yet, are you sure you want to leave this page?' | ||
103 | } | ||
104 | |||
105 | return { | ||
106 | canDeactivate: !this.isUploadingVideo, | ||
107 | text | ||
108 | } | ||
90 | } | 109 | } |
91 | 110 | ||
92 | fileChange () { | 111 | fileChange () { |
diff --git a/client/src/app/videos/+video-edit/video-add.module.ts b/client/src/app/videos/+video-edit/video-add.module.ts index af9696a03..1bfedf251 100644 --- a/client/src/app/videos/+video-edit/video-add.module.ts +++ b/client/src/app/videos/+video-edit/video-add.module.ts | |||
@@ -4,7 +4,7 @@ import { SharedModule } from '../../shared' | |||
4 | import { VideoEditModule } from './shared/video-edit.module' | 4 | import { VideoEditModule } from './shared/video-edit.module' |
5 | import { VideoAddRoutingModule } from './video-add-routing.module' | 5 | import { VideoAddRoutingModule } from './video-add-routing.module' |
6 | import { VideoAddComponent } from './video-add.component' | 6 | import { VideoAddComponent } from './video-add.component' |
7 | import { CanDeactivateGuard } from '../../shared/can-deactivate-guard.service' | 7 | import { CanDeactivateGuard } from '../../shared/guards/can-deactivate-guard.service' |
8 | 8 | ||
9 | @NgModule({ | 9 | @NgModule({ |
10 | imports: [ | 10 | imports: [ |