Upgrade to rxjs 6
This commit is contained in:
parent
54c3a22faa
commit
db400f447a
|
@ -1,8 +1,8 @@
|
||||||
printWidth: 80
|
printWidth: 140
|
||||||
tabWidth: 2
|
tabWidth: 2
|
||||||
useTabs: false
|
useTabs: false
|
||||||
semi: false
|
semi: false
|
||||||
singleQuote: true
|
singleQuote: true
|
||||||
trailingComma: all
|
trailingComma: false
|
||||||
bracketSpacing: true
|
bracketSpacing: true
|
||||||
arrowParens: always
|
arrowParens: always
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
import { Component, OnDestroy, OnInit } from '@angular/core'
|
import { Component, OnInit } from '@angular/core'
|
||||||
import { ActivatedRoute, Router } from '@angular/router'
|
import { ActivatedRoute } 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 { Account } from '@app/shared/account/account.model'
|
import { Account } from '@app/shared/account/account.model'
|
||||||
import { AccountService } from '@app/shared/account/account.service'
|
import { AccountService } from '@app/shared/account/account.service'
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { Component, OnInit } from '@angular/core'
|
import { Component, OnInit } from '@angular/core'
|
||||||
import { ActivatedRoute } from '@angular/router'
|
import { ActivatedRoute } from '@angular/router'
|
||||||
import 'rxjs/add/observable/from'
|
|
||||||
import 'rxjs/add/operator/concatAll'
|
|
||||||
import { Account } from '@app/shared/account/account.model'
|
import { Account } from '@app/shared/account/account.model'
|
||||||
import { AccountService } from '@app/shared/account/account.service'
|
import { AccountService } from '@app/shared/account/account.service'
|
||||||
import { VideoChannel } from '../../../../../shared/models/videos'
|
import { VideoChannel } from '../../../../../shared/models/videos'
|
||||||
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
|
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
|
||||||
|
import { flatMap, map, tap } from 'rxjs/operators'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-account-video-channels',
|
selector: 'my-account-video-channels',
|
||||||
|
@ -25,9 +24,11 @@ export class AccountVideoChannelsComponent implements OnInit {
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
// Parent get the account for us
|
// Parent get the account for us
|
||||||
this.accountService.accountLoaded
|
this.accountService.accountLoaded
|
||||||
.do(account => this.account = account)
|
.pipe(
|
||||||
.flatMap(account => this.videoChannelService.listAccountVideoChannels(account.id))
|
tap(account => this.account = account),
|
||||||
.map(res => res.data)
|
flatMap(account => this.videoChannelService.listAccountVideoChannels(account.id)),
|
||||||
|
map(res => res.data)
|
||||||
|
)
|
||||||
.subscribe(videoChannels => this.videoChannels = videoChannels)
|
.subscribe(videoChannels => this.videoChannels = videoChannels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@ import { ActivatedRoute, Router } from '@angular/router'
|
||||||
import { Location } from '@angular/common'
|
import { Location } from '@angular/common'
|
||||||
import { immutableAssign } from '@app/shared/misc/utils'
|
import { immutableAssign } from '@app/shared/misc/utils'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import 'rxjs/add/observable/from'
|
|
||||||
import 'rxjs/add/operator/concatAll'
|
|
||||||
import { AuthService } from '../../core/auth'
|
import { AuthService } from '../../core/auth'
|
||||||
import { ConfirmService } from '../../core/confirm'
|
import { ConfirmService } from '../../core/confirm'
|
||||||
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
|
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { catchError } from 'rxjs/operators'
|
||||||
import { HttpClient } from '@angular/common/http'
|
import { HttpClient } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model'
|
import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model'
|
||||||
|
@ -16,11 +17,11 @@ export class ConfigService {
|
||||||
|
|
||||||
getCustomConfig () {
|
getCustomConfig () {
|
||||||
return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom')
|
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) {
|
updateCustomConfig (data: CustomConfig) {
|
||||||
return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data)
|
return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data)
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
.pipe(catchError(res => this.restExtractor.handleError(res)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
|
import { catchError, map } from 'rxjs/operators'
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http'
|
import { HttpClient, HttpParams } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { SortMeta } from 'primeng/primeng'
|
import { SortMeta } from 'primeng/primeng'
|
||||||
import 'rxjs/add/operator/catch'
|
import { Observable } from 'rxjs'
|
||||||
import 'rxjs/add/operator/map'
|
|
||||||
import { Observable } from 'rxjs/Observable'
|
|
||||||
import { AccountFollow, ResultList } from '../../../../../../shared'
|
import { AccountFollow, ResultList } from '../../../../../../shared'
|
||||||
import { environment } from '../../../../environments/environment'
|
import { environment } from '../../../../environments/environment'
|
||||||
import { RestExtractor, RestPagination, RestService } from '../../../shared'
|
import { RestExtractor, RestPagination, RestService } from '../../../shared'
|
||||||
|
@ -16,24 +15,29 @@ export class FollowService {
|
||||||
private authHttp: HttpClient,
|
private authHttp: HttpClient,
|
||||||
private restService: RestService,
|
private restService: RestService,
|
||||||
private restExtractor: RestExtractor
|
private restExtractor: RestExtractor
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> {
|
getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> {
|
||||||
let params = new HttpParams()
|
let params = new HttpParams()
|
||||||
params = this.restService.addRestGetParams(params, pagination, sort)
|
params = this.restService.addRestGetParams(params, pagination, sort)
|
||||||
|
|
||||||
return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/following', { params })
|
return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/following', { params })
|
||||||
.map(res => this.restExtractor.convertResultListDateToHuman(res))
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(res => this.restExtractor.convertResultListDateToHuman(res)),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> {
|
getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<AccountFollow>> {
|
||||||
let params = new HttpParams()
|
let params = new HttpParams()
|
||||||
params = this.restService.addRestGetParams(params, pagination, sort)
|
params = this.restService.addRestGetParams(params, pagination, sort)
|
||||||
|
|
||||||
return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/followers', { params })
|
return this.authHttp.get<ResultList<AccountFollow>>(FollowService.BASE_APPLICATION_URL + '/followers', { params })
|
||||||
.map(res => this.restExtractor.convertResultListDateToHuman(res))
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(res => this.restExtractor.convertResultListDateToHuman(res)),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
follow (notEmptyHosts: string[]) {
|
follow (notEmptyHosts: string[]) {
|
||||||
|
@ -42,13 +46,17 @@ export class FollowService {
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.authHttp.post(FollowService.BASE_APPLICATION_URL + '/following', body)
|
return this.authHttp.post(FollowService.BASE_APPLICATION_URL + '/following', body)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
unfollow (follow: AccountFollow) {
|
unfollow (follow: AccountFollow) {
|
||||||
return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host)
|
return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
|
import { catchError, map } from 'rxjs/operators'
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http'
|
import { HttpClient, HttpParams } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { SortMeta } from 'primeng/primeng'
|
import { SortMeta } from 'primeng/primeng'
|
||||||
import 'rxjs/add/operator/catch'
|
import { Observable } from 'rxjs'
|
||||||
import 'rxjs/add/operator/map'
|
|
||||||
import { Observable } from 'rxjs/Observable'
|
|
||||||
import { ResultList } from '../../../../../../shared'
|
import { ResultList } from '../../../../../../shared'
|
||||||
import { JobState } from '../../../../../../shared/models'
|
import { JobState } from '../../../../../../shared/models'
|
||||||
import { Job } from '../../../../../../shared/models/server/job.model'
|
import { Job } from '../../../../../../shared/models/server/job.model'
|
||||||
|
@ -25,9 +24,11 @@ export class JobService {
|
||||||
params = this.restService.addRestGetParams(params, pagination, sort)
|
params = this.restService.addRestGetParams(params, pagination, sort)
|
||||||
|
|
||||||
return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + '/' + state, { params })
|
return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + '/' + state, { params })
|
||||||
.map(res => this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'updatedAt' ]))
|
.pipe(
|
||||||
.map(res => this.restExtractor.applyToResultListData(res, this.prettyPrintData))
|
map(res => this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'updatedAt' ])),
|
||||||
.catch(err => this.restExtractor.handleError(err))
|
map(res => this.restExtractor.applyToResultListData(res, this.prettyPrintData)),
|
||||||
|
catchError(err => this.restExtractor.handleError(err))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private prettyPrintData (obj: Job) {
|
private prettyPrintData (obj: Job) {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
|
import { catchError, map } from 'rxjs/operators'
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http'
|
import { HttpClient, HttpParams } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { BytesPipe } from 'ngx-pipes'
|
import { BytesPipe } from 'ngx-pipes'
|
||||||
import { SortMeta } from 'primeng/components/common/sortmeta'
|
import { SortMeta } from 'primeng/components/common/sortmeta'
|
||||||
import 'rxjs/add/operator/catch'
|
import { Observable } from 'rxjs'
|
||||||
import 'rxjs/add/operator/map'
|
|
||||||
import { Observable } from 'rxjs/Observable'
|
|
||||||
import { ResultList, UserCreate, UserUpdate } from '../../../../../../shared'
|
import { ResultList, UserCreate, UserUpdate } from '../../../../../../shared'
|
||||||
import { environment } from '../../../../environments/environment'
|
import { environment } from '../../../../environments/environment'
|
||||||
import { RestExtractor, RestPagination, RestService, User } from '../../../shared'
|
import { RestExtractor, RestPagination, RestService, User } from '../../../shared'
|
||||||
|
@ -18,23 +17,28 @@ export class UserService {
|
||||||
private authHttp: HttpClient,
|
private authHttp: HttpClient,
|
||||||
private restService: RestService,
|
private restService: RestService,
|
||||||
private restExtractor: RestExtractor
|
private restExtractor: RestExtractor
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
addUser (userCreate: UserCreate) {
|
addUser (userCreate: UserCreate) {
|
||||||
return this.authHttp.post(UserService.BASE_USERS_URL, userCreate)
|
return this.authHttp.post(UserService.BASE_USERS_URL, userCreate)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(err => this.restExtractor.handleError(err))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(err => this.restExtractor.handleError(err))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUser (userId: number, userUpdate: UserUpdate) {
|
updateUser (userId: number, userUpdate: UserUpdate) {
|
||||||
return this.authHttp.put(UserService.BASE_USERS_URL + userId, userUpdate)
|
return this.authHttp.put(UserService.BASE_USERS_URL + userId, userUpdate)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(err => this.restExtractor.handleError(err))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(err => this.restExtractor.handleError(err))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getUser (userId: number) {
|
getUser (userId: number) {
|
||||||
return this.authHttp.get<User>(UserService.BASE_USERS_URL + userId)
|
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>> {
|
getUsers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<User>> {
|
||||||
|
@ -42,13 +46,16 @@ export class UserService {
|
||||||
params = this.restService.addRestGetParams(params, pagination, sort)
|
params = this.restService.addRestGetParams(params, pagination, sort)
|
||||||
|
|
||||||
return this.authHttp.get<ResultList<User>>(UserService.BASE_USERS_URL, { params })
|
return this.authHttp.get<ResultList<User>>(UserService.BASE_USERS_URL, { params })
|
||||||
.map(res => this.restExtractor.convertResultListDateToHuman(res))
|
.pipe(
|
||||||
.map(res => this.restExtractor.applyToResultListData(res, this.formatUser.bind(this)))
|
map(res => this.restExtractor.convertResultListDateToHuman(res)),
|
||||||
.catch(err => this.restExtractor.handleError(err))
|
map(res => this.restExtractor.applyToResultListData(res, this.formatUser.bind(this))),
|
||||||
|
catchError(err => this.restExtractor.handleError(err))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
removeUser (user: User) {
|
removeUser (user: User) {
|
||||||
return this.authHttp.delete(UserService.BASE_USERS_URL + user.id)
|
return this.authHttp.delete(UserService.BASE_USERS_URL + user.id)
|
||||||
|
.pipe(catchError(err => this.restExtractor.handleError(err)))
|
||||||
}
|
}
|
||||||
|
|
||||||
private formatUser (user: User) {
|
private formatUser (user: User) {
|
||||||
|
|
|
@ -1,20 +1,13 @@
|
||||||
import { Component, OnDestroy, OnInit } from '@angular/core'
|
import { Component, OnDestroy, OnInit } from '@angular/core'
|
||||||
import { FormBuilder, FormGroup } from '@angular/forms'
|
import { FormBuilder, FormGroup } from '@angular/forms'
|
||||||
import { ActivatedRoute, Router } from '@angular/router'
|
import { ActivatedRoute, Router } from '@angular/router'
|
||||||
import { Subscription } from 'rxjs/Subscription'
|
import { Subscription } from 'rxjs'
|
||||||
|
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
|
|
||||||
import { UserService } from '../shared'
|
import { UserService } from '../shared'
|
||||||
import {
|
import { User, USER_EMAIL, USER_ROLE, USER_VIDEO_QUOTA } from '../../../shared'
|
||||||
USER_EMAIL,
|
|
||||||
USER_VIDEO_QUOTA,
|
|
||||||
USER_ROLE,
|
|
||||||
User
|
|
||||||
} from '../../../shared'
|
|
||||||
import { ServerService } from '../../../core'
|
import { ServerService } from '../../../core'
|
||||||
import { UserEdit } from './user-edit'
|
import { UserEdit } from './user-edit'
|
||||||
import { UserUpdate, UserRole } from '../../../../../../shared'
|
import { UserUpdate } from '../../../../../../shared'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-user-update',
|
selector: 'my-user-update',
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { Component, OnInit } from '@angular/core'
|
import { Component, OnInit } from '@angular/core'
|
||||||
import { Router } from '@angular/router'
|
import { Router } from '@angular/router'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import 'rxjs/add/observable/from'
|
|
||||||
import 'rxjs/add/operator/concatAll'
|
|
||||||
import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
|
import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
|
||||||
import { FormBuilder, FormGroup } from '@angular/forms'
|
import { FormBuilder, FormGroup } from '@angular/forms'
|
||||||
import { VideoChannelCreate } from '../../../../../shared/models/videos'
|
import { VideoChannelCreate } from '../../../../../shared/models/videos'
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { Component, OnInit, OnDestroy } from '@angular/core'
|
import { Component, OnDestroy, OnInit } from '@angular/core'
|
||||||
import { ActivatedRoute, Router } from '@angular/router'
|
import { ActivatedRoute, Router } from '@angular/router'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import 'rxjs/add/observable/from'
|
|
||||||
import 'rxjs/add/operator/concatAll'
|
|
||||||
import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
|
import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
|
||||||
import { FormBuilder, FormGroup } from '@angular/forms'
|
import { FormBuilder, FormGroup } from '@angular/forms'
|
||||||
import { VideoChannelUpdate } from '../../../../../shared/models/videos'
|
import { VideoChannelUpdate } from '../../../../../shared/models/videos'
|
||||||
|
@ -12,7 +10,7 @@ import {
|
||||||
VIDEO_CHANNEL_SUPPORT
|
VIDEO_CHANNEL_SUPPORT
|
||||||
} from '@app/shared/forms/form-validators/video-channel'
|
} from '@app/shared/forms/form-validators/video-channel'
|
||||||
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
|
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 { VideoChannel } from '@app/shared/video-channel/video-channel.model'
|
||||||
import { AuthService } from '@app/core'
|
import { AuthService } from '@app/core'
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import { Component, OnInit } from '@angular/core'
|
import { Component, OnInit } from '@angular/core'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import 'rxjs/add/observable/from'
|
|
||||||
import 'rxjs/add/operator/concatAll'
|
|
||||||
import { AuthService } from '../../core/auth'
|
import { AuthService } from '../../core/auth'
|
||||||
import { ConfirmService } from '../../core/confirm'
|
import { ConfirmService } from '../../core/confirm'
|
||||||
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
|
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
|
||||||
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
|
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
|
||||||
import { User } from '@app/shared'
|
import { User } from '@app/shared'
|
||||||
|
import { flatMap } from 'rxjs/operators'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-account-video-channels',
|
selector: 'my-account-video-channels',
|
||||||
|
@ -53,7 +52,7 @@ export class MyAccountVideoChannelsComponent implements OnInit {
|
||||||
|
|
||||||
private loadVideoChannels () {
|
private loadVideoChannels () {
|
||||||
this.authService.userInformationLoaded
|
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)
|
.subscribe(res => this.videoChannels = res.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
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 { ActivatedRoute, Router } from '@angular/router'
|
||||||
import { Location } from '@angular/common'
|
import { Location } from '@angular/common'
|
||||||
import { immutableAssign } from '@app/shared/misc/utils'
|
import { immutableAssign } from '@app/shared/misc/utils'
|
||||||
import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
|
import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
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 { AuthService } from '../../core/auth'
|
||||||
import { ConfirmService } from '../../core/confirm'
|
import { ConfirmService } from '../../core/confirm'
|
||||||
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
|
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
|
||||||
|
@ -79,13 +78,13 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni
|
||||||
for (const videoId of toDeleteVideosIds) {
|
for (const videoId of toDeleteVideosIds) {
|
||||||
const o = this.videoService
|
const o = this.videoService
|
||||||
.removeVideo(videoId)
|
.removeVideo(videoId)
|
||||||
.do(() => this.spliceVideosById(videoId))
|
.pipe(tap(() => this.spliceVideosById(videoId)))
|
||||||
|
|
||||||
observables.push(o)
|
observables.push(o)
|
||||||
}
|
}
|
||||||
|
|
||||||
Observable.from(observables)
|
observableFrom(observables).pipe(
|
||||||
.concatAll()
|
concatAll())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
res => {
|
res => {
|
||||||
this.notificationsService.success('Success', `${toDeleteVideosIds.length} videos deleted.`)
|
this.notificationsService.success('Success', `${toDeleteVideosIds.length} videos deleted.`)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { Component, OnInit } from '@angular/core'
|
import { Component, OnInit } from '@angular/core'
|
||||||
import { ActivatedRoute } from '@angular/router'
|
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 { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
|
||||||
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
|
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@ import { ActivatedRoute, Router } from '@angular/router'
|
||||||
import { Location } from '@angular/common'
|
import { Location } from '@angular/common'
|
||||||
import { immutableAssign } from '@app/shared/misc/utils'
|
import { immutableAssign } from '@app/shared/misc/utils'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import 'rxjs/add/observable/from'
|
|
||||||
import 'rxjs/add/operator/concatAll'
|
|
||||||
import { AuthService } from '../../core/auth'
|
import { AuthService } from '../../core/auth'
|
||||||
import { ConfirmService } from '../../core/confirm'
|
import { ConfirmService } from '../../core/confirm'
|
||||||
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
|
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
|
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 { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { Router } from '@angular/router'
|
import { Router } from '@angular/router'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
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 { OAuthClientLocal, User as UserServerModel, UserRefreshToken } from '../../../../../shared'
|
||||||
import { User } from '../../../../../shared/models/users'
|
import { User } from '../../../../../shared/models/users'
|
||||||
import { UserLogin } from '../../../../../shared/models/users/user-login.model'
|
import { UserLogin } from '../../../../../shared/models/users/user-login.model'
|
||||||
|
@ -58,7 +53,7 @@ export class AuthService {
|
||||||
// Fetch the client_id/client_secret
|
// Fetch the client_id/client_secret
|
||||||
// FIXME: save in local storage?
|
// FIXME: save in local storage?
|
||||||
this.http.get<OAuthClientLocal>(AuthService.BASE_CLIENT_URL)
|
this.http.get<OAuthClientLocal>(AuthService.BASE_CLIENT_URL)
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
.pipe(catchError(res => this.restExtractor.handleError(res)))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
res => {
|
res => {
|
||||||
this.clientId = res.client_id
|
this.clientId = res.client_id
|
||||||
|
@ -129,10 +124,12 @@ export class AuthService {
|
||||||
|
|
||||||
const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
|
const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
return this.http.post<UserLogin>(AuthService.BASE_TOKEN_URL, body.toString(), { headers })
|
return this.http.post<UserLogin>(AuthService.BASE_TOKEN_URL, body.toString(), { headers })
|
||||||
.map(res => Object.assign(res, { username }))
|
.pipe(
|
||||||
.flatMap(res => this.mergeUserInformation(res))
|
map(res => Object.assign(res, { username })),
|
||||||
.map(res => this.handleLogin(res))
|
mergeMap(res => this.mergeUserInformation(res)),
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(res => this.handleLogin(res)),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
logout () {
|
logout () {
|
||||||
|
@ -161,9 +158,10 @@ export class AuthService {
|
||||||
const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
|
const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
|
|
||||||
this.refreshingTokenObservable = this.http.post<UserRefreshToken>(AuthService.BASE_TOKEN_URL, body, { headers })
|
this.refreshingTokenObservable = this.http.post<UserRefreshToken>(AuthService.BASE_TOKEN_URL, body, { headers })
|
||||||
.map(res => this.handleRefreshToken(res))
|
.pipe(
|
||||||
.do(() => this.refreshingTokenObservable = null)
|
map(res => this.handleRefreshToken(res)),
|
||||||
.catch(err => {
|
tap(() => this.refreshingTokenObservable = null),
|
||||||
|
catchError(err => {
|
||||||
this.refreshingTokenObservable = null
|
this.refreshingTokenObservable = null
|
||||||
|
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
@ -171,10 +169,11 @@ export class AuthService {
|
||||||
this.logout()
|
this.logout()
|
||||||
this.router.navigate([ '/login' ])
|
this.router.navigate([ '/login' ])
|
||||||
|
|
||||||
return Observable.throw({
|
return observableThrowError({
|
||||||
error: 'You need to reconnect.'
|
error: 'You need to reconnect.'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
|
||||||
return this.refreshingTokenObservable
|
return this.refreshingTokenObservable
|
||||||
}
|
}
|
||||||
|
@ -203,7 +202,7 @@ export class AuthService {
|
||||||
const headers = new HttpHeaders().set('Authorization', `${obj.token_type} ${obj.access_token}`)
|
const headers = new HttpHeaders().set('Authorization', `${obj.token_type} ${obj.access_token}`)
|
||||||
|
|
||||||
return this.http.get<UserServerModel>(AuthService.BASE_USER_INFORMATION_URL, { headers })
|
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) {
|
private handleLogin (obj: UserLoginWithUserInformation) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|
import { first } from 'rxjs/operators'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { Subject } from 'rxjs/Subject'
|
import { Subject } from 'rxjs'
|
||||||
import 'rxjs/add/operator/first'
|
|
||||||
import 'rxjs/add/operator/toPromise'
|
|
||||||
|
|
||||||
type ConfirmOptions = {
|
type ConfirmOptions = {
|
||||||
title: string
|
title: string
|
||||||
|
@ -19,12 +18,12 @@ export class ConfirmService {
|
||||||
confirm (message: string, title = '', confirmButtonText?: string) {
|
confirm (message: string, title = '', confirmButtonText?: string) {
|
||||||
this.showConfirm.next({ title, message, confirmButtonText })
|
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) {
|
confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
|
||||||
this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
|
this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
|
||||||
|
|
||||||
return this.confirmResponse.asObservable().first().toPromise()
|
return this.confirmResponse.asObservable().pipe(first()).toPromise()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import { Route, PreloadingStrategy } from '@angular/router'
|
import { Observable, timer as observableTimer, of as ofObservable } from 'rxjs'
|
||||||
import { Observable } from 'rxjs/Observable'
|
import { switchMap } from 'rxjs/operators'
|
||||||
import 'rxjs/add/observable/timer'
|
import { PreloadingStrategy, Route } from '@angular/router'
|
||||||
import 'rxjs/add/operator/switchMap'
|
|
||||||
|
|
||||||
export class PreloadSelectedModulesList implements PreloadingStrategy {
|
export class PreloadSelectedModulesList implements PreloadingStrategy {
|
||||||
preload (route: Route, load: Function): Observable<any> {
|
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') {
|
if (typeof route.data.preload === 'number') {
|
||||||
return Observable.timer(route.data.preload).switchMap(() => load())
|
return observableTimer(route.data.preload).pipe(switchMap(() => load()))
|
||||||
}
|
}
|
||||||
|
|
||||||
return load()
|
return load()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
import { tap } from 'rxjs/operators'
|
||||||
import { HttpClient } from '@angular/common/http'
|
import { HttpClient } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
|
import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
|
||||||
import 'rxjs/add/operator/do'
|
import { ReplaySubject } from 'rxjs'
|
||||||
import { ReplaySubject } from 'rxjs/ReplaySubject'
|
|
||||||
import { ServerConfig } from '../../../../../shared'
|
import { ServerConfig } from '../../../../../shared'
|
||||||
import { About } from '../../../../../shared/models/server/about.model'
|
import { About } from '../../../../../shared/models/server/about.model'
|
||||||
import { environment } from '../../../environments/environment'
|
import { environment } from '../../../environments/environment'
|
||||||
|
@ -69,7 +69,7 @@ export class ServerService {
|
||||||
|
|
||||||
loadConfig () {
|
loadConfig () {
|
||||||
this.http.get<ServerConfig>(ServerService.BASE_CONFIG_URL)
|
this.http.get<ServerConfig>(ServerService.BASE_CONFIG_URL)
|
||||||
.do(this.saveConfigLocally)
|
.pipe(tap(this.saveConfigLocally))
|
||||||
.subscribe(data => {
|
.subscribe(data => {
|
||||||
this.config = data
|
this.config = data
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
import { filter, map } from 'rxjs/operators'
|
||||||
import { Component, OnInit } from '@angular/core'
|
import { Component, OnInit } from '@angular/core'
|
||||||
import { Router, NavigationEnd } from '@angular/router'
|
import { NavigationEnd, Router } from '@angular/router'
|
||||||
import { getParameterByName } from '../shared/misc/utils'
|
import { getParameterByName } from '../shared/misc/utils'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -15,9 +16,11 @@ export class HeaderComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.router.events
|
this.router.events
|
||||||
.filter(e => e instanceof NavigationEnd)
|
.pipe(
|
||||||
.map(() => getParameterByName('search', window.location.href))
|
filter(e => e instanceof NavigationEnd),
|
||||||
.filter(searchQuery => !!searchQuery)
|
map(() => getParameterByName('search', window.location.href)),
|
||||||
|
filter(searchQuery => !!searchQuery)
|
||||||
|
)
|
||||||
.subscribe(searchQuery => this.searchValue = searchQuery)
|
.subscribe(searchQuery => this.searchValue = searchQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
|
import { map, tap, catchError } from 'rxjs/operators'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import 'rxjs/add/operator/catch'
|
|
||||||
import 'rxjs/add/operator/map'
|
|
||||||
import { environment } from '../../../environments/environment'
|
import { environment } from '../../../environments/environment'
|
||||||
import { Observable } from 'rxjs/Observable'
|
import { Observable, ReplaySubject } from 'rxjs'
|
||||||
import { Account } from '@app/shared/account/account.model'
|
import { Account } from '@app/shared/account/account.model'
|
||||||
import { RestExtractor } from '@app/shared/rest/rest-extractor.service'
|
import { RestExtractor } from '@app/shared/rest/rest-extractor.service'
|
||||||
import { RestService } from '@app/shared/rest/rest.service'
|
|
||||||
import { HttpClient } from '@angular/common/http'
|
import { HttpClient } from '@angular/common/http'
|
||||||
import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model'
|
import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model'
|
||||||
import { ReplaySubject } from 'rxjs/ReplaySubject'
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AccountService {
|
export class AccountService {
|
||||||
|
@ -18,14 +15,15 @@ export class AccountService {
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private authHttp: HttpClient,
|
private authHttp: HttpClient,
|
||||||
private restExtractor: RestExtractor,
|
private restExtractor: RestExtractor
|
||||||
private restService: RestService
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
getAccount (id: number): Observable<Account> {
|
getAccount (id: number): Observable<Account> {
|
||||||
return this.authHttp.get<ServerAccount>(AccountService.BASE_ACCOUNT_URL + id)
|
return this.authHttp.get<ServerAccount>(AccountService.BASE_ACCOUNT_URL + id)
|
||||||
.map(accountHash => new Account(accountHash))
|
.pipe(
|
||||||
.do(account => this.accountLoaded.next(account))
|
map(accountHash => new Account(accountHash)),
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
tap(account => this.accountLoaded.next(account)),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ export abstract class Actor implements ActorServer {
|
||||||
host: string
|
host: string
|
||||||
followingCount: number
|
followingCount: number
|
||||||
followersCount: number
|
followersCount: number
|
||||||
createdAt: Date
|
createdAt: Date | string
|
||||||
updatedAt: Date
|
updatedAt: Date | string
|
||||||
avatar: Avatar
|
avatar: Avatar
|
||||||
|
|
||||||
avatarUrl: string
|
avatarUrl: string
|
||||||
|
@ -41,8 +41,8 @@ export abstract class Actor implements ActorServer {
|
||||||
this.host = hash.host
|
this.host = hash.host
|
||||||
this.followingCount = hash.followingCount
|
this.followingCount = hash.followingCount
|
||||||
this.followersCount = hash.followersCount
|
this.followersCount = hash.followersCount
|
||||||
this.createdAt = new Date(hash.createdAt)
|
this.createdAt = new Date(hash.createdAt.toString())
|
||||||
this.updatedAt = new Date(hash.updatedAt)
|
this.updatedAt = new Date(hash.updatedAt.toString())
|
||||||
this.avatar = hash.avatar
|
this.avatar = hash.avatar
|
||||||
|
|
||||||
this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this)
|
this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this)
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
|
import { Observable, throwError as observableThrowError } from 'rxjs'
|
||||||
|
import { catchError, switchMap } from 'rxjs/operators'
|
||||||
import { Injectable, Injector } from '@angular/core'
|
import { Injectable, Injector } from '@angular/core'
|
||||||
import {
|
import { HTTP_INTERCEPTORS, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'
|
||||||
HttpInterceptor,
|
|
||||||
HttpRequest,
|
|
||||||
HttpEvent,
|
|
||||||
HttpHandler, HTTP_INTERCEPTORS
|
|
||||||
} from '@angular/common/http'
|
|
||||||
import { Observable } from 'rxjs/Observable'
|
|
||||||
|
|
||||||
import { AuthService } from '../../core'
|
import { AuthService } from '../../core'
|
||||||
import 'rxjs/add/operator/switchMap'
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthInterceptor implements HttpInterceptor {
|
export class AuthInterceptor implements HttpInterceptor {
|
||||||
|
@ -27,22 +21,26 @@ export class AuthInterceptor implements HttpInterceptor {
|
||||||
// Pass on the cloned request instead of the original request
|
// Pass on the cloned request instead of the original request
|
||||||
// Catch 401 errors (refresh token expired)
|
// Catch 401 errors (refresh token expired)
|
||||||
return next.handle(authReq)
|
return next.handle(authReq)
|
||||||
.catch(err => {
|
.pipe(
|
||||||
|
catchError(err => {
|
||||||
if (err.status === 401 && err.error && err.error.code === 'invalid_token') {
|
if (err.status === 401 && err.error && err.error.code === 'invalid_token') {
|
||||||
return this.handleTokenExpired(req, next)
|
return this.handleTokenExpired(req, next)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Observable.throw(err)
|
return observableThrowError(err)
|
||||||
})
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleTokenExpired (req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
private handleTokenExpired (req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||||
return this.authService.refreshAccessToken()
|
return this.authService.refreshAccessToken()
|
||||||
.switchMap(() => {
|
.pipe(
|
||||||
|
switchMap(() => {
|
||||||
const authReq = this.cloneRequestWithAuth(req)
|
const authReq = this.cloneRequestWithAuth(req)
|
||||||
|
|
||||||
return next.handle(authReq)
|
return next.handle(authReq)
|
||||||
})
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private cloneRequestWithAuth (req: HttpRequest<any>) {
|
private cloneRequestWithAuth (req: HttpRequest<any>) {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
|
import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
|
||||||
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
||||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
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 { isInSmallView } from '@app/shared/misc/utils'
|
||||||
import { MarkdownService } from '@app/videos/shared'
|
import { MarkdownService } from '@app/videos/shared'
|
||||||
import { Subject } from 'rxjs/Subject'
|
import { Subject } from 'rxjs'
|
||||||
import truncate from 'lodash-es/truncate'
|
import truncate from 'lodash-es/truncate'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -40,8 +39,10 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.contentChanged
|
this.contentChanged
|
||||||
.debounceTime(150)
|
.pipe(
|
||||||
.distinctUntilChanged()
|
debounceTime(150),
|
||||||
|
distinctUntilChanged()
|
||||||
|
)
|
||||||
.subscribe(() => this.updatePreviews())
|
.subscribe(() => this.updatePreviews())
|
||||||
|
|
||||||
this.contentChanged.next(this.content)
|
this.contentChanged.next(this.content)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'
|
import { ActivatedRouteSnapshot, CanDeactivate, RouterStateSnapshot } from '@angular/router'
|
||||||
import { Observable } from 'rxjs/Observable'
|
import { Observable } from 'rxjs'
|
||||||
import { ConfirmService } from '../../core/index'
|
import { ConfirmService } from '../../core/index'
|
||||||
|
|
||||||
export interface CanComponentDeactivate {
|
export interface CanComponentDeactivate {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { HttpErrorResponse } from '@angular/common/http'
|
import { of, throwError as observableThrowError } from 'rxjs'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { dateToHuman } from '@app/shared/misc/utils'
|
import { dateToHuman } from '@app/shared/misc/utils'
|
||||||
import { Observable } from 'rxjs/Observable'
|
|
||||||
import { ResultList } from '../../../../../shared'
|
import { ResultList } from '../../../../../shared'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -86,6 +85,8 @@ export class RestExtractor {
|
||||||
errorObj.body = err.error
|
errorObj.body = err.error
|
||||||
}
|
}
|
||||||
|
|
||||||
return Observable.throw(errorObj)
|
observableThrowError(errorObj)
|
||||||
|
|
||||||
|
return of(undefined)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|
import { catchError, map } from 'rxjs/operators'
|
||||||
import { HttpClient } from '@angular/common/http'
|
import { HttpClient } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import 'rxjs/add/operator/catch'
|
|
||||||
import 'rxjs/add/operator/map'
|
|
||||||
import { UserCreate, UserUpdateMe } from '../../../../../shared'
|
import { UserCreate, UserUpdateMe } from '../../../../../shared'
|
||||||
import { environment } from '../../../environments/environment'
|
import { environment } from '../../../environments/environment'
|
||||||
import { RestExtractor } from '../rest'
|
import { RestExtractor } from '../rest'
|
||||||
|
@ -13,7 +12,8 @@ export class UserService {
|
||||||
constructor (
|
constructor (
|
||||||
private authHttp: HttpClient,
|
private authHttp: HttpClient,
|
||||||
private restExtractor: RestExtractor
|
private restExtractor: RestExtractor
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
changePassword (newPassword: string) {
|
changePassword (newPassword: string) {
|
||||||
const url = UserService.BASE_USERS_URL + 'me'
|
const url = UserService.BASE_USERS_URL + 'me'
|
||||||
|
@ -22,44 +22,52 @@ export class UserService {
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.authHttp.put(url, body)
|
return this.authHttp.put(url, body)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMyProfile (profile: UserUpdateMe) {
|
updateMyProfile (profile: UserUpdateMe) {
|
||||||
const url = UserService.BASE_USERS_URL + 'me'
|
const url = UserService.BASE_USERS_URL + 'me'
|
||||||
|
|
||||||
return this.authHttp.put(url, profile)
|
return this.authHttp.put(url, profile)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
changeAvatar (avatarForm: FormData) {
|
changeAvatar (avatarForm: FormData) {
|
||||||
const url = UserService.BASE_USERS_URL + 'me/avatar/pick'
|
const url = UserService.BASE_USERS_URL + 'me/avatar/pick'
|
||||||
|
|
||||||
return this.authHttp.post(url, avatarForm)
|
return this.authHttp.post(url, avatarForm)
|
||||||
.catch(this.restExtractor.handleError)
|
.pipe(catchError(this.restExtractor.handleError))
|
||||||
}
|
}
|
||||||
|
|
||||||
signup (userCreate: UserCreate) {
|
signup (userCreate: UserCreate) {
|
||||||
return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate)
|
return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getMyVideoQuotaUsed () {
|
getMyVideoQuotaUsed () {
|
||||||
const url = UserService.BASE_USERS_URL + '/me/video-quota-used'
|
const url = UserService.BASE_USERS_URL + '/me/video-quota-used'
|
||||||
|
|
||||||
return this.authHttp.get(url)
|
return this.authHttp.get(url)
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
.pipe(catchError(res => this.restExtractor.handleError(res)))
|
||||||
}
|
}
|
||||||
|
|
||||||
askResetPassword (email: string) {
|
askResetPassword (email: string) {
|
||||||
const url = UserService.BASE_USERS_URL + '/ask-reset-password'
|
const url = UserService.BASE_USERS_URL + '/ask-reset-password'
|
||||||
|
|
||||||
return this.authHttp.post(url, { email })
|
return this.authHttp.post(url, { email })
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
resetPassword (userId: number, verificationString: string, password: string) {
|
resetPassword (userId: number, verificationString: string, password: string) {
|
||||||
|
@ -70,7 +78,9 @@ export class UserService {
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.authHttp.post(url, body)
|
return this.authHttp.post(url, body)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
|
import { catchError, map } from 'rxjs/operators'
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http'
|
import { HttpClient, HttpParams } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { SortMeta } from 'primeng/components/common/sortmeta'
|
import { SortMeta } from 'primeng/components/common/sortmeta'
|
||||||
import 'rxjs/add/operator/catch'
|
import { Observable } from 'rxjs'
|
||||||
import 'rxjs/add/operator/map'
|
|
||||||
import { Observable } from 'rxjs/Observable'
|
|
||||||
import { ResultList, VideoAbuse } from '../../../../../shared'
|
import { ResultList, VideoAbuse } from '../../../../../shared'
|
||||||
import { environment } from '../../../environments/environment'
|
import { environment } from '../../../environments/environment'
|
||||||
import { RestExtractor, RestPagination, RestService } from '../rest'
|
import { RestExtractor, RestPagination, RestService } from '../rest'
|
||||||
|
@ -25,8 +24,10 @@ export class VideoAbuseService {
|
||||||
params = this.restService.addRestGetParams(params, pagination, sort)
|
params = this.restService.addRestGetParams(params, pagination, sort)
|
||||||
|
|
||||||
return this.authHttp.get<ResultList<VideoAbuse>>(url, { params })
|
return this.authHttp.get<ResultList<VideoAbuse>>(url, { params })
|
||||||
.map(res => this.restExtractor.convertResultListDateToHuman(res))
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(res => this.restExtractor.convertResultListDateToHuman(res)),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
reportVideo (id: number, reason: string) {
|
reportVideo (id: number, reason: string) {
|
||||||
|
@ -36,7 +37,9 @@ export class VideoAbuseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.authHttp.post(url, body)
|
return this.authHttp.post(url, body)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
|
import { catchError, map } from 'rxjs/operators'
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http'
|
import { HttpClient, HttpParams } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { SortMeta } from 'primeng/components/common/sortmeta'
|
import { SortMeta } from 'primeng/components/common/sortmeta'
|
||||||
import 'rxjs/add/operator/catch'
|
import { Observable } from 'rxjs'
|
||||||
import 'rxjs/add/operator/map'
|
|
||||||
import { Observable } from 'rxjs/Observable'
|
|
||||||
import { BlacklistedVideo, ResultList } from '../../../../../shared'
|
import { BlacklistedVideo, ResultList } from '../../../../../shared'
|
||||||
import { environment } from '../../../environments/environment'
|
import { environment } from '../../../environments/environment'
|
||||||
import { RestExtractor, RestPagination, RestService } from '../rest'
|
import { RestExtractor, RestPagination, RestService } from '../rest'
|
||||||
|
@ -23,19 +22,25 @@ export class VideoBlacklistService {
|
||||||
params = this.restService.addRestGetParams(params, pagination, sort)
|
params = this.restService.addRestGetParams(params, pagination, sort)
|
||||||
|
|
||||||
return this.authHttp.get<ResultList<BlacklistedVideo>>(VideoBlacklistService.BASE_VIDEOS_URL + 'blacklist', { params })
|
return this.authHttp.get<ResultList<BlacklistedVideo>>(VideoBlacklistService.BASE_VIDEOS_URL + 'blacklist', { params })
|
||||||
.map(res => this.restExtractor.convertResultListDateToHuman(res))
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(res => this.restExtractor.convertResultListDateToHuman(res)),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
removeVideoFromBlacklist (videoId: number) {
|
removeVideoFromBlacklist (videoId: number) {
|
||||||
return this.authHttp.delete(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist')
|
return this.authHttp.delete(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist')
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
blacklistVideo (videoId: number) {
|
blacklistVideo (videoId: number) {
|
||||||
return this.authHttp.post(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist', {})
|
return this.authHttp.post(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist', {})
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
|
import { catchError, map, tap } from 'rxjs/operators'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import 'rxjs/add/operator/catch'
|
import { Observable, ReplaySubject } from 'rxjs'
|
||||||
import 'rxjs/add/operator/map'
|
|
||||||
import { Observable } from 'rxjs/Observable'
|
|
||||||
import { RestExtractor } from '../rest/rest-extractor.service'
|
import { RestExtractor } from '../rest/rest-extractor.service'
|
||||||
import { RestService } from '../rest/rest.service'
|
|
||||||
import { HttpClient } from '@angular/common/http'
|
import { HttpClient } from '@angular/common/http'
|
||||||
import { VideoChannel as VideoChannelServer, VideoChannelCreate, VideoChannelUpdate } from '../../../../../shared/models/videos'
|
import { VideoChannel as VideoChannelServer, VideoChannelCreate, VideoChannelUpdate } from '../../../../../shared/models/videos'
|
||||||
import { AccountService } from '../account/account.service'
|
import { AccountService } from '../account/account.service'
|
||||||
import { ResultList } from '../../../../../shared'
|
import { ResultList } from '../../../../../shared'
|
||||||
import { VideoChannel } from './video-channel.model'
|
import { VideoChannel } from './video-channel.model'
|
||||||
import { ReplaySubject } from 'rxjs/ReplaySubject'
|
|
||||||
import { environment } from '../../../environments/environment'
|
import { environment } from '../../../environments/environment'
|
||||||
import { UserService } from '@app/+admin/users/shared/user.service'
|
|
||||||
import { User } from '@app/shared'
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class VideoChannelService {
|
export class VideoChannelService {
|
||||||
|
@ -22,39 +17,48 @@ export class VideoChannelService {
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private authHttp: HttpClient,
|
private authHttp: HttpClient,
|
||||||
private restExtractor: RestExtractor,
|
private restExtractor: RestExtractor
|
||||||
private restService: RestService
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
getVideoChannel (videoChannelUUID: string) {
|
getVideoChannel (videoChannelUUID: string) {
|
||||||
return this.authHttp.get<VideoChannel>(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID)
|
return this.authHttp.get<VideoChannel>(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID)
|
||||||
.map(videoChannelHash => new VideoChannel(videoChannelHash))
|
.pipe(
|
||||||
.do(videoChannel => this.videoChannelLoaded.next(videoChannel))
|
map(videoChannelHash => new VideoChannel(videoChannelHash)),
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
tap(videoChannel => this.videoChannelLoaded.next(videoChannel)),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
listAccountVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> {
|
listAccountVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> {
|
||||||
return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels')
|
return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels')
|
||||||
.map(res => this.extractVideoChannels(res))
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(res => this.extractVideoChannels(res)),
|
||||||
|
catchError((res) => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
createVideoChannel (videoChannel: VideoChannelCreate) {
|
createVideoChannel (videoChannel: VideoChannelCreate) {
|
||||||
return this.authHttp.post(VideoChannelService.BASE_VIDEO_CHANNEL_URL, videoChannel)
|
return this.authHttp.post(VideoChannelService.BASE_VIDEO_CHANNEL_URL, videoChannel)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(err => this.restExtractor.handleError(err))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(err => this.restExtractor.handleError(err))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVideoChannel (videoChannelUUID: string, videoChannel: VideoChannelUpdate) {
|
updateVideoChannel (videoChannelUUID: string, videoChannel: VideoChannelUpdate) {
|
||||||
return this.authHttp.put(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID, videoChannel)
|
return this.authHttp.put(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannelUUID, videoChannel)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(err => this.restExtractor.handleError(err))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(err => this.restExtractor.handleError(err))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
removeVideoChannel (videoChannel: VideoChannel) {
|
removeVideoChannel (videoChannel: VideoChannel) {
|
||||||
return this.authHttp.delete(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid)
|
return this.authHttp.delete(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(err => this.restExtractor.handleError(err))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(err => this.restExtractor.handleError(err))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private extractVideoChannels (result: ResultList<VideoChannelServer>) {
|
private extractVideoChannels (result: ResultList<VideoChannelServer>) {
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
|
import { debounceTime } from 'rxjs/operators'
|
||||||
import { ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'
|
import { ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'
|
||||||
import { ActivatedRoute, Router } from '@angular/router'
|
import { ActivatedRoute, Router } from '@angular/router'
|
||||||
import { Location } from '@angular/common'
|
import { Location } from '@angular/common'
|
||||||
import { isInMobileView } from '@app/shared/misc/utils'
|
import { isInMobileView } from '@app/shared/misc/utils'
|
||||||
import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive'
|
import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import 'rxjs/add/operator/debounceTime'
|
import { fromEvent, Observable, Subscription } from 'rxjs'
|
||||||
import { Observable } from 'rxjs/Observable'
|
|
||||||
import { fromEvent } from 'rxjs/observable/fromEvent'
|
|
||||||
import { Subscription } from 'rxjs/Subscription'
|
|
||||||
import { AuthService } from '../../core/auth'
|
import { AuthService } from '../../core/auth'
|
||||||
import { ComponentPagination } from '../rest/component-pagination.model'
|
import { ComponentPagination } from '../rest/component-pagination.model'
|
||||||
import { VideoSortField } from './sort-field.type'
|
import { VideoSortField } from './sort-field.type'
|
||||||
|
@ -64,7 +62,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
|
||||||
this.loadRouteParams(routeParams)
|
this.loadRouteParams(routeParams)
|
||||||
|
|
||||||
this.resizeSubscription = fromEvent(window, 'resize')
|
this.resizeSubscription = fromEvent(window, 'resize')
|
||||||
.debounceTime(500)
|
.pipe(debounceTime(500))
|
||||||
.subscribe(() => this.calcPageSizes())
|
.subscribe(() => this.calcPageSizes())
|
||||||
|
|
||||||
this.calcPageSizes()
|
this.calcPageSizes()
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
|
import { distinct, distinctUntilChanged, filter, map, share, startWith, throttleTime } from 'rxjs/operators'
|
||||||
import { Directive, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'
|
import { Directive, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'
|
||||||
import 'rxjs/add/operator/debounceTime'
|
import { fromEvent, Subscription } from 'rxjs'
|
||||||
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'
|
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[myInfiniteScroller]'
|
selector: '[myInfiniteScroller]'
|
||||||
|
@ -51,43 +43,51 @@ export class InfiniteScrollerDirective implements OnInit, OnDestroy {
|
||||||
const throttleOptions = { leading: true, trailing: true }
|
const throttleOptions = { leading: true, trailing: true }
|
||||||
|
|
||||||
const scrollObservable = fromEvent(window, 'scroll')
|
const scrollObservable = fromEvent(window, 'scroll')
|
||||||
.startWith(true)
|
.pipe(
|
||||||
.throttleTime(200, undefined, throttleOptions)
|
startWith(null),
|
||||||
.map(() => ({ current: window.scrollY, maximumScroll: document.body.clientHeight - window.innerHeight }))
|
throttleTime(200, undefined, throttleOptions),
|
||||||
.distinctUntilChanged((o1, o2) => o1.current === o2.current)
|
map(() => ({ current: window.scrollY, maximumScroll: document.body.clientHeight - window.innerHeight })),
|
||||||
.share()
|
distinctUntilChanged((o1, o2) => o1.current === o2.current),
|
||||||
|
share()
|
||||||
|
)
|
||||||
|
|
||||||
// Scroll Down
|
// Scroll Down
|
||||||
this.scrollDownSub = scrollObservable
|
this.scrollDownSub = scrollObservable
|
||||||
|
.pipe(
|
||||||
// Check we scroll down
|
// Check we scroll down
|
||||||
.filter(({ current }) => {
|
filter(({ current }) => {
|
||||||
const res = this.lastCurrentBottom < current
|
const res = this.lastCurrentBottom < current
|
||||||
|
|
||||||
this.lastCurrentBottom = current
|
this.lastCurrentBottom = current
|
||||||
return res
|
return res
|
||||||
})
|
}),
|
||||||
.filter(({ current, maximumScroll }) => maximumScroll <= 0 || (current / maximumScroll) > this.decimalLimit)
|
filter(({ current, maximumScroll }) => maximumScroll <= 0 || (current / maximumScroll) > this.decimalLimit)
|
||||||
|
)
|
||||||
.subscribe(() => this.nearOfBottom.emit())
|
.subscribe(() => this.nearOfBottom.emit())
|
||||||
|
|
||||||
// Scroll up
|
// Scroll up
|
||||||
this.scrollUpSub = scrollObservable
|
this.scrollUpSub = scrollObservable
|
||||||
|
.pipe(
|
||||||
// Check we scroll up
|
// Check we scroll up
|
||||||
.filter(({ current }) => {
|
filter(({ current }) => {
|
||||||
const res = this.lastCurrentTop > current
|
const res = this.lastCurrentTop > current
|
||||||
|
|
||||||
this.lastCurrentTop = current
|
this.lastCurrentTop = current
|
||||||
return res
|
return res
|
||||||
})
|
}),
|
||||||
.filter(({ current, maximumScroll }) => {
|
filter(({ current, maximumScroll }) => {
|
||||||
return current !== 0 && (1 - (current / maximumScroll)) > this.decimalLimit
|
return current !== 0 && (1 - (current / maximumScroll)) > this.decimalLimit
|
||||||
})
|
})
|
||||||
|
)
|
||||||
.subscribe(() => this.nearOfTop.emit())
|
.subscribe(() => this.nearOfTop.emit())
|
||||||
|
|
||||||
// Page change
|
// Page change
|
||||||
this.pageChangeSub = scrollObservable
|
this.pageChangeSub = scrollObservable
|
||||||
.distinct()
|
.pipe(
|
||||||
.map(({ current }) => this.calculateCurrentPage(current))
|
distinct(),
|
||||||
.distinctUntilChanged()
|
map(({ current }) => this.calculateCurrentPage(current)),
|
||||||
|
distinctUntilChanged()
|
||||||
|
)
|
||||||
.subscribe(res => this.pageChanged.emit(res))
|
.subscribe(res => this.pageChanged.emit(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
|
import { catchError, map } from 'rxjs/operators'
|
||||||
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
|
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import 'rxjs/add/operator/catch'
|
import { Observable } from 'rxjs'
|
||||||
import 'rxjs/add/operator/map'
|
|
||||||
import { Observable } from 'rxjs/Observable'
|
|
||||||
import { Video as VideoServerModel, VideoDetails as VideoDetailsServerModel } from '../../../../../shared'
|
import { Video as VideoServerModel, VideoDetails as VideoDetailsServerModel } from '../../../../../shared'
|
||||||
import { ResultList } from '../../../../../shared/models/result-list.model'
|
import { ResultList } from '../../../../../shared/models/result-list.model'
|
||||||
import { UserVideoRateUpdate } from '../../../../../shared/models/videos/user-video-rate-update.model'
|
import { UserVideoRateUpdate } from '../../../../../shared/models/videos/user-video-rate-update.model'
|
||||||
|
@ -43,14 +42,18 @@ export class VideoService {
|
||||||
|
|
||||||
getVideo (uuid: string): Observable<VideoDetails> {
|
getVideo (uuid: string): Observable<VideoDetails> {
|
||||||
return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + uuid)
|
return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + uuid)
|
||||||
.map(videoHash => new VideoDetails(videoHash))
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(videoHash => new VideoDetails(videoHash)),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
viewVideo (uuid: string): Observable<VideoDetails> {
|
viewVideo (uuid: string): Observable<VideoDetails> {
|
||||||
return this.authHttp.post(this.getVideoViewUrl(uuid), {})
|
return this.authHttp.post(this.getVideoViewUrl(uuid), {})
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(this.restExtractor.handleError)
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(this.restExtractor.handleError)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVideo (video: VideoEdit) {
|
updateVideo (video: VideoEdit) {
|
||||||
|
@ -79,8 +82,10 @@ export class VideoService {
|
||||||
const data = objectToFormData(body)
|
const data = objectToFormData(body)
|
||||||
|
|
||||||
return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, data)
|
return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, data)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(this.restExtractor.handleError)
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(this.restExtractor.handleError)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadVideo (video: FormData) {
|
uploadVideo (video: FormData) {
|
||||||
|
@ -88,7 +93,7 @@ export class VideoService {
|
||||||
|
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.request(req)
|
.request(req)
|
||||||
.catch(this.restExtractor.handleError)
|
.pipe(catchError(this.restExtractor.handleError))
|
||||||
}
|
}
|
||||||
|
|
||||||
getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField): Observable<{ videos: Video[], totalVideos: number}> {
|
getMyVideos (videoPagination: ComponentPagination, sort: VideoSortField): Observable<{ videos: Video[], totalVideos: number}> {
|
||||||
|
@ -98,8 +103,10 @@ export class VideoService {
|
||||||
params = this.restService.addRestGetParams(params, pagination, sort)
|
params = this.restService.addRestGetParams(params, pagination, sort)
|
||||||
|
|
||||||
return this.authHttp.get(UserService.BASE_USERS_URL + '/me/videos', { params })
|
return this.authHttp.get(UserService.BASE_USERS_URL + '/me/videos', { params })
|
||||||
.map(this.extractVideos)
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(this.extractVideos),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getAccountVideos (
|
getAccountVideos (
|
||||||
|
@ -114,8 +121,10 @@ export class VideoService {
|
||||||
|
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.get(AccountService.BASE_ACCOUNT_URL + account.id + '/videos', { params })
|
.get(AccountService.BASE_ACCOUNT_URL + account.id + '/videos', { params })
|
||||||
.map(this.extractVideos)
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(this.extractVideos),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getVideoChannelVideos (
|
getVideoChannelVideos (
|
||||||
|
@ -130,8 +139,10 @@ export class VideoService {
|
||||||
|
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.get(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid + '/videos', { params })
|
.get(VideoChannelService.BASE_VIDEO_CHANNEL_URL + videoChannel.uuid + '/videos', { params })
|
||||||
.map(this.extractVideos)
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(this.extractVideos),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getVideos (
|
getVideos (
|
||||||
|
@ -150,8 +161,10 @@ export class VideoService {
|
||||||
|
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.get(VideoService.BASE_VIDEO_URL, { params })
|
.get(VideoService.BASE_VIDEO_URL, { params })
|
||||||
.map(this.extractVideos)
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(this.extractVideos),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
buildBaseFeedUrls (params: HttpParams) {
|
buildBaseFeedUrls (params: HttpParams) {
|
||||||
|
@ -216,22 +229,28 @@ export class VideoService {
|
||||||
|
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.get<ResultList<VideoServerModel>>(url, { params })
|
.get<ResultList<VideoServerModel>>(url, { params })
|
||||||
.map(this.extractVideos)
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(this.extractVideos),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
removeVideo (id: number) {
|
removeVideo (id: number) {
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.delete(VideoService.BASE_VIDEO_URL + id)
|
.delete(VideoService.BASE_VIDEO_URL + id)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadCompleteDescription (descriptionPath: string) {
|
loadCompleteDescription (descriptionPath: string) {
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.get(environment.apiUrl + descriptionPath)
|
.get(environment.apiUrl + descriptionPath)
|
||||||
.map(res => res['description'])
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(res => res[ 'description' ]),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
setVideoLike (id: number) {
|
setVideoLike (id: number) {
|
||||||
|
@ -251,7 +270,7 @@ export class VideoService {
|
||||||
|
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.get(url)
|
.get(url)
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
.pipe(catchError(res => this.restExtractor.handleError(res)))
|
||||||
}
|
}
|
||||||
|
|
||||||
private setVideoRate (id: number, rateType: VideoRateType) {
|
private setVideoRate (id: number, rateType: VideoRateType) {
|
||||||
|
@ -262,8 +281,10 @@ export class VideoService {
|
||||||
|
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.put(url, body)
|
.put(url, body)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch(res => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError(res => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private extractVideos (result: ResultList<VideoServerModel>) {
|
private extractVideos (result: ResultList<VideoServerModel>) {
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { FormBuilder, FormControl, FormGroup } from '@angular/forms'
|
||||||
import { ActivatedRoute, Router } from '@angular/router'
|
import { ActivatedRoute, Router } from '@angular/router'
|
||||||
import { VIDEO_IMAGE, VIDEO_SUPPORT } from '@app/shared'
|
import { VIDEO_IMAGE, VIDEO_SUPPORT } from '@app/shared'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import 'rxjs/add/observable/forkJoin'
|
|
||||||
import { ServerService } from '../../../core/server'
|
import { ServerService } from '../../../core/server'
|
||||||
import { VIDEO_CHANNEL } from '../../../shared/forms/form-validators'
|
import { VIDEO_CHANNEL } from '../../../shared/forms/form-validators'
|
||||||
import { ValidatorMessage } from '../../../shared/forms/form-validators/validator-message'
|
import { ValidatorMessage } from '../../../shared/forms/form-validators/validator-message'
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { Component, forwardRef, Input } from '@angular/core'
|
||||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||||
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'
|
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'
|
||||||
import { ServerService } from '@app/core'
|
import { ServerService } from '@app/core'
|
||||||
import 'rxjs/add/observable/forkJoin'
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-video-image',
|
selector: 'my-video-image',
|
||||||
|
@ -16,7 +15,6 @@ import 'rxjs/add/observable/forkJoin'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class VideoImageComponent implements ControlValueAccessor {
|
export class VideoImageComponent implements ControlValueAccessor {
|
||||||
@Input() inputLabel: string
|
@Input() inputLabel: string
|
||||||
@Input() inputName: string
|
@Input() inputName: string
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.
|
||||||
import { LoadingBarService } from '@ngx-loading-bar/core'
|
import { LoadingBarService } from '@ngx-loading-bar/core'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import { BytesPipe } from 'ngx-pipes'
|
import { BytesPipe } from 'ngx-pipes'
|
||||||
import { Subscription } from 'rxjs/Subscription'
|
import { Subscription } from 'rxjs'
|
||||||
import { VideoPrivacy } from '../../../../../shared/models/videos'
|
import { VideoPrivacy } from '../../../../../shared/models/videos'
|
||||||
import { AuthService, ServerService } from '../../core'
|
import { AuthService, ServerService } from '../../core'
|
||||||
import { FormReactive } from '../../shared'
|
import { FormReactive } from '../../shared'
|
||||||
|
@ -24,7 +24,6 @@ import { VideoService } from '../../shared/video/video.service'
|
||||||
'./video-add.component.scss'
|
'./video-add.component.scss'
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy, CanComponentDeactivate {
|
export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy, CanComponentDeactivate {
|
||||||
@ViewChild('videofileInput') videofileInput
|
@ViewChild('videofileInput') videofileInput
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
import { map, switchMap } from 'rxjs/operators'
|
||||||
import { Component, OnInit } from '@angular/core'
|
import { Component, OnInit } from '@angular/core'
|
||||||
import { FormBuilder, FormGroup } from '@angular/forms'
|
import { FormBuilder, FormGroup } from '@angular/forms'
|
||||||
import { ActivatedRoute, Router } from '@angular/router'
|
import { ActivatedRoute, Router } from '@angular/router'
|
||||||
import { LoadingBarService } from '@ngx-loading-bar/core'
|
import { LoadingBarService } from '@ngx-loading-bar/core'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import 'rxjs/add/observable/forkJoin'
|
|
||||||
import { VideoPrivacy } from '../../../../../shared/models/videos'
|
import { VideoPrivacy } from '../../../../../shared/models/videos'
|
||||||
import { ServerService } from '../../core'
|
import { ServerService } from '../../core'
|
||||||
import { AuthService } from '../../core/auth'
|
import { AuthService } from '../../core/auth'
|
||||||
|
@ -18,7 +18,6 @@ import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils'
|
||||||
styleUrls: [ './shared/video-edit.component.scss' ],
|
styleUrls: [ './shared/video-edit.component.scss' ],
|
||||||
templateUrl: './video-update.component.html'
|
templateUrl: './video-update.component.html'
|
||||||
})
|
})
|
||||||
|
|
||||||
export class VideoUpdateComponent extends FormReactive implements OnInit {
|
export class VideoUpdateComponent extends FormReactive implements OnInit {
|
||||||
video: VideoEdit
|
video: VideoEdit
|
||||||
|
|
||||||
|
@ -53,13 +52,15 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
|
||||||
this.serverService.videoPrivaciesLoaded
|
this.serverService.videoPrivaciesLoaded
|
||||||
.subscribe(() => this.videoPrivacies = this.serverService.getVideoPrivacies())
|
.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)
|
this.videoService.getVideo(uuid)
|
||||||
.switchMap(video => {
|
.pipe(
|
||||||
|
switchMap(video => {
|
||||||
return this.videoService
|
return this.videoService
|
||||||
.loadCompleteDescription(video.descriptionPath)
|
.loadCompleteDescription(video.descriptionPath)
|
||||||
.map(description => Object.assign(video, { description }))
|
.pipe(map(description => Object.assign(video, { description })))
|
||||||
})
|
})
|
||||||
|
)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
video => {
|
video => {
|
||||||
this.video = new VideoEdit(video)
|
this.video = new VideoEdit(video)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
|
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
|
||||||
import { FormBuilder, FormGroup } from '@angular/forms'
|
import { FormBuilder, FormGroup } from '@angular/forms'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import { Observable } from 'rxjs/Observable'
|
import { Observable } from 'rxjs'
|
||||||
import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model'
|
import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model'
|
||||||
import { FormReactive } from '../../../shared'
|
import { FormReactive } from '../../../shared'
|
||||||
import { VIDEO_COMMENT_TEXT } from '../../../shared/forms/form-validators/video-comment'
|
import { VIDEO_COMMENT_TEXT } from '../../../shared/forms/form-validators/video-comment'
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
|
import { catchError, map } from 'rxjs/operators'
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http'
|
import { HttpClient, HttpParams } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { lineFeedToHtml } from '@app/shared/misc/utils'
|
import { lineFeedToHtml } from '@app/shared/misc/utils'
|
||||||
import { MarkdownService } from '@app/videos/shared'
|
import { Observable } from 'rxjs'
|
||||||
import 'rxjs/add/operator/catch'
|
|
||||||
import 'rxjs/add/operator/map'
|
|
||||||
import { Observable } from 'rxjs/Observable'
|
|
||||||
import { ResultList } from '../../../../../../shared/models'
|
import { ResultList } from '../../../../../../shared/models'
|
||||||
import {
|
import {
|
||||||
VideoComment as VideoCommentServerModel,
|
VideoComment as VideoCommentServerModel,
|
||||||
|
@ -32,8 +30,10 @@ export class VideoCommentService {
|
||||||
const normalizedComment = lineFeedToHtml(comment, 'text')
|
const normalizedComment = lineFeedToHtml(comment, 'text')
|
||||||
|
|
||||||
return this.authHttp.post(url, normalizedComment)
|
return this.authHttp.post(url, normalizedComment)
|
||||||
.map(data => this.extractVideoComment(data['comment']))
|
.pipe(
|
||||||
.catch(this.restExtractor.handleError)
|
map(data => this.extractVideoComment(data['comment'])),
|
||||||
|
catchError(this.restExtractor.handleError)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
addCommentReply (videoId: number | string, inReplyToCommentId: number, comment: VideoCommentCreate) {
|
addCommentReply (videoId: number | string, inReplyToCommentId: number, comment: VideoCommentCreate) {
|
||||||
|
@ -41,8 +41,10 @@ export class VideoCommentService {
|
||||||
const normalizedComment = lineFeedToHtml(comment, 'text')
|
const normalizedComment = lineFeedToHtml(comment, 'text')
|
||||||
|
|
||||||
return this.authHttp.post(url, normalizedComment)
|
return this.authHttp.post(url, normalizedComment)
|
||||||
.map(data => this.extractVideoComment(data['comment']))
|
.pipe(
|
||||||
.catch(this.restExtractor.handleError)
|
map(data => this.extractVideoComment(data[ 'comment' ])),
|
||||||
|
catchError(this.restExtractor.handleError)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getVideoCommentThreads (
|
getVideoCommentThreads (
|
||||||
|
@ -58,8 +60,10 @@ export class VideoCommentService {
|
||||||
const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads'
|
const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads'
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.get(url, { params })
|
.get(url, { params })
|
||||||
.map(this.extractVideoComments)
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(this.extractVideoComments),
|
||||||
|
catchError((res) => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getVideoThreadComments (videoId: number | string, threadId: number): Observable<VideoCommentThreadTree> {
|
getVideoThreadComments (videoId: number | string, threadId: number): Observable<VideoCommentThreadTree> {
|
||||||
|
@ -67,8 +71,10 @@ export class VideoCommentService {
|
||||||
|
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.get(url)
|
.get(url)
|
||||||
.map(tree => this.extractVideoCommentTree(tree as VideoCommentThreadTree))
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(tree => this.extractVideoCommentTree(tree as VideoCommentThreadTree)),
|
||||||
|
catchError((res) => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteVideoComment (videoId: number | string, commentId: number) {
|
deleteVideoComment (videoId: number | string, commentId: number) {
|
||||||
|
@ -76,8 +82,10 @@ export class VideoCommentService {
|
||||||
|
|
||||||
return this.authHttp
|
return this.authHttp
|
||||||
.delete(url)
|
.delete(url)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.pipe(
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
map(this.restExtractor.extractDataBool),
|
||||||
|
catchError((res) => this.restExtractor.handleError(res))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private extractVideoComment (videoComment: VideoCommentServerModel) {
|
private extractVideoComment (videoComment: VideoCommentServerModel) {
|
||||||
|
@ -87,7 +95,7 @@ export class VideoCommentService {
|
||||||
private extractVideoComments (result: ResultList<VideoCommentServerModel>) {
|
private extractVideoComments (result: ResultList<VideoCommentServerModel>) {
|
||||||
const videoCommentsJson = result.data
|
const videoCommentsJson = result.data
|
||||||
const totalComments = result.total
|
const totalComments = result.total
|
||||||
const comments = []
|
const comments: VideoComment[] = []
|
||||||
|
|
||||||
for (const videoCommentJson of videoCommentsJson) {
|
for (const videoCommentJson of videoCommentsJson) {
|
||||||
comments.push(new VideoComment(videoCommentJson))
|
comments.push(new VideoComment(videoCommentJson))
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@
|
||||||
import { ActivatedRoute } from '@angular/router'
|
import { ActivatedRoute } from '@angular/router'
|
||||||
import { ConfirmService } from '@app/core'
|
import { ConfirmService } from '@app/core'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import { Subscription } from 'rxjs/Subscription'
|
import { Subscription } from 'rxjs'
|
||||||
import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
|
import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
|
||||||
import { AuthService } from '../../../core/auth'
|
import { AuthService } from '../../../core/auth'
|
||||||
import { ComponentPagination } from '../../../shared/rest/component-pagination.model'
|
import { ComponentPagination } from '../../../shared/rest/component-pagination.model'
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
|
||||||
import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-support.component'
|
import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-support.component'
|
||||||
import { MetaService } from '@ngx-meta/core'
|
import { MetaService } from '@ngx-meta/core'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import { Subscription } from 'rxjs/Subscription'
|
import { Subscription } from 'rxjs'
|
||||||
import * as videojs from 'video.js'
|
import * as videojs from 'video.js'
|
||||||
import 'videojs-hotkeys'
|
import 'videojs-hotkeys'
|
||||||
import * as WebTorrent from 'webtorrent'
|
import * as WebTorrent from 'webtorrent'
|
||||||
|
@ -13,7 +13,6 @@ import { UserVideoRateType, VideoRateType } from '../../../../../shared'
|
||||||
import '../../../assets/player/peertube-videojs-plugin'
|
import '../../../assets/player/peertube-videojs-plugin'
|
||||||
import { AuthService, ConfirmService } from '../../core'
|
import { AuthService, ConfirmService } from '../../core'
|
||||||
import { VideoBlacklistService } from '../../shared'
|
import { VideoBlacklistService } from '../../shared'
|
||||||
import { Account } from '../../shared/account/account.model'
|
|
||||||
import { VideoDetails } from '../../shared/video/video-details.model'
|
import { VideoDetails } from '../../shared/video/video-details.model'
|
||||||
import { Video } from '../../shared/video/video.model'
|
import { Video } from '../../shared/video/video.model'
|
||||||
import { VideoService } from '../../shared/video/video.service'
|
import { VideoService } from '../../shared/video/video.service'
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Location } from '@angular/common'
|
||||||
import { RedirectService } from '@app/core'
|
import { RedirectService } from '@app/core'
|
||||||
import { immutableAssign } from '@app/shared/misc/utils'
|
import { immutableAssign } from '@app/shared/misc/utils'
|
||||||
import { NotificationsService } from 'angular2-notifications'
|
import { NotificationsService } from 'angular2-notifications'
|
||||||
import { Subscription } from 'rxjs/Subscription'
|
import { Subscription } from 'rxjs'
|
||||||
import { AuthService } from '../../core/auth'
|
import { AuthService } from '../../core/auth'
|
||||||
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
|
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
|
||||||
import { VideoService } from '../../shared/video/video.service'
|
import { VideoService } from '../../shared/video/video.service'
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{js,ts,css,md}": "precise-commits",
|
"*.{css,md}": "precise-commits",
|
||||||
"*.scss": [
|
"*.scss": [
|
||||||
"sass-lint-auto-fix -c .sass-lint.yml --verbose",
|
"sass-lint-auto-fix -c .sass-lint.yml --verbose",
|
||||||
"git add"
|
"git add"
|
||||||
|
|
|
@ -4,4 +4,4 @@ set -eu
|
||||||
|
|
||||||
cd client
|
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
|
||||||
|
|
Loading…
Reference in New Issue