diff options
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/video-channel/video-channel.service.ts | 15 | ||||
-rw-r--r-- | client/src/app/shared/video/video-miniature.component.html | 4 | ||||
-rw-r--r-- | client/src/app/shared/video/video.service.ts | 25 |
3 files changed, 41 insertions, 3 deletions
diff --git a/client/src/app/shared/video-channel/video-channel.service.ts b/client/src/app/shared/video-channel/video-channel.service.ts index 1f9088c38..d8efcc171 100644 --- a/client/src/app/shared/video-channel/video-channel.service.ts +++ b/client/src/app/shared/video-channel/video-channel.service.ts | |||
@@ -9,16 +9,29 @@ import { VideoChannel as VideoChannelServer } from '../../../../../shared/models | |||
9 | import { AccountService } from '../account/account.service' | 9 | import { AccountService } from '../account/account.service' |
10 | import { ResultList } from '../../../../../shared' | 10 | import { ResultList } from '../../../../../shared' |
11 | import { VideoChannel } from './video-channel.model' | 11 | import { VideoChannel } from './video-channel.model' |
12 | import { ReplaySubject } from 'rxjs/ReplaySubject' | ||
13 | import { environment } from '../../../environments/environment' | ||
12 | 14 | ||
13 | @Injectable() | 15 | @Injectable() |
14 | export class VideoChannelService { | 16 | export class VideoChannelService { |
17 | static BASE_VIDEO_CHANNEL_URL = environment.apiUrl + '/api/v1/video-channels/' | ||
18 | |||
19 | videoChannelLoaded = new ReplaySubject<VideoChannel>(1) | ||
20 | |||
15 | constructor ( | 21 | constructor ( |
16 | private authHttp: HttpClient, | 22 | private authHttp: HttpClient, |
17 | private restExtractor: RestExtractor, | 23 | private restExtractor: RestExtractor, |
18 | private restService: RestService | 24 | private restService: RestService |
19 | ) {} | 25 | ) {} |
20 | 26 | ||
21 | getVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> { | 27 | getVideoChannel (videoChannelUUID: string) { |
28 | return this.authHttp.get<VideoChannel>(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID) | ||
29 | .map(videoChannelHash => new VideoChannel(videoChannelHash)) | ||
30 | .do(videoChannel => this.videoChannelLoaded.next(videoChannel)) | ||
31 | .catch((res) => this.restExtractor.handleError(res)) | ||
32 | } | ||
33 | |||
34 | listAccountVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> { | ||
22 | return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels') | 35 | return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels') |
23 | .map(res => this.extractVideoChannels(res)) | 36 | .map(res => this.extractVideoChannels(res)) |
24 | .catch((res) => this.restExtractor.handleError(res)) | 37 | .catch((res) => this.restExtractor.handleError(res)) |
diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html index d0b305509..e26cb058a 100644 --- a/client/src/app/shared/video/video-miniature.component.html +++ b/client/src/app/shared/video/video-miniature.component.html | |||
@@ -5,13 +5,13 @@ | |||
5 | <span class="video-miniature-name"> | 5 | <span class="video-miniature-name"> |
6 | <a | 6 | <a |
7 | class="video-miniature-name" | 7 | class="video-miniature-name" |
8 | [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur() }" | 8 | [routerLink]="[ '/videos/watch', video.uuid ]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur() }" |
9 | > | 9 | > |
10 | {{ video.name }} | 10 | {{ video.name }} |
11 | </a> | 11 | </a> |
12 | </span> | 12 | </span> |
13 | 13 | ||
14 | <span class="video-miniature-created-at-views">{{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span> | 14 | <span class="video-miniature-created-at-views">{{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span> |
15 | <a class="video-miniature-account" [routerLink]="[ '/account', video.account.id ]">{{ video.by }}</a> | 15 | <a class="video-miniature-account" [routerLink]="[ '/accounts', video.account.id ]">{{ video.by }}</a> |
16 | </div> | 16 | </div> |
17 | </div> | 17 | </div> |
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index f82aa7389..8870cbee4 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts | |||
@@ -23,6 +23,8 @@ import { Video } from './video.model' | |||
23 | import { objectToFormData } from '@app/shared/misc/utils' | 23 | import { objectToFormData } from '@app/shared/misc/utils' |
24 | import { Account } from '@app/shared/account/account.model' | 24 | import { Account } from '@app/shared/account/account.model' |
25 | import { AccountService } from '@app/shared/account/account.service' | 25 | import { AccountService } from '@app/shared/account/account.service' |
26 | import { VideoChannel } from '../../../../../shared/models/videos' | ||
27 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | ||
26 | 28 | ||
27 | @Injectable() | 29 | @Injectable() |
28 | export class VideoService { | 30 | export class VideoService { |
@@ -115,6 +117,22 @@ export class VideoService { | |||
115 | .catch((res) => this.restExtractor.handleError(res)) | 117 | .catch((res) => this.restExtractor.handleError(res)) |
116 | } | 118 | } |
117 | 119 | ||
120 | getVideoChannelVideos ( | ||
121 | videoChannel: VideoChannel, | ||
122 | videoPagination: ComponentPagination, | ||
123 | sort: VideoSortField | ||
124 | ): Observable<{ videos: Video[], totalVideos: number}> { | ||
125 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) | ||
126 | |||
127 | let params = new HttpParams() | ||
128 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
129 | |||
130 | return this.authHttp | ||
131 | .get(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid + '/videos', { params }) | ||
132 | .map(this.extractVideos) | ||
133 | .catch((res) => this.restExtractor.handleError(res)) | ||
134 | } | ||
135 | |||
118 | getVideos ( | 136 | getVideos ( |
119 | videoPagination: ComponentPagination, | 137 | videoPagination: ComponentPagination, |
120 | sort: VideoSortField, | 138 | sort: VideoSortField, |
@@ -175,6 +193,13 @@ export class VideoService { | |||
175 | return this.buildBaseFeedUrls(params) | 193 | return this.buildBaseFeedUrls(params) |
176 | } | 194 | } |
177 | 195 | ||
196 | getVideoChannelFeedUrls (videoChannelId: number) { | ||
197 | let params = this.restService.addRestGetParams(new HttpParams()) | ||
198 | params = params.set('videoChannelId', videoChannelId.toString()) | ||
199 | |||
200 | return this.buildBaseFeedUrls(params) | ||
201 | } | ||
202 | |||
178 | searchVideos ( | 203 | searchVideos ( |
179 | search: string, | 204 | search: string, |
180 | videoPagination: ComponentPagination, | 205 | videoPagination: ComponentPagination, |