diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-17 11:28:11 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-17 11:28:11 +0200 |
commit | 154898b0b7bc1af41fc5a94974e338a3590c90f3 (patch) | |
tree | 5fb90f66da7587aed53c99ac1884c7acd0c1f7ca /client/src/app/videos | |
parent | df98563e2104b82b119c00a3cd83cd0dc1242d25 (diff) | |
download | PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.tar.gz PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.tar.zst PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.zip |
Share models between server and client
Diffstat (limited to 'client/src/app/videos')
-rw-r--r-- | client/src/app/videos/shared/rate-type.type.ts | 1 | ||||
-rw-r--r-- | client/src/app/videos/shared/video.service.ts | 6 | ||||
-rw-r--r-- | client/src/app/videos/video-watch/video-watch.component.ts | 10 |
3 files changed, 8 insertions, 9 deletions
diff --git a/client/src/app/videos/shared/rate-type.type.ts b/client/src/app/videos/shared/rate-type.type.ts deleted file mode 100644 index 20eea3ae5..000000000 --- a/client/src/app/videos/shared/rate-type.type.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export type RateType = 'like' | 'dislike' | ||
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts index a4e3d16df..977b82118 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts | |||
@@ -6,7 +6,6 @@ import 'rxjs/add/operator/map' | |||
6 | 6 | ||
7 | import { Search } from '../../shared' | 7 | import { Search } from '../../shared' |
8 | import { SortField } from './sort-field.type' | 8 | import { SortField } from './sort-field.type' |
9 | import { RateType } from './rate-type.type' | ||
10 | import { AuthService } from '../../core' | 9 | import { AuthService } from '../../core' |
11 | import { | 10 | import { |
12 | AuthHttp, | 11 | AuthHttp, |
@@ -17,6 +16,7 @@ import { | |||
17 | UserService | 16 | UserService |
18 | } from '../../shared' | 17 | } from '../../shared' |
19 | import { Video } from './video.model' | 18 | import { Video } from './video.model' |
19 | import { VideoRateType } from '../../../../../shared' | ||
20 | 20 | ||
21 | @Injectable() | 21 | @Injectable() |
22 | export class VideoService { | 22 | export class VideoService { |
@@ -145,7 +145,7 @@ export class VideoService { | |||
145 | return this.setVideoRate(id, 'dislike') | 145 | return this.setVideoRate(id, 'dislike') |
146 | } | 146 | } |
147 | 147 | ||
148 | getUserVideoRating (id: string) { | 148 | getUserVideoRating (id: string): Observable<VideoRateType> { |
149 | const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating' | 149 | const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating' |
150 | 150 | ||
151 | return this.authHttp.get(url) | 151 | return this.authHttp.get(url) |
@@ -159,7 +159,7 @@ export class VideoService { | |||
159 | .catch((res) => this.restExtractor.handleError(res)) | 159 | .catch((res) => this.restExtractor.handleError(res)) |
160 | } | 160 | } |
161 | 161 | ||
162 | private setVideoRate (id: string, rateType: RateType) { | 162 | private setVideoRate (id: string, rateType: VideoRateType) { |
163 | const url = VideoService.BASE_VIDEO_URL + id + '/rate' | 163 | const url = VideoService.BASE_VIDEO_URL + id + '/rate' |
164 | const body = { | 164 | const body = { |
165 | rating: rateType | 165 | rating: rateType |
diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts index 4a547f7e4..808e0eda9 100644 --- a/client/src/app/videos/video-watch/video-watch.component.ts +++ b/client/src/app/videos/video-watch/video-watch.component.ts | |||
@@ -11,15 +11,15 @@ import { AuthService, ConfirmService } from '../../core' | |||
11 | import { VideoMagnetComponent } from './video-magnet.component' | 11 | import { VideoMagnetComponent } from './video-magnet.component' |
12 | import { VideoShareComponent } from './video-share.component' | 12 | import { VideoShareComponent } from './video-share.component' |
13 | import { VideoReportComponent } from './video-report.component' | 13 | import { VideoReportComponent } from './video-report.component' |
14 | import { RateType, Video, VideoService } from '../shared' | 14 | import { Video, VideoService } from '../shared' |
15 | import { WebTorrentService } from './webtorrent.service' | 15 | import { WebTorrentService } from './webtorrent.service' |
16 | import { UserVideoRateType, VideoRateType, UserVideoRate } from '../../../../../shared' | ||
16 | 17 | ||
17 | @Component({ | 18 | @Component({ |
18 | selector: 'my-video-watch', | 19 | selector: 'my-video-watch', |
19 | templateUrl: './video-watch.component.html', | 20 | templateUrl: './video-watch.component.html', |
20 | styleUrls: [ './video-watch.component.scss' ] | 21 | styleUrls: [ './video-watch.component.scss' ] |
21 | }) | 22 | }) |
22 | |||
23 | export class VideoWatchComponent implements OnInit, OnDestroy { | 23 | export class VideoWatchComponent implements OnInit, OnDestroy { |
24 | private static LOADTIME_TOO_LONG = 20000 | 24 | private static LOADTIME_TOO_LONG = 20000 |
25 | 25 | ||
@@ -34,7 +34,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
34 | player: videojs.Player | 34 | player: videojs.Player |
35 | playerElement: Element | 35 | playerElement: Element |
36 | uploadSpeed: number | 36 | uploadSpeed: number |
37 | userRating: RateType = null | 37 | userRating: UserVideoRateType = null |
38 | video: Video = null | 38 | video: Video = null |
39 | videoNotFound = false | 39 | videoNotFound = false |
40 | 40 | ||
@@ -249,7 +249,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
249 | 249 | ||
250 | this.videoService.getUserVideoRating(this.video.id) | 250 | this.videoService.getUserVideoRating(this.video.id) |
251 | .subscribe( | 251 | .subscribe( |
252 | ratingObject => { | 252 | (ratingObject: UserVideoRate) => { |
253 | if (ratingObject) { | 253 | if (ratingObject) { |
254 | this.userRating = ratingObject.rating | 254 | this.userRating = ratingObject.rating |
255 | } | 255 | } |
@@ -282,7 +282,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
282 | ) | 282 | ) |
283 | } | 283 | } |
284 | 284 | ||
285 | private updateVideoRating (oldRating: RateType, newRating: RateType) { | 285 | private updateVideoRating (oldRating: UserVideoRateType, newRating: VideoRateType) { |
286 | let likesToIncrement = 0 | 286 | let likesToIncrement = 0 |
287 | let dislikesToIncrement = 0 | 287 | let dislikesToIncrement = 0 |
288 | 288 | ||