aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/videos
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-23 12:15:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-23 12:15:03 +0200
commitaff038cd784ab09a9f62b2e81816110e100ba7b8 (patch)
treef840355a06dbfe8f3868059a5515faf4d2998026 /client/angular/videos
parentcf20596c107eb0833259fa1098cc784267298a19 (diff)
downloadPeerTube-aff038cd784ab09a9f62b2e81816110e100ba7b8.tar.gz
PeerTube-aff038cd784ab09a9f62b2e81816110e100ba7b8.tar.zst
PeerTube-aff038cd784ab09a9f62b2e81816110e100ba7b8.zip
Lint the client
Diffstat (limited to 'client/angular/videos')
-rw-r--r--client/angular/videos/components/list/video-sort.component.ts12
-rw-r--r--client/angular/videos/components/list/videos-list.component.ts4
-rw-r--r--client/angular/videos/video.ts39
-rw-r--r--client/angular/videos/videos.service.ts6
4 files changed, 32 insertions, 29 deletions
diff --git a/client/angular/videos/components/list/video-sort.component.ts b/client/angular/videos/components/list/video-sort.component.ts
index e63a70e9e..0373cea38 100644
--- a/client/angular/videos/components/list/video-sort.component.ts
+++ b/client/angular/videos/components/list/video-sort.component.ts
@@ -15,12 +15,12 @@ export class VideoSortComponent {
15 15
16 sortChoices = { 16 sortChoices = {
17 'name': 'Name - Asc', 17 'name': 'Name - Asc',
18 '-name': "Name - Desc", 18 '-name': 'Name - Desc',
19 'duration': "Duration - Asc", 19 'duration': 'Duration - Asc',
20 '-duration': "Duration - Desc", 20 '-duration': 'Duration - Desc',
21 'createdDate': "Created Date - Asc", 21 'createdDate': 'Created Date - Asc',
22 '-createdDate': "Created Date - Desc" 22 '-createdDate': 'Created Date - Desc'
23 } 23 };
24 24
25 get choiceKeys() { 25 get choiceKeys() {
26 return Object.keys(this.sortChoices); 26 return Object.keys(this.sortChoices);
diff --git a/client/angular/videos/components/list/videos-list.component.ts b/client/angular/videos/components/list/videos-list.component.ts
index 98fe7b153..db64a856e 100644
--- a/client/angular/videos/components/list/videos-list.component.ts
+++ b/client/angular/videos/components/list/videos-list.component.ts
@@ -27,7 +27,7 @@ export class VideosListComponent implements OnInit {
27 currentPage: 1, 27 currentPage: 1,
28 itemsPerPage: 9, 28 itemsPerPage: 9,
29 total: 0 29 total: 0
30 } 30 };
31 sort: SortField; 31 sort: SortField;
32 32
33 private search: Search; 33 private search: Search;
@@ -41,7 +41,7 @@ export class VideosListComponent implements OnInit {
41 this.search = { 41 this.search = {
42 value: this._routeParams.get('search'), 42 value: this._routeParams.get('search'),
43 field: <SearchField>this._routeParams.get('field') 43 field: <SearchField>this._routeParams.get('field')
44 } 44 };
45 45
46 this.sort = <SortField>this._routeParams.get('sort') || '-createdDate'; 46 this.sort = <SortField>this._routeParams.get('sort') || '-createdDate';
47 } 47 }
diff --git a/client/angular/videos/video.ts b/client/angular/videos/video.ts
index 32ff64eb3..eec537c9e 100644
--- a/client/angular/videos/video.ts
+++ b/client/angular/videos/video.ts
@@ -11,6 +11,27 @@ export class Video {
11 by: string; 11 by: string;
12 duration: string; 12 duration: string;
13 13
14 private static createDurationString(duration: number): string {
15 const minutes = Math.floor(duration / 60);
16 const seconds = duration % 60;
17 const minutes_padding = minutes >= 10 ? '' : '0';
18 const seconds_padding = seconds >= 10 ? '' : '0';
19
20 return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
21 }
22
23 private static createByString(author: string, podUrl: string): string {
24 let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':');
25
26 if (port === '80' || port === '443') {
27 port = '';
28 } else {
29 port = ':' + port;
30 }
31
32 return author + '@' + host + port;
33 }
34
14 constructor(hash: { 35 constructor(hash: {
15 id: string, 36 id: string,
16 name: string, 37 name: string,
@@ -39,22 +60,4 @@ export class Video {
39 isRemovableBy(user): boolean { 60 isRemovableBy(user): boolean {
40 return this.isLocal === true && user && this.author === user.username; 61 return this.isLocal === true && user && this.author === user.username;
41 } 62 }
42
43 private static createDurationString(duration: number): string {
44 const minutes = Math.floor(duration / 60);
45 const seconds = duration % 60;
46 const minutes_padding = minutes >= 10 ? '' : '0';
47 const seconds_padding = seconds >= 10 ? '' : '0'
48
49 return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
50 }
51
52 private static createByString(author: string, podUrl: string): string {
53 let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':');
54
55 if (port === '80' || port === '443') port = '';
56 else port = ':' + port;
57
58 return author + '@' + host + port;
59 }
60} 63}
diff --git a/client/angular/videos/videos.service.ts b/client/angular/videos/videos.service.ts
index 43e3346aa..d5438fd82 100644
--- a/client/angular/videos/videos.service.ts
+++ b/client/angular/videos/videos.service.ts
@@ -1,5 +1,5 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import { Http, Response, RequestOptions, URLSearchParams } from '@angular/http'; 2import { Http, Response, URLSearchParams } from '@angular/http';
3import { Observable } from 'rxjs/Rx'; 3import { Observable } from 'rxjs/Rx';
4 4
5import { Pagination } from './pagination'; 5import { Pagination } from './pagination';
@@ -17,7 +17,7 @@ export class VideosService {
17 getVideos(pagination: Pagination, sort: SortField) { 17 getVideos(pagination: Pagination, sort: SortField) {
18 const params = this.createPaginationParams(pagination); 18 const params = this.createPaginationParams(pagination);
19 19
20 if (sort) params.set('sort', sort) 20 if (sort) params.set('sort', sort);
21 21
22 return this.http.get(this._baseVideoUrl, { search: params }) 22 return this.http.get(this._baseVideoUrl, { search: params })
23 .map(res => res.json()) 23 .map(res => res.json())
@@ -42,7 +42,7 @@ export class VideosService {
42 const params = this.createPaginationParams(pagination); 42 const params = this.createPaginationParams(pagination);
43 43
44 if (search.field) params.set('field', search.field); 44 if (search.field) params.set('field', search.field);
45 if (sort) params.set('sort', sort) 45 if (sort) params.set('sort', sort);
46 46
47 return this.http.get(this._baseVideoUrl + 'search/' + encodeURIComponent(search.value), { search: params }) 47 return this.http.get(this._baseVideoUrl + 'search/' + encodeURIComponent(search.value), { search: params })
48 .map(res => res.json()) 48 .map(res => res.json())