From 5fcbd89841be29b373c6e4c8eeaa1f27414c8c7d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 16 May 2018 11:00:57 +0200 Subject: Fix typings --- client/src/app/+admin/follows/shared/follow.service.ts | 2 +- client/src/app/shared/users/user.service.ts | 7 ++++--- client/src/app/shared/video/video.service.ts | 9 ++++----- server/controllers/api/users.ts | 6 ++++-- shared/models/users/index.ts | 1 + shared/models/users/user-video-quota.model.ts | 3 +++ 6 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 shared/models/users/user-video-quota.model.ts diff --git a/client/src/app/+admin/follows/shared/follow.service.ts b/client/src/app/+admin/follows/shared/follow.service.ts index 5897e64ca..87ea5fb0c 100644 --- a/client/src/app/+admin/follows/shared/follow.service.ts +++ b/client/src/app/+admin/follows/shared/follow.service.ts @@ -22,7 +22,7 @@ export class FollowService { let params = new HttpParams() params = this.restService.addRestGetParams(params, pagination, sort) - return this.authHttp.get>(FollowService.BASE_APPLICATION_URL + '/following', { params }) + return this.authHttp.get>(FollowService.BASE_APPLICATION_URL + '/following', { params }) .pipe( map(res => this.restExtractor.convertResultListDateToHuman(res)), catchError(res => this.restExtractor.handleError(res)) diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts index 4843be618..9fe6c8b60 100644 --- a/client/src/app/shared/users/user.service.ts +++ b/client/src/app/shared/users/user.service.ts @@ -1,9 +1,10 @@ import { catchError, map } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' -import { UserCreate, UserUpdateMe } from '../../../../../shared' +import { UserCreate, UserUpdateMe, UserVideoQuota } from '../../../../../shared' import { environment } from '../../../environments/environment' import { RestExtractor } from '../rest' +import { Avatar } from '../../../../../shared/models/avatars/avatar.model' @Injectable() export class UserService { @@ -41,7 +42,7 @@ export class UserService { changeAvatar (avatarForm: FormData) { const url = UserService.BASE_USERS_URL + 'me/avatar/pick' - return this.authHttp.post(url, avatarForm) + return this.authHttp.post<{ avatar: Avatar }>(url, avatarForm) .pipe(catchError(this.restExtractor.handleError)) } @@ -56,7 +57,7 @@ export class UserService { getMyVideoQuotaUsed () { const url = UserService.BASE_USERS_URL + '/me/video-quota-used' - return this.authHttp.get(url) + return this.authHttp.get(url) .pipe(catchError(res => this.restExtractor.handleError(res))) } diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index f57cb6d6d..5b8e2467a 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts @@ -48,7 +48,7 @@ export class VideoService { ) } - viewVideo (uuid: string): Observable { + viewVideo (uuid: string): Observable { return this.authHttp.post(this.getVideoViewUrl(uuid), {}) .pipe( map(this.restExtractor.extractDataBool), @@ -92,7 +92,7 @@ export class VideoService { const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true }) return this.authHttp - .request(req) + .request<{ video: { id: number, uuid: string} }>(req) .pipe(catchError(this.restExtractor.handleError)) } @@ -265,11 +265,10 @@ export class VideoService { return this.setVideoRate(id, 'none') } - getUserVideoRating (id: number): Observable { + getUserVideoRating (id: number) { const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating' - return this.authHttp - .get(url) + return this.authHttp.get(url) .pipe(catchError(res => this.restExtractor.handleError(res))) } diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts index 2342c23dd..0a591f11d 100644 --- a/server/controllers/api/users.ts +++ b/server/controllers/api/users.ts @@ -44,6 +44,7 @@ import { OAuthTokenModel } from '../../models/oauth/oauth-token' import { VideoModel } from '../../models/video/video' import { VideoSortField } from '../../../client/src/app/shared/video/sort-field.type' import { createReqFiles } from '../../helpers/express-utils' +import { UserVideoQuota } from '../../../shared/models/users/user-video-quota.model' const reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR }) const loginRateLimiter = new RateLimit({ @@ -253,9 +254,10 @@ async function getUserVideoQuotaUsed (req: express.Request, res: express.Respons const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username) const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user) - return res.json({ + const data: UserVideoQuota = { videoQuotaUsed - }) + } + return res.json(data) } function getUser (req: express.Request, res: express.Response, next: express.NextFunction) { diff --git a/shared/models/users/index.ts b/shared/models/users/index.ts index a260bd380..15c2f99c2 100644 --- a/shared/models/users/index.ts +++ b/shared/models/users/index.ts @@ -6,3 +6,4 @@ export * from './user-update.model' export * from './user-update-me.model' export * from './user-right.enum' export * from './user-role' +export * from './user-video-quota.model' diff --git a/shared/models/users/user-video-quota.model.ts b/shared/models/users/user-video-quota.model.ts new file mode 100644 index 000000000..b856fd9fc --- /dev/null +++ b/shared/models/users/user-video-quota.model.ts @@ -0,0 +1,3 @@ +export interface UserVideoQuota { + videoQuotaUsed: number +} -- cgit v1.2.3