diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-25 15:43:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-25 15:43:19 +0200 |
commit | d3e91a5f72ac9c986cdb67d7d6c85bb4819e680c (patch) | |
tree | 3c2406346c7774587ba4e095ab595e5953e25c61 /client/src/app/shared/video-channel | |
parent | 03e12d7c4954e1071fdeb7ef362ea5c3965d4075 (diff) | |
download | PeerTube-d3e91a5f72ac9c986cdb67d7d6c85bb4819e680c.tar.gz PeerTube-d3e91a5f72ac9c986cdb67d7d6c85bb4819e680c.tar.zst PeerTube-d3e91a5f72ac9c986cdb67d7d6c85bb4819e680c.zip |
Add video channel account list
Diffstat (limited to 'client/src/app/shared/video-channel')
-rw-r--r-- | client/src/app/shared/video-channel/video-channel.model.ts | 23 | ||||
-rw-r--r-- | client/src/app/shared/video-channel/video-channel.service.ts | 36 |
2 files changed, 59 insertions, 0 deletions
diff --git a/client/src/app/shared/video-channel/video-channel.model.ts b/client/src/app/shared/video-channel/video-channel.model.ts new file mode 100644 index 000000000..01381ac30 --- /dev/null +++ b/client/src/app/shared/video-channel/video-channel.model.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | import { VideoChannel as ServerVideoChannel } from '../../../../../shared/models/videos/video-channel.model' | ||
2 | import { Actor } from '../actor/actor.model' | ||
3 | |||
4 | export class VideoChannel extends Actor implements ServerVideoChannel { | ||
5 | displayName: string | ||
6 | description: string | ||
7 | support: string | ||
8 | isLocal: boolean | ||
9 | ownerAccount?: { | ||
10 | id: number | ||
11 | uuid: string | ||
12 | } | ||
13 | |||
14 | constructor (hash: ServerVideoChannel) { | ||
15 | super(hash) | ||
16 | |||
17 | this.displayName = hash.displayName | ||
18 | this.description = hash.description | ||
19 | this.support = hash.support | ||
20 | this.isLocal = hash.isLocal | ||
21 | this.ownerAccount = hash.ownerAccount | ||
22 | } | ||
23 | } | ||
diff --git a/client/src/app/shared/video-channel/video-channel.service.ts b/client/src/app/shared/video-channel/video-channel.service.ts new file mode 100644 index 000000000..1f9088c38 --- /dev/null +++ b/client/src/app/shared/video-channel/video-channel.service.ts | |||
@@ -0,0 +1,36 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import 'rxjs/add/operator/catch' | ||
3 | import 'rxjs/add/operator/map' | ||
4 | import { Observable } from 'rxjs/Observable' | ||
5 | import { RestExtractor } from '../rest/rest-extractor.service' | ||
6 | import { RestService } from '../rest/rest.service' | ||
7 | import { HttpClient } from '@angular/common/http' | ||
8 | import { VideoChannel as VideoChannelServer } from '../../../../../shared/models/videos' | ||
9 | import { AccountService } from '../account/account.service' | ||
10 | import { ResultList } from '../../../../../shared' | ||
11 | import { VideoChannel } from './video-channel.model' | ||
12 | |||
13 | @Injectable() | ||
14 | export class VideoChannelService { | ||
15 | constructor ( | ||
16 | private authHttp: HttpClient, | ||
17 | private restExtractor: RestExtractor, | ||
18 | private restService: RestService | ||
19 | ) {} | ||
20 | |||
21 | getVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> { | ||
22 | return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels') | ||
23 | .map(res => this.extractVideoChannels(res)) | ||
24 | .catch((res) => this.restExtractor.handleError(res)) | ||
25 | } | ||
26 | |||
27 | private extractVideoChannels (result: ResultList<VideoChannelServer>) { | ||
28 | const videoChannels: VideoChannel[] = [] | ||
29 | |||
30 | for (const videoChannelJSON of result.data) { | ||
31 | videoChannels.push(new VideoChannel(videoChannelJSON)) | ||
32 | } | ||
33 | |||
34 | return { data: videoChannels, total: result.total } | ||
35 | } | ||
36 | } | ||