From d592e0a9b2931c7c9cbedb27fb8efc9aaacad9bb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Sep 2017 11:57:49 +0200 Subject: Move to HttpClient and PrimeNG data table --- client/src/app/videos/shared/index.ts | 1 + .../app/videos/shared/video-pagination.model.ts | 5 + client/src/app/videos/shared/video.model.ts | 4 +- client/src/app/videos/shared/video.service.ts | 111 +++++++++++---------- 4 files changed, 66 insertions(+), 55 deletions(-) create mode 100644 client/src/app/videos/shared/video-pagination.model.ts (limited to 'client/src/app/videos/shared') diff --git a/client/src/app/videos/shared/index.ts b/client/src/app/videos/shared/index.ts index 97d795321..8168e3bfd 100644 --- a/client/src/app/videos/shared/index.ts +++ b/client/src/app/videos/shared/index.ts @@ -1,3 +1,4 @@ export * from './sort-field.type' export * from './video.model' export * from './video.service' +export * from './video-pagination.model' diff --git a/client/src/app/videos/shared/video-pagination.model.ts b/client/src/app/videos/shared/video-pagination.model.ts new file mode 100644 index 000000000..9e71769cb --- /dev/null +++ b/client/src/app/videos/shared/video-pagination.model.ts @@ -0,0 +1,5 @@ +export interface VideoPagination { + currentPage: number + itemsPerPage: number + totalItems: number +} diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts index 1a413db9d..17f41059d 100644 --- a/client/src/app/videos/shared/video.model.ts +++ b/client/src/app/videos/shared/video.model.ts @@ -46,7 +46,7 @@ export class Video implements VideoServerModel { constructor (hash: { author: string, - createdAt: string, + createdAt: Date | string, categoryLabel: string, category: number, licenceLabel: string, @@ -70,7 +70,7 @@ export class Video implements VideoServerModel { files: VideoFile[] }) { this.author = hash.author - this.createdAt = new Date(hash.createdAt) + this.createdAt = new Date(hash.createdAt.toString()) this.categoryLabel = hash.categoryLabel this.category = hash.category this.licenceLabel = hash.licenceLabel diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts index 67091a8d8..b6d2a0666 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts @@ -1,27 +1,26 @@ import { Injectable } from '@angular/core' -import { Http, Headers, RequestOptions } from '@angular/http' import { Observable } from 'rxjs/Observable' import 'rxjs/add/operator/catch' import 'rxjs/add/operator/map' +import { HttpClient, HttpParams } from '@angular/common/http' import { Search } from '../../shared' import { SortField } from './sort-field.type' -import { AuthService } from '../../core' import { - AuthHttp, RestExtractor, - RestPagination, RestService, - ResultList, UserService } from '../../shared' import { Video } from './video.model' +import { VideoPagination } from './video-pagination.model' import { - UserVideoRate, - VideoRateType, - VideoUpdate, - VideoAbuseCreate, - UserVideoRateUpdate +UserVideoRate, +VideoRateType, +VideoUpdate, +VideoAbuseCreate, +UserVideoRateUpdate, +Video as VideoServerModel, +ResultList } from '../../../../../shared' @Injectable() @@ -33,9 +32,7 @@ export class VideoService { videoLanguages: Array<{ id: number, label: string }> = [] constructor ( - private authService: AuthService, - private authHttp: AuthHttp, - private http: Http, + private authHttp: HttpClient, private restExtractor: RestExtractor, private restService: RestService ) {} @@ -52,11 +49,10 @@ export class VideoService { return this.loadVideoAttributeEnum('languages', this.videoLanguages) } - getVideo (uuid: string): Observable