1
0
Fork 0

Fix typings

This commit is contained in:
Chocobozzz 2018-05-16 11:00:57 +02:00
parent 1335920348
commit 5fcbd89841
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 17 additions and 11 deletions

View File

@ -22,7 +22,7 @@ export class FollowService {
let params = new HttpParams() let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort) params = this.restService.addRestGetParams(params, pagination, sort)
return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/following', { params }) return this.authHttp.get<ResultList<AccountFollow>>(FollowService.BASE_APPLICATION_URL + '/following', { params })
.pipe( .pipe(
map(res => this.restExtractor.convertResultListDateToHuman(res)), map(res => this.restExtractor.convertResultListDateToHuman(res)),
catchError(res => this.restExtractor.handleError(res)) catchError(res => this.restExtractor.handleError(res))

View File

@ -1,9 +1,10 @@
import { catchError, map } from 'rxjs/operators' import { catchError, map } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http' import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { UserCreate, UserUpdateMe } from '../../../../../shared' import { UserCreate, UserUpdateMe, UserVideoQuota } from '../../../../../shared'
import { environment } from '../../../environments/environment' import { environment } from '../../../environments/environment'
import { RestExtractor } from '../rest' import { RestExtractor } from '../rest'
import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
@Injectable() @Injectable()
export class UserService { export class UserService {
@ -41,7 +42,7 @@ export class UserService {
changeAvatar (avatarForm: FormData) { changeAvatar (avatarForm: FormData) {
const url = UserService.BASE_USERS_URL + 'me/avatar/pick' 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)) .pipe(catchError(this.restExtractor.handleError))
} }
@ -56,7 +57,7 @@ export class UserService {
getMyVideoQuotaUsed () { getMyVideoQuotaUsed () {
const url = UserService.BASE_USERS_URL + '/me/video-quota-used' const url = UserService.BASE_USERS_URL + '/me/video-quota-used'
return this.authHttp.get(url) return this.authHttp.get<UserVideoQuota>(url)
.pipe(catchError(res => this.restExtractor.handleError(res))) .pipe(catchError(res => this.restExtractor.handleError(res)))
} }

View File

@ -48,7 +48,7 @@ export class VideoService {
) )
} }
viewVideo (uuid: string): Observable<VideoDetails> { viewVideo (uuid: string): Observable<boolean> {
return this.authHttp.post(this.getVideoViewUrl(uuid), {}) return this.authHttp.post(this.getVideoViewUrl(uuid), {})
.pipe( .pipe(
map(this.restExtractor.extractDataBool), map(this.restExtractor.extractDataBool),
@ -92,7 +92,7 @@ export class VideoService {
const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true }) const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true })
return this.authHttp return this.authHttp
.request(req) .request<{ video: { id: number, uuid: string} }>(req)
.pipe(catchError(this.restExtractor.handleError)) .pipe(catchError(this.restExtractor.handleError))
} }
@ -265,11 +265,10 @@ export class VideoService {
return this.setVideoRate(id, 'none') return this.setVideoRate(id, 'none')
} }
getUserVideoRating (id: number): Observable<UserVideoRate> { getUserVideoRating (id: number) {
const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating' const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating'
return this.authHttp return this.authHttp.get<UserVideoRate>(url)
.get(url)
.pipe(catchError(res => this.restExtractor.handleError(res))) .pipe(catchError(res => this.restExtractor.handleError(res)))
} }

View File

@ -44,6 +44,7 @@ import { OAuthTokenModel } from '../../models/oauth/oauth-token'
import { VideoModel } from '../../models/video/video' import { VideoModel } from '../../models/video/video'
import { VideoSortField } from '../../../client/src/app/shared/video/sort-field.type' import { VideoSortField } from '../../../client/src/app/shared/video/sort-field.type'
import { createReqFiles } from '../../helpers/express-utils' 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 reqAvatarFile = createReqFiles([ 'avatarfile' ], IMAGE_MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.AVATARS_DIR })
const loginRateLimiter = new RateLimit({ 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 user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user) const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user)
return res.json({ const data: UserVideoQuota = {
videoQuotaUsed videoQuotaUsed
}) }
return res.json(data)
} }
function getUser (req: express.Request, res: express.Response, next: express.NextFunction) { function getUser (req: express.Request, res: express.Response, next: express.NextFunction) {

View File

@ -6,3 +6,4 @@ export * from './user-update.model'
export * from './user-update-me.model' export * from './user-update-me.model'
export * from './user-right.enum' export * from './user-right.enum'
export * from './user-role' export * from './user-role'
export * from './user-video-quota.model'

View File

@ -0,0 +1,3 @@
export interface UserVideoQuota {
videoQuotaUsed: number
}