diff options
30 files changed, 89 insertions, 61 deletions
diff --git a/client/src/app/+admin/friends/friend-list/friend-list.component.ts b/client/src/app/+admin/friends/friend-list/friend-list.component.ts index 7bf9d2c6b..9f0256d7f 100644 --- a/client/src/app/+admin/friends/friend-list/friend-list.component.ts +++ b/client/src/app/+admin/friends/friend-list/friend-list.component.ts | |||
@@ -5,7 +5,7 @@ import { ServerDataSource } from 'ng2-smart-table' | |||
5 | 5 | ||
6 | import { ConfirmService } from '../../../core' | 6 | import { ConfirmService } from '../../../core' |
7 | import { Utils } from '../../../shared' | 7 | import { Utils } from '../../../shared' |
8 | import { Friend, FriendService } from '../shared' | 8 | import { FriendService } from '../shared' |
9 | 9 | ||
10 | @Component({ | 10 | @Component({ |
11 | selector: 'my-friend-list', | 11 | selector: 'my-friend-list', |
diff --git a/client/src/app/+admin/friends/shared/friend.model.ts b/client/src/app/+admin/friends/shared/friend.model.ts deleted file mode 100644 index 6950405b9..000000000 --- a/client/src/app/+admin/friends/shared/friend.model.ts +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | export interface Friend { | ||
2 | id: string | ||
3 | host: string | ||
4 | score: number | ||
5 | email: string | ||
6 | createdAt: Date | ||
7 | } | ||
diff --git a/client/src/app/+admin/friends/shared/friend.service.ts b/client/src/app/+admin/friends/shared/friend.service.ts index f4ecd36ad..79de4470e 100644 --- a/client/src/app/+admin/friends/shared/friend.service.ts +++ b/client/src/app/+admin/friends/shared/friend.service.ts | |||
@@ -5,7 +5,6 @@ import 'rxjs/add/operator/map' | |||
5 | 5 | ||
6 | import { ServerDataSource } from 'ng2-smart-table' | 6 | import { ServerDataSource } from 'ng2-smart-table' |
7 | 7 | ||
8 | import { Friend } from './friend.model' | ||
9 | import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared' | 8 | import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared' |
10 | 9 | ||
11 | @Injectable() | 10 | @Injectable() |
diff --git a/client/src/app/+admin/requests/request-stats/request-stats.component.ts b/client/src/app/+admin/requests/request-stats/request-stats.component.ts index cca4926cf..140aaf47e 100644 --- a/client/src/app/+admin/requests/request-stats/request-stats.component.ts +++ b/client/src/app/+admin/requests/request-stats/request-stats.component.ts | |||
@@ -2,7 +2,8 @@ import { Component, OnInit, OnDestroy } from '@angular/core' | |||
2 | 2 | ||
3 | import { NotificationsService } from 'angular2-notifications' | 3 | import { NotificationsService } from 'angular2-notifications' |
4 | 4 | ||
5 | import { RequestService, RequestStats } from '../shared' | 5 | import { RequestService, RequestSchedulerStatsAttributes } from '../shared' |
6 | import { RequestScheduler } from '../../../../../../shared' | ||
6 | 7 | ||
7 | @Component({ | 8 | @Component({ |
8 | selector: 'my-request-stats', | 9 | selector: 'my-request-stats', |
@@ -16,11 +17,7 @@ export class RequestStatsComponent implements OnInit, OnDestroy { | |||
16 | requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler' | 17 | requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler' |
17 | } | 18 | } |
18 | 19 | ||
19 | stats: { [ id: string ]: RequestStats } = { | 20 | stats: RequestScheduler |
20 | requestScheduler: null, | ||
21 | requestVideoEventScheduler: null, | ||
22 | requestVideoQaduScheduler: null | ||
23 | } | ||
24 | 21 | ||
25 | private intervals: { [ id: string ]: number } = { | 22 | private intervals: { [ id: string ]: number } = { |
26 | requestScheduler: null, | 23 | requestScheduler: null, |
@@ -67,7 +64,7 @@ export class RequestStatsComponent implements OnInit, OnDestroy { | |||
67 | private runIntervals () { | 64 | private runIntervals () { |
68 | Object.keys(this.intervals).forEach(requestSchedulerName => { | 65 | Object.keys(this.intervals).forEach(requestSchedulerName => { |
69 | this.intervals[requestSchedulerName] = window.setInterval(() => { | 66 | this.intervals[requestSchedulerName] = window.setInterval(() => { |
70 | const stats = this.stats[requestSchedulerName] | 67 | const stats: RequestSchedulerStatsAttributes = this.stats[requestSchedulerName] |
71 | 68 | ||
72 | stats.remainingMilliSeconds -= 1000 | 69 | stats.remainingMilliSeconds -= 1000 |
73 | 70 | ||
diff --git a/client/src/app/+admin/requests/shared/index.ts b/client/src/app/+admin/requests/shared/index.ts index 2442e810a..857fe9d29 100644 --- a/client/src/app/+admin/requests/shared/index.ts +++ b/client/src/app/+admin/requests/shared/index.ts | |||
@@ -1,2 +1,2 @@ | |||
1 | export * from './request-stats.model' | 1 | export * from './request-stats-attributes.model' |
2 | export * from './request.service' | 2 | export * from './request.service' |
diff --git a/client/src/app/+admin/requests/shared/request-stats.model.ts b/client/src/app/+admin/requests/shared/request-stats-attributes.model.ts index 31550b5c0..394acc73d 100644 --- a/client/src/app/+admin/requests/shared/request-stats.model.ts +++ b/client/src/app/+admin/requests/shared/request-stats-attributes.model.ts | |||
@@ -1,9 +1,11 @@ | |||
1 | import { RequestSchedulerAttributes as FormatedRequestSchedulerAttributes } from '../../../../../../shared' | ||
2 | |||
1 | export interface Request { | 3 | export interface Request { |
2 | request: any | 4 | request: any |
3 | to: any | 5 | to: any |
4 | } | 6 | } |
5 | 7 | ||
6 | export class RequestStats { | 8 | export class RequestSchedulerStatsAttributes implements FormatedRequestSchedulerAttributes { |
7 | requestsLimitPods: number | 9 | requestsLimitPods: number |
8 | requestsLimitPerPod: number | 10 | requestsLimitPerPod: number |
9 | milliSecondsInterval: number | 11 | milliSecondsInterval: number |
diff --git a/client/src/app/+admin/requests/shared/request.service.ts b/client/src/app/+admin/requests/shared/request.service.ts index faa6b9383..53682b111 100644 --- a/client/src/app/+admin/requests/shared/request.service.ts +++ b/client/src/app/+admin/requests/shared/request.service.ts | |||
@@ -3,8 +3,9 @@ import { Observable } from 'rxjs/Observable' | |||
3 | import 'rxjs/add/operator/catch' | 3 | import 'rxjs/add/operator/catch' |
4 | import 'rxjs/add/operator/map' | 4 | import 'rxjs/add/operator/map' |
5 | 5 | ||
6 | import { RequestStats } from './request-stats.model' | 6 | import { RequestScheduler } from '../../../../../../shared' |
7 | import { AuthHttp, RestExtractor } from '../../../shared' | 7 | import { AuthHttp, RestExtractor } from '../../../shared' |
8 | import { RequestSchedulerStatsAttributes } from './request-stats-attributes.model' | ||
8 | 9 | ||
9 | @Injectable() | 10 | @Injectable() |
10 | export class RequestService { | 11 | export class RequestService { |
@@ -15,18 +16,18 @@ export class RequestService { | |||
15 | private restExtractor: RestExtractor | 16 | private restExtractor: RestExtractor |
16 | ) {} | 17 | ) {} |
17 | 18 | ||
18 | getStats (): Observable<{ [ id: string ]: RequestStats }> { | 19 | getStats (): Observable<RequestScheduler> { |
19 | return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats') | 20 | return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats') |
20 | .map(this.restExtractor.extractDataGet) | 21 | .map(this.restExtractor.extractDataGet) |
21 | .map(this.buildRequestObjects) | 22 | .map(this.buildRequestObjects) |
22 | .catch((res) => this.restExtractor.handleError(res)) | 23 | .catch((res) => this.restExtractor.handleError(res)) |
23 | } | 24 | } |
24 | 25 | ||
25 | private buildRequestObjects (data: any) { | 26 | private buildRequestObjects (data: RequestScheduler) { |
26 | const requestSchedulers = {} | 27 | const requestSchedulers = {} |
27 | 28 | ||
28 | Object.keys(data).forEach(requestSchedulerName => { | 29 | Object.keys(data).forEach(requestSchedulerName => { |
29 | requestSchedulers[requestSchedulerName] = new RequestStats(data[requestSchedulerName]) | 30 | requestSchedulers[requestSchedulerName] = new RequestSchedulerStatsAttributes(data[requestSchedulerName]) |
30 | }) | 31 | }) |
31 | 32 | ||
32 | return requestSchedulers | 33 | return requestSchedulers |
diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts index 60eaebb44..7c838fbf0 100644 --- a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts +++ b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts | |||
@@ -2,7 +2,8 @@ import { Component } from '@angular/core' | |||
2 | 2 | ||
3 | import { NotificationsService } from 'angular2-notifications' | 3 | import { NotificationsService } from 'angular2-notifications' |
4 | 4 | ||
5 | import { Utils, VideoAbuseService, VideoAbuse } from '../../../shared' | 5 | import { Utils, VideoAbuseService } from '../../../shared' |
6 | import { VideoAbuse } from '../../../../../shared' | ||
6 | 7 | ||
7 | @Component({ | 8 | @Component({ |
8 | selector: 'my-video-abuse-list', | 9 | selector: 'my-video-abuse-list', |
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 32f7a5503..fcc6b9bb6 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -11,6 +11,7 @@ import { NotificationsService } from 'angular2-notifications' | |||
11 | 11 | ||
12 | import { AuthStatus } from './auth-status.model' | 12 | import { AuthStatus } from './auth-status.model' |
13 | import { AuthUser } from './auth-user.model' | 13 | import { AuthUser } from './auth-user.model' |
14 | import { ClientLocal } from '../../../../../shared' | ||
14 | // Do not use the barrel (dependency loop) | 15 | // Do not use the barrel (dependency loop) |
15 | import { RestExtractor } from '../../shared/rest' | 16 | import { RestExtractor } from '../../shared/rest' |
16 | 17 | ||
@@ -40,9 +41,9 @@ export class AuthService { | |||
40 | // FIXME: save in local storage? | 41 | // FIXME: save in local storage? |
41 | this.http.get(AuthService.BASE_CLIENT_URL) | 42 | this.http.get(AuthService.BASE_CLIENT_URL) |
42 | .map(this.restExtractor.extractDataGet) | 43 | .map(this.restExtractor.extractDataGet) |
43 | .catch((res) => this.restExtractor.handleError(res)) | 44 | .catch(res => this.restExtractor.handleError(res)) |
44 | .subscribe( | 45 | .subscribe( |
45 | result => { | 46 | (result: ClientLocal) => { |
46 | this.clientId = result.client_id | 47 | this.clientId = result.client_id |
47 | this.clientSecret = result.client_secret | 48 | this.clientSecret = result.client_secret |
48 | console.log('Client credentials loaded.') | 49 | console.log('Client credentials loaded.') |
diff --git a/client/src/app/core/config/config.service.ts b/client/src/app/core/config/config.service.ts index a83ec61d2..b8cb15e84 100644 --- a/client/src/app/core/config/config.service.ts +++ b/client/src/app/core/config/config.service.ts | |||
@@ -2,16 +2,13 @@ import { Injectable } from '@angular/core' | |||
2 | import { Http } from '@angular/http' | 2 | import { Http } from '@angular/http' |
3 | 3 | ||
4 | import { RestExtractor } from '../../shared/rest' | 4 | import { RestExtractor } from '../../shared/rest' |
5 | import { ServerConfig } from '../../../../../shared' | ||
5 | 6 | ||
6 | @Injectable() | 7 | @Injectable() |
7 | export class ConfigService { | 8 | export class ConfigService { |
8 | private static BASE_CONFIG_URL = API_URL + '/api/v1/config/' | 9 | private static BASE_CONFIG_URL = API_URL + '/api/v1/config/' |
9 | 10 | ||
10 | private config: { | 11 | private config: ServerConfig = { |
11 | signup: { | ||
12 | enabled: boolean | ||
13 | } | ||
14 | } = { | ||
15 | signup: { | 12 | signup: { |
16 | enabled: false | 13 | enabled: false |
17 | } | 14 | } |
diff --git a/client/src/app/shared/video-abuse/video-abuse.model.ts b/client/src/app/shared/video-abuse/video-abuse.model.ts deleted file mode 100644 index 49c87d6b8..000000000 --- a/client/src/app/shared/video-abuse/video-abuse.model.ts +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | export interface VideoAbuse { | ||
2 | id: string | ||
3 | reason: string | ||
4 | reporterPodHost: string | ||
5 | reporterUsername: string | ||
6 | videoId: string | ||
7 | createdAt: Date | ||
8 | } | ||
diff --git a/client/src/app/shared/video-abuse/video-abuse.service.ts b/client/src/app/shared/video-abuse/video-abuse.service.ts index 4317f9353..32f13b430 100644 --- a/client/src/app/shared/video-abuse/video-abuse.service.ts +++ b/client/src/app/shared/video-abuse/video-abuse.service.ts | |||
@@ -7,7 +7,7 @@ import 'rxjs/add/operator/map' | |||
7 | import { AuthService } from '../core' | 7 | import { AuthService } from '../core' |
8 | import { AuthHttp } from '../auth' | 8 | import { AuthHttp } from '../auth' |
9 | import { RestDataSource, RestExtractor, ResultList } from '../rest' | 9 | import { RestDataSource, RestExtractor, ResultList } from '../rest' |
10 | import { VideoAbuse } from './video-abuse.model' | 10 | import { VideoAbuse } from '../../../../../shared' |
11 | 11 | ||
12 | @Injectable() | 12 | @Injectable() |
13 | export class VideoAbuseService { | 13 | export class VideoAbuseService { |
diff --git a/client/src/app/videos/shared/rate-type.type.ts b/client/src/app/videos/shared/rate-type.type.ts deleted file mode 100644 index 20eea3ae5..000000000 --- a/client/src/app/videos/shared/rate-type.type.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export type RateType = 'like' | 'dislike' | ||
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts index a4e3d16df..977b82118 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts | |||
@@ -6,7 +6,6 @@ import 'rxjs/add/operator/map' | |||
6 | 6 | ||
7 | import { Search } from '../../shared' | 7 | import { Search } from '../../shared' |
8 | import { SortField } from './sort-field.type' | 8 | import { SortField } from './sort-field.type' |
9 | import { RateType } from './rate-type.type' | ||
10 | import { AuthService } from '../../core' | 9 | import { AuthService } from '../../core' |
11 | import { | 10 | import { |
12 | AuthHttp, | 11 | AuthHttp, |
@@ -17,6 +16,7 @@ import { | |||
17 | UserService | 16 | UserService |
18 | } from '../../shared' | 17 | } from '../../shared' |
19 | import { Video } from './video.model' | 18 | import { Video } from './video.model' |
19 | import { VideoRateType } from '../../../../../shared' | ||
20 | 20 | ||
21 | @Injectable() | 21 | @Injectable() |
22 | export class VideoService { | 22 | export class VideoService { |
@@ -145,7 +145,7 @@ export class VideoService { | |||
145 | return this.setVideoRate(id, 'dislike') | 145 | return this.setVideoRate(id, 'dislike') |
146 | } | 146 | } |
147 | 147 | ||
148 | getUserVideoRating (id: string) { | 148 | getUserVideoRating (id: string): Observable<VideoRateType> { |
149 | const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating' | 149 | const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating' |
150 | 150 | ||
151 | return this.authHttp.get(url) | 151 | return this.authHttp.get(url) |
@@ -159,7 +159,7 @@ export class VideoService { | |||
159 | .catch((res) => this.restExtractor.handleError(res)) | 159 | .catch((res) => this.restExtractor.handleError(res)) |
160 | } | 160 | } |
161 | 161 | ||
162 | private setVideoRate (id: string, rateType: RateType) { | 162 | private setVideoRate (id: string, rateType: VideoRateType) { |
163 | const url = VideoService.BASE_VIDEO_URL + id + '/rate' | 163 | const url = VideoService.BASE_VIDEO_URL + id + '/rate' |
164 | const body = { | 164 | const body = { |
165 | rating: rateType | 165 | rating: rateType |
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 4a547f7e4..808e0eda9 100644 --- a/client/src/app/videos/video-watch/video-watch.component.ts +++ b/client/src/app/videos/video-watch/video-watch.component.ts | |||
@@ -11,15 +11,15 @@ import { AuthService, ConfirmService } from '../../core' | |||
11 | import { VideoMagnetComponent } from './video-magnet.component' | 11 | import { VideoMagnetComponent } from './video-magnet.component' |
12 | import { VideoShareComponent } from './video-share.component' | 12 | import { VideoShareComponent } from './video-share.component' |
13 | import { VideoReportComponent } from './video-report.component' | 13 | import { VideoReportComponent } from './video-report.component' |
14 | import { RateType, Video, VideoService } from '../shared' | 14 | import { Video, VideoService } from '../shared' |
15 | import { WebTorrentService } from './webtorrent.service' | 15 | import { WebTorrentService } from './webtorrent.service' |
16 | import { UserVideoRateType, VideoRateType, UserVideoRate } from '../../../../../shared' | ||
16 | 17 | ||
17 | @Component({ | 18 | @Component({ |
18 | selector: 'my-video-watch', | 19 | selector: 'my-video-watch', |
19 | templateUrl: './video-watch.component.html', | 20 | templateUrl: './video-watch.component.html', |
20 | styleUrls: [ './video-watch.component.scss' ] | 21 | styleUrls: [ './video-watch.component.scss' ] |
21 | }) | 22 | }) |
22 | |||
23 | export class VideoWatchComponent implements OnInit, OnDestroy { | 23 | export class VideoWatchComponent implements OnInit, OnDestroy { |
24 | private static LOADTIME_TOO_LONG = 20000 | 24 | private static LOADTIME_TOO_LONG = 20000 |
25 | 25 | ||
@@ -34,7 +34,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
34 | player: videojs.Player | 34 | player: videojs.Player |
35 | playerElement: Element | 35 | playerElement: Element |
36 | uploadSpeed: number | 36 | uploadSpeed: number |
37 | userRating: RateType = null | 37 | userRating: UserVideoRateType = null |
38 | video: Video = null | 38 | video: Video = null |
39 | videoNotFound = false | 39 | videoNotFound = false |
40 | 40 | ||
@@ -249,7 +249,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
249 | 249 | ||
250 | this.videoService.getUserVideoRating(this.video.id) | 250 | this.videoService.getUserVideoRating(this.video.id) |
251 | .subscribe( | 251 | .subscribe( |
252 | ratingObject => { | 252 | (ratingObject: UserVideoRate) => { |
253 | if (ratingObject) { | 253 | if (ratingObject) { |
254 | this.userRating = ratingObject.rating | 254 | this.userRating = ratingObject.rating |
255 | } | 255 | } |
@@ -282,7 +282,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
282 | ) | 282 | ) |
283 | } | 283 | } |
284 | 284 | ||
285 | private updateVideoRating (oldRating: RateType, newRating: RateType) { | 285 | private updateVideoRating (oldRating: UserVideoRateType, newRating: VideoRateType) { |
286 | let likesToIncrement = 0 | 286 | let likesToIncrement = 0 |
287 | let dislikesToIncrement = 0 | 287 | let dislikesToIncrement = 0 |
288 | 288 | ||
diff --git a/server/controllers/api/clients.ts b/server/controllers/api/clients.ts index 8c460096b..96490d04a 100644 --- a/server/controllers/api/clients.ts +++ b/server/controllers/api/clients.ts | |||
@@ -3,6 +3,7 @@ import * as express from 'express' | |||
3 | import { CONFIG } from '../../initializers' | 3 | import { CONFIG } from '../../initializers' |
4 | import { logger } from '../../helpers' | 4 | import { logger } from '../../helpers' |
5 | import { database as db } from '../../initializers/database' | 5 | import { database as db } from '../../initializers/database' |
6 | import { ClientLocal } from '../../../shared' | ||
6 | 7 | ||
7 | const clientsRouter = express.Router() | 8 | const clientsRouter = express.Router() |
8 | 9 | ||
@@ -27,10 +28,11 @@ function getLocalClient (req: express.Request, res: express.Response, next: expr | |||
27 | if (err) return next(err) | 28 | if (err) return next(err) |
28 | if (!client) return next(new Error('No client available.')) | 29 | if (!client) return next(new Error('No client available.')) |
29 | 30 | ||
30 | res.json({ | 31 | const json: ClientLocal = { |
31 | client_id: client.clientId, | 32 | client_id: client.clientId, |
32 | client_secret: client.clientSecret | 33 | client_secret: client.clientSecret |
33 | }) | 34 | } |
35 | res.json(json) | ||
34 | }) | 36 | }) |
35 | } | 37 | } |
36 | 38 | ||
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index c63981797..3e9aa77a5 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | 2 | ||
3 | import { CONFIG } from '../../initializers' | 3 | import { CONFIG } from '../../initializers' |
4 | import { ServerConfig } from '../../../shared' | ||
4 | 5 | ||
5 | const configRouter = express.Router() | 6 | const configRouter = express.Router() |
6 | 7 | ||
@@ -8,11 +9,12 @@ configRouter.get('/', getConfig) | |||
8 | 9 | ||
9 | // Get the client credentials for the PeerTube front end | 10 | // Get the client credentials for the PeerTube front end |
10 | function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { | 11 | function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { |
11 | res.json({ | 12 | const json: ServerConfig = { |
12 | signup: { | 13 | signup: { |
13 | enabled: CONFIG.SIGNUP.ENABLED | 14 | enabled: CONFIG.SIGNUP.ENABLED |
14 | } | 15 | } |
15 | }) | 16 | } |
17 | res.json(json) | ||
16 | } | 18 | } |
17 | 19 | ||
18 | // --------------------------------------------------------------------------- | 20 | // --------------------------------------------------------------------------- |
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts index ffe5881e5..1e9e65689 100644 --- a/server/controllers/api/users.ts +++ b/server/controllers/api/users.ts | |||
@@ -17,6 +17,7 @@ import { | |||
17 | setUsersSort, | 17 | setUsersSort, |
18 | token | 18 | token |
19 | } from '../../middlewares' | 19 | } from '../../middlewares' |
20 | import { UserVideoRate as FormatedUserVideoRate } from '../../../shared' | ||
20 | 21 | ||
21 | const usersRouter = express.Router() | 22 | const usersRouter = express.Router() |
22 | 23 | ||
@@ -119,10 +120,11 @@ function getUserVideoRating (req: express.Request, res: express.Response, next: | |||
119 | 120 | ||
120 | const rating = ratingObj ? ratingObj.type : 'none' | 121 | const rating = ratingObj ? ratingObj.type : 'none' |
121 | 122 | ||
122 | res.json({ | 123 | const json: FormatedUserVideoRate = { |
123 | videoId, | 124 | videoId, |
124 | rating | 125 | rating |
125 | }) | 126 | } |
127 | res.json(json) | ||
126 | }) | 128 | }) |
127 | } | 129 | } |
128 | 130 | ||
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 07c1b3f51..5b8d21f70 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -22,8 +22,12 @@ function createEmptyCallback () { | |||
22 | } | 22 | } |
23 | } | 23 | } |
24 | 24 | ||
25 | function getFormatedObjects (objects: any[], objectsTotal: number) { | 25 | interface FormatableToJSON { |
26 | const formatedObjects = [] | 26 | toFormatedJSON() |
27 | } | ||
28 | |||
29 | function getFormatedObjects<U, T extends FormatableToJSON> (objects: T[], objectsTotal: number) { | ||
30 | const formatedObjects: U[] = [] | ||
27 | 31 | ||
28 | objects.forEach(function (object) { | 32 | objects.forEach(function (object) { |
29 | formatedObjects.push(object.toFormatedJSON()) | 33 | formatedObjects.push(object.toFormatedJSON()) |
diff --git a/server/models/user/user-interface.ts b/server/models/user/user-interface.ts index fd98a042e..48c67678b 100644 --- a/server/models/user/user-interface.ts +++ b/server/models/user/user-interface.ts | |||
@@ -58,6 +58,10 @@ export interface UserInstance extends UserClass, UserAttributes, Sequelize.Insta | |||
58 | id: number | 58 | id: number |
59 | createdAt: Date | 59 | createdAt: Date |
60 | updatedAt: Date | 60 | updatedAt: Date |
61 | |||
62 | isPasswordMatch: UserMethods.IsPasswordMatch | ||
63 | toFormatedJSON: UserMethods.ToFormatedJSON | ||
64 | isAdmin: UserMethods.IsAdmin | ||
61 | } | 65 | } |
62 | 66 | ||
63 | export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {} | 67 | export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {} |
diff --git a/server/models/user/user-video-rate.ts b/server/models/user/user-video-rate.ts index 1094eb281..4bdd35bc9 100644 --- a/server/models/user/user-video-rate.ts +++ b/server/models/user/user-video-rate.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | User rates per video. | 2 | User rates per video. |
3 | |||
4 | */ | 3 | */ |
5 | import { values } from 'lodash' | 4 | import { values } from 'lodash' |
6 | import * as Sequelize from 'sequelize' | 5 | import * as Sequelize from 'sequelize' |
diff --git a/server/models/video/video-abuse-interface.ts b/server/models/video/video-abuse-interface.ts index f3e32f79c..c85d09091 100644 --- a/server/models/video/video-abuse-interface.ts +++ b/server/models/video/video-abuse-interface.ts | |||
@@ -6,7 +6,7 @@ import { PodInstance } from '../pod' | |||
6 | import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model' | 6 | import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model' |
7 | 7 | ||
8 | export namespace VideoAbuseMethods { | 8 | export namespace VideoAbuseMethods { |
9 | export type toFormatedJSON = () => FormatedVideoAbuse | 9 | export type ToFormatedJSON = (this: VideoAbuseInstance) => FormatedVideoAbuse |
10 | 10 | ||
11 | export type ListForApiCallback = (err: Error, videoAbuseInstances?: VideoAbuseInstance[], total?: number) => void | 11 | export type ListForApiCallback = (err: Error, videoAbuseInstances?: VideoAbuseInstance[], total?: number) => void |
12 | export type ListForApi = (start: number, count: number, sort: string, callback: ListForApiCallback) => void | 12 | export type ListForApi = (start: number, count: number, sort: string, callback: ListForApiCallback) => void |
@@ -28,6 +28,8 @@ export interface VideoAbuseInstance extends VideoAbuseClass, VideoAbuseAttribute | |||
28 | updatedAt: Date | 28 | updatedAt: Date |
29 | 29 | ||
30 | Pod: PodInstance | 30 | Pod: PodInstance |
31 | |||
32 | toFormatedJSON: VideoAbuseMethods.ToFormatedJSON | ||
31 | } | 33 | } |
32 | 34 | ||
33 | export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {} | 35 | export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {} |
diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts index f5b4debe6..bc5f01e21 100644 --- a/server/models/video/video-abuse.ts +++ b/server/models/video/video-abuse.ts | |||
@@ -13,6 +13,7 @@ import { | |||
13 | } from './video-abuse-interface' | 13 | } from './video-abuse-interface' |
14 | 14 | ||
15 | let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> | 15 | let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> |
16 | let toFormatedJSON: VideoAbuseMethods.ToFormatedJSON | ||
16 | let listForApi: VideoAbuseMethods.ListForApi | 17 | let listForApi: VideoAbuseMethods.ListForApi |
17 | 18 | ||
18 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { | 19 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { |
@@ -66,7 +67,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
66 | 67 | ||
67 | // ------------------------------ METHODS ------------------------------ | 68 | // ------------------------------ METHODS ------------------------------ |
68 | 69 | ||
69 | function toFormatedJSON (this: VideoAbuseInstance) { | 70 | toFormatedJSON = function (this: VideoAbuseInstance) { |
70 | let reporterPodHost | 71 | let reporterPodHost |
71 | 72 | ||
72 | if (this.Pod) { | 73 | if (this.Pod) { |
@@ -108,7 +109,7 @@ function associate (models) { | |||
108 | }) | 109 | }) |
109 | } | 110 | } |
110 | 111 | ||
111 | listForApi = function (start, count, sort, callback) { | 112 | listForApi = function (start: number, count: number, sort: string, callback: VideoAbuseMethods.ListForApiCallback) { |
112 | const query = { | 113 | const query = { |
113 | offset: start, | 114 | offset: start, |
114 | limit: count, | 115 | limit: count, |
diff --git a/server/models/video/video-blacklist-interface.ts b/server/models/video/video-blacklist-interface.ts index c34e7fb09..d4d6528d1 100644 --- a/server/models/video/video-blacklist-interface.ts +++ b/server/models/video/video-blacklist-interface.ts | |||
@@ -39,6 +39,8 @@ export interface BlacklistedVideoInstance extends BlacklistedVideoClass, Blackli | |||
39 | id: number | 39 | id: number |
40 | createdAt: Date | 40 | createdAt: Date |
41 | updatedAt: Date | 41 | updatedAt: Date |
42 | |||
43 | toFormatedJSON: BlacklistedVideoMethods.ToFormatedJSON | ||
42 | } | 44 | } |
43 | 45 | ||
44 | export interface BlacklistedVideoModel extends BlacklistedVideoClass, Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes> {} | 46 | export interface BlacklistedVideoModel extends BlacklistedVideoClass, Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes> {} |
diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts index 5fefc2bb1..4b591b9e7 100644 --- a/server/models/video/video-interface.ts +++ b/server/models/video/video-interface.ts | |||
@@ -146,6 +146,17 @@ export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.In | |||
146 | id: string | 146 | id: string |
147 | createdAt: Date | 147 | createdAt: Date |
148 | updatedAt: Date | 148 | updatedAt: Date |
149 | |||
150 | generateMagnetUri: VideoMethods.GenerateMagnetUri | ||
151 | getVideoFilename: VideoMethods.GetVideoFilename | ||
152 | getThumbnailName: VideoMethods.GetThumbnailName | ||
153 | getPreviewName: VideoMethods.GetPreviewName | ||
154 | getTorrentName: VideoMethods.GetTorrentName | ||
155 | isOwned: VideoMethods.IsOwned | ||
156 | toFormatedJSON: VideoMethods.ToFormatedJSON | ||
157 | toAddRemoteJSON: VideoMethods.ToAddRemoteJSON | ||
158 | toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON | ||
159 | transcodeVideofile: VideoMethods.TranscodeVideofile | ||
149 | } | 160 | } |
150 | 161 | ||
151 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} | 162 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} |
diff --git a/shared/models/client-local.model.ts b/shared/models/client-local.model.ts new file mode 100644 index 000000000..c27963e88 --- /dev/null +++ b/shared/models/client-local.model.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export interface ClientLocal { | ||
2 | client_id: string | ||
3 | client_secret: string | ||
4 | } | ||
diff --git a/shared/models/index.ts b/shared/models/index.ts index 1ddc8545f..fffac795e 100644 --- a/shared/models/index.ts +++ b/shared/models/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | export * from './client-local.model' | ||
1 | export * from './job.model' | 2 | export * from './job.model' |
2 | export * from './pod.model' | 3 | export * from './pod.model' |
3 | export * from './request-scheduler.model' | 4 | export * from './request-scheduler.model' |
@@ -6,3 +7,4 @@ export * from './user.model' | |||
6 | export * from './video-abuse.model' | 7 | export * from './video-abuse.model' |
7 | export * from './video-blacklist.model' | 8 | export * from './video-blacklist.model' |
8 | export * from './video.model' | 9 | export * from './video.model' |
10 | export * from './server-config.model' | ||
diff --git a/shared/models/server-config.model.ts b/shared/models/server-config.model.ts new file mode 100644 index 000000000..a39156963 --- /dev/null +++ b/shared/models/server-config.model.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export interface ServerConfig { | ||
2 | signup: { | ||
3 | enabled: boolean | ||
4 | } | ||
5 | } | ||
diff --git a/shared/models/user-video-rate.model.ts b/shared/models/user-video-rate.model.ts index d48774a4b..b770f4073 100644 --- a/shared/models/user-video-rate.model.ts +++ b/shared/models/user-video-rate.model.ts | |||
@@ -1 +1,7 @@ | |||
1 | export type VideoRateType = 'like' | 'dislike' | 1 | export type VideoRateType = 'like' | 'dislike' |
2 | export type UserVideoRateType = 'like' | 'dislike' | 'none' | ||
3 | |||
4 | export interface UserVideoRate { | ||
5 | videoId: string | ||
6 | rating: UserVideoRateType | ||
7 | } | ||
diff --git a/shared/models/video-abuse.model.ts b/shared/models/video-abuse.model.ts index e005a1fd5..72e32cbc7 100644 --- a/shared/models/video-abuse.model.ts +++ b/shared/models/video-abuse.model.ts | |||
@@ -3,6 +3,6 @@ export interface VideoAbuse { | |||
3 | reporterPodHost: string | 3 | reporterPodHost: string |
4 | reason: string | 4 | reason: string |
5 | reporterUsername: string | 5 | reporterUsername: string |
6 | videoId: number | 6 | videoId: string |
7 | createdAt: Date | 7 | createdAt: Date |
8 | } | 8 | } |