mirror of https://github.com/Chocobozzz/PeerTube
Sort channels by -updatedAt
parent
e024fd6a74
commit
dc2b2938c2
|
@ -79,7 +79,13 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMoreChannels () {
|
loadMoreChannels () {
|
||||||
this.videoChannelService.listAccountVideoChannels(this.account, this.channelPagination)
|
const options = {
|
||||||
|
account: this.account,
|
||||||
|
componentPagination: this.channelPagination,
|
||||||
|
sort: '-updatedAt'
|
||||||
|
}
|
||||||
|
|
||||||
|
this.videoChannelService.listAccountVideoChannels(options)
|
||||||
.pipe(
|
.pipe(
|
||||||
tap(res => this.channelPagination.totalItems = res.total),
|
tap(res => this.channelPagination.totalItems = res.total),
|
||||||
switchMap(res => from(res.data)),
|
switchMap(res => from(res.data)),
|
||||||
|
|
|
@ -66,7 +66,7 @@ export class AccountsComponent implements OnInit, OnDestroy {
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
switchMap(accountId => this.accountService.getAccount(accountId)),
|
switchMap(accountId => this.accountService.getAccount(accountId)),
|
||||||
tap(account => this.onAccount(account)),
|
tap(account => this.onAccount(account)),
|
||||||
switchMap(account => this.videoChannelService.listAccountVideoChannels(account)),
|
switchMap(account => this.videoChannelService.listAccountVideoChannels({ account })),
|
||||||
catchError(err => this.restExtractor.redirectTo404IfNotFound(err, 'other', [
|
catchError(err => this.restExtractor.redirectTo404IfNotFound(err, 'other', [
|
||||||
HttpStatusCode.BAD_REQUEST_400,
|
HttpStatusCode.BAD_REQUEST_400,
|
||||||
HttpStatusCode.NOT_FOUND_404
|
HttpStatusCode.NOT_FOUND_404
|
||||||
|
|
|
@ -68,8 +68,14 @@ channel with the same name (${videoChannel.name})!`,
|
||||||
this.authService.userInformationLoaded
|
this.authService.userInformationLoaded
|
||||||
.pipe(mergeMap(() => {
|
.pipe(mergeMap(() => {
|
||||||
const user = this.authService.getUser()
|
const user = this.authService.getUser()
|
||||||
|
const options = {
|
||||||
|
account: user.account,
|
||||||
|
withStats: true,
|
||||||
|
search: this.search,
|
||||||
|
sort: '-updatedAt'
|
||||||
|
}
|
||||||
|
|
||||||
return this.videoChannelService.listAccountVideoChannels(user.account, null, true, this.search)
|
return this.videoChannelService.listAccountVideoChannels(options)
|
||||||
})).subscribe(res => {
|
})).subscribe(res => {
|
||||||
this.videoChannels = res.data
|
this.videoChannels = res.data
|
||||||
this.totalItems = res.total
|
this.totalItems = res.total
|
||||||
|
|
|
@ -8,13 +8,8 @@
|
||||||
<div class="modal-body" [formGroup]="form">
|
<div class="modal-body" [formGroup]="form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label i18n for="channel">Select a channel to receive the video</label>
|
<label i18n for="channel">Select a channel to receive the video</label>
|
||||||
<div class="peertube-select-container">
|
<my-select-channel labelForId="channel" formControlName="channel" [items]="videoChannels"></my-select-channel>
|
||||||
<select formControlName="channel" id="channel" class="form-control">
|
|
||||||
<option i18n value="undefined" disabled>Channel that will receive the video</option>
|
|
||||||
<option *ngFor="let channel of videoChannels" [value]="channel.id">{{ channel.displayName }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="formErrors.channel" class="form-error">{{ formErrors.channel }}</div>
|
<div *ngIf="formErrors.channel" class="form-error">{{ formErrors.channel }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { switchMap } from 'rxjs/operators'
|
import { SelectChannelItem } from 'src/types/select-options-item.model'
|
||||||
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
|
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
|
||||||
import { AuthService, Notifier } from '@app/core'
|
import { AuthService, Notifier } from '@app/core'
|
||||||
|
import { listUserChannels } from '@app/helpers'
|
||||||
import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
|
import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
|
||||||
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
|
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
|
||||||
import { VideoChannelService, VideoOwnershipService } from '@app/shared/shared-main'
|
import { VideoOwnershipService } from '@app/shared/shared-main'
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { VideoChangeOwnership, VideoChannel } from '@shared/models'
|
import { VideoChangeOwnership } from '@shared/models'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-accept-ownership',
|
selector: 'my-accept-ownership',
|
||||||
|
@ -18,8 +19,7 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit {
|
||||||
@ViewChild('modal', { static: true }) modal: ElementRef
|
@ViewChild('modal', { static: true }) modal: ElementRef
|
||||||
|
|
||||||
videoChangeOwnership: VideoChangeOwnership | undefined = undefined
|
videoChangeOwnership: VideoChangeOwnership | undefined = undefined
|
||||||
|
videoChannels: SelectChannelItem[]
|
||||||
videoChannels: VideoChannel[]
|
|
||||||
|
|
||||||
error: string = null
|
error: string = null
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit {
|
||||||
private videoOwnershipService: VideoOwnershipService,
|
private videoOwnershipService: VideoOwnershipService,
|
||||||
private notifier: Notifier,
|
private notifier: Notifier,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private videoChannelService: VideoChannelService,
|
|
||||||
private modalService: NgbModal
|
private modalService: NgbModal
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
|
@ -37,9 +36,8 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit {
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.videoChannels = []
|
this.videoChannels = []
|
||||||
|
|
||||||
this.authService.userInformationLoaded
|
listUserChannels(this.authService)
|
||||||
.pipe(switchMap(() => this.videoChannelService.listAccountVideoChannels(this.authService.getUser().account)))
|
.subscribe(channels => this.videoChannels = channels)
|
||||||
.subscribe(videoChannels => this.videoChannels = videoChannels.data)
|
|
||||||
|
|
||||||
this.buildForm({
|
this.buildForm({
|
||||||
channel: OWNERSHIP_CHANGE_CHANNEL_VALIDATOR
|
channel: OWNERSHIP_CHANGE_CHANNEL_VALIDATOR
|
||||||
|
|
|
@ -2,7 +2,9 @@ import { forkJoin, of } from 'rxjs'
|
||||||
import { map, switchMap } from 'rxjs/operators'
|
import { map, switchMap } from 'rxjs/operators'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
|
import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
|
||||||
import { VideoCaptionService, VideoChannelService, VideoDetails, VideoService } from '@app/shared/shared-main'
|
import { AuthService } from '@app/core'
|
||||||
|
import { listUserChannels } from '@app/helpers'
|
||||||
|
import { VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main'
|
||||||
import { LiveVideoService } from '@app/shared/shared-video-live'
|
import { LiveVideoService } from '@app/shared/shared-video-live'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -10,7 +12,7 @@ export class VideoUpdateResolver implements Resolve<any> {
|
||||||
constructor (
|
constructor (
|
||||||
private videoService: VideoService,
|
private videoService: VideoService,
|
||||||
private liveVideoService: LiveVideoService,
|
private liveVideoService: LiveVideoService,
|
||||||
private videoChannelService: VideoChannelService,
|
private authService: AuthService,
|
||||||
private videoCaptionService: VideoCaptionService
|
private videoCaptionService: VideoCaptionService
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
@ -31,17 +33,7 @@ export class VideoUpdateResolver implements Resolve<any> {
|
||||||
.loadCompleteDescription(video.descriptionPath)
|
.loadCompleteDescription(video.descriptionPath)
|
||||||
.pipe(map(description => Object.assign(video, { description }))),
|
.pipe(map(description => Object.assign(video, { description }))),
|
||||||
|
|
||||||
this.videoChannelService
|
listUserChannels(this.authService),
|
||||||
.listAccountVideoChannels(video.account)
|
|
||||||
.pipe(
|
|
||||||
map(result => result.data),
|
|
||||||
map(videoChannels => videoChannels.map(c => ({
|
|
||||||
id: c.id,
|
|
||||||
label: c.displayName,
|
|
||||||
support: c.support,
|
|
||||||
avatarPath: c.avatar?.path
|
|
||||||
})))
|
|
||||||
),
|
|
||||||
|
|
||||||
this.videoCaptionService
|
this.videoCaptionService
|
||||||
.listCaptions(video.id)
|
.listCaptions(video.id)
|
||||||
|
|
|
@ -30,7 +30,13 @@ function listUserChannels (authService: AuthService) {
|
||||||
const videoChannels = user.videoChannels
|
const videoChannels = user.videoChannels
|
||||||
if (Array.isArray(videoChannels) === false) return undefined
|
if (Array.isArray(videoChannels) === false) return undefined
|
||||||
|
|
||||||
return videoChannels.map(c => ({
|
return videoChannels
|
||||||
|
.sort((a, b) => {
|
||||||
|
if (a.updatedAt < b.updatedAt) return 1
|
||||||
|
if (a.updatedAt > b.updatedAt) return -1
|
||||||
|
return 0
|
||||||
|
})
|
||||||
|
.map(c => ({
|
||||||
id: c.id,
|
id: c.id,
|
||||||
label: c.displayName,
|
label: c.displayName,
|
||||||
support: c.support,
|
support: c.support,
|
||||||
|
|
|
@ -4,8 +4,12 @@ import { Actor } from './actor.model'
|
||||||
export class Account extends Actor implements ServerAccount {
|
export class Account extends Actor implements ServerAccount {
|
||||||
displayName: string
|
displayName: string
|
||||||
description: string
|
description: string
|
||||||
|
|
||||||
|
updatedAt: Date | string
|
||||||
|
|
||||||
nameWithHost: string
|
nameWithHost: string
|
||||||
nameWithHostForced: string
|
nameWithHostForced: string
|
||||||
|
|
||||||
mutedByUser: boolean
|
mutedByUser: boolean
|
||||||
mutedByInstance: boolean
|
mutedByInstance: boolean
|
||||||
mutedServerByUser: boolean
|
mutedServerByUser: boolean
|
||||||
|
@ -30,6 +34,8 @@ export class Account extends Actor implements ServerAccount {
|
||||||
this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
|
this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
|
||||||
this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
|
this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
|
||||||
|
|
||||||
|
if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString())
|
||||||
|
|
||||||
this.mutedByUser = false
|
this.mutedByUser = false
|
||||||
this.mutedByInstance = false
|
this.mutedByInstance = false
|
||||||
this.mutedServerByUser = false
|
this.mutedServerByUser = false
|
||||||
|
|
|
@ -12,7 +12,6 @@ export abstract class Actor implements ServerActor {
|
||||||
followersCount: number
|
followersCount: number
|
||||||
|
|
||||||
createdAt: Date | string
|
createdAt: Date | string
|
||||||
updatedAt: Date | string
|
|
||||||
|
|
||||||
avatar: ActorImage
|
avatar: ActorImage
|
||||||
|
|
||||||
|
@ -55,7 +54,6 @@ export abstract class Actor implements ServerActor {
|
||||||
this.followersCount = hash.followersCount
|
this.followersCount = hash.followersCount
|
||||||
|
|
||||||
if (hash.createdAt) this.createdAt = new Date(hash.createdAt.toString())
|
if (hash.createdAt) this.createdAt = new Date(hash.createdAt.toString())
|
||||||
if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString())
|
|
||||||
|
|
||||||
this.avatar = hash.avatar
|
this.avatar = hash.avatar
|
||||||
this.isLocal = Actor.IS_LOCAL(this.host)
|
this.isLocal = Actor.IS_LOCAL(this.host)
|
||||||
|
|
|
@ -16,6 +16,8 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
|
||||||
banner: ActorImage
|
banner: ActorImage
|
||||||
bannerUrl: string
|
bannerUrl: string
|
||||||
|
|
||||||
|
updatedAt: Date | string
|
||||||
|
|
||||||
ownerAccount?: ServerAccount
|
ownerAccount?: ServerAccount
|
||||||
ownerBy?: string
|
ownerBy?: string
|
||||||
|
|
||||||
|
@ -59,6 +61,8 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
|
||||||
|
|
||||||
this.videosCount = hash.videosCount
|
this.videosCount = hash.videosCount
|
||||||
|
|
||||||
|
if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString())
|
||||||
|
|
||||||
if (hash.viewsPerDay) {
|
if (hash.viewsPerDay) {
|
||||||
this.viewsPerDay = hash.viewsPerDay.map(v => ({ ...v, date: new Date(v.date) }))
|
this.viewsPerDay = hash.viewsPerDay.map(v => ({ ...v, date: new Date(v.date) }))
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,23 +40,24 @@ export class VideoChannelService {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
listAccountVideoChannels (
|
listAccountVideoChannels (options: {
|
||||||
account: Account,
|
account: Account
|
||||||
componentPagination?: ComponentPaginationLight,
|
componentPagination?: ComponentPaginationLight
|
||||||
withStats = false,
|
withStats?: boolean
|
||||||
|
sort?: string
|
||||||
search?: string
|
search?: string
|
||||||
): Observable<ResultList<VideoChannel>> {
|
}): Observable<ResultList<VideoChannel>> {
|
||||||
|
const { account, componentPagination, withStats = false, sort, search } = options
|
||||||
|
|
||||||
const pagination = componentPagination
|
const pagination = componentPagination
|
||||||
? this.restService.componentPaginationToRestPagination(componentPagination)
|
? this.restService.componentPaginationToRestPagination(componentPagination)
|
||||||
: { start: 0, count: 20 }
|
: { start: 0, count: 20 }
|
||||||
|
|
||||||
let params = new HttpParams()
|
let params = new HttpParams()
|
||||||
params = this.restService.addRestGetParams(params, pagination)
|
params = this.restService.addRestGetParams(params, pagination, sort)
|
||||||
params = params.set('withStats', withStats + '')
|
params = params.set('withStats', withStats + '')
|
||||||
|
|
||||||
if (search) {
|
if (search) params = params.set('search', search)
|
||||||
params = params.set('search', search)
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/video-channels'
|
const url = AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/video-channels'
|
||||||
return this.authHttp.get<ResultList<VideoChannelServer>>(url, { params })
|
return this.authHttp.get<ResultList<VideoChannelServer>>(url, { params })
|
||||||
|
|
Loading…
Reference in New Issue