From 7da18e4420c4b71a8ecfda07f39324fbfec081c3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 9 Aug 2016 21:45:21 +0200 Subject: Client: add user management --- client/src/app/videos/video-list/video-list.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'client/src/app/videos') diff --git a/client/src/app/videos/video-list/video-list.component.ts b/client/src/app/videos/video-list/video-list.component.ts index 5691d684e..062340ec5 100644 --- a/client/src/app/videos/video-list/video-list.component.ts +++ b/client/src/app/videos/video-list/video-list.component.ts @@ -12,7 +12,7 @@ import { Video, VideoService } from '../shared'; -import { AuthService, Search, SearchField, User } from '../../shared'; +import { AuthService, AuthUser, Search, SearchField } from '../../shared'; import { VideoMiniatureComponent } from './video-miniature.component'; import { VideoSortComponent } from './video-sort.component'; import { SearchService } from '../../shared'; @@ -33,7 +33,7 @@ export class VideoListComponent implements OnInit, OnDestroy { totalItems: null }; sort: SortField; - user: User = null; + user: AuthUser = null; videos: Video[] = []; private search: Search; @@ -51,7 +51,7 @@ export class VideoListComponent implements OnInit, OnDestroy { ngOnInit() { if (this.authService.isLoggedIn()) { - this.user = User.load(); + this.user = AuthUser.load(); } // Subscribe to route changes -- cgit v1.2.3 From c323efb9cdc6a605242d112ac0c9db9f67eabaad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 12 Aug 2016 17:35:00 +0200 Subject: Update webtorrent -> 0.96 --- .../app/videos/video-watch/video-watch.component.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'client/src/app/videos') diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts index 09255de5d..bc0e3157d 100644 --- a/client/src/app/videos/video-watch/video-watch.component.ts +++ b/client/src/app/videos/video-watch/video-watch.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef, OnDestroy, OnInit } from '@angular/core'; +import { Component, ElementRef, NgZone, OnDestroy, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe'; @@ -31,6 +31,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { constructor( private elementRef: ElementRef, + private ngZone: NgZone, private route: ActivatedRoute, private videoService: VideoService, private webTorrentService: WebTorrentService @@ -65,12 +66,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } }); - // Refresh each second - this.torrentInfosInterval = setInterval(() => { - this.downloadSpeed = torrent.downloadSpeed; - this.numPeers = torrent.numPeers; - this.uploadSpeed = torrent.uploadSpeed; - }, 1000); + this.runInProgress(torrent); }); } @@ -99,4 +95,15 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.error = true; console.error('The video load seems to be abnormally long.'); } + + private runInProgress(torrent: any) { + // Refresh each second + this.torrentInfosInterval = setInterval(() => { + this.ngZone.run(() => { + this.downloadSpeed = torrent.downloadSpeed; + this.numPeers = torrent.numPeers; + this.uploadSpeed = torrent.uploadSpeed; + }); + }, 1000); + } } -- cgit v1.2.3 From 7eef95353f9202e1f3285606282fc8fd904c90ef Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 Aug 2016 19:05:52 +0200 Subject: Client: reset pagination when we search something --- client/src/app/videos/video-list/video-list.component.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'client/src/app/videos') diff --git a/client/src/app/videos/video-list/video-list.component.ts b/client/src/app/videos/video-list/video-list.component.ts index 062340ec5..7c6d4b992 100644 --- a/client/src/app/videos/video-list/video-list.component.ts +++ b/client/src/app/videos/video-list/video-list.component.ts @@ -66,6 +66,8 @@ export class VideoListComponent implements OnInit, OnDestroy { // Subscribe to search changes this.subSearch = this.searchService.searchUpdated.subscribe(search => { this.search = search; + // Reset pagination + this.pagination.currentPage = 1; this.navigateToNewParams(); }); @@ -76,7 +78,7 @@ export class VideoListComponent implements OnInit, OnDestroy { this.subSearch.unsubscribe(); } - getVideos(detectChanges = true) { + getVideos() { this.loading.next(true); this.videos = []; @@ -153,7 +155,11 @@ export class VideoListComponent implements OnInit, OnDestroy { this.sort = routeParams['sort'] || '-createdDate'; - this.pagination.currentPage = parseInt(routeParams['page']) || 1; + if (routeParams['page'] !== undefined) { + this.pagination.currentPage = parseInt(routeParams['page']); + } else { + this.pagination.currentPage = 1; + } this.changeDetector.detectChanges(); } -- cgit v1.2.3 From 0f6da32b148c0f4146b2ae9ad1add9a9f00cc339 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Aug 2016 14:37:49 +0200 Subject: Client: update to new form api --- client/src/app/videos/video-add/video-add.component.html | 14 +++++++------- client/src/app/videos/video-add/video-add.component.ts | 15 ++++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'client/src/app/videos') diff --git a/client/src/app/videos/video-add/video-add.component.html b/client/src/app/videos/video-add/video-add.component.html index bcd78c7cb..76bb61f7d 100644 --- a/client/src/app/videos/video-add/video-add.component.html +++ b/client/src/app/videos/video-add/video-add.component.html @@ -2,14 +2,14 @@
{{ error }}
-
+
-
+
A name is required and should be between 3 and 50 characters long
@@ -18,9 +18,9 @@ -
+
A tag should be between 2 and 10 characters (alphanumeric) long
@@ -54,10 +54,10 @@ -
+
A description is required and should be between 3 and 250 characters long
diff --git a/client/src/app/videos/video-add/video-add.component.ts b/client/src/app/videos/video-add/video-add.component.ts index c0f8cb9c4..900ef1da3 100644 --- a/client/src/app/videos/video-add/video-add.component.ts +++ b/client/src/app/videos/video-add/video-add.component.ts @@ -1,5 +1,6 @@ -import { Control, ControlGroup, Validators } from '@angular/common'; +import { Validators } from '@angular/common'; import { Component, ElementRef, OnInit } from '@angular/core'; +import { FormControl, FormGroup, REACTIVE_FORM_DIRECTIVES } from '@angular/forms'; import { Router } from '@angular/router'; import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe'; @@ -12,14 +13,14 @@ import { AuthService } from '../../shared'; selector: 'my-videos-add', styles: [ require('./video-add.component.scss') ], template: require('./video-add.component.html'), - directives: [ FileSelectDirective, PROGRESSBAR_DIRECTIVES ], + directives: [ FileSelectDirective, PROGRESSBAR_DIRECTIVES, REACTIVE_FORM_DIRECTIVES ], pipes: [ BytesPipe ] }) export class VideoAddComponent implements OnInit { currentTag: string; // Tag the user is writing in the input error: string = null; - videoForm: ControlGroup; + videoForm: FormGroup; uploader: FileUploader; video = { name: '', @@ -70,10 +71,10 @@ export class VideoAddComponent implements OnInit { } ngOnInit() { - this.videoForm = new ControlGroup({ - name: new Control('', Validators.compose([ Validators.required, Validators.minLength(3), Validators.maxLength(50) ])), - description: new Control('', Validators.compose([ Validators.required, Validators.minLength(3), Validators.maxLength(250) ])), - tags: new Control('', Validators.pattern('^[a-zA-Z0-9]{2,10}$')) + this.videoForm = new FormGroup({ + name: new FormControl('', [ Validators.required, Validators.minLength(3), Validators.maxLength(50) ]), + description: new FormControl('', [ Validators.required, Validators.minLength(3), Validators.maxLength(250) ]), + tags: new FormControl('', Validators.pattern('^[a-zA-Z0-9]{2,10}$')) }); -- cgit v1.2.3 From de59c48f5f317018e3f746bbe4a7b7efe00109f2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Aug 2016 16:54:21 +0200 Subject: Client: centralize http res extraction in a service --- client/src/app/videos/shared/index.ts | 1 - client/src/app/videos/shared/pagination.model.ts | 5 -- client/src/app/videos/shared/video.service.ts | 62 ++++++++-------------- .../app/videos/video-list/video-list.component.ts | 5 +- 4 files changed, 24 insertions(+), 49 deletions(-) delete mode 100644 client/src/app/videos/shared/pagination.model.ts (limited to 'client/src/app/videos') diff --git a/client/src/app/videos/shared/index.ts b/client/src/app/videos/shared/index.ts index a54120f5d..67d16ead1 100644 --- a/client/src/app/videos/shared/index.ts +++ b/client/src/app/videos/shared/index.ts @@ -1,5 +1,4 @@ export * from './loader'; -export * from './pagination.model'; export * from './sort-field.type'; export * from './video.model'; export * from './video.service'; diff --git a/client/src/app/videos/shared/pagination.model.ts b/client/src/app/videos/shared/pagination.model.ts deleted file mode 100644 index eda44ebfb..000000000 --- a/client/src/app/videos/shared/pagination.model.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface Pagination { - currentPage: number; - itemsPerPage: number; - totalItems: number; -} diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts index b4396f767..ad8557533 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts @@ -1,11 +1,10 @@ import { Injectable } from '@angular/core'; -import { Http, Response, URLSearchParams } from '@angular/http'; +import { Http } from '@angular/http'; import { Observable } from 'rxjs/Observable'; -import { Pagination } from './pagination.model'; import { Search } from '../../shared'; import { SortField } from './sort-field.type'; -import { AuthHttp, AuthService } from '../../shared'; +import { AuthHttp, AuthService, RestExtractor, RestPagination, RestService, ResultList } from '../../shared'; import { Video } from './video.model'; @Injectable() @@ -15,68 +14,51 @@ export class VideoService { constructor( private authService: AuthService, private authHttp: AuthHttp, - private http: Http + private http: Http, + private restExtractor: RestExtractor, + private restService: RestService ) {} - getVideo(id: string) { + getVideo(id: string): Observable