Fix typings
authorChocobozzz <me@florianbigard.com>
Wed, 16 May 2018 09:00:57 +0000 (11:00 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 16 May 2018 09:06:33 +0000 (11:06 +0200)
client/src/app/+admin/follows/shared/follow.service.ts
client/src/app/shared/users/user.service.ts
client/src/app/shared/video/video.service.ts
server/controllers/api/users.ts
shared/models/users/index.ts
shared/models/users/user-video-quota.model.ts [new file with mode: 0644]

index 5897e64cabd22a70a692d521812375ed8da38c6b..87ea5fb0c69362e41c09bd679d4d996ce2e4eac3 100644 (file)
@@ -22,7 +22,7 @@ export class FollowService {
     let params = new HttpParams()
     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(
                  map(res => this.restExtractor.convertResultListDateToHuman(res)),
                  catchError(res => this.restExtractor.handleError(res))
index 4843be618e3bbe1d07179ad42d97b315af65e0ef..9fe6c8b603621ef10c0caca2dfc160844dfca1be 100644 (file)
@@ -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<UserVideoQuota>(url)
                .pipe(catchError(res => this.restExtractor.handleError(res)))
   }
 
index f57cb6d6d8bca820924679a4fb41b7b944452d67..5b8e2467a6c5eb8e9d29f47b13b6a1992b4c7324 100644 (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), {})
                .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<UserVideoRate> {
+  getUserVideoRating (id: number) {
     const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating'
 
-    return this.authHttp
-               .get(url)
+    return this.authHttp.get<UserVideoRate>(url)
                .pipe(catchError(res => this.restExtractor.handleError(res)))
   }
 
index 2342c23dd683b809ba9db028907033cb382ed04d..0a591f11dd121866f373df7a18a8cf89d1994718 100644 (file)
@@ -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) {
index a260bd38058bc288999c969b01ce1d151357b24e..15c2f99c204f3a1dea66f19a6730020e9a3b80ef 100644 (file)
@@ -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 (file)
index 0000000..b856fd9
--- /dev/null
@@ -0,0 +1,3 @@
+export interface UserVideoQuota {
+  videoQuotaUsed: number
+}