diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-30 14:58:00 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-31 09:19:58 +0200 |
commit | 2d3741d6d92e9bd1f41694c7442a6d1da434e1f2 (patch) | |
tree | 93a1e609e14bc14ca9e77a6661ddc9c0e461d6f3 /client/src/app/shared | |
parent | d9eaee3939bf2e93e5d775d32bce77842201faba (diff) | |
download | PeerTube-2d3741d6d92e9bd1f41694c7442a6d1da434e1f2.tar.gz PeerTube-2d3741d6d92e9bd1f41694c7442a6d1da434e1f2.tar.zst PeerTube-2d3741d6d92e9bd1f41694c7442a6d1da434e1f2.zip |
Videos overview page: first version
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/overview/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/shared/overview/overview.service.ts | 76 | ||||
-rw-r--r-- | client/src/app/shared/overview/videos-overview.model.ts | 19 | ||||
-rw-r--r-- | client/src/app/shared/shared.module.ts | 2 | ||||
-rw-r--r-- | client/src/app/shared/video/abstract-video-list.html | 8 | ||||
-rw-r--r-- | client/src/app/shared/video/video.service.ts | 8 |
6 files changed, 100 insertions, 14 deletions
diff --git a/client/src/app/shared/overview/index.ts b/client/src/app/shared/overview/index.ts new file mode 100644 index 000000000..2f7e41298 --- /dev/null +++ b/client/src/app/shared/overview/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './overview.service' | |||
diff --git a/client/src/app/shared/overview/overview.service.ts b/client/src/app/shared/overview/overview.service.ts new file mode 100644 index 000000000..4a4714af6 --- /dev/null +++ b/client/src/app/shared/overview/overview.service.ts | |||
@@ -0,0 +1,76 @@ | |||
1 | import { catchError, map, switchMap, tap } from 'rxjs/operators' | ||
2 | import { HttpClient } from '@angular/common/http' | ||
3 | import { Injectable } from '@angular/core' | ||
4 | import { forkJoin, Observable, of } from 'rxjs' | ||
5 | import { VideosOverview as VideosOverviewServer, peertubeTranslate } from '../../../../../shared/models' | ||
6 | import { environment } from '../../../environments/environment' | ||
7 | import { RestExtractor } from '../rest/rest-extractor.service' | ||
8 | import { RestService } from '../rest/rest.service' | ||
9 | import { VideosOverview } from '@app/shared/overview/videos-overview.model' | ||
10 | import { VideoService } from '@app/shared/video/video.service' | ||
11 | import { ServerService } from '@app/core' | ||
12 | import { immutableAssign } from '@app/shared/misc/utils' | ||
13 | |||
14 | @Injectable() | ||
15 | export class OverviewService { | ||
16 | static BASE_OVERVIEW_URL = environment.apiUrl + '/api/v1/overviews/' | ||
17 | |||
18 | constructor ( | ||
19 | private authHttp: HttpClient, | ||
20 | private restExtractor: RestExtractor, | ||
21 | private restService: RestService, | ||
22 | private videosService: VideoService, | ||
23 | private serverService: ServerService | ||
24 | ) {} | ||
25 | |||
26 | getVideosOverview (): Observable<VideosOverview> { | ||
27 | return this.authHttp | ||
28 | .get<VideosOverviewServer>(OverviewService.BASE_OVERVIEW_URL + 'videos') | ||
29 | .pipe( | ||
30 | switchMap(serverVideosOverview => this.updateVideosOverview(serverVideosOverview)), | ||
31 | catchError(err => this.restExtractor.handleError(err)) | ||
32 | ) | ||
33 | } | ||
34 | |||
35 | private updateVideosOverview (serverVideosOverview: VideosOverviewServer): Observable<VideosOverview> { | ||
36 | const observables: Observable<any>[] = [] | ||
37 | const videosOverviewResult: VideosOverview = { | ||
38 | tags: [], | ||
39 | categories: [], | ||
40 | channels: [] | ||
41 | } | ||
42 | |||
43 | // Build videos objects | ||
44 | for (const key of Object.keys(serverVideosOverview)) { | ||
45 | for (const object of serverVideosOverview[ key ]) { | ||
46 | observables.push( | ||
47 | of(object.videos) | ||
48 | .pipe( | ||
49 | switchMap(videos => this.videosService.extractVideos({ total: 0, data: videos })), | ||
50 | map(result => result.videos), | ||
51 | tap(videos => { | ||
52 | videosOverviewResult[key].push(immutableAssign(object, { videos })) | ||
53 | }) | ||
54 | ) | ||
55 | ) | ||
56 | } | ||
57 | } | ||
58 | |||
59 | return forkJoin(observables) | ||
60 | .pipe( | ||
61 | // Translate categories | ||
62 | switchMap(() => { | ||
63 | return this.serverService.localeObservable | ||
64 | .pipe( | ||
65 | tap(translations => { | ||
66 | for (const c of videosOverviewResult.categories) { | ||
67 | c.category.label = peertubeTranslate(c.category.label, translations) | ||
68 | } | ||
69 | }) | ||
70 | ) | ||
71 | }), | ||
72 | map(() => videosOverviewResult) | ||
73 | ) | ||
74 | } | ||
75 | |||
76 | } | ||
diff --git a/client/src/app/shared/overview/videos-overview.model.ts b/client/src/app/shared/overview/videos-overview.model.ts new file mode 100644 index 000000000..cf02bdb3d --- /dev/null +++ b/client/src/app/shared/overview/videos-overview.model.ts | |||
@@ -0,0 +1,19 @@ | |||
1 | import { VideoChannelAttribute, VideoConstant, VideosOverview as VideosOverviewServer } from '../../../../../shared/models' | ||
2 | import { Video } from '@app/shared/video/video.model' | ||
3 | |||
4 | export class VideosOverview implements VideosOverviewServer { | ||
5 | channels: { | ||
6 | channel: VideoChannelAttribute | ||
7 | videos: Video[] | ||
8 | }[] | ||
9 | |||
10 | categories: { | ||
11 | category: VideoConstant<number> | ||
12 | videos: Video[] | ||
13 | }[] | ||
14 | |||
15 | tags: { | ||
16 | tag: string | ||
17 | videos: Video[] | ||
18 | }[] | ||
19 | } | ||
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 2cbaaf4ae..b96a9aa41 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts | |||
@@ -52,6 +52,7 @@ import { ActionDropdownComponent } from '@app/shared/buttons/action-dropdown.com | |||
52 | import { NgbDropdownModule, NgbModalModule, NgbPopoverModule, NgbTabsetModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap' | 52 | import { NgbDropdownModule, NgbModalModule, NgbPopoverModule, NgbTabsetModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap' |
53 | import { SubscribeButtonComponent, UserSubscriptionService } from '@app/shared/user-subscription' | 53 | import { SubscribeButtonComponent, UserSubscriptionService } from '@app/shared/user-subscription' |
54 | import { InstanceFeaturesTableComponent } from '@app/shared/instance/instance-features-table.component' | 54 | import { InstanceFeaturesTableComponent } from '@app/shared/instance/instance-features-table.component' |
55 | import { OverviewService } from '@app/shared/overview' | ||
55 | 56 | ||
56 | @NgModule({ | 57 | @NgModule({ |
57 | imports: [ | 58 | imports: [ |
@@ -154,6 +155,7 @@ import { InstanceFeaturesTableComponent } from '@app/shared/instance/instance-fe | |||
154 | VideoValidatorsService, | 155 | VideoValidatorsService, |
155 | VideoCaptionsValidatorsService, | 156 | VideoCaptionsValidatorsService, |
156 | VideoBlacklistValidatorsService, | 157 | VideoBlacklistValidatorsService, |
158 | OverviewService, | ||
157 | 159 | ||
158 | I18nPrimengCalendarService, | 160 | I18nPrimengCalendarService, |
159 | ScreenService, | 161 | ScreenService, |
diff --git a/client/src/app/shared/video/abstract-video-list.html b/client/src/app/shared/video/abstract-video-list.html index d4b00c07c..0f48b9a64 100644 --- a/client/src/app/shared/video/abstract-video-list.html +++ b/client/src/app/shared/video/abstract-video-list.html | |||
@@ -4,7 +4,7 @@ | |||
4 | </div> | 4 | </div> |
5 | <my-video-feed [syndicationItems]="syndicationItems"></my-video-feed> | 5 | <my-video-feed [syndicationItems]="syndicationItems"></my-video-feed> |
6 | 6 | ||
7 | <div i18n *ngIf="pagination.totalItems === 0">No results.</div> | 7 | <div class="no-results" i18n *ngIf="pagination.totalItems === 0">No results.</div> |
8 | <div | 8 | <div |
9 | myInfiniteScroller | 9 | myInfiniteScroller |
10 | [pageHeight]="pageHeight" | 10 | [pageHeight]="pageHeight" |
@@ -12,11 +12,7 @@ | |||
12 | class="videos" #videosElement | 12 | class="videos" #videosElement |
13 | > | 13 | > |
14 | <div *ngFor="let videos of videoPages" class="videos-page"> | 14 | <div *ngFor="let videos of videoPages" class="videos-page"> |
15 | <my-video-miniature | 15 | <my-video-miniature *ngFor="let video of videos" [video]="video" [user]="user" [ownerDisplayType]="ownerDisplayType"></my-video-miniature> |
16 | class="ng-animate" | ||
17 | *ngFor="let video of videos" [video]="video" [user]="user" [ownerDisplayType]="ownerDisplayType" | ||
18 | > | ||
19 | </my-video-miniature> | ||
20 | </div> | 16 | </div> |
21 | </div> | 17 | </div> |
22 | </div> | 18 | </div> |
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index 558db9543..7cc98c77a 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts | |||
@@ -51,14 +51,6 @@ export class VideoService { | |||
51 | ) | 51 | ) |
52 | } | 52 | } |
53 | 53 | ||
54 | viewVideo (uuid: string): Observable<boolean> { | ||
55 | return this.authHttp.post(this.getVideoViewUrl(uuid), {}) | ||
56 | .pipe( | ||
57 | map(this.restExtractor.extractDataBool), | ||
58 | catchError(err => this.restExtractor.handleError(err)) | ||
59 | ) | ||
60 | } | ||
61 | |||
62 | updateVideo (video: VideoEdit) { | 54 | updateVideo (video: VideoEdit) { |
63 | const language = video.language || null | 55 | const language = video.language || null |
64 | const licence = video.licence || null | 56 | const licence = video.licence || null |