diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-12-11 11:06:32 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-12-11 11:06:32 +0100 |
commit | fada8d75550dc7365f7e18ee1569b9406251d660 (patch) | |
tree | db9dc01c18693824f83fce5020f4c1f3ae7c0865 /client/src/app/videos/video-list | |
parent | 492fd28167f770d79a430fc57451b5a9e075d8e7 (diff) | |
parent | c2830fa8f84f61462098bf36add824f89436dfa9 (diff) | |
download | PeerTube-fada8d75550dc7365f7e18ee1569b9406251d660.tar.gz PeerTube-fada8d75550dc7365f7e18ee1569b9406251d660.tar.zst PeerTube-fada8d75550dc7365f7e18ee1569b9406251d660.zip |
Merge branch 'feature/design' into develop
Diffstat (limited to 'client/src/app/videos/video-list')
15 files changed, 118 insertions, 502 deletions
diff --git a/client/src/app/videos/video-list/index.ts b/client/src/app/videos/video-list/index.ts index ed2bb1657..5e7c7886c 100644 --- a/client/src/app/videos/video-list/index.ts +++ b/client/src/app/videos/video-list/index.ts | |||
@@ -1,3 +1,3 @@ | |||
1 | export * from './my-videos.component' | 1 | export * from './video-recently-added.component' |
2 | export * from './video-list.component' | 2 | export * from './video-trending.component' |
3 | export * from './shared' | 3 | export * from './video-search.component' |
diff --git a/client/src/app/videos/video-list/my-videos.component.ts b/client/src/app/videos/video-list/my-videos.component.ts deleted file mode 100644 index 648741a40..000000000 --- a/client/src/app/videos/video-list/my-videos.component.ts +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute, Router } from '@angular/router' | ||
3 | |||
4 | import { NotificationsService } from 'angular2-notifications' | ||
5 | |||
6 | import { AbstractVideoList } from './shared' | ||
7 | import { VideoService } from '../shared' | ||
8 | |||
9 | @Component({ | ||
10 | selector: 'my-videos', | ||
11 | styleUrls: [ './shared/abstract-video-list.scss' ], | ||
12 | templateUrl: './shared/abstract-video-list.html' | ||
13 | }) | ||
14 | export class MyVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { | ||
15 | |||
16 | constructor ( | ||
17 | protected router: Router, | ||
18 | protected route: ActivatedRoute, | ||
19 | protected notificationsService: NotificationsService, | ||
20 | private videoService: VideoService | ||
21 | ) { | ||
22 | super() | ||
23 | } | ||
24 | |||
25 | ngOnInit () { | ||
26 | super.ngOnInit() | ||
27 | } | ||
28 | |||
29 | ngOnDestroy () { | ||
30 | this.subActivatedRoute.unsubscribe() | ||
31 | } | ||
32 | |||
33 | getVideosObservable () { | ||
34 | return this.videoService.getMyVideos(this.pagination, this.sort) | ||
35 | } | ||
36 | } | ||
diff --git a/client/src/app/videos/video-list/shared/abstract-video-list.html b/client/src/app/videos/video-list/shared/abstract-video-list.html deleted file mode 100644 index 680fba3f5..000000000 --- a/client/src/app/videos/video-list/shared/abstract-video-list.html +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | <div class="row"> | ||
2 | <div class="content-padding"> | ||
3 | <div class="videos-info"> | ||
4 | <div class="col-md-9 col-xs-5 videos-total-results"> | ||
5 | <span *ngIf="pagination.totalItems !== null">{{ pagination.totalItems }} videos</span> | ||
6 | |||
7 | <my-loader [loading]="loading | async"></my-loader> | ||
8 | </div> | ||
9 | |||
10 | <my-video-sort class="col-md-3 col-xs-7" [currentSort]="sort" (sort)="onSort($event)"></my-video-sort> | ||
11 | </div> | ||
12 | </div> | ||
13 | </div> | ||
14 | |||
15 | <div class="content-padding videos-miniatures"> | ||
16 | <div class="no-video" *ngIf="isThereNoVideo()">There is no video.</div> | ||
17 | |||
18 | <my-video-miniature | ||
19 | class="ng-animate" | ||
20 | *ngFor="let video of videos" [video]="video" [user]="user" [currentSort]="sort" | ||
21 | > | ||
22 | </my-video-miniature> | ||
23 | </div> | ||
24 | |||
25 | <pagination *ngIf="pagination.totalItems !== null && pagination.totalItems !== 0" | ||
26 | [totalItems]="pagination.totalItems" [itemsPerPage]="pagination.itemsPerPage" [maxSize]="6" [boundaryLinks]="true" [rotate]="false" | ||
27 | [(ngModel)]="pagination.currentPage" (pageChanged)="onPageChanged($event)" | ||
28 | ></pagination> | ||
diff --git a/client/src/app/videos/video-list/shared/abstract-video-list.scss b/client/src/app/videos/video-list/shared/abstract-video-list.scss deleted file mode 100644 index 4b4409602..000000000 --- a/client/src/app/videos/video-list/shared/abstract-video-list.scss +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | .videos-info { | ||
2 | @media screen and (max-width: 400px) { | ||
3 | margin-left: 0; | ||
4 | } | ||
5 | |||
6 | border-bottom: 1px solid #f1f1f1; | ||
7 | height: 40px; | ||
8 | line-height: 40px; | ||
9 | |||
10 | .videos-total-results { | ||
11 | font-size: 13px; | ||
12 | } | ||
13 | |||
14 | my-loader { | ||
15 | display: inline-block; | ||
16 | margin-left: 5px; | ||
17 | } | ||
18 | } | ||
19 | |||
20 | .videos-miniatures { | ||
21 | text-align: center; | ||
22 | padding-top: 0; | ||
23 | |||
24 | my-video-miniature { | ||
25 | text-align: left; | ||
26 | } | ||
27 | |||
28 | .no-video { | ||
29 | margin-top: 50px; | ||
30 | text-align: center; | ||
31 | } | ||
32 | } | ||
33 | |||
34 | pagination { | ||
35 | display: block; | ||
36 | text-align: center; | ||
37 | } | ||
diff --git a/client/src/app/videos/video-list/shared/abstract-video-list.ts b/client/src/app/videos/video-list/shared/abstract-video-list.ts deleted file mode 100644 index 87d5bc48a..000000000 --- a/client/src/app/videos/video-list/shared/abstract-video-list.ts +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | import { OnDestroy, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute, Router } from '@angular/router' | ||
3 | import { Subscription } from 'rxjs/Subscription' | ||
4 | import { BehaviorSubject } from 'rxjs/BehaviorSubject' | ||
5 | import { Observable } from 'rxjs/Observable' | ||
6 | |||
7 | import { NotificationsService } from 'angular2-notifications' | ||
8 | |||
9 | import { | ||
10 | SortField, | ||
11 | Video, | ||
12 | VideoPagination | ||
13 | } from '../../shared' | ||
14 | |||
15 | export abstract class AbstractVideoList implements OnInit, OnDestroy { | ||
16 | loading: BehaviorSubject<boolean> = new BehaviorSubject(false) | ||
17 | pagination: VideoPagination = { | ||
18 | currentPage: 1, | ||
19 | itemsPerPage: 25, | ||
20 | totalItems: null | ||
21 | } | ||
22 | sort: SortField | ||
23 | videos: Video[] = [] | ||
24 | |||
25 | protected notificationsService: NotificationsService | ||
26 | protected router: Router | ||
27 | protected route: ActivatedRoute | ||
28 | |||
29 | protected subActivatedRoute: Subscription | ||
30 | |||
31 | abstract getVideosObservable (): Observable<{ videos: Video[], totalVideos: number}> | ||
32 | |||
33 | ngOnInit () { | ||
34 | // Subscribe to route changes | ||
35 | this.subActivatedRoute = this.route.params.subscribe(routeParams => { | ||
36 | this.loadRouteParams(routeParams) | ||
37 | |||
38 | this.getVideos() | ||
39 | }) | ||
40 | } | ||
41 | |||
42 | ngOnDestroy () { | ||
43 | this.subActivatedRoute.unsubscribe() | ||
44 | } | ||
45 | |||
46 | getVideos () { | ||
47 | this.loading.next(true) | ||
48 | this.videos = [] | ||
49 | |||
50 | const observable = this.getVideosObservable() | ||
51 | |||
52 | observable.subscribe( | ||
53 | ({ videos, totalVideos }) => { | ||
54 | this.videos = videos | ||
55 | this.pagination.totalItems = totalVideos | ||
56 | |||
57 | this.loading.next(false) | ||
58 | }, | ||
59 | error => this.notificationsService.error('Error', error.text) | ||
60 | ) | ||
61 | } | ||
62 | |||
63 | isThereNoVideo () { | ||
64 | return !this.loading.getValue() && this.videos.length === 0 | ||
65 | } | ||
66 | |||
67 | onPageChanged (event: { page: number }) { | ||
68 | // Be sure the current page is set | ||
69 | this.pagination.currentPage = event.page | ||
70 | |||
71 | this.navigateToNewParams() | ||
72 | } | ||
73 | |||
74 | onSort (sort: SortField) { | ||
75 | this.sort = sort | ||
76 | |||
77 | this.navigateToNewParams() | ||
78 | } | ||
79 | |||
80 | protected buildRouteParams () { | ||
81 | // There is always a sort and a current page | ||
82 | const params = { | ||
83 | sort: this.sort, | ||
84 | page: this.pagination.currentPage | ||
85 | } | ||
86 | |||
87 | return params | ||
88 | } | ||
89 | |||
90 | protected loadRouteParams (routeParams: { [ key: string ]: any }) { | ||
91 | this.sort = routeParams['sort'] as SortField || '-createdAt' | ||
92 | |||
93 | if (routeParams['page'] !== undefined) { | ||
94 | this.pagination.currentPage = parseInt(routeParams['page'], 10) | ||
95 | } else { | ||
96 | this.pagination.currentPage = 1 | ||
97 | } | ||
98 | } | ||
99 | |||
100 | protected navigateToNewParams () { | ||
101 | const routeParams = this.buildRouteParams() | ||
102 | this.router.navigate([ '/videos/list', routeParams ]) | ||
103 | } | ||
104 | } | ||
diff --git a/client/src/app/videos/video-list/shared/index.ts b/client/src/app/videos/video-list/shared/index.ts deleted file mode 100644 index d8f73bcda..000000000 --- a/client/src/app/videos/video-list/shared/index.ts +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | export * from './abstract-video-list' | ||
2 | export * from './video-miniature.component' | ||
3 | export * from './video-sort.component' | ||
diff --git a/client/src/app/videos/video-list/shared/video-miniature.component.html b/client/src/app/videos/video-list/shared/video-miniature.component.html deleted file mode 100644 index 6bbd29666..000000000 --- a/client/src/app/videos/video-list/shared/video-miniature.component.html +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | <div class="video-miniature"> | ||
2 | <a | ||
3 | [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.description" | ||
4 | class="video-miniature-thumbnail" | ||
5 | > | ||
6 | <img [attr.src]="video.thumbnailUrl" alt="video thumbnail" [ngClass]="{ 'blur-filter': isVideoNSFWForThisUser() }" /> | ||
7 | |||
8 | <div class="video-miniature-thumbnail-overlay"> | ||
9 | <span class="video-miniature-thumbnail-overlay-views">{{ video.views }} views</span> | ||
10 | <span class="video-miniature-thumbnail-overlay-duration">{{ video.durationLabel }}</span> | ||
11 | </div> | ||
12 | </a> | ||
13 | |||
14 | <div class="video-miniature-information"> | ||
15 | <span class="video-miniature-name"> | ||
16 | <a | ||
17 | class="video-miniature-name" | ||
18 | [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoNSFWForThisUser() }" | ||
19 | > | ||
20 | {{ video.name }} | ||
21 | </a> | ||
22 | </span> | ||
23 | |||
24 | <div class="video-miniature-tags"> | ||
25 | <span *ngFor="let tag of video.tags" class="video-miniature-tag"> | ||
26 | <a [routerLink]="['/videos/list', { field: 'tags', search: tag, sort: currentSort }]" class="label label-primary">{{ tag }}</a> | ||
27 | </span> | ||
28 | </div> | ||
29 | |||
30 | <a [routerLink]="['/videos/list', { field: 'account', search: video.account, sort: currentSort }]" class="video-miniature-account">{{ video.by }}</a> | ||
31 | <span class="video-miniature-created-at">{{ video.createdAt | date:'short' }}</span> | ||
32 | </div> | ||
33 | </div> | ||
diff --git a/client/src/app/videos/video-list/shared/video-miniature.component.scss b/client/src/app/videos/video-list/shared/video-miniature.component.scss deleted file mode 100644 index 507ace098..000000000 --- a/client/src/app/videos/video-list/shared/video-miniature.component.scss +++ /dev/null | |||
@@ -1,101 +0,0 @@ | |||
1 | .video-miniature { | ||
2 | margin: 15px 10px; | ||
3 | display: inline-block; | ||
4 | position: relative; | ||
5 | height: 190px; | ||
6 | vertical-align: top; | ||
7 | |||
8 | .video-miniature-thumbnail { | ||
9 | display: inline-block; | ||
10 | position: relative; | ||
11 | border-radius: 3px; | ||
12 | overflow: hidden; | ||
13 | |||
14 | &:hover { | ||
15 | text-decoration: none !important; | ||
16 | } | ||
17 | |||
18 | img.blur-filter { | ||
19 | filter: blur(5px); | ||
20 | transform : scale(1.03); | ||
21 | } | ||
22 | |||
23 | .video-miniature-thumbnail-overlay { | ||
24 | position: absolute; | ||
25 | right: 0px; | ||
26 | bottom: 0px; | ||
27 | display: inline-block; | ||
28 | background-color: rgba(0, 0, 0, 0.7); | ||
29 | color: #fff; | ||
30 | padding: 3px 5px; | ||
31 | font-size: 11px; | ||
32 | font-weight: bold; | ||
33 | width: 100%; | ||
34 | |||
35 | .video-miniature-thumbnail-overlay-views { | ||
36 | |||
37 | } | ||
38 | |||
39 | .video-miniature-thumbnail-overlay-duration { | ||
40 | float: right; | ||
41 | } | ||
42 | } | ||
43 | } | ||
44 | |||
45 | .video-miniature-information { | ||
46 | width: 200px; | ||
47 | |||
48 | .video-miniature-name { | ||
49 | height: 23px; | ||
50 | display: block; | ||
51 | overflow: hidden; | ||
52 | text-overflow: ellipsis; | ||
53 | white-space: nowrap; | ||
54 | font-weight: bold; | ||
55 | transition: color 0.2s; | ||
56 | font-size: 15px; | ||
57 | |||
58 | &:hover { | ||
59 | text-decoration: none; | ||
60 | } | ||
61 | |||
62 | &.blur-filter { | ||
63 | filter: blur(3px); | ||
64 | padding-left: 4px; | ||
65 | } | ||
66 | |||
67 | .video-miniature-tags { | ||
68 | // Fix for chrome when tags are long | ||
69 | width: 201px; | ||
70 | |||
71 | .video-miniature-tag { | ||
72 | font-size: 13px; | ||
73 | cursor: pointer; | ||
74 | position: relative; | ||
75 | top: -2px; | ||
76 | |||
77 | .label { | ||
78 | transition: background-color 0.2s; | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | |||
84 | .video-miniature-account, .video-miniature-created-at { | ||
85 | display: block; | ||
86 | margin-left: 1px; | ||
87 | font-size: 11px; | ||
88 | color: $video-miniature-other-infos; | ||
89 | opacity: 0.9; | ||
90 | } | ||
91 | |||
92 | .video-miniature-account { | ||
93 | transition: color 0.2s; | ||
94 | |||
95 | &:hover { | ||
96 | color: #23527c; | ||
97 | text-decoration: none; | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | } | ||
diff --git a/client/src/app/videos/video-list/shared/video-miniature.component.ts b/client/src/app/videos/video-list/shared/video-miniature.component.ts deleted file mode 100644 index e5a87907b..000000000 --- a/client/src/app/videos/video-list/shared/video-miniature.component.ts +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | import { Component, Input } from '@angular/core' | ||
2 | |||
3 | import { SortField, Video } from '../../shared' | ||
4 | import { User } from '../../../shared' | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-video-miniature', | ||
8 | styleUrls: [ './video-miniature.component.scss' ], | ||
9 | templateUrl: './video-miniature.component.html' | ||
10 | }) | ||
11 | export class VideoMiniatureComponent { | ||
12 | @Input() currentSort: SortField | ||
13 | @Input() user: User | ||
14 | @Input() video: Video | ||
15 | |||
16 | isVideoNSFWForThisUser () { | ||
17 | return this.video.isVideoNSFWForUser(this.user) | ||
18 | } | ||
19 | } | ||
diff --git a/client/src/app/videos/video-list/shared/video-sort.component.html b/client/src/app/videos/video-list/shared/video-sort.component.html deleted file mode 100644 index 3bece0b22..000000000 --- a/client/src/app/videos/video-list/shared/video-sort.component.html +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | <select class="form-control input-sm" [(ngModel)]="currentSort" (ngModelChange)="onSortChange()"> | ||
2 | <option *ngFor="let choice of choiceKeys" [value]="choice"> | ||
3 | {{ getStringChoice(choice) }} | ||
4 | </option> | ||
5 | </select> | ||
diff --git a/client/src/app/videos/video-list/shared/video-sort.component.ts b/client/src/app/videos/video-list/shared/video-sort.component.ts deleted file mode 100644 index 8aa89d32b..000000000 --- a/client/src/app/videos/video-list/shared/video-sort.component.ts +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | import { Component, EventEmitter, Input, Output } from '@angular/core' | ||
2 | |||
3 | import { SortField } from '../../shared' | ||
4 | |||
5 | @Component({ | ||
6 | selector: 'my-video-sort', | ||
7 | templateUrl: './video-sort.component.html' | ||
8 | }) | ||
9 | |||
10 | export class VideoSortComponent { | ||
11 | @Output() sort = new EventEmitter<any>() | ||
12 | |||
13 | @Input() currentSort: SortField | ||
14 | |||
15 | sortChoices: { [ P in SortField ]: string } = { | ||
16 | 'name': 'Name - Asc', | ||
17 | '-name': 'Name - Desc', | ||
18 | 'duration': 'Duration - Asc', | ||
19 | '-duration': 'Duration - Desc', | ||
20 | 'createdAt': 'Created Date - Asc', | ||
21 | '-createdAt': 'Created Date - Desc', | ||
22 | 'views': 'Views - Asc', | ||
23 | '-views': 'Views - Desc', | ||
24 | 'likes': 'Likes - Asc', | ||
25 | '-likes': 'Likes - Desc' | ||
26 | } | ||
27 | |||
28 | get choiceKeys () { | ||
29 | return Object.keys(this.sortChoices) | ||
30 | } | ||
31 | |||
32 | getStringChoice (choiceKey: SortField) { | ||
33 | return this.sortChoices[choiceKey] | ||
34 | } | ||
35 | |||
36 | onSortChange () { | ||
37 | this.sort.emit(this.currentSort) | ||
38 | } | ||
39 | } | ||
diff --git a/client/src/app/videos/video-list/video-list.component.ts b/client/src/app/videos/video-list/video-list.component.ts deleted file mode 100644 index 784162679..000000000 --- a/client/src/app/videos/video-list/video-list.component.ts +++ /dev/null | |||
@@ -1,94 +0,0 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute, Router } from '@angular/router' | ||
3 | import { Subscription } from 'rxjs/Subscription' | ||
4 | |||
5 | import { NotificationsService } from 'angular2-notifications' | ||
6 | |||
7 | import { VideoService } from '../shared' | ||
8 | import { Search, SearchField, SearchService } from '../../shared' | ||
9 | import { AbstractVideoList } from './shared' | ||
10 | |||
11 | @Component({ | ||
12 | selector: 'my-videos-list', | ||
13 | styleUrls: [ './shared/abstract-video-list.scss' ], | ||
14 | templateUrl: './shared/abstract-video-list.html' | ||
15 | }) | ||
16 | export class VideoListComponent extends AbstractVideoList implements OnInit, OnDestroy { | ||
17 | private search: Search | ||
18 | private subSearch: Subscription | ||
19 | |||
20 | constructor ( | ||
21 | protected router: Router, | ||
22 | protected route: ActivatedRoute, | ||
23 | protected notificationsService: NotificationsService, | ||
24 | private videoService: VideoService, | ||
25 | private searchService: SearchService | ||
26 | ) { | ||
27 | super() | ||
28 | } | ||
29 | |||
30 | ngOnInit () { | ||
31 | // Subscribe to route changes | ||
32 | this.subActivatedRoute = this.route.params.subscribe(routeParams => { | ||
33 | this.loadRouteParams(routeParams) | ||
34 | |||
35 | // Update the search service component | ||
36 | this.searchService.updateSearch.next(this.search) | ||
37 | this.getVideos() | ||
38 | }) | ||
39 | |||
40 | // Subscribe to search changes | ||
41 | this.subSearch = this.searchService.searchUpdated.subscribe(search => { | ||
42 | this.search = search | ||
43 | // Reset pagination | ||
44 | this.pagination.currentPage = 1 | ||
45 | |||
46 | this.navigateToNewParams() | ||
47 | }) | ||
48 | } | ||
49 | |||
50 | ngOnDestroy () { | ||
51 | super.ngOnDestroy() | ||
52 | |||
53 | this.subSearch.unsubscribe() | ||
54 | } | ||
55 | |||
56 | getVideosObservable () { | ||
57 | let observable = null | ||
58 | if (this.search.value) { | ||
59 | observable = this.videoService.searchVideos(this.search, this.pagination, this.sort) | ||
60 | } else { | ||
61 | observable = this.videoService.getVideos(this.pagination, this.sort) | ||
62 | } | ||
63 | |||
64 | return observable | ||
65 | } | ||
66 | |||
67 | protected buildRouteParams () { | ||
68 | const params = super.buildRouteParams() | ||
69 | |||
70 | // Maybe there is a search | ||
71 | if (this.search.value) { | ||
72 | params['field'] = this.search.field | ||
73 | params['search'] = this.search.value | ||
74 | } | ||
75 | |||
76 | return params | ||
77 | } | ||
78 | |||
79 | protected loadRouteParams (routeParams: { [ key: string ]: any }) { | ||
80 | super.loadRouteParams(routeParams) | ||
81 | |||
82 | if (routeParams['search'] !== undefined) { | ||
83 | this.search = { | ||
84 | value: routeParams['search'], | ||
85 | field: routeParams['field'] as SearchField | ||
86 | } | ||
87 | } else { | ||
88 | this.search = { | ||
89 | value: '', | ||
90 | field: 'name' | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | } | ||
diff --git a/client/src/app/videos/video-list/video-recently-added.component.ts b/client/src/app/videos/video-list/video-recently-added.component.ts new file mode 100644 index 000000000..6168fac95 --- /dev/null +++ b/client/src/app/videos/video-list/video-recently-added.component.ts | |||
@@ -0,0 +1,32 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute, Router } from '@angular/router' | ||
3 | import { NotificationsService } from 'angular2-notifications' | ||
4 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' | ||
5 | import { SortField } from '../../shared/video/sort-field.type' | ||
6 | import { VideoService } from '../../shared/video/video.service' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-videos-recently-added', | ||
10 | styleUrls: [ '../../shared/video/abstract-video-list.scss' ], | ||
11 | templateUrl: '../../shared/video/abstract-video-list.html' | ||
12 | }) | ||
13 | export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit { | ||
14 | titlePage = 'Recently added' | ||
15 | currentRoute = '/videos/recently-added' | ||
16 | sort: SortField = '-createdAt' | ||
17 | |||
18 | constructor (protected router: Router, | ||
19 | protected route: ActivatedRoute, | ||
20 | protected notificationsService: NotificationsService, | ||
21 | private videoService: VideoService) { | ||
22 | super() | ||
23 | } | ||
24 | |||
25 | ngOnInit () { | ||
26 | super.ngOnInit() | ||
27 | } | ||
28 | |||
29 | getVideosObservable () { | ||
30 | return this.videoService.getVideos(this.pagination, this.sort) | ||
31 | } | ||
32 | } | ||
diff --git a/client/src/app/videos/video-list/video-search.component.ts b/client/src/app/videos/video-list/video-search.component.ts new file mode 100644 index 000000000..ba851d27e --- /dev/null +++ b/client/src/app/videos/video-list/video-search.component.ts | |||
@@ -0,0 +1,51 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute, Router } from '@angular/router' | ||
3 | import { NotificationsService } from 'angular2-notifications' | ||
4 | import { AbstractVideoList } from 'app/shared/video/abstract-video-list' | ||
5 | import { Subscription } from 'rxjs/Subscription' | ||
6 | import { SortField } from '../../shared/video/sort-field.type' | ||
7 | import { VideoService } from '../../shared/video/video.service' | ||
8 | |||
9 | @Component({ | ||
10 | selector: 'my-videos-search', | ||
11 | styleUrls: [ '../../shared/video/abstract-video-list.scss' ], | ||
12 | templateUrl: '../../shared/video/abstract-video-list.html' | ||
13 | }) | ||
14 | export class VideoSearchComponent extends AbstractVideoList implements OnInit, OnDestroy { | ||
15 | titlePage = 'Search' | ||
16 | currentRoute = '/videos/search' | ||
17 | loadOnInit = false | ||
18 | |||
19 | private search = '' | ||
20 | private subActivatedRoute: Subscription | ||
21 | |||
22 | constructor (protected router: Router, | ||
23 | protected route: ActivatedRoute, | ||
24 | protected notificationsService: NotificationsService, | ||
25 | private videoService: VideoService) { | ||
26 | super() | ||
27 | } | ||
28 | |||
29 | ngOnInit () { | ||
30 | super.ngOnInit() | ||
31 | |||
32 | this.subActivatedRoute = this.route.queryParams.subscribe( | ||
33 | queryParams => { | ||
34 | this.search = queryParams['search'] | ||
35 | this.reloadVideos() | ||
36 | }, | ||
37 | |||
38 | err => this.notificationsService.error('Error', err.text) | ||
39 | ) | ||
40 | } | ||
41 | |||
42 | ngOnDestroy () { | ||
43 | if (this.subActivatedRoute) { | ||
44 | this.subActivatedRoute.unsubscribe() | ||
45 | } | ||
46 | } | ||
47 | |||
48 | getVideosObservable () { | ||
49 | return this.videoService.searchVideos(this.search, this.pagination, this.sort) | ||
50 | } | ||
51 | } | ||
diff --git a/client/src/app/videos/video-list/video-trending.component.ts b/client/src/app/videos/video-list/video-trending.component.ts new file mode 100644 index 000000000..e80fd7f2c --- /dev/null +++ b/client/src/app/videos/video-list/video-trending.component.ts | |||
@@ -0,0 +1,32 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute, Router } from '@angular/router' | ||
3 | import { NotificationsService } from 'angular2-notifications' | ||
4 | import { AbstractVideoList } from 'app/shared/video/abstract-video-list' | ||
5 | import { SortField } from '../../shared/video/sort-field.type' | ||
6 | import { VideoService } from '../../shared/video/video.service' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-videos-trending', | ||
10 | styleUrls: [ '../../shared/video/abstract-video-list.scss' ], | ||
11 | templateUrl: '../../shared/video/abstract-video-list.html' | ||
12 | }) | ||
13 | export class VideoTrendingComponent extends AbstractVideoList implements OnInit { | ||
14 | titlePage = 'Trending' | ||
15 | currentRoute = '/videos/trending' | ||
16 | defaultSort: SortField = '-views' | ||
17 | |||
18 | constructor (protected router: Router, | ||
19 | protected route: ActivatedRoute, | ||
20 | protected notificationsService: NotificationsService, | ||
21 | private videoService: VideoService) { | ||
22 | super() | ||
23 | } | ||
24 | |||
25 | ngOnInit () { | ||
26 | super.ngOnInit() | ||
27 | } | ||
28 | |||
29 | getVideosObservable () { | ||
30 | return this.videoService.getVideos(this.pagination, this.sort) | ||
31 | } | ||
32 | } | ||