-printWidth: 80
+printWidth: 140
tabWidth: 2
useTabs: false
semi: false
singleQuote: true
-trailingComma: all
+trailingComma: false
bracketSpacing: true
arrowParens: always
-import { Component, OnDestroy, OnInit } from '@angular/core'
-import { ActivatedRoute, Router } from '@angular/router'
-import { Location } from '@angular/common'
-import { getParameterByName, immutableAssign } from '@app/shared/misc/utils'
-import { NotificationsService } from 'angular2-notifications'
-import 'rxjs/add/observable/from'
-import 'rxjs/add/operator/concatAll'
-import { AuthService } from '../../core/auth'
-import { ConfirmService } from '../../core/confirm'
-import { AbstractVideoList } from '../../shared/video/abstract-video-list'
-import { VideoService } from '../../shared/video/video.service'
+import { Component, OnInit } from '@angular/core'
+import { ActivatedRoute } from '@angular/router'
import { Account } from '@app/shared/account/account.model'
import { AccountService } from '@app/shared/account/account.service'
import { Component, OnInit } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
-import 'rxjs/add/observable/from'
-import 'rxjs/add/operator/concatAll'
import { Account } from '@app/shared/account/account.model'
import { AccountService } from '@app/shared/account/account.service'
import { VideoChannel } from '../../../../../shared/models/videos'
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
+import { flatMap, map, tap } from 'rxjs/operators'
@Component({
selector: 'my-account-video-channels',
ngOnInit () {
// Parent get the account for us
this.accountService.accountLoaded
- .do(account => this.account = account)
- .flatMap(account => this.videoChannelService.listAccountVideoChannels(account.id))
- .map(res => res.data)
+ .pipe(
+ tap(account => this.account = account),
+ flatMap(account => this.videoChannelService.listAccountVideoChannels(account.id)),
+ map(res => res.data)
+ )
.subscribe(videoChannels => this.videoChannels = videoChannels)
}
}
import { Location } from '@angular/common'
import { immutableAssign } from '@app/shared/misc/utils'
import { NotificationsService } from 'angular2-notifications'
-import 'rxjs/add/observable/from'
-import 'rxjs/add/operator/concatAll'
import { AuthService } from '../../core/auth'
import { ConfirmService } from '../../core/confirm'
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
+import { catchError } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model'
getCustomConfig () {
return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom')
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(catchError(res => this.restExtractor.handleError(res)))
}
updateCustomConfig (data: CustomConfig) {
return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(catchError(res => this.restExtractor.handleError(res)))
}
}
+import { catchError, map } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { SortMeta } from 'primeng/primeng'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
-import { Observable } from 'rxjs/Observable'
+import { Observable } from 'rxjs'
import { AccountFollow, ResultList } from '../../../../../../shared'
import { environment } from '../../../../environments/environment'
import { RestExtractor, RestPagination, RestService } from '../../../shared'
private authHttp: HttpClient,
private restService: RestService,
private restExtractor: RestExtractor
- ) {}
+ ) {
+ }
getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> {
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/following', { params })
- .map(res => this.restExtractor.convertResultListDateToHuman(res))
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(res => this.restExtractor.convertResultListDateToHuman(res)),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> {
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
- return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/followers', { params })
- .map(res => this.restExtractor.convertResultListDateToHuman(res))
- .catch(res => this.restExtractor.handleError(res))
+ return this.authHttp.get<ResultList<AccountFollow>>(FollowService.BASE_APPLICATION_URL + '/followers', { params })
+ .pipe(
+ map(res => this.restExtractor.convertResultListDateToHuman(res)),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
follow (notEmptyHosts: string[]) {
}
return this.authHttp.post(FollowService.BASE_APPLICATION_URL + '/following', body)
- .map(this.restExtractor.extractDataBool)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
unfollow (follow: AccountFollow) {
return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host)
- .map(this.restExtractor.extractDataBool)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
}
+import { catchError, map } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { SortMeta } from 'primeng/primeng'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
-import { Observable } from 'rxjs/Observable'
+import { Observable } from 'rxjs'
import { ResultList } from '../../../../../../shared'
import { JobState } from '../../../../../../shared/models'
import { Job } from '../../../../../../shared/models/server/job.model'
params = this.restService.addRestGetParams(params, pagination, sort)
return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + '/' + state, { params })
- .map(res => this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'updatedAt' ]))
- .map(res => this.restExtractor.applyToResultListData(res, this.prettyPrintData))
- .catch(err => this.restExtractor.handleError(err))
+ .pipe(
+ map(res => this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'updatedAt' ])),
+ map(res => this.restExtractor.applyToResultListData(res, this.prettyPrintData)),
+ catchError(err => this.restExtractor.handleError(err))
+ )
}
private prettyPrintData (obj: Job) {
+import { catchError, map } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { BytesPipe } from 'ngx-pipes'
import { SortMeta } from 'primeng/components/common/sortmeta'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
-import { Observable } from 'rxjs/Observable'
+import { Observable } from 'rxjs'
import { ResultList, UserCreate, UserUpdate } from '../../../../../../shared'
import { environment } from '../../../../environments/environment'
import { RestExtractor, RestPagination, RestService, User } from '../../../shared'
private authHttp: HttpClient,
private restService: RestService,
private restExtractor: RestExtractor
- ) {}
+ ) {
+ }
addUser (userCreate: UserCreate) {
return this.authHttp.post(UserService.BASE_USERS_URL, userCreate)
- .map(this.restExtractor.extractDataBool)
- .catch(err => this.restExtractor.handleError(err))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(err => this.restExtractor.handleError(err))
+ )
}
updateUser (userId: number, userUpdate: UserUpdate) {
return this.authHttp.put(UserService.BASE_USERS_URL + userId, userUpdate)
- .map(this.restExtractor.extractDataBool)
- .catch(err => this.restExtractor.handleError(err))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(err => this.restExtractor.handleError(err))
+ )
}
getUser (userId: number) {
return this.authHttp.get<User>(UserService.BASE_USERS_URL + userId)
- .catch(err => this.restExtractor.handleError(err))
+ .pipe(catchError(err => this.restExtractor.handleError(err)))
}
getUsers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<User>> {
params = this.restService.addRestGetParams(params, pagination, sort)
return this.authHttp.get<ResultList<User>>(UserService.BASE_USERS_URL, { params })
- .map(res => this.restExtractor.convertResultListDateToHuman(res))
- .map(res => this.restExtractor.applyToResultListData(res, this.formatUser.bind(this)))
- .catch(err => this.restExtractor.handleError(err))
+ .pipe(
+ map(res => this.restExtractor.convertResultListDateToHuman(res)),
+ map(res => this.restExtractor.applyToResultListData(res, this.formatUser.bind(this))),
+ catchError(err => this.restExtractor.handleError(err))
+ )
}
removeUser (user: User) {
return this.authHttp.delete(UserService.BASE_USERS_URL + user.id)
+ .pipe(catchError(err => this.restExtractor.handleError(err)))
}
private formatUser (user: User) {
import { Component, OnDestroy, OnInit } from '@angular/core'
import { FormBuilder, FormGroup } from '@angular/forms'
import { ActivatedRoute, Router } from '@angular/router'
-import { Subscription } from 'rxjs/Subscription'
-
+import { Subscription } from 'rxjs'
import { NotificationsService } from 'angular2-notifications'
-
import { UserService } from '../shared'
-import {
- USER_EMAIL,
- USER_VIDEO_QUOTA,
- USER_ROLE,
- User
-} from '../../../shared'
+import { User, USER_EMAIL, USER_ROLE, USER_VIDEO_QUOTA } from '../../../shared'
import { ServerService } from '../../../core'
import { UserEdit } from './user-edit'
-import { UserUpdate, UserRole } from '../../../../../../shared'
+import { UserUpdate } from '../../../../../../shared'
@Component({
selector: 'my-user-update',
import { Component, OnInit } from '@angular/core'
import { Router } from '@angular/router'
import { NotificationsService } from 'angular2-notifications'
-import 'rxjs/add/observable/from'
-import 'rxjs/add/operator/concatAll'
import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
import { FormBuilder, FormGroup } from '@angular/forms'
import { VideoChannelCreate } from '../../../../../shared/models/videos'
-import { Component, OnInit, OnDestroy } from '@angular/core'
+import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { NotificationsService } from 'angular2-notifications'
-import 'rxjs/add/observable/from'
-import 'rxjs/add/operator/concatAll'
import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
import { FormBuilder, FormGroup } from '@angular/forms'
import { VideoChannelUpdate } from '../../../../../shared/models/videos'
VIDEO_CHANNEL_SUPPORT
} from '@app/shared/forms/form-validators/video-channel'
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
-import { Subscription } from 'rxjs/Subscription'
+import { Subscription } from 'rxjs'
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
import { AuthService } from '@app/core'
import { Component, OnInit } from '@angular/core'
import { NotificationsService } from 'angular2-notifications'
-import 'rxjs/add/observable/from'
-import 'rxjs/add/operator/concatAll'
import { AuthService } from '../../core/auth'
import { ConfirmService } from '../../core/confirm'
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
import { User } from '@app/shared'
+import { flatMap } from 'rxjs/operators'
@Component({
selector: 'my-account-video-channels',
private loadVideoChannels () {
this.authService.userInformationLoaded
- .flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account.id))
+ .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account.id)))
.subscribe(res => this.videoChannels = res.data)
}
}
-import { Component, OnInit, OnDestroy } from '@angular/core'
+import { from as observableFrom, Observable } from 'rxjs'
+import { concatAll, tap } from 'rxjs/operators'
+import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { Location } from '@angular/common'
import { immutableAssign } from '@app/shared/misc/utils'
import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
import { NotificationsService } from 'angular2-notifications'
-import 'rxjs/add/observable/from'
-import 'rxjs/add/operator/concatAll'
-import { Observable } from 'rxjs/Observable'
import { AuthService } from '../../core/auth'
import { ConfirmService } from '../../core/confirm'
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
const observables: Observable<any>[] = []
for (const videoId of toDeleteVideosIds) {
const o = this.videoService
- .removeVideo(videoId)
- .do(() => this.spliceVideosById(videoId))
+ .removeVideo(videoId)
+ .pipe(tap(() => this.spliceVideosById(videoId)))
observables.push(o)
}
- Observable.from(observables)
- .concatAll()
+ observableFrom(observables).pipe(
+ concatAll())
.subscribe(
res => {
this.notificationsService.success('Success', `${toDeleteVideosIds.length} videos deleted.`)
import { Component, OnInit } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
-import 'rxjs/add/observable/from'
-import 'rxjs/add/operator/concatAll'
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
import { Location } from '@angular/common'
import { immutableAssign } from '@app/shared/misc/utils'
import { NotificationsService } from 'angular2-notifications'
-import 'rxjs/add/observable/from'
-import 'rxjs/add/operator/concatAll'
import { AuthService } from '../../core/auth'
import { ConfirmService } from '../../core/confirm'
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
+import { Observable, ReplaySubject, Subject, throwError as observableThrowError } from 'rxjs'
+import { catchError, map, mergeMap, tap } from 'rxjs/operators'
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Router } from '@angular/router'
import { NotificationsService } from 'angular2-notifications'
-import 'rxjs/add/observable/throw'
-import 'rxjs/add/operator/do'
-import 'rxjs/add/operator/map'
-import 'rxjs/add/operator/mergeMap'
-import { Observable } from 'rxjs/Observable'
-import { ReplaySubject } from 'rxjs/ReplaySubject'
-import { Subject } from 'rxjs/Subject'
import { OAuthClientLocal, User as UserServerModel, UserRefreshToken } from '../../../../../shared'
import { User } from '../../../../../shared/models/users'
import { UserLogin } from '../../../../../shared/models/users/user-login.model'
private notificationsService: NotificationsService,
private restExtractor: RestExtractor,
private router: Router
- ) {
+ ) {
this.loginChanged = new Subject<AuthStatus>()
this.loginChangedSource = this.loginChanged.asObservable()
// Fetch the client_id/client_secret
// FIXME: save in local storage?
this.http.get<OAuthClientLocal>(AuthService.BASE_CLIENT_URL)
- .catch(res => this.restExtractor.handleError(res))
- .subscribe(
- res => {
- this.clientId = res.client_id
- this.clientSecret = res.client_secret
- console.log('Client credentials loaded.')
- },
-
- error => {
- let errorMessage = error.message
-
- if (error.status === 403) {
- errorMessage = `Cannot retrieve OAuth Client credentials: ${error.text}. \n`
- errorMessage += 'Ensure you have correctly configured PeerTube (config/ directory), ' +
- 'in particular the "webserver" section.'
- }
-
- // We put a bigger timeout
- // This is an important message
- this.notificationsService.error('Error', errorMessage, { timeOut: 7000 })
- }
- )
+ .pipe(catchError(res => this.restExtractor.handleError(res)))
+ .subscribe(
+ res => {
+ this.clientId = res.client_id
+ this.clientSecret = res.client_secret
+ console.log('Client credentials loaded.')
+ },
+
+ error => {
+ let errorMessage = error.message
+
+ if (error.status === 403) {
+ errorMessage = `Cannot retrieve OAuth Client credentials: ${error.text}. \n`
+ errorMessage += 'Ensure you have correctly configured PeerTube (config/ directory), ' +
+ 'in particular the "webserver" section.'
+ }
+
+ // We put a bigger timeout
+ // This is an important message
+ this.notificationsService.error('Error', errorMessage, { timeOut: 7000 })
+ }
+ )
}
getRefreshToken () {
const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
return this.http.post<UserLogin>(AuthService.BASE_TOKEN_URL, body.toString(), { headers })
- .map(res => Object.assign(res, { username }))
- .flatMap(res => this.mergeUserInformation(res))
- .map(res => this.handleLogin(res))
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(res => Object.assign(res, { username })),
+ mergeMap(res => this.mergeUserInformation(res)),
+ map(res => this.handleLogin(res)),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
logout () {
const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
this.refreshingTokenObservable = this.http.post<UserRefreshToken>(AuthService.BASE_TOKEN_URL, body, { headers })
- .map(res => this.handleRefreshToken(res))
- .do(() => this.refreshingTokenObservable = null)
- .catch(err => {
- this.refreshingTokenObservable = null
-
- console.error(err)
- console.log('Cannot refresh token -> logout...')
- this.logout()
- this.router.navigate([ '/login' ])
-
- return Observable.throw({
- error: 'You need to reconnect.'
- })
- })
+ .pipe(
+ map(res => this.handleRefreshToken(res)),
+ tap(() => this.refreshingTokenObservable = null),
+ catchError(err => {
+ this.refreshingTokenObservable = null
+
+ console.error(err)
+ console.log('Cannot refresh token -> logout...')
+ this.logout()
+ this.router.navigate([ '/login' ])
+
+ return observableThrowError({
+ error: 'You need to reconnect.'
+ })
+ })
+ )
return this.refreshingTokenObservable
}
}
this.mergeUserInformation(obj)
- .subscribe(
- res => {
- this.user.patch(res)
- this.user.save()
+ .subscribe(
+ res => {
+ this.user.patch(res)
+ this.user.save()
- this.userInformationLoaded.next(true)
- }
- )
+ this.userInformationLoaded.next(true)
+ }
+ )
}
private mergeUserInformation (obj: UserLoginWithUsername): Observable<UserLoginWithUserInformation> {
const headers = new HttpHeaders().set('Authorization', `${obj.token_type} ${obj.access_token}`)
return this.http.get<UserServerModel>(AuthService.BASE_USER_INFORMATION_URL, { headers })
- .map(res => Object.assign(obj, res))
+ .pipe(map(res => Object.assign(obj, res)))
}
private handleLogin (obj: UserLoginWithUserInformation) {
+import { first } from 'rxjs/operators'
import { Injectable } from '@angular/core'
-import { Subject } from 'rxjs/Subject'
-import 'rxjs/add/operator/first'
-import 'rxjs/add/operator/toPromise'
+import { Subject } from 'rxjs'
type ConfirmOptions = {
title: string
confirm (message: string, title = '', confirmButtonText?: string) {
this.showConfirm.next({ title, message, confirmButtonText })
- return this.confirmResponse.asObservable().first().toPromise()
+ return this.confirmResponse.asObservable().pipe(first()).toPromise()
}
confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
- return this.confirmResponse.asObservable().first().toPromise()
+ return this.confirmResponse.asObservable().pipe(first()).toPromise()
}
}
-import { Route, PreloadingStrategy } from '@angular/router'
-import { Observable } from 'rxjs/Observable'
-import 'rxjs/add/observable/timer'
-import 'rxjs/add/operator/switchMap'
+import { Observable, timer as observableTimer, of as ofObservable } from 'rxjs'
+import { switchMap } from 'rxjs/operators'
+import { PreloadingStrategy, Route } from '@angular/router'
export class PreloadSelectedModulesList implements PreloadingStrategy {
preload (route: Route, load: Function): Observable<any> {
- if (!route.data || !route.data.preload) return Observable.of(null)
+ if (!route.data || !route.data.preload) return ofObservable(null)
if (typeof route.data.preload === 'number') {
- return Observable.timer(route.data.preload).switchMap(() => load())
+ return observableTimer(route.data.preload).pipe(switchMap(() => load()))
}
return load()
+import { tap } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
-import 'rxjs/add/operator/do'
-import { ReplaySubject } from 'rxjs/ReplaySubject'
+import { ReplaySubject } from 'rxjs'
import { ServerConfig } from '../../../../../shared'
import { About } from '../../../../../shared/models/server/about.model'
import { environment } from '../../../environments/environment'
loadConfig () {
this.http.get<ServerConfig>(ServerService.BASE_CONFIG_URL)
- .do(this.saveConfigLocally)
- .subscribe(data => {
- this.config = data
+ .pipe(tap(this.saveConfigLocally))
+ .subscribe(data => {
+ this.config = data
- this.configLoaded.next(true)
- })
+ this.configLoaded.next(true)
+ })
}
loadVideoCategories () {
+import { filter, map } from 'rxjs/operators'
import { Component, OnInit } from '@angular/core'
-import { Router, NavigationEnd } from '@angular/router'
+import { NavigationEnd, Router } from '@angular/router'
import { getParameterByName } from '../shared/misc/utils'
@Component({
ngOnInit () {
this.router.events
- .filter(e => e instanceof NavigationEnd)
- .map(() => getParameterByName('search', window.location.href))
- .filter(searchQuery => !!searchQuery)
+ .pipe(
+ filter(e => e instanceof NavigationEnd),
+ map(() => getParameterByName('search', window.location.href)),
+ filter(searchQuery => !!searchQuery)
+ )
.subscribe(searchQuery => this.searchValue = searchQuery)
}
+import { map, tap, catchError } from 'rxjs/operators'
import { Injectable } from '@angular/core'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
import { environment } from '../../../environments/environment'
-import { Observable } from 'rxjs/Observable'
+import { Observable, ReplaySubject } from 'rxjs'
import { Account } from '@app/shared/account/account.model'
import { RestExtractor } from '@app/shared/rest/rest-extractor.service'
-import { RestService } from '@app/shared/rest/rest.service'
import { HttpClient } from '@angular/common/http'
import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model'
-import { ReplaySubject } from 'rxjs/ReplaySubject'
@Injectable()
export class AccountService {
constructor (
private authHttp: HttpClient,
- private restExtractor: RestExtractor,
- private restService: RestService
+ private restExtractor: RestExtractor
) {}
getAccount (id: number): Observable<Account> {
return this.authHttp.get<ServerAccount>(AccountService.BASE_ACCOUNT_URL + id)
- .map(accountHash => new Account(accountHash))
- .do(account => this.accountLoaded.next(account))
- .catch((res) => this.restExtractor.handleError(res))
+ .pipe(
+ map(accountHash => new Account(accountHash)),
+ tap(account => this.accountLoaded.next(account)),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
}
host: string
followingCount: number
followersCount: number
- createdAt: Date
- updatedAt: Date
+ createdAt: Date | string
+ updatedAt: Date | string
avatar: Avatar
avatarUrl: string
this.host = hash.host
this.followingCount = hash.followingCount
this.followersCount = hash.followersCount
- this.createdAt = new Date(hash.createdAt)
- this.updatedAt = new Date(hash.updatedAt)
+ this.createdAt = new Date(hash.createdAt.toString())
+ this.updatedAt = new Date(hash.updatedAt.toString())
this.avatar = hash.avatar
this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this)
+import { Observable, throwError as observableThrowError } from 'rxjs'
+import { catchError, switchMap } from 'rxjs/operators'
import { Injectable, Injector } from '@angular/core'
-import {
- HttpInterceptor,
- HttpRequest,
- HttpEvent,
- HttpHandler, HTTP_INTERCEPTORS
-} from '@angular/common/http'
-import { Observable } from 'rxjs/Observable'
-
+import { HTTP_INTERCEPTORS, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'
import { AuthService } from '../../core'
-import 'rxjs/add/operator/switchMap'
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
// Pass on the cloned request instead of the original request
// Catch 401 errors (refresh token expired)
return next.handle(authReq)
- .catch(err => {
- if (err.status === 401 && err.error && err.error.code === 'invalid_token') {
- return this.handleTokenExpired(req, next)
- }
-
- return Observable.throw(err)
- })
+ .pipe(
+ catchError(err => {
+ if (err.status === 401 && err.error && err.error.code === 'invalid_token') {
+ return this.handleTokenExpired(req, next)
+ }
+
+ return observableThrowError(err)
+ })
+ )
}
private handleTokenExpired (req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return this.authService.refreshAccessToken()
- .switchMap(() => {
- const authReq = this.cloneRequestWithAuth(req)
+ .pipe(
+ switchMap(() => {
+ const authReq = this.cloneRequestWithAuth(req)
- return next.handle(authReq)
- })
+ return next.handle(authReq)
+ })
+ )
}
private cloneRequestWithAuth (req: HttpRequest<any>) {
+import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
import { Component, forwardRef, Input, OnInit } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
-import 'rxjs/add/operator/debounceTime'
-import 'rxjs/add/operator/distinctUntilChanged'
import { isInSmallView } from '@app/shared/misc/utils'
import { MarkdownService } from '@app/videos/shared'
-import { Subject } from 'rxjs/Subject'
+import { Subject } from 'rxjs'
import truncate from 'lodash-es/truncate'
@Component({
ngOnInit () {
this.contentChanged
- .debounceTime(150)
- .distinctUntilChanged()
- .subscribe(() => this.updatePreviews())
+ .pipe(
+ debounceTime(150),
+ distinctUntilChanged()
+ )
+ .subscribe(() => this.updatePreviews())
this.contentChanged.next(this.content)
import { Injectable } from '@angular/core'
-import { CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'
-import { Observable } from 'rxjs/Observable'
+import { ActivatedRouteSnapshot, CanDeactivate, RouterStateSnapshot } from '@angular/router'
+import { Observable } from 'rxjs'
import { ConfirmService } from '../../core/index'
export interface CanComponentDeactivate {
-import { HttpErrorResponse } from '@angular/common/http'
+import { of, throwError as observableThrowError } from 'rxjs'
import { Injectable } from '@angular/core'
import { dateToHuman } from '@app/shared/misc/utils'
-import { Observable } from 'rxjs/Observable'
import { ResultList } from '../../../../../shared'
@Injectable()
errorObj.body = err.error
}
- return Observable.throw(errorObj)
+ observableThrowError(errorObj)
+
+ return of(undefined)
}
}
+import { catchError, map } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
import { UserCreate, UserUpdateMe } from '../../../../../shared'
import { environment } from '../../../environments/environment'
import { RestExtractor } from '../rest'
constructor (
private authHttp: HttpClient,
private restExtractor: RestExtractor
- ) {}
+ ) {
+ }
changePassword (newPassword: string) {
const url = UserService.BASE_USERS_URL + 'me'
}
return this.authHttp.put(url, body)
- .map(this.restExtractor.extractDataBool)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
updateMyProfile (profile: UserUpdateMe) {
const url = UserService.BASE_USERS_URL + 'me'
return this.authHttp.put(url, profile)
- .map(this.restExtractor.extractDataBool)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
changeAvatar (avatarForm: FormData) {
const url = UserService.BASE_USERS_URL + 'me/avatar/pick'
return this.authHttp.post(url, avatarForm)
- .catch(this.restExtractor.handleError)
+ .pipe(catchError(this.restExtractor.handleError))
}
signup (userCreate: UserCreate) {
return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate)
- .map(this.restExtractor.extractDataBool)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
getMyVideoQuotaUsed () {
const url = UserService.BASE_USERS_URL + '/me/video-quota-used'
return this.authHttp.get(url)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(catchError(res => this.restExtractor.handleError(res)))
}
askResetPassword (email: string) {
const url = UserService.BASE_USERS_URL + '/ask-reset-password'
return this.authHttp.post(url, { email })
- .map(this.restExtractor.extractDataBool)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
resetPassword (userId: number, verificationString: string, password: string) {
}
return this.authHttp.post(url, body)
- .map(this.restExtractor.extractDataBool)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
}
+import { catchError, map } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { SortMeta } from 'primeng/components/common/sortmeta'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
-import { Observable } from 'rxjs/Observable'
+import { Observable } from 'rxjs'
import { ResultList, VideoAbuse } from '../../../../../shared'
import { environment } from '../../../environments/environment'
import { RestExtractor, RestPagination, RestService } from '../rest'
params = this.restService.addRestGetParams(params, pagination, sort)
return this.authHttp.get<ResultList<VideoAbuse>>(url, { params })
- .map(res => this.restExtractor.convertResultListDateToHuman(res))
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(res => this.restExtractor.convertResultListDateToHuman(res)),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
reportVideo (id: number, reason: string) {
}
return this.authHttp.post(url, body)
- .map(this.restExtractor.extractDataBool)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
}
+import { catchError, map } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { SortMeta } from 'primeng/components/common/sortmeta'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
-import { Observable } from 'rxjs/Observable'
+import { Observable } from 'rxjs'
import { BlacklistedVideo, ResultList } from '../../../../../shared'
import { environment } from '../../../environments/environment'
import { RestExtractor, RestPagination, RestService } from '../rest'
params = this.restService.addRestGetParams(params, pagination, sort)
return this.authHttp.get<ResultList<BlacklistedVideo>>(VideoBlacklistService.BASE_VIDEOS_URL + 'blacklist', { params })
- .map(res => this.restExtractor.convertResultListDateToHuman(res))
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(res => this.restExtractor.convertResultListDateToHuman(res)),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
removeVideoFromBlacklist (videoId: number) {
return this.authHttp.delete(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist')
- .map(this.restExtractor.extractDataBool)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
blacklistVideo (videoId: number) {
return this.authHttp.post(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist', {})
- .map(this.restExtractor.extractDataBool)
- .catch(res => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
}
+import { catchError, map, tap } from 'rxjs/operators'
import { Injectable } from '@angular/core'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
-import { Observable } from 'rxjs/Observable'
+import { Observable, ReplaySubject } from 'rxjs'
import { RestExtractor } from '../rest/rest-extractor.service'
-import { RestService } from '../rest/rest.service'
import { HttpClient } from '@angular/common/http'
import { VideoChannel as VideoChannelServer, VideoChannelCreate, VideoChannelUpdate } from '../../../../../shared/models/videos'
import { AccountService } from '../account/account.service'
import { ResultList } from '../../../../../shared'
import { VideoChannel } from './video-channel.model'
-import { ReplaySubject } from 'rxjs/ReplaySubject'
import { environment } from '../../../environments/environment'
-import { UserService } from '@app/+admin/users/shared/user.service'
-import { User } from '@app/shared'
@Injectable()
export class VideoChannelService {
constructor (
private authHttp: HttpClient,
- private restExtractor: RestExtractor,
- private restService: RestService
+ private restExtractor: RestExtractor
) {}
getVideoChannel (videoChannelUUID: string) {
return this.authHttp.get<VideoChannel>(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID)
- .map(videoChannelHash => new VideoChannel(videoChannelHash))
- .do(videoChannel => this.videoChannelLoaded.next(videoChannel))
- .catch((res) => this.restExtractor.handleError(res))
+ .pipe(
+ map(videoChannelHash => new VideoChannel(videoChannelHash)),
+ tap(videoChannel => this.videoChannelLoaded.next(videoChannel)),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
listAccountVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> {
return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels')
- .map(res => this.extractVideoChannels(res))
- .catch((res) => this.restExtractor.handleError(res))
+ .pipe(
+ map(res => this.extractVideoChannels(res)),
+ catchError((res) => this.restExtractor.handleError(res))
+ )
}
createVideoChannel (videoChannel: VideoChannelCreate) {
return this.authHttp.post(VideoChannelService.BASE_VIDEO_CHANNEL_URL, videoChannel)
- .map(this.restExtractor.extractDataBool)
- .catch(err => this.restExtractor.handleError(err))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(err => this.restExtractor.handleError(err))
+ )
}
updateVideoChannel (videoChannelUUID: string, videoChannel: VideoChannelUpdate) {
return this.authHttp.put(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID, videoChannel)
- .map(this.restExtractor.extractDataBool)
- .catch(err => this.restExtractor.handleError(err))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(err => this.restExtractor.handleError(err))
+ )
}
removeVideoChannel (videoChannel: VideoChannel) {
return this.authHttp.delete(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid)
- .map(this.restExtractor.extractDataBool)
- .catch(err => this.restExtractor.handleError(err))
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(err => this.restExtractor.handleError(err))
+ )
}
private extractVideoChannels (result: ResultList<VideoChannelServer>) {
+import { debounceTime } from 'rxjs/operators'
import { ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { Location } from '@angular/common'
import { isInMobileView } from '@app/shared/misc/utils'
import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive'
import { NotificationsService } from 'angular2-notifications'
-import 'rxjs/add/operator/debounceTime'
-import { Observable } from 'rxjs/Observable'
-import { fromEvent } from 'rxjs/observable/fromEvent'
-import { Subscription } from 'rxjs/Subscription'
+import { fromEvent, Observable, Subscription } from 'rxjs'
import { AuthService } from '../../core/auth'
import { ComponentPagination } from '../rest/component-pagination.model'
import { VideoSortField } from './sort-field.type'
this.loadRouteParams(routeParams)
this.resizeSubscription = fromEvent(window, 'resize')
- .debounceTime(500)
+ .pipe(debounceTime(500))
.subscribe(() => this.calcPageSizes())
this.calcPageSizes()
+import { distinct, distinctUntilChanged, filter, map, share, startWith, throttleTime } from 'rxjs/operators'
import { Directive, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'
-import 'rxjs/add/operator/debounceTime'
-import 'rxjs/add/operator/distinct'
-import 'rxjs/add/operator/distinctUntilChanged'
-import 'rxjs/add/operator/filter'
-import 'rxjs/add/operator/map'
-import 'rxjs/add/operator/share'
-import 'rxjs/add/operator/startWith'
-import 'rxjs/add/operator/throttleTime'
-import { fromEvent } from 'rxjs/observable/fromEvent'
-import { Subscription } from 'rxjs/Subscription'
+import { fromEvent, Subscription } from 'rxjs'
@Directive({
selector: '[myInfiniteScroller]'
const throttleOptions = { leading: true, trailing: true }
const scrollObservable = fromEvent(window, 'scroll')
- .startWith(true)
- .throttleTime(200, undefined, throttleOptions)
- .map(() => ({ current: window.scrollY, maximumScroll: document.body.clientHeight - window.innerHeight }))
- .distinctUntilChanged((o1, o2) => o1.current === o2.current)
- .share()
+ .pipe(
+ startWith(null),
+ throttleTime(200, undefined, throttleOptions),
+ map(() => ({ current: window.scrollY, maximumScroll: document.body.clientHeight - window.innerHeight })),
+ distinctUntilChanged((o1, o2) => o1.current === o2.current),
+ share()
+ )
// Scroll Down
this.scrollDownSub = scrollObservable
- // Check we scroll down
- .filter(({ current }) => {
- const res = this.lastCurrentBottom < current
+ .pipe(
+ // Check we scroll down
+ filter(({ current }) => {
+ const res = this.lastCurrentBottom < current
- this.lastCurrentBottom = current
- return res
- })
- .filter(({ current, maximumScroll }) => maximumScroll <= 0 || (current / maximumScroll) > this.decimalLimit)
+ this.lastCurrentBottom = current
+ return res
+ }),
+ filter(({ current, maximumScroll }) => maximumScroll <= 0 || (current / maximumScroll) > this.decimalLimit)
+ )
.subscribe(() => this.nearOfBottom.emit())
// Scroll up
this.scrollUpSub = scrollObservable
- // Check we scroll up
- .filter(({ current }) => {
- const res = this.lastCurrentTop > current
+ .pipe(
+ // Check we scroll up
+ filter(({ current }) => {
+ const res = this.lastCurrentTop > current
- this.lastCurrentTop = current
- return res
- })
- .filter(({ current, maximumScroll }) => {
- return current !== 0 && (1 - (current / maximumScroll)) > this.decimalLimit
- })
+ this.lastCurrentTop = current
+ return res
+ }),
+ filter(({ current, maximumScroll }) => {
+ return current !== 0 && (1 - (current / maximumScroll)) > this.decimalLimit
+ })
+ )
.subscribe(() => this.nearOfTop.emit())
// Page change
this.pageChangeSub = scrollObservable
- .distinct()
- .map(({ current }) => this.calculateCurrentPage(current))
- .distinctUntilChanged()
+ .pipe(
+ distinct(),
+ map(({ current }) => this.calculateCurrentPage(current)),
+ distinctUntilChanged()
+ )
.subscribe(res => this.pageChanged.emit(res))
}
+import { catchError, map } from 'rxjs/operators'
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
import { Injectable } from '@angular/core'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
-import { Observable } from 'rxjs/Observable'
+import { Observable } from 'rxjs'
import { Video as VideoServerModel, VideoDetails as VideoDetailsServerModel } from '../../../../../shared'
import { ResultList } from '../../../../../shared/models/result-list.model'
import { UserVideoRateUpdate } from '../../../../../shared/models/videos/user-video-rate-update.model'
getVideo (uuid: string): Observable<VideoDetails> {
return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + uuid)
- .map(videoHash => new VideoDetails(videoHash))
- .catch((res) => this.restExtractor.handleError(res))
+ .pipe(
+ map(videoHash => new VideoDetails(videoHash)),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
viewVideo (uuid: string): Observable<VideoDetails> {
return this.authHttp.post(this.getVideoViewUrl(uuid), {})
- .map(this.restExtractor.extractDataBool)
- .catch(this.restExtractor.handleError)
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(this.restExtractor.handleError)
+ )
}
updateVideo (video: VideoEdit) {
const data = objectToFormData(body)
return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, data)
- .map(this.restExtractor.extractDataBool)
- .catch(this.restExtractor.handleError)
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(this.restExtractor.handleError)
+ )
}
uploadVideo (video: FormData) {
const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true })
return this.authHttp
- .request(req)
- .catch(this.restExtractor.handleError)
+ .request(req)
+ .pipe(catchError(this.restExtractor.handleError))
}
getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField): Observable<{ videos: Video[], totalVideos: number}> {
params = this.restService.addRestGetParams(params, pagination, sort)
return this.authHttp.get(UserService.BASE_USERS_URL + '/me/videos', { params })
- .map(this.extractVideos)
- .catch((res) => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.extractVideos),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
getAccountVideos (
return this.authHttp
.get(AccountService.BASE_ACCOUNT_URL + account.id + '/videos', { params })
- .map(this.extractVideos)
- .catch((res) => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.extractVideos),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
getVideoChannelVideos (
return this.authHttp
.get(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid + '/videos', { params })
- .map(this.extractVideos)
- .catch((res) => this.restExtractor.handleError(res))
+ .pipe(
+ map(this.extractVideos),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
getVideos (
}
return this.authHttp
- .get(VideoService.BASE_VIDEO_URL, { params })
- .map(this.extractVideos)
- .catch((res) => this.restExtractor.handleError(res))
+ .get(VideoService.BASE_VIDEO_URL, { params })
+ .pipe(
+ map(this.extractVideos),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
buildBaseFeedUrls (params: HttpParams) {
params = params.append('search', search)
return this.authHttp
- .get<ResultList<VideoServerModel>>(url, { params })
- .map(this.extractVideos)
- .catch((res) => this.restExtractor.handleError(res))
+ .get<ResultList<VideoServerModel>>(url, { params })
+ .pipe(
+ map(this.extractVideos),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
removeVideo (id: number) {
return this.authHttp
- .delete(VideoService.BASE_VIDEO_URL + id)
- .map(this.restExtractor.extractDataBool)
- .catch((res) => this.restExtractor.handleError(res))
+ .delete(VideoService.BASE_VIDEO_URL + id)
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
loadCompleteDescription (descriptionPath: string) {
return this.authHttp
- .get(environment.apiUrl + descriptionPath)
- .map(res => res['description'])
- .catch((res) => this.restExtractor.handleError(res))
+ .get(environment.apiUrl + descriptionPath)
+ .pipe(
+ map(res => res[ 'description' ]),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
setVideoLike (id: number) {
const url = UserService.BASE_USERS_URL + 'me/videos/' + id + '/rating'
return this.authHttp
- .get(url)
- .catch(res => this.restExtractor.handleError(res))
+ .get(url)
+ .pipe(catchError(res => this.restExtractor.handleError(res)))
}
private setVideoRate (id: number, rateType: VideoRateType) {
}
return this.authHttp
- .put(url, body)
- .map(this.restExtractor.extractDataBool)
- .catch(res => this.restExtractor.handleError(res))
+ .put(url, body)
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
private extractVideos (result: ResultList<VideoServerModel>) {
import { ActivatedRoute, Router } from '@angular/router'
import { VIDEO_IMAGE, VIDEO_SUPPORT } from '@app/shared'
import { NotificationsService } from 'angular2-notifications'
-import 'rxjs/add/observable/forkJoin'
import { ServerService } from '../../../core/server'
import { VIDEO_CHANNEL } from '../../../shared/forms/form-validators'
import { ValidatorMessage } from '../../../shared/forms/form-validators/validator-message'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'
import { ServerService } from '@app/core'
-import 'rxjs/add/observable/forkJoin'
@Component({
selector: 'my-video-image',
}
]
})
-
export class VideoImageComponent implements ControlValueAccessor {
@Input() inputLabel: string
@Input() inputName: string
import { LoadingBarService } from '@ngx-loading-bar/core'
import { NotificationsService } from 'angular2-notifications'
import { BytesPipe } from 'ngx-pipes'
-import { Subscription } from 'rxjs/Subscription'
+import { Subscription } from 'rxjs'
import { VideoPrivacy } from '../../../../../shared/models/videos'
import { AuthService, ServerService } from '../../core'
import { FormReactive } from '../../shared'
'./video-add.component.scss'
]
})
-
export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy, CanComponentDeactivate {
@ViewChild('videofileInput') videofileInput
+import { map, switchMap } from 'rxjs/operators'
import { Component, OnInit } from '@angular/core'
import { FormBuilder, FormGroup } from '@angular/forms'
import { ActivatedRoute, Router } from '@angular/router'
import { LoadingBarService } from '@ngx-loading-bar/core'
import { NotificationsService } from 'angular2-notifications'
-import 'rxjs/add/observable/forkJoin'
import { VideoPrivacy } from '../../../../../shared/models/videos'
import { ServerService } from '../../core'
import { AuthService } from '../../core/auth'
styleUrls: [ './shared/video-edit.component.scss' ],
templateUrl: './video-update.component.html'
})
-
export class VideoUpdateComponent extends FormReactive implements OnInit {
video: VideoEdit
this.serverService.videoPrivaciesLoaded
.subscribe(() => this.videoPrivacies = this.serverService.getVideoPrivacies())
- const uuid: string = this.route.snapshot.params['uuid']
+ const uuid: string = this.route.snapshot.params[ 'uuid' ]
this.videoService.getVideo(uuid)
- .switchMap(video => {
- return this.videoService
- .loadCompleteDescription(video.descriptionPath)
- .map(description => Object.assign(video, { description }))
- })
- .subscribe(
- video => {
- this.video = new VideoEdit(video)
-
- populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
- .catch(err => console.error(err))
-
- // We cannot set private a video that was not private
- if (video.privacy.id !== VideoPrivacy.PRIVATE) {
- const newVideoPrivacies = []
- for (const p of this.videoPrivacies) {
- if (p.id !== VideoPrivacy.PRIVATE) newVideoPrivacies.push(p)
+ .pipe(
+ switchMap(video => {
+ return this.videoService
+ .loadCompleteDescription(video.descriptionPath)
+ .pipe(map(description => Object.assign(video, { description })))
+ })
+ )
+ .subscribe(
+ video => {
+ this.video = new VideoEdit(video)
+
+ populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
+ .catch(err => console.error(err))
+
+ // We cannot set private a video that was not private
+ if (video.privacy.id !== VideoPrivacy.PRIVATE) {
+ const newVideoPrivacies = []
+ for (const p of this.videoPrivacies) {
+ if (p.id !== VideoPrivacy.PRIVATE) newVideoPrivacies.push(p)
+ }
+
+ this.videoPrivacies = newVideoPrivacies
}
- this.videoPrivacies = newVideoPrivacies
- }
+ this.hydrateFormFromVideo()
+ },
- this.hydrateFormFromVideo()
- },
-
- err => {
- console.error(err)
- this.notificationsService.error('Error', err.message)
- }
- )
+ err => {
+ console.error(err)
+ this.notificationsService.error('Error', err.message)
+ }
+ )
}
checkForm () {
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
import { FormBuilder, FormGroup } from '@angular/forms'
import { NotificationsService } from 'angular2-notifications'
-import { Observable } from 'rxjs/Observable'
+import { Observable } from 'rxjs'
import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model'
import { FormReactive } from '../../../shared'
import { VIDEO_COMMENT_TEXT } from '../../../shared/forms/form-validators/video-comment'
+import { catchError, map } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { lineFeedToHtml } from '@app/shared/misc/utils'
-import { MarkdownService } from '@app/videos/shared'
-import 'rxjs/add/operator/catch'
-import 'rxjs/add/operator/map'
-import { Observable } from 'rxjs/Observable'
+import { Observable } from 'rxjs'
import { ResultList } from '../../../../../../shared/models'
import {
VideoComment as VideoCommentServerModel,
const normalizedComment = lineFeedToHtml(comment, 'text')
return this.authHttp.post(url, normalizedComment)
- .map(data => this.extractVideoComment(data['comment']))
- .catch(this.restExtractor.handleError)
+ .pipe(
+ map(data => this.extractVideoComment(data['comment'])),
+ catchError(this.restExtractor.handleError)
+ )
}
addCommentReply (videoId: number | string, inReplyToCommentId: number, comment: VideoCommentCreate) {
const normalizedComment = lineFeedToHtml(comment, 'text')
return this.authHttp.post(url, normalizedComment)
- .map(data => this.extractVideoComment(data['comment']))
- .catch(this.restExtractor.handleError)
+ .pipe(
+ map(data => this.extractVideoComment(data[ 'comment' ])),
+ catchError(this.restExtractor.handleError)
+ )
}
getVideoCommentThreads (
const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads'
return this.authHttp
- .get(url, { params })
- .map(this.extractVideoComments)
- .catch((res) => this.restExtractor.handleError(res))
+ .get(url, { params })
+ .pipe(
+ map(this.extractVideoComments),
+ catchError((res) => this.restExtractor.handleError(res))
+ )
}
getVideoThreadComments (videoId: number | string, threadId: number): Observable<VideoCommentThreadTree> {
const url = `${VideoCommentService.BASE_VIDEO_URL + videoId}/comment-threads/${threadId}`
return this.authHttp
- .get(url)
- .map(tree => this.extractVideoCommentTree(tree as VideoCommentThreadTree))
- .catch((res) => this.restExtractor.handleError(res))
+ .get(url)
+ .pipe(
+ map(tree => this.extractVideoCommentTree(tree as VideoCommentThreadTree)),
+ catchError((res) => this.restExtractor.handleError(res))
+ )
}
deleteVideoComment (videoId: number | string, commentId: number) {
const url = `${VideoCommentService.BASE_VIDEO_URL + videoId}/comments/${commentId}`
return this.authHttp
- .delete(url)
- .map(this.restExtractor.extractDataBool)
- .catch((res) => this.restExtractor.handleError(res))
+ .delete(url)
+ .pipe(
+ map(this.restExtractor.extractDataBool),
+ catchError((res) => this.restExtractor.handleError(res))
+ )
}
private extractVideoComment (videoComment: VideoCommentServerModel) {
private extractVideoComments (result: ResultList<VideoCommentServerModel>) {
const videoCommentsJson = result.data
const totalComments = result.total
- const comments = []
+ const comments: VideoComment[] = []
for (const videoCommentJson of videoCommentsJson) {
comments.push(new VideoComment(videoCommentJson))
import { ActivatedRoute } from '@angular/router'
import { ConfirmService } from '@app/core'
import { NotificationsService } from 'angular2-notifications'
-import { Subscription } from 'rxjs/Subscription'
+import { Subscription } from 'rxjs'
import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
import { AuthService } from '../../../core/auth'
import { ComponentPagination } from '../../../shared/rest/component-pagination.model'
import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-support.component'
import { MetaService } from '@ngx-meta/core'
import { NotificationsService } from 'angular2-notifications'
-import { Subscription } from 'rxjs/Subscription'
+import { Subscription } from 'rxjs'
import * as videojs from 'video.js'
import 'videojs-hotkeys'
import * as WebTorrent from 'webtorrent'
import '../../../assets/player/peertube-videojs-plugin'
import { AuthService, ConfirmService } from '../../core'
import { VideoBlacklistService } from '../../shared'
-import { Account } from '../../shared/account/account.model'
import { VideoDetails } from '../../shared/video/video-details.model'
import { Video } from '../../shared/video/video.model'
import { VideoService } from '../../shared/video/video.service'
import { RedirectService } from '@app/core'
import { immutableAssign } from '@app/shared/misc/utils'
import { NotificationsService } from 'angular2-notifications'
-import { Subscription } from 'rxjs/Subscription'
+import { Subscription } from 'rxjs'
import { AuthService } from '../../core/auth'
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
import { VideoService } from '../../shared/video/video.service'
}
},
"lint-staged": {
- "*.{js,ts,css,md}": "precise-commits",
+ "*.{css,md}": "precise-commits",
"*.scss": [
"sass-lint-auto-fix -c .sass-lint.yml --verbose",
"git add"
cd client
-npm run ng -- server --hmr --host 0.0.0.0 --disable-host-check --port 3000
+npm run ng -- serve --hmr --host 0.0.0.0 --disable-host-check --port 3000