aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-25 16:56:13 +0200
committerChocobozzz <me@florianbigard.com>2018-04-25 16:56:13 +0200
commit170726f523ff48f89da45473fc53ca54784f43dd (patch)
treef9f783ebdfc934c6831396c2bf33f658d6640583 /client/src/app/shared
parentcc918ac3f45e32f031cce7b6e0473e5c2c34b8ae (diff)
downloadPeerTube-170726f523ff48f89da45473fc53ca54784f43dd.tar.gz
PeerTube-170726f523ff48f89da45473fc53ca54784f43dd.tar.zst
PeerTube-170726f523ff48f89da45473fc53ca54784f43dd.zip
Implement video channel views
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/video-channel/video-channel.service.ts15
-rw-r--r--client/src/app/shared/video/video-miniature.component.html4
-rw-r--r--client/src/app/shared/video/video.service.ts25
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
9import { AccountService } from '../account/account.service' 9import { AccountService } from '../account/account.service'
10import { ResultList } from '../../../../../shared' 10import { ResultList } from '../../../../../shared'
11import { VideoChannel } from './video-channel.model' 11import { VideoChannel } from './video-channel.model'
12import { ReplaySubject } from 'rxjs/ReplaySubject'
13import { environment } from '../../../environments/environment'
12 14
13@Injectable() 15@Injectable()
14export class VideoChannelService { 16export 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'
23import { objectToFormData } from '@app/shared/misc/utils' 23import { objectToFormData } from '@app/shared/misc/utils'
24import { Account } from '@app/shared/account/account.model' 24import { Account } from '@app/shared/account/account.model'
25import { AccountService } from '@app/shared/account/account.service' 25import { AccountService } from '@app/shared/account/account.service'
26import { VideoChannel } from '../../../../../shared/models/videos'
27import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
26 28
27@Injectable() 29@Injectable()
28export class VideoService { 30export 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,