diff options
Diffstat (limited to 'client/src/app/videos')
-rw-r--r-- | client/src/app/videos/shared/video.service.ts | 10 | ||||
-rw-r--r-- | client/src/app/videos/video-add/video-add.component.ts | 18 |
2 files changed, 21 insertions, 7 deletions
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts index dcbef7717..b4396f767 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts | |||
@@ -5,7 +5,7 @@ import { Observable } from 'rxjs/Observable'; | |||
5 | import { Pagination } from './pagination.model'; | 5 | import { Pagination } from './pagination.model'; |
6 | import { Search } from '../../shared'; | 6 | import { Search } from '../../shared'; |
7 | import { SortField } from './sort-field.type'; | 7 | import { SortField } from './sort-field.type'; |
8 | import { AuthService } from '../../shared'; | 8 | import { AuthHttp, AuthService } from '../../shared'; |
9 | import { Video } from './video.model'; | 9 | import { Video } from './video.model'; |
10 | 10 | ||
11 | @Injectable() | 11 | @Injectable() |
@@ -14,6 +14,7 @@ export class VideoService { | |||
14 | 14 | ||
15 | constructor( | 15 | constructor( |
16 | private authService: AuthService, | 16 | private authService: AuthService, |
17 | private authHttp: AuthHttp, | ||
17 | private http: Http | 18 | private http: Http |
18 | ) {} | 19 | ) {} |
19 | 20 | ||
@@ -35,10 +36,9 @@ export class VideoService { | |||
35 | } | 36 | } |
36 | 37 | ||
37 | removeVideo(id: string) { | 38 | removeVideo(id: string) { |
38 | const options = this.authService.getAuthRequestOptions(); | 39 | return this.authHttp.delete(VideoService.BASE_VIDEO_URL + id) |
39 | return this.http.delete(VideoService.BASE_VIDEO_URL + id, options) | 40 | .map(res => <number> res.status) |
40 | .map(res => <number> res.status) | 41 | .catch(this.handleError); |
41 | .catch(this.handleError); | ||
42 | } | 42 | } |
43 | 43 | ||
44 | searchVideos(search: Search, pagination: Pagination, sort: SortField) { | 44 | searchVideos(search: Search, pagination: Pagination, sort: SortField) { |
diff --git a/client/src/app/videos/video-add/video-add.component.ts b/client/src/app/videos/video-add/video-add.component.ts index 342935e36..c0f8cb9c4 100644 --- a/client/src/app/videos/video-add/video-add.component.ts +++ b/client/src/app/videos/video-add/video-add.component.ts | |||
@@ -130,8 +130,22 @@ export class VideoAddComponent implements OnInit { | |||
130 | }; | 130 | }; |
131 | 131 | ||
132 | item.onError = (response: string, status: number) => { | 132 | item.onError = (response: string, status: number) => { |
133 | this.error = (status === 400) ? response : 'Unknow error'; | 133 | // We need to handle manually these cases beceause we use the FileUpload component |
134 | console.error(this.error); | 134 | if (status === 400) { |
135 | this.error = response; | ||
136 | } else if (status === 401) { | ||
137 | this.error = 'Access token was expired, refreshing token...'; | ||
138 | this.authService.refreshAccessToken().subscribe( | ||
139 | () => { | ||
140 | // Update the uploader request header | ||
141 | this.uploader.authToken = this.authService.getRequestHeaderValue(); | ||
142 | this.error += ' access token refreshed. Please retry your request.'; | ||
143 | } | ||
144 | ); | ||
145 | } else { | ||
146 | this.error = 'Unknow error'; | ||
147 | console.error(this.error); | ||
148 | } | ||
135 | }; | 149 | }; |
136 | 150 | ||
137 | 151 | ||