diff options
Diffstat (limited to 'client/app')
-rw-r--r-- | client/app/app.component.ts | 21 | ||||
-rw-r--r-- | client/app/friends/friend.service.ts | 12 | ||||
-rw-r--r-- | client/app/shared/search.component.ts | 9 | ||||
-rw-r--r-- | client/app/users/login/login.component.ts | 8 | ||||
-rw-r--r-- | client/app/users/shared/auth.service.ts | 41 | ||||
-rw-r--r-- | client/app/users/shared/token.model.ts | 7 | ||||
-rw-r--r-- | client/app/users/shared/user.model.ts | 6 | ||||
-rw-r--r-- | client/app/videos/shared/video.model.ts | 6 | ||||
-rw-r--r-- | client/app/videos/shared/video.service.ts | 18 | ||||
-rw-r--r-- | client/app/videos/video-add/video-add.component.ts | 2 | ||||
-rw-r--r-- | client/app/videos/video-list/video-list.component.ts | 26 | ||||
-rw-r--r-- | client/app/videos/video-list/video-miniature.component.ts | 8 | ||||
-rw-r--r-- | client/app/videos/video-list/video-sort.component.ts | 2 | ||||
-rw-r--r-- | client/app/videos/video-watch/video-watch.component.ts | 20 |
14 files changed, 94 insertions, 92 deletions
diff --git a/client/app/app.component.ts b/client/app/app.component.ts index c94ff79a7..20c8c8724 100644 --- a/client/app/app.component.ts +++ b/client/app/app.component.ts | |||
@@ -51,16 +51,15 @@ import { | |||
51 | export class AppComponent { | 51 | export class AppComponent { |
52 | isLoggedIn: boolean; | 52 | isLoggedIn: boolean; |
53 | search_field: string = name; | 53 | search_field: string = name; |
54 | choices = [ ]; | 54 | choices = []; |
55 | |||
56 | constructor(private _friendService: FriendService, | ||
57 | private _authService: AuthService, | ||
58 | private _router: Router | ||
59 | 55 | ||
56 | constructor(private friendService: FriendService, | ||
57 | private authService: AuthService, | ||
58 | private router: Router | ||
60 | ) { | 59 | ) { |
61 | this.isLoggedIn = this._authService.isLoggedIn(); | 60 | this.isLoggedIn = this.authService.isLoggedIn(); |
62 | 61 | ||
63 | this._authService.loginChanged$.subscribe( | 62 | this.authService.loginChangedSource.subscribe( |
64 | status => { | 63 | status => { |
65 | if (status === AuthStatus.LoggedIn) { | 64 | if (status === AuthStatus.LoggedIn) { |
66 | this.isLoggedIn = true; | 65 | this.isLoggedIn = true; |
@@ -75,9 +74,9 @@ export class AppComponent { | |||
75 | search: search.value, | 74 | search: search.value, |
76 | field: search.field | 75 | field: search.field |
77 | }; | 76 | }; |
78 | this._router.navigate(['VideosList', params]); | 77 | this.router.navigate(['VideosList', params]); |
79 | } else { | 78 | } else { |
80 | this._router.navigate(['VideosList']); | 79 | this.router.navigate(['VideosList']); |
81 | } | 80 | } |
82 | } | 81 | } |
83 | 82 | ||
@@ -86,7 +85,7 @@ export class AppComponent { | |||
86 | } | 85 | } |
87 | 86 | ||
88 | makeFriends() { | 87 | makeFriends() { |
89 | this._friendService.makeFriends().subscribe( | 88 | this.friendService.makeFriends().subscribe( |
90 | status => { | 89 | status => { |
91 | if (status === 409) { | 90 | if (status === 409) { |
92 | alert('Already made friends!'); | 91 | alert('Already made friends!'); |
@@ -99,7 +98,7 @@ export class AppComponent { | |||
99 | } | 98 | } |
100 | 99 | ||
101 | quitFriends() { | 100 | quitFriends() { |
102 | this._friendService.quitFriends().subscribe( | 101 | this.friendService.quitFriends().subscribe( |
103 | status => { | 102 | status => { |
104 | alert('Quit friends!'); | 103 | alert('Quit friends!'); |
105 | }, | 104 | }, |
diff --git a/client/app/friends/friend.service.ts b/client/app/friends/friend.service.ts index d143ec40d..bdfa7baec 100644 --- a/client/app/friends/friend.service.ts +++ b/client/app/friends/friend.service.ts | |||
@@ -4,23 +4,23 @@ import { Observable } from 'rxjs/Rx'; | |||
4 | 4 | ||
5 | @Injectable() | 5 | @Injectable() |
6 | export class FriendService { | 6 | export class FriendService { |
7 | private _baseFriendsUrl = '/api/v1/pods/'; | 7 | private static BASE_FRIEND_URL: string = '/api/v1/pods/'; |
8 | 8 | ||
9 | constructor (private http: Http) {} | 9 | constructor (private http: Http) {} |
10 | 10 | ||
11 | makeFriends() { | 11 | makeFriends() { |
12 | return this.http.get(this._baseFriendsUrl + 'makefriends') | 12 | return this.http.get(FriendService.BASE_FRIEND_URL + 'makefriends') |
13 | .map(res => <number> res.status) | 13 | .map(res => res.status) |
14 | .catch(this.handleError); | 14 | .catch(this.handleError); |
15 | } | 15 | } |
16 | 16 | ||
17 | quitFriends() { | 17 | quitFriends() { |
18 | return this.http.get(this._baseFriendsUrl + 'quitfriends') | 18 | return this.http.get(FriendService.BASE_FRIEND_URL + 'quitfriends') |
19 | .map(res => <number> res.status) | 19 | .map(res => res.status) |
20 | .catch(this.handleError); | 20 | .catch(this.handleError); |
21 | } | 21 | } |
22 | 22 | ||
23 | private handleError (error: Response) { | 23 | private handleError (error: Response): Observable<number> { |
24 | console.error(error); | 24 | console.error(error); |
25 | return Observable.throw(error.json().error || 'Server error'); | 25 | return Observable.throw(error.json().error || 'Server error'); |
26 | } | 26 | } |
diff --git a/client/app/shared/search.component.ts b/client/app/shared/search.component.ts index 519810f9b..674518aba 100644 --- a/client/app/shared/search.component.ts +++ b/client/app/shared/search.component.ts | |||
@@ -12,12 +12,13 @@ import { SearchField } from './search-field.type'; | |||
12 | }) | 12 | }) |
13 | 13 | ||
14 | export class SearchComponent { | 14 | export class SearchComponent { |
15 | @Output() search: EventEmitter<Search> = new EventEmitter<Search>(); | 15 | @Output() search = new EventEmitter<Search>(); |
16 | 16 | ||
17 | searchCriterias: Search = { | 17 | searchCriterias: Search = { |
18 | field: 'name', | 18 | field: 'name', |
19 | value: '' | 19 | value: '' |
20 | }; | 20 | }; |
21 | |||
21 | fieldChoices = { | 22 | fieldChoices = { |
22 | name: 'Name', | 23 | name: 'Name', |
23 | author: 'Author', | 24 | author: 'Author', |
@@ -29,18 +30,18 @@ export class SearchComponent { | |||
29 | return Object.keys(this.fieldChoices); | 30 | return Object.keys(this.fieldChoices); |
30 | } | 31 | } |
31 | 32 | ||
32 | getStringChoice(choiceKey: SearchField): string { | 33 | getStringChoice(choiceKey: SearchField) { |
33 | return this.fieldChoices[choiceKey]; | 34 | return this.fieldChoices[choiceKey]; |
34 | } | 35 | } |
35 | 36 | ||
36 | choose($event:MouseEvent, choice: SearchField) { | 37 | choose($event: MouseEvent, choice: SearchField) { |
37 | $event.preventDefault(); | 38 | $event.preventDefault(); |
38 | $event.stopPropagation(); | 39 | $event.stopPropagation(); |
39 | 40 | ||
40 | this.searchCriterias.field = choice; | 41 | this.searchCriterias.field = choice; |
41 | } | 42 | } |
42 | 43 | ||
43 | doSearch(): void { | 44 | doSearch() { |
44 | this.search.emit(this.searchCriterias); | 45 | this.search.emit(this.searchCriterias); |
45 | } | 46 | } |
46 | 47 | ||
diff --git a/client/app/users/login/login.component.ts b/client/app/users/login/login.component.ts index 33590ad4c..8e369541d 100644 --- a/client/app/users/login/login.component.ts +++ b/client/app/users/login/login.component.ts | |||
@@ -10,17 +10,17 @@ import { AuthService, AuthStatus, User } from '../shared/index'; | |||
10 | }) | 10 | }) |
11 | 11 | ||
12 | export class UserLoginComponent { | 12 | export class UserLoginComponent { |
13 | constructor(private _authService: AuthService, private _router: Router) {} | 13 | constructor(private authService: AuthService, private router: Router) {} |
14 | 14 | ||
15 | login(username: string, password: string) { | 15 | login(username: string, password: string) { |
16 | this._authService.login(username, password).subscribe( | 16 | this.authService.login(username, password).subscribe( |
17 | result => { | 17 | result => { |
18 | const user = new User(username, result); | 18 | const user = new User(username, result); |
19 | user.save(); | 19 | user.save(); |
20 | 20 | ||
21 | this._authService.setStatus(AuthStatus.LoggedIn); | 21 | this.authService.setStatus(AuthStatus.LoggedIn); |
22 | 22 | ||
23 | this._router.navigate(['VideosList']); | 23 | this.router.navigate(['VideosList']); |
24 | }, | 24 | }, |
25 | error => { | 25 | error => { |
26 | if (error.error === 'invalid_grant') { | 26 | if (error.error === 'invalid_grant') { |
diff --git a/client/app/users/shared/auth.service.ts b/client/app/users/shared/auth.service.ts index 1cb042db5..b1da94436 100644 --- a/client/app/users/shared/auth.service.ts +++ b/client/app/users/shared/auth.service.ts | |||
@@ -7,27 +7,28 @@ import { User } from './user.model'; | |||
7 | 7 | ||
8 | @Injectable() | 8 | @Injectable() |
9 | export class AuthService { | 9 | export class AuthService { |
10 | loginChanged$; | 10 | private static BASE_LOGIN_URL = '/api/v1/users/token'; |
11 | private static BASE_CLIENT_URL = '/api/v1/users/client'; | ||
11 | 12 | ||
12 | private _loginChanged; | 13 | loginChangedSource: Observable<AuthStatus>; |
13 | private _baseLoginUrl = '/api/v1/users/token'; | ||
14 | private _baseClientUrl = '/api/v1/users/client'; | ||
15 | private _clientId = ''; | ||
16 | private _clientSecret = ''; | ||
17 | 14 | ||
18 | constructor (private http: Http) { | 15 | private loginChanged: Subject<AuthStatus>; |
19 | this._loginChanged = new Subject<AuthStatus>(); | 16 | private clientId: string; |
20 | this.loginChanged$ = this._loginChanged.asObservable(); | 17 | private clientSecret: string; |
18 | |||
19 | constructor(private http: Http) { | ||
20 | this.loginChanged = new Subject<AuthStatus>(); | ||
21 | this.loginChangedSource = this.loginChanged.asObservable(); | ||
21 | 22 | ||
22 | // Fetch the client_id/client_secret | 23 | // Fetch the client_id/client_secret |
23 | // FIXME: save in local storage? | 24 | // FIXME: save in local storage? |
24 | this.http.get(this._baseClientUrl) | 25 | this.http.get(AuthService.BASE_CLIENT_URL) |
25 | .map(res => res.json()) | 26 | .map(res => res.json()) |
26 | .catch(this.handleError) | 27 | .catch(this.handleError) |
27 | .subscribe( | 28 | .subscribe( |
28 | result => { | 29 | result => { |
29 | this._clientId = result.client_id; | 30 | this.clientId = result.client_id; |
30 | this._clientSecret = result.client_secret; | 31 | this.clientSecret = result.client_secret; |
31 | console.log('Client credentials loaded.'); | 32 | console.log('Client credentials loaded.'); |
32 | }, | 33 | }, |
33 | error => { | 34 | error => { |
@@ -38,8 +39,8 @@ export class AuthService { | |||
38 | 39 | ||
39 | login(username: string, password: string) { | 40 | login(username: string, password: string) { |
40 | let body = new URLSearchParams(); | 41 | let body = new URLSearchParams(); |
41 | body.set('client_id', this._clientId); | 42 | body.set('client_id', this.clientId); |
42 | body.set('client_secret', this._clientSecret); | 43 | body.set('client_secret', this.clientSecret); |
43 | body.set('response_type', 'code'); | 44 | body.set('response_type', 'code'); |
44 | body.set('grant_type', 'password'); | 45 | body.set('grant_type', 'password'); |
45 | body.set('scope', 'upload'); | 46 | body.set('scope', 'upload'); |
@@ -53,7 +54,7 @@ export class AuthService { | |||
53 | headers: headers | 54 | headers: headers |
54 | }; | 55 | }; |
55 | 56 | ||
56 | return this.http.post(this._baseLoginUrl, body.toString(), options) | 57 | return this.http.post(AuthService.BASE_LOGIN_URL, body.toString(), options) |
57 | .map(res => res.json()) | 58 | .map(res => res.json()) |
58 | .catch(this.handleError); | 59 | .catch(this.handleError); |
59 | } | 60 | } |
@@ -62,7 +63,7 @@ export class AuthService { | |||
62 | // TODO make HTTP request | 63 | // TODO make HTTP request |
63 | } | 64 | } |
64 | 65 | ||
65 | getRequestHeader(): Headers { | 66 | getRequestHeader() { |
66 | return new Headers({ 'Authorization': `${this.getTokenType()} ${this.getToken()}` }); | 67 | return new Headers({ 'Authorization': `${this.getTokenType()} ${this.getToken()}` }); |
67 | } | 68 | } |
68 | 69 | ||
@@ -70,11 +71,11 @@ export class AuthService { | |||
70 | return new RequestOptions({ headers: this.getRequestHeader() }); | 71 | return new RequestOptions({ headers: this.getRequestHeader() }); |
71 | } | 72 | } |
72 | 73 | ||
73 | getToken(): string { | 74 | getToken() { |
74 | return localStorage.getItem('access_token'); | 75 | return localStorage.getItem('access_token'); |
75 | } | 76 | } |
76 | 77 | ||
77 | getTokenType(): string { | 78 | getTokenType() { |
78 | return localStorage.getItem('token_type'); | 79 | return localStorage.getItem('token_type'); |
79 | } | 80 | } |
80 | 81 | ||
@@ -88,7 +89,7 @@ export class AuthService { | |||
88 | return user; | 89 | return user; |
89 | } | 90 | } |
90 | 91 | ||
91 | isLoggedIn(): boolean { | 92 | isLoggedIn() { |
92 | if (this.getToken()) { | 93 | if (this.getToken()) { |
93 | return true; | 94 | return true; |
94 | } else { | 95 | } else { |
@@ -97,7 +98,7 @@ export class AuthService { | |||
97 | } | 98 | } |
98 | 99 | ||
99 | setStatus(status: AuthStatus) { | 100 | setStatus(status: AuthStatus) { |
100 | this._loginChanged.next(status); | 101 | this.loginChanged.next(status); |
101 | } | 102 | } |
102 | 103 | ||
103 | private handleError (error: Response) { | 104 | private handleError (error: Response) { |
diff --git a/client/app/users/shared/token.model.ts b/client/app/users/shared/token.model.ts index b7872e74a..021c83fad 100644 --- a/client/app/users/shared/token.model.ts +++ b/client/app/users/shared/token.model.ts | |||
@@ -3,7 +3,7 @@ export class Token { | |||
3 | refresh_token: string; | 3 | refresh_token: string; |
4 | token_type: string; | 4 | token_type: string; |
5 | 5 | ||
6 | static load(): Token { | 6 | static load() { |
7 | return new Token({ | 7 | return new Token({ |
8 | access_token: localStorage.getItem('access_token'), | 8 | access_token: localStorage.getItem('access_token'), |
9 | refresh_token: localStorage.getItem('refresh_token'), | 9 | refresh_token: localStorage.getItem('refresh_token'), |
@@ -11,10 +11,11 @@ export class Token { | |||
11 | }); | 11 | }); |
12 | } | 12 | } |
13 | 13 | ||
14 | constructor (hash?: any) { | 14 | constructor(hash?: any) { |
15 | if (hash) { | 15 | if (hash) { |
16 | this.access_token = hash.access_token; | 16 | this.access_token = hash.access_token; |
17 | this.refresh_token = hash.refresh_token; | 17 | this.refresh_token = hash.refresh_token; |
18 | |||
18 | if (hash.token_type === 'bearer') { | 19 | if (hash.token_type === 'bearer') { |
19 | this.token_type = 'Bearer'; | 20 | this.token_type = 'Bearer'; |
20 | } else { | 21 | } else { |
@@ -23,7 +24,7 @@ export class Token { | |||
23 | } | 24 | } |
24 | } | 25 | } |
25 | 26 | ||
26 | save():void { | 27 | save() { |
27 | localStorage.setItem('access_token', this.access_token); | 28 | localStorage.setItem('access_token', this.access_token); |
28 | localStorage.setItem('refresh_token', this.refresh_token); | 29 | localStorage.setItem('refresh_token', this.refresh_token); |
29 | localStorage.setItem('token_type', this.token_type); | 30 | localStorage.setItem('token_type', this.token_type); |
diff --git a/client/app/users/shared/user.model.ts b/client/app/users/shared/user.model.ts index 73fd4ddc0..ca0a5f26c 100644 --- a/client/app/users/shared/user.model.ts +++ b/client/app/users/shared/user.model.ts | |||
@@ -4,16 +4,16 @@ export class User { | |||
4 | username: string; | 4 | username: string; |
5 | token: Token; | 5 | token: Token; |
6 | 6 | ||
7 | static load(): User { | 7 | static load() { |
8 | return new User(localStorage.getItem('username'), Token.load()); | 8 | return new User(localStorage.getItem('username'), Token.load()); |
9 | } | 9 | } |
10 | 10 | ||
11 | constructor (username: string, hash_token: any) { | 11 | constructor(username: string, hash_token: any) { |
12 | this.username = username; | 12 | this.username = username; |
13 | this.token = new Token(hash_token); | 13 | this.token = new Token(hash_token); |
14 | } | 14 | } |
15 | 15 | ||
16 | save(): void { | 16 | save() { |
17 | localStorage.setItem('username', this.username); | 17 | localStorage.setItem('username', this.username); |
18 | this.token.save(); | 18 | this.token.save(); |
19 | } | 19 | } |
diff --git a/client/app/videos/shared/video.model.ts b/client/app/videos/shared/video.model.ts index eec537c9e..2b018ad86 100644 --- a/client/app/videos/shared/video.model.ts +++ b/client/app/videos/shared/video.model.ts | |||
@@ -11,7 +11,7 @@ export class Video { | |||
11 | by: string; | 11 | by: string; |
12 | duration: string; | 12 | duration: string; |
13 | 13 | ||
14 | private static createDurationString(duration: number): string { | 14 | private static createDurationString(duration: number) { |
15 | const minutes = Math.floor(duration / 60); | 15 | const minutes = Math.floor(duration / 60); |
16 | const seconds = duration % 60; | 16 | const seconds = duration % 60; |
17 | const minutes_padding = minutes >= 10 ? '' : '0'; | 17 | const minutes_padding = minutes >= 10 ? '' : '0'; |
@@ -20,7 +20,7 @@ export class Video { | |||
20 | return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString(); | 20 | return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString(); |
21 | } | 21 | } |
22 | 22 | ||
23 | private static createByString(author: string, podUrl: string): string { | 23 | private static createByString(author: string, podUrl: string) { |
24 | let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':'); | 24 | let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':'); |
25 | 25 | ||
26 | if (port === '80' || port === '443') { | 26 | if (port === '80' || port === '443') { |
@@ -57,7 +57,7 @@ export class Video { | |||
57 | this.by = Video.createByString(hash.author, hash.podUrl); | 57 | this.by = Video.createByString(hash.author, hash.podUrl); |
58 | } | 58 | } |
59 | 59 | ||
60 | isRemovableBy(user): boolean { | 60 | isRemovableBy(user) { |
61 | return this.isLocal === true && user && this.author === user.username; | 61 | return this.isLocal === true && user && this.author === user.username; |
62 | } | 62 | } |
63 | } | 63 | } |
diff --git a/client/app/videos/shared/video.service.ts b/client/app/videos/shared/video.service.ts index 78789c3cc..b6e0800a0 100644 --- a/client/app/videos/shared/video.service.ts +++ b/client/app/videos/shared/video.service.ts | |||
@@ -10,30 +10,30 @@ import { Video } from './video.model'; | |||
10 | 10 | ||
11 | @Injectable() | 11 | @Injectable() |
12 | export class VideoService { | 12 | export class VideoService { |
13 | private _baseVideoUrl = '/api/v1/videos/'; | 13 | private static BASE_VIDEO_URL = '/api/v1/videos/'; |
14 | 14 | ||
15 | constructor (private http: Http, private _authService: AuthService) {} | 15 | constructor(private http: Http, private authService: AuthService) {} |
16 | 16 | ||
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(VideoService.BASE_VIDEO_URL, { search: params }) |
23 | .map(res => res.json()) | 23 | .map(res => res.json()) |
24 | .map(this.extractVideos) | 24 | .map(this.extractVideos) |
25 | .catch(this.handleError); | 25 | .catch(this.handleError); |
26 | } | 26 | } |
27 | 27 | ||
28 | getVideo(id: string) { | 28 | getVideo(id: string) { |
29 | return this.http.get(this._baseVideoUrl + id) | 29 | return this.http.get(VideoService.BASE_VIDEO_URL + id) |
30 | .map(res => <Video> res.json()) | 30 | .map(res => <Video> res.json()) |
31 | .catch(this.handleError); | 31 | .catch(this.handleError); |
32 | } | 32 | } |
33 | 33 | ||
34 | removeVideo(id: string) { | 34 | removeVideo(id: string) { |
35 | const options = this._authService.getAuthRequestOptions(); | 35 | const options = this.authService.getAuthRequestOptions(); |
36 | return this.http.delete(this._baseVideoUrl + id, options) | 36 | return this.http.delete(VideoService.BASE_VIDEO_URL + id, options) |
37 | .map(res => <number> res.status) | 37 | .map(res => <number> res.status) |
38 | .catch(this.handleError); | 38 | .catch(this.handleError); |
39 | } | 39 | } |
@@ -44,13 +44,13 @@ export class VideoService { | |||
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(VideoService.BASE_VIDEO_URL + 'search/' + encodeURIComponent(search.value), { search: params }) |
48 | .map(res => res.json()) | 48 | .map(res => res.json()) |
49 | .map(this.extractVideos) | 49 | .map(this.extractVideos) |
50 | .catch(this.handleError); | 50 | .catch(this.handleError); |
51 | } | 51 | } |
52 | 52 | ||
53 | private extractVideos (body: any) { | 53 | private extractVideos(body: any) { |
54 | const videos_json = body.data; | 54 | const videos_json = body.data; |
55 | const totalVideos = body.total; | 55 | const totalVideos = body.total; |
56 | const videos = []; | 56 | const videos = []; |
@@ -61,7 +61,7 @@ export class VideoService { | |||
61 | return { videos, totalVideos }; | 61 | return { videos, totalVideos }; |
62 | } | 62 | } |
63 | 63 | ||
64 | private handleError (error: Response) { | 64 | private handleError(error: Response) { |
65 | console.error(error); | 65 | console.error(error); |
66 | return Observable.throw(error.json().error || 'Server error'); | 66 | return Observable.throw(error.json().error || 'Server error'); |
67 | } | 67 | } |
diff --git a/client/app/videos/video-add/video-add.component.ts b/client/app/videos/video-add/video-add.component.ts index ca583a103..67a04a2b4 100644 --- a/client/app/videos/video-add/video-add.component.ts +++ b/client/app/videos/video-add/video-add.component.ts | |||
@@ -7,7 +7,7 @@ import { PROGRESSBAR_DIRECTIVES } from 'ng2-bootstrap/components/progressbar'; | |||
7 | import { AuthService, User } from '../../users/index'; | 7 | import { AuthService, User } from '../../users/index'; |
8 | 8 | ||
9 | // TODO: import it with systemjs | 9 | // TODO: import it with systemjs |
10 | declare var jQuery:any; | 10 | declare var jQuery: any; |
11 | 11 | ||
12 | @Component({ | 12 | @Component({ |
13 | selector: 'my-videos-add', | 13 | selector: 'my-videos-add', |
diff --git a/client/app/videos/video-list/video-list.component.ts b/client/app/videos/video-list/video-list.component.ts index a88fb379a..3f54c98ce 100644 --- a/client/app/videos/video-list/video-list.component.ts +++ b/client/app/videos/video-list/video-list.component.ts | |||
@@ -31,26 +31,26 @@ export class VideoListComponent implements OnInit { | |||
31 | total: 0 | 31 | total: 0 |
32 | }; | 32 | }; |
33 | sort: SortField; | 33 | sort: SortField; |
34 | loading: boolean = false; | 34 | loading = false; |
35 | 35 | ||
36 | private search: Search; | 36 | private search: Search; |
37 | 37 | ||
38 | constructor( | 38 | constructor( |
39 | private _authService: AuthService, | 39 | private authService: AuthService, |
40 | private _videoService: VideoService, | 40 | private videoService: VideoService, |
41 | private _routeParams: RouteParams, | 41 | private routeParams: RouteParams, |
42 | private _router: Router | 42 | private router: Router |
43 | ) { | 43 | ) { |
44 | this.search = { | 44 | this.search = { |
45 | value: this._routeParams.get('search'), | 45 | value: this.routeParams.get('search'), |
46 | field: <SearchField>this._routeParams.get('field') | 46 | field: <SearchField>this.routeParams.get('field') |
47 | }; | 47 | }; |
48 | 48 | ||
49 | this.sort = <SortField>this._routeParams.get('sort') || '-createdDate'; | 49 | this.sort = <SortField>this.routeParams.get('sort') || '-createdDate'; |
50 | } | 50 | } |
51 | 51 | ||
52 | ngOnInit() { | 52 | ngOnInit() { |
53 | if (this._authService.isLoggedIn()) { | 53 | if (this.authService.isLoggedIn()) { |
54 | this.user = User.load(); | 54 | this.user = User.load(); |
55 | } | 55 | } |
56 | 56 | ||
@@ -64,9 +64,9 @@ export class VideoListComponent implements OnInit { | |||
64 | let observable = null; | 64 | let observable = null; |
65 | 65 | ||
66 | if (this.search.value !== null) { | 66 | if (this.search.value !== null) { |
67 | observable = this._videoService.searchVideos(this.search, this.pagination, this.sort); | 67 | observable = this.videoService.searchVideos(this.search, this.pagination, this.sort); |
68 | } else { | 68 | } else { |
69 | observable = this._videoService.getVideos(this.pagination, this.sort); | 69 | observable = this.videoService.getVideos(this.pagination, this.sort); |
70 | } | 70 | } |
71 | 71 | ||
72 | observable.subscribe( | 72 | observable.subscribe( |
@@ -79,7 +79,7 @@ export class VideoListComponent implements OnInit { | |||
79 | ); | 79 | ); |
80 | } | 80 | } |
81 | 81 | ||
82 | onRemoved(video: Video): void { | 82 | onRemoved(video: Video) { |
83 | this.videos.splice(this.videos.indexOf(video), 1); | 83 | this.videos.splice(this.videos.indexOf(video), 1); |
84 | } | 84 | } |
85 | 85 | ||
@@ -95,7 +95,7 @@ export class VideoListComponent implements OnInit { | |||
95 | params.field = this.search.field; | 95 | params.field = this.search.field; |
96 | } | 96 | } |
97 | 97 | ||
98 | this._router.navigate(['VideosList', params]); | 98 | this.router.navigate(['VideosList', params]); |
99 | this.getVideos(); | 99 | this.getVideos(); |
100 | } | 100 | } |
101 | } | 101 | } |
diff --git a/client/app/videos/video-list/video-miniature.component.ts b/client/app/videos/video-list/video-miniature.component.ts index 817636768..73416607a 100644 --- a/client/app/videos/video-list/video-miniature.component.ts +++ b/client/app/videos/video-list/video-miniature.component.ts | |||
@@ -19,9 +19,9 @@ export class VideoMiniatureComponent { | |||
19 | @Input() video: Video; | 19 | @Input() video: Video; |
20 | @Input() user: User; | 20 | @Input() user: User; |
21 | 21 | ||
22 | hovering: boolean = false; | 22 | hovering = false; |
23 | 23 | ||
24 | constructor(private _videoService: VideoService) {} | 24 | constructor(private videoService: VideoService) {} |
25 | 25 | ||
26 | onHover() { | 26 | onHover() { |
27 | this.hovering = true; | 27 | this.hovering = true; |
@@ -31,13 +31,13 @@ export class VideoMiniatureComponent { | |||
31 | this.hovering = false; | 31 | this.hovering = false; |
32 | } | 32 | } |
33 | 33 | ||
34 | displayRemoveIcon(): boolean { | 34 | displayRemoveIcon() { |
35 | return this.hovering && this.video.isRemovableBy(this.user); | 35 | return this.hovering && this.video.isRemovableBy(this.user); |
36 | } | 36 | } |
37 | 37 | ||
38 | removeVideo(id: string) { | 38 | removeVideo(id: string) { |
39 | if (confirm('Do you really want to remove this video?')) { | 39 | if (confirm('Do you really want to remove this video?')) { |
40 | this._videoService.removeVideo(id).subscribe( | 40 | this.videoService.removeVideo(id).subscribe( |
41 | status => this.removed.emit(true), | 41 | status => this.removed.emit(true), |
42 | error => alert(error) | 42 | error => alert(error) |
43 | ); | 43 | ); |
diff --git a/client/app/videos/video-list/video-sort.component.ts b/client/app/videos/video-list/video-sort.component.ts index d00d7ed49..ed06c7510 100644 --- a/client/app/videos/video-list/video-sort.component.ts +++ b/client/app/videos/video-list/video-sort.component.ts | |||
@@ -26,7 +26,7 @@ export class VideoSortComponent { | |||
26 | return Object.keys(this.sortChoices); | 26 | return Object.keys(this.sortChoices); |
27 | } | 27 | } |
28 | 28 | ||
29 | getStringChoice(choiceKey: SortField): string { | 29 | getStringChoice(choiceKey: SortField) { |
30 | return this.sortChoices[choiceKey]; | 30 | return this.sortChoices[choiceKey]; |
31 | } | 31 | } |
32 | 32 | ||
diff --git a/client/app/videos/video-watch/video-watch.component.ts b/client/app/videos/video-watch/video-watch.component.ts index 891e6563f..c159b4004 100644 --- a/client/app/videos/video-watch/video-watch.component.ts +++ b/client/app/videos/video-watch/video-watch.component.ts | |||
@@ -23,21 +23,21 @@ export class VideoWatchComponent implements OnInit, CanDeactivate { | |||
23 | numPeers: number; | 23 | numPeers: number; |
24 | loading: boolean = false; | 24 | loading: boolean = false; |
25 | 25 | ||
26 | private _interval: NodeJS.Timer; | 26 | private interval: NodeJS.Timer; |
27 | private client: any; | 27 | private client: any; |
28 | 28 | ||
29 | constructor( | 29 | constructor( |
30 | private _videoService: VideoService, | 30 | private videoService: VideoService, |
31 | private _routeParams: RouteParams, | 31 | private routeParams: RouteParams, |
32 | private _elementRef: ElementRef | 32 | private elementRef: ElementRef |
33 | ) { | 33 | ) { |
34 | // TODO: use a service | 34 | // TODO: use a service |
35 | this.client = new WebTorrent({ dht: false }); | 35 | this.client = new WebTorrent({ dht: false }); |
36 | } | 36 | } |
37 | 37 | ||
38 | ngOnInit() { | 38 | ngOnInit() { |
39 | let id = this._routeParams.get('id'); | 39 | let id = this.routeParams.get('id'); |
40 | this._videoService.getVideo(id).subscribe( | 40 | this.videoService.getVideo(id).subscribe( |
41 | video => this.loadVideo(video), | 41 | video => this.loadVideo(video), |
42 | error => alert(error) | 42 | error => alert(error) |
43 | ); | 43 | ); |
@@ -50,7 +50,7 @@ export class VideoWatchComponent implements OnInit, CanDeactivate { | |||
50 | this.client.add(this.video.magnetUri, (torrent) => { | 50 | this.client.add(this.video.magnetUri, (torrent) => { |
51 | this.loading = false; | 51 | this.loading = false; |
52 | console.log('Added ' + this.video.magnetUri + '.'); | 52 | console.log('Added ' + this.video.magnetUri + '.'); |
53 | torrent.files[0].appendTo(this._elementRef.nativeElement.querySelector('.embed-responsive'), (err) => { | 53 | torrent.files[0].appendTo(this.elementRef.nativeElement.querySelector('.embed-responsive'), (err) => { |
54 | if (err) { | 54 | if (err) { |
55 | alert('Cannot append the file.'); | 55 | alert('Cannot append the file.'); |
56 | console.error(err); | 56 | console.error(err); |
@@ -58,7 +58,7 @@ export class VideoWatchComponent implements OnInit, CanDeactivate { | |||
58 | }); | 58 | }); |
59 | 59 | ||
60 | // Refresh each second | 60 | // Refresh each second |
61 | this._interval = setInterval(() => { | 61 | this.interval = setInterval(() => { |
62 | this.downloadSpeed = torrent.downloadSpeed; | 62 | this.downloadSpeed = torrent.downloadSpeed; |
63 | this.uploadSpeed = torrent.uploadSpeed; | 63 | this.uploadSpeed = torrent.uploadSpeed; |
64 | this.numPeers = torrent.numPeers; | 64 | this.numPeers = torrent.numPeers; |
@@ -66,9 +66,9 @@ export class VideoWatchComponent implements OnInit, CanDeactivate { | |||
66 | }); | 66 | }); |
67 | } | 67 | } |
68 | 68 | ||
69 | routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any { | 69 | routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) { |
70 | console.log('Removing video from webtorrent.'); | 70 | console.log('Removing video from webtorrent.'); |
71 | clearInterval(this._interval); | 71 | clearInterval(this.interval); |
72 | this.client.remove(this.video.magnetUri); | 72 | this.client.remove(this.video.magnetUri); |
73 | return true; | 73 | return true; |
74 | } | 74 | } |