import { ConfirmService } from '../../../core'
import { Utils } from '../../../shared'
-import { Friend, FriendService } from '../shared'
+import { FriendService } from '../shared'
@Component({
selector: 'my-friend-list',
+++ /dev/null
-export interface Friend {
- id: string
- host: string
- score: number
- email: string
- createdAt: Date
-}
import { ServerDataSource } from 'ng2-smart-table'
-import { Friend } from './friend.model'
import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared'
@Injectable()
import { NotificationsService } from 'angular2-notifications'
-import { RequestService, RequestStats } from '../shared'
+import { RequestService, RequestSchedulerStatsAttributes } from '../shared'
+import { RequestScheduler } from '../../../../../../shared'
@Component({
selector: 'my-request-stats',
requestVideoQaduScheduler: 'Quick and dirty video updates request scheduler'
}
- stats: { [ id: string ]: RequestStats } = {
- requestScheduler: null,
- requestVideoEventScheduler: null,
- requestVideoQaduScheduler: null
- }
+ stats: RequestScheduler
private intervals: { [ id: string ]: number } = {
requestScheduler: null,
private runIntervals () {
Object.keys(this.intervals).forEach(requestSchedulerName => {
this.intervals[requestSchedulerName] = window.setInterval(() => {
- const stats = this.stats[requestSchedulerName]
+ const stats: RequestSchedulerStatsAttributes = this.stats[requestSchedulerName]
stats.remainingMilliSeconds -= 1000
-export * from './request-stats.model'
+export * from './request-stats-attributes.model'
export * from './request.service'
--- /dev/null
+import { RequestSchedulerAttributes as FormatedRequestSchedulerAttributes } from '../../../../../../shared'
+
+export interface Request {
+ request: any
+ to: any
+}
+
+export class RequestSchedulerStatsAttributes implements FormatedRequestSchedulerAttributes {
+ requestsLimitPods: number
+ requestsLimitPerPod: number
+ milliSecondsInterval: number
+ remainingMilliSeconds: number
+ totalRequests: number
+
+ constructor (hash: {
+ requestsLimitPods: number,
+ requestsLimitPerPod: number,
+ milliSecondsInterval: number,
+ remainingMilliSeconds: number,
+ totalRequests: number
+ }) {
+ this.requestsLimitPods = hash.requestsLimitPods
+ this.requestsLimitPerPod = hash.requestsLimitPerPod
+ this.milliSecondsInterval = hash.milliSecondsInterval
+ this.remainingMilliSeconds = hash.remainingMilliSeconds
+ this.totalRequests = hash.totalRequests
+ }
+
+ get remainingSeconds () {
+ return Math.floor(this.remainingMilliSeconds / 1000)
+ }
+
+ get secondsInterva () {
+ return Math.floor(this.milliSecondsInterval / 1000)
+ }
+
+}
+++ /dev/null
-export interface Request {
- request: any
- to: any
-}
-
-export class RequestStats {
- requestsLimitPods: number
- requestsLimitPerPod: number
- milliSecondsInterval: number
- remainingMilliSeconds: number
- totalRequests: number
-
- constructor (hash: {
- requestsLimitPods: number,
- requestsLimitPerPod: number,
- milliSecondsInterval: number,
- remainingMilliSeconds: number,
- totalRequests: number
- }) {
- this.requestsLimitPods = hash.requestsLimitPods
- this.requestsLimitPerPod = hash.requestsLimitPerPod
- this.milliSecondsInterval = hash.milliSecondsInterval
- this.remainingMilliSeconds = hash.remainingMilliSeconds
- this.totalRequests = hash.totalRequests
- }
-
- get remainingSeconds () {
- return Math.floor(this.remainingMilliSeconds / 1000)
- }
-
- get secondsInterva () {
- return Math.floor(this.milliSecondsInterval / 1000)
- }
-
-}
import 'rxjs/add/operator/catch'
import 'rxjs/add/operator/map'
-import { RequestStats } from './request-stats.model'
+import { RequestScheduler } from '../../../../../../shared'
import { AuthHttp, RestExtractor } from '../../../shared'
+import { RequestSchedulerStatsAttributes } from './request-stats-attributes.model'
@Injectable()
export class RequestService {
private restExtractor: RestExtractor
) {}
- getStats (): Observable<{ [ id: string ]: RequestStats }> {
+ getStats (): Observable<RequestScheduler> {
return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats')
.map(this.restExtractor.extractDataGet)
.map(this.buildRequestObjects)
.catch((res) => this.restExtractor.handleError(res))
}
- private buildRequestObjects (data: any) {
+ private buildRequestObjects (data: RequestScheduler) {
const requestSchedulers = {}
Object.keys(data).forEach(requestSchedulerName => {
- requestSchedulers[requestSchedulerName] = new RequestStats(data[requestSchedulerName])
+ requestSchedulers[requestSchedulerName] = new RequestSchedulerStatsAttributes(data[requestSchedulerName])
})
return requestSchedulers
import { NotificationsService } from 'angular2-notifications'
-import { Utils, VideoAbuseService, VideoAbuse } from '../../../shared'
+import { Utils, VideoAbuseService } from '../../../shared'
+import { VideoAbuse } from '../../../../../shared'
@Component({
selector: 'my-video-abuse-list',
import { AuthStatus } from './auth-status.model'
import { AuthUser } from './auth-user.model'
+import { ClientLocal } from '../../../../../shared'
// Do not use the barrel (dependency loop)
import { RestExtractor } from '../../shared/rest'
// FIXME: save in local storage?
this.http.get(AuthService.BASE_CLIENT_URL)
.map(this.restExtractor.extractDataGet)
- .catch((res) => this.restExtractor.handleError(res))
+ .catch(res => this.restExtractor.handleError(res))
.subscribe(
- result => {
+ (result: ClientLocal) => {
this.clientId = result.client_id
this.clientSecret = result.client_secret
console.log('Client credentials loaded.')
import { Http } from '@angular/http'
import { RestExtractor } from '../../shared/rest'
+import { ServerConfig } from '../../../../../shared'
@Injectable()
export class ConfigService {
private static BASE_CONFIG_URL = API_URL + '/api/v1/config/'
- private config: {
- signup: {
- enabled: boolean
- }
- } = {
+ private config: ServerConfig = {
signup: {
enabled: false
}
+++ /dev/null
-export interface VideoAbuse {
- id: string
- reason: string
- reporterPodHost: string
- reporterUsername: string
- videoId: string
- createdAt: Date
-}
import { AuthService } from '../core'
import { AuthHttp } from '../auth'
import { RestDataSource, RestExtractor, ResultList } from '../rest'
-import { VideoAbuse } from './video-abuse.model'
+import { VideoAbuse } from '../../../../../shared'
@Injectable()
export class VideoAbuseService {
+++ /dev/null
-export type RateType = 'like' | 'dislike'
import { Search } from '../../shared'
import { SortField } from './sort-field.type'
-import { RateType } from './rate-type.type'
import { AuthService } from '../../core'
import {
AuthHttp,
UserService
} from '../../shared'
import { Video } from './video.model'
+import { VideoRateType } from '../../../../../shared'
@Injectable()
export class VideoService {
return this.setVideoRate(id, 'dislike')
}
- getUserVideoRating (id: string) {
+ getUserVideoRating (id: string): Observable<VideoRateType> {
const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating'
return this.authHttp.get(url)
.catch((res) => this.restExtractor.handleError(res))
}
- private setVideoRate (id: string, rateType: RateType) {
+ private setVideoRate (id: string, rateType: VideoRateType) {
const url = VideoService.BASE_VIDEO_URL + id + '/rate'
const body = {
rating: rateType
import { VideoMagnetComponent } from './video-magnet.component'
import { VideoShareComponent } from './video-share.component'
import { VideoReportComponent } from './video-report.component'
-import { RateType, Video, VideoService } from '../shared'
+import { Video, VideoService } from '../shared'
import { WebTorrentService } from './webtorrent.service'
+import { UserVideoRateType, VideoRateType, UserVideoRate } from '../../../../../shared'
@Component({
selector: 'my-video-watch',
templateUrl: './video-watch.component.html',
styleUrls: [ './video-watch.component.scss' ]
})
-
export class VideoWatchComponent implements OnInit, OnDestroy {
private static LOADTIME_TOO_LONG = 20000
player: videojs.Player
playerElement: Element
uploadSpeed: number
- userRating: RateType = null
+ userRating: UserVideoRateType = null
video: Video = null
videoNotFound = false
this.videoService.getUserVideoRating(this.video.id)
.subscribe(
- ratingObject => {
+ (ratingObject: UserVideoRate) => {
if (ratingObject) {
this.userRating = ratingObject.rating
}
)
}
- private updateVideoRating (oldRating: RateType, newRating: RateType) {
+ private updateVideoRating (oldRating: UserVideoRateType, newRating: VideoRateType) {
let likesToIncrement = 0
let dislikesToIncrement = 0
import { CONFIG } from '../../initializers'
import { logger } from '../../helpers'
import { database as db } from '../../initializers/database'
+import { ClientLocal } from '../../../shared'
const clientsRouter = express.Router()
if (err) return next(err)
if (!client) return next(new Error('No client available.'))
- res.json({
+ const json: ClientLocal = {
client_id: client.clientId,
client_secret: client.clientSecret
- })
+ }
+ res.json(json)
})
}
import * as express from 'express'
import { CONFIG } from '../../initializers'
+import { ServerConfig } from '../../../shared'
const configRouter = express.Router()
// Get the client credentials for the PeerTube front end
function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
- res.json({
+ const json: ServerConfig = {
signup: {
enabled: CONFIG.SIGNUP.ENABLED
}
- })
+ }
+ res.json(json)
}
// ---------------------------------------------------------------------------
setUsersSort,
token
} from '../../middlewares'
+import { UserVideoRate as FormatedUserVideoRate } from '../../../shared'
const usersRouter = express.Router()
const rating = ratingObj ? ratingObj.type : 'none'
- res.json({
+ const json: FormatedUserVideoRate = {
videoId,
rating
- })
+ }
+ res.json(json)
})
}
}
}
-function getFormatedObjects (objects: any[], objectsTotal: number) {
- const formatedObjects = []
+interface FormatableToJSON {
+ toFormatedJSON()
+}
+
+function getFormatedObjects<U, T extends FormatableToJSON> (objects: T[], objectsTotal: number) {
+ const formatedObjects: U[] = []
objects.forEach(function (object) {
formatedObjects.push(object.toFormatedJSON())
id: number
createdAt: Date
updatedAt: Date
+
+ isPasswordMatch: UserMethods.IsPasswordMatch
+ toFormatedJSON: UserMethods.ToFormatedJSON
+ isAdmin: UserMethods.IsAdmin
}
export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {}
/*
User rates per video.
-
*/
import { values } from 'lodash'
import * as Sequelize from 'sequelize'
import { VideoAbuse as FormatedVideoAbuse } from '../../../shared/models/video-abuse.model'
export namespace VideoAbuseMethods {
- export type toFormatedJSON = () => FormatedVideoAbuse
+ export type ToFormatedJSON = (this: VideoAbuseInstance) => FormatedVideoAbuse
export type ListForApiCallback = (err: Error, videoAbuseInstances?: VideoAbuseInstance[], total?: number) => void
export type ListForApi = (start: number, count: number, sort: string, callback: ListForApiCallback) => void
updatedAt: Date
Pod: PodInstance
+
+ toFormatedJSON: VideoAbuseMethods.ToFormatedJSON
}
export interface VideoAbuseModel extends VideoAbuseClass, Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes> {}
} from './video-abuse-interface'
let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes>
+let toFormatedJSON: VideoAbuseMethods.ToFormatedJSON
let listForApi: VideoAbuseMethods.ListForApi
export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
// ------------------------------ METHODS ------------------------------
-function toFormatedJSON (this: VideoAbuseInstance) {
+toFormatedJSON = function (this: VideoAbuseInstance) {
let reporterPodHost
if (this.Pod) {
})
}
-listForApi = function (start, count, sort, callback) {
+listForApi = function (start: number, count: number, sort: string, callback: VideoAbuseMethods.ListForApiCallback) {
const query = {
offset: start,
limit: count,
id: number
createdAt: Date
updatedAt: Date
+
+ toFormatedJSON: BlacklistedVideoMethods.ToFormatedJSON
}
export interface BlacklistedVideoModel extends BlacklistedVideoClass, Sequelize.Model<BlacklistedVideoInstance, BlacklistedVideoAttributes> {}
id: string
createdAt: Date
updatedAt: Date
+
+ generateMagnetUri: VideoMethods.GenerateMagnetUri
+ getVideoFilename: VideoMethods.GetVideoFilename
+ getThumbnailName: VideoMethods.GetThumbnailName
+ getPreviewName: VideoMethods.GetPreviewName
+ getTorrentName: VideoMethods.GetTorrentName
+ isOwned: VideoMethods.IsOwned
+ toFormatedJSON: VideoMethods.ToFormatedJSON
+ toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
+ toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
+ transcodeVideofile: VideoMethods.TranscodeVideofile
}
export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {}
--- /dev/null
+export interface ClientLocal {
+ client_id: string
+ client_secret: string
+}
+export * from './client-local.model'
export * from './job.model'
export * from './pod.model'
export * from './request-scheduler.model'
export * from './video-abuse.model'
export * from './video-blacklist.model'
export * from './video.model'
+export * from './server-config.model'
--- /dev/null
+export interface ServerConfig {
+ signup: {
+ enabled: boolean
+ }
+}
export type VideoRateType = 'like' | 'dislike'
+export type UserVideoRateType = 'like' | 'dislike' | 'none'
+
+export interface UserVideoRate {
+ videoId: string
+ rating: UserVideoRateType
+}
reporterPodHost: string
reason: string
reporterUsername: string
- videoId: number
+ videoId: string
createdAt: Date
}