diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-10 09:31:33 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-10 09:38:11 +0200 |
commit | dc2b2938c293bae271a27a6c823f66496998b4d3 (patch) | |
tree | 5952837923f46f31684dfee68688091eb112938d /client/src | |
parent | e024fd6a7494b37251da1d59470324305cdb4129 (diff) | |
download | PeerTube-dc2b2938c293bae271a27a6c823f66496998b4d3.tar.gz PeerTube-dc2b2938c293bae271a27a6c823f66496998b4d3.tar.zst PeerTube-dc2b2938c293bae271a27a6c823f66496998b4d3.zip |
Sort channels by -updatedAt
Diffstat (limited to 'client/src')
11 files changed, 61 insertions, 49 deletions
diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts index 0628c7a96..7e916e122 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts | |||
@@ -79,7 +79,13 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy { | |||
79 | } | 79 | } |
80 | 80 | ||
81 | loadMoreChannels () { | 81 | loadMoreChannels () { |
82 | this.videoChannelService.listAccountVideoChannels(this.account, this.channelPagination) | 82 | const options = { |
83 | account: this.account, | ||
84 | componentPagination: this.channelPagination, | ||
85 | sort: '-updatedAt' | ||
86 | } | ||
87 | |||
88 | this.videoChannelService.listAccountVideoChannels(options) | ||
83 | .pipe( | 89 | .pipe( |
84 | tap(res => this.channelPagination.totalItems = res.total), | 90 | tap(res => this.channelPagination.totalItems = res.total), |
85 | switchMap(res => from(res.data)), | 91 | switchMap(res => from(res.data)), |
diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts index fbd7380a9..c69b04a01 100644 --- a/client/src/app/+accounts/accounts.component.ts +++ b/client/src/app/+accounts/accounts.component.ts | |||
@@ -66,7 +66,7 @@ export class AccountsComponent implements OnInit, OnDestroy { | |||
66 | distinctUntilChanged(), | 66 | distinctUntilChanged(), |
67 | switchMap(accountId => this.accountService.getAccount(accountId)), | 67 | switchMap(accountId => this.accountService.getAccount(accountId)), |
68 | tap(account => this.onAccount(account)), | 68 | tap(account => this.onAccount(account)), |
69 | switchMap(account => this.videoChannelService.listAccountVideoChannels(account)), | 69 | switchMap(account => this.videoChannelService.listAccountVideoChannels({ account })), |
70 | catchError(err => this.restExtractor.redirectTo404IfNotFound(err, 'other', [ | 70 | catchError(err => this.restExtractor.redirectTo404IfNotFound(err, 'other', [ |
71 | HttpStatusCode.BAD_REQUEST_400, | 71 | HttpStatusCode.BAD_REQUEST_400, |
72 | HttpStatusCode.NOT_FOUND_404 | 72 | HttpStatusCode.NOT_FOUND_404 |
diff --git a/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts b/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts index 9e3bf35b4..67b3ee496 100644 --- a/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts +++ b/client/src/app/+my-library/+my-video-channels/my-video-channels.component.ts | |||
@@ -68,8 +68,14 @@ channel with the same name (${videoChannel.name})!`, | |||
68 | this.authService.userInformationLoaded | 68 | this.authService.userInformationLoaded |
69 | .pipe(mergeMap(() => { | 69 | .pipe(mergeMap(() => { |
70 | const user = this.authService.getUser() | 70 | const user = this.authService.getUser() |
71 | const options = { | ||
72 | account: user.account, | ||
73 | withStats: true, | ||
74 | search: this.search, | ||
75 | sort: '-updatedAt' | ||
76 | } | ||
71 | 77 | ||
72 | return this.videoChannelService.listAccountVideoChannels(user.account, null, true, this.search) | 78 | return this.videoChannelService.listAccountVideoChannels(options) |
73 | })).subscribe(res => { | 79 | })).subscribe(res => { |
74 | this.videoChannels = res.data | 80 | this.videoChannels = res.data |
75 | this.totalItems = res.total | 81 | this.totalItems = res.total |
diff --git a/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.html b/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.html index 088765b20..d0393a2a4 100644 --- a/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.html +++ b/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.html | |||
@@ -8,13 +8,8 @@ | |||
8 | <div class="modal-body" [formGroup]="form"> | 8 | <div class="modal-body" [formGroup]="form"> |
9 | <div class="form-group"> | 9 | <div class="form-group"> |
10 | <label i18n for="channel">Select a channel to receive the video</label> | 10 | <label i18n for="channel">Select a channel to receive the video</label> |
11 | <div class="peertube-select-container"> | 11 | <my-select-channel labelForId="channel" formControlName="channel" [items]="videoChannels"></my-select-channel> |
12 | <select formControlName="channel" id="channel" class="form-control"> | 12 | |
13 | <option i18n value="undefined" disabled>Channel that will receive the video</option> | ||
14 | <option *ngFor="let channel of videoChannels" [value]="channel.id">{{ channel.displayName }} | ||
15 | </option> | ||
16 | </select> | ||
17 | </div> | ||
18 | <div *ngIf="formErrors.channel" class="form-error">{{ formErrors.channel }}</div> | 13 | <div *ngIf="formErrors.channel" class="form-error">{{ formErrors.channel }}</div> |
19 | </div> | 14 | </div> |
20 | </div> | 15 | </div> |
diff --git a/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts b/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts index 0e2395754..7889d0985 100644 --- a/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts +++ b/client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import { switchMap } from 'rxjs/operators' | 1 | import { SelectChannelItem } from 'src/types/select-options-item.model' |
2 | import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' | 2 | import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' |
3 | import { AuthService, Notifier } from '@app/core' | 3 | import { AuthService, Notifier } from '@app/core' |
4 | import { listUserChannels } from '@app/helpers' | ||
4 | import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators' | 5 | import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators' |
5 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' | 6 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' |
6 | import { VideoChannelService, VideoOwnershipService } from '@app/shared/shared-main' | 7 | import { VideoOwnershipService } from '@app/shared/shared-main' |
7 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 8 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
8 | import { VideoChangeOwnership, VideoChannel } from '@shared/models' | 9 | import { VideoChangeOwnership } from '@shared/models' |
9 | 10 | ||
10 | @Component({ | 11 | @Component({ |
11 | selector: 'my-accept-ownership', | 12 | selector: 'my-accept-ownership', |
@@ -18,8 +19,7 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit { | |||
18 | @ViewChild('modal', { static: true }) modal: ElementRef | 19 | @ViewChild('modal', { static: true }) modal: ElementRef |
19 | 20 | ||
20 | videoChangeOwnership: VideoChangeOwnership | undefined = undefined | 21 | videoChangeOwnership: VideoChangeOwnership | undefined = undefined |
21 | 22 | videoChannels: SelectChannelItem[] | |
22 | videoChannels: VideoChannel[] | ||
23 | 23 | ||
24 | error: string = null | 24 | error: string = null |
25 | 25 | ||
@@ -28,7 +28,6 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit { | |||
28 | private videoOwnershipService: VideoOwnershipService, | 28 | private videoOwnershipService: VideoOwnershipService, |
29 | private notifier: Notifier, | 29 | private notifier: Notifier, |
30 | private authService: AuthService, | 30 | private authService: AuthService, |
31 | private videoChannelService: VideoChannelService, | ||
32 | private modalService: NgbModal | 31 | private modalService: NgbModal |
33 | ) { | 32 | ) { |
34 | super() | 33 | super() |
@@ -37,9 +36,8 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit { | |||
37 | ngOnInit () { | 36 | ngOnInit () { |
38 | this.videoChannels = [] | 37 | this.videoChannels = [] |
39 | 38 | ||
40 | this.authService.userInformationLoaded | 39 | listUserChannels(this.authService) |
41 | .pipe(switchMap(() => this.videoChannelService.listAccountVideoChannels(this.authService.getUser().account))) | 40 | .subscribe(channels => this.videoChannels = channels) |
42 | .subscribe(videoChannels => this.videoChannels = videoChannels.data) | ||
43 | 41 | ||
44 | this.buildForm({ | 42 | this.buildForm({ |
45 | channel: OWNERSHIP_CHANGE_CHANNEL_VALIDATOR | 43 | channel: OWNERSHIP_CHANGE_CHANNEL_VALIDATOR |
diff --git a/client/src/app/+videos/+video-edit/video-update.resolver.ts b/client/src/app/+videos/+video-edit/video-update.resolver.ts index 276548b79..9172b78a8 100644 --- a/client/src/app/+videos/+video-edit/video-update.resolver.ts +++ b/client/src/app/+videos/+video-edit/video-update.resolver.ts | |||
@@ -2,7 +2,9 @@ import { forkJoin, of } from 'rxjs' | |||
2 | import { map, switchMap } from 'rxjs/operators' | 2 | import { map, switchMap } from 'rxjs/operators' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { ActivatedRouteSnapshot, Resolve } from '@angular/router' | 4 | import { ActivatedRouteSnapshot, Resolve } from '@angular/router' |
5 | import { VideoCaptionService, VideoChannelService, VideoDetails, VideoService } from '@app/shared/shared-main' | 5 | import { AuthService } from '@app/core' |
6 | import { listUserChannels } from '@app/helpers' | ||
7 | import { VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main' | ||
6 | import { LiveVideoService } from '@app/shared/shared-video-live' | 8 | import { LiveVideoService } from '@app/shared/shared-video-live' |
7 | 9 | ||
8 | @Injectable() | 10 | @Injectable() |
@@ -10,7 +12,7 @@ export class VideoUpdateResolver implements Resolve<any> { | |||
10 | constructor ( | 12 | constructor ( |
11 | private videoService: VideoService, | 13 | private videoService: VideoService, |
12 | private liveVideoService: LiveVideoService, | 14 | private liveVideoService: LiveVideoService, |
13 | private videoChannelService: VideoChannelService, | 15 | private authService: AuthService, |
14 | private videoCaptionService: VideoCaptionService | 16 | private videoCaptionService: VideoCaptionService |
15 | ) { | 17 | ) { |
16 | } | 18 | } |
@@ -31,17 +33,7 @@ export class VideoUpdateResolver implements Resolve<any> { | |||
31 | .loadCompleteDescription(video.descriptionPath) | 33 | .loadCompleteDescription(video.descriptionPath) |
32 | .pipe(map(description => Object.assign(video, { description }))), | 34 | .pipe(map(description => Object.assign(video, { description }))), |
33 | 35 | ||
34 | this.videoChannelService | 36 | listUserChannels(this.authService), |
35 | .listAccountVideoChannels(video.account) | ||
36 | .pipe( | ||
37 | map(result => result.data), | ||
38 | map(videoChannels => videoChannels.map(c => ({ | ||
39 | id: c.id, | ||
40 | label: c.displayName, | ||
41 | support: c.support, | ||
42 | avatarPath: c.avatar?.path | ||
43 | }))) | ||
44 | ), | ||
45 | 37 | ||
46 | this.videoCaptionService | 38 | this.videoCaptionService |
47 | .listCaptions(video.id) | 39 | .listCaptions(video.id) |
diff --git a/client/src/app/helpers/utils.ts b/client/src/app/helpers/utils.ts index a1747af3c..17eb5effc 100644 --- a/client/src/app/helpers/utils.ts +++ b/client/src/app/helpers/utils.ts | |||
@@ -30,12 +30,18 @@ function listUserChannels (authService: AuthService) { | |||
30 | const videoChannels = user.videoChannels | 30 | const videoChannels = user.videoChannels |
31 | if (Array.isArray(videoChannels) === false) return undefined | 31 | if (Array.isArray(videoChannels) === false) return undefined |
32 | 32 | ||
33 | return videoChannels.map(c => ({ | 33 | return videoChannels |
34 | id: c.id, | 34 | .sort((a, b) => { |
35 | label: c.displayName, | 35 | if (a.updatedAt < b.updatedAt) return 1 |
36 | support: c.support, | 36 | if (a.updatedAt > b.updatedAt) return -1 |
37 | avatarPath: c.avatar?.path | 37 | return 0 |
38 | }) as SelectChannelItem) | 38 | }) |
39 | .map(c => ({ | ||
40 | id: c.id, | ||
41 | label: c.displayName, | ||
42 | support: c.support, | ||
43 | avatarPath: c.avatar?.path | ||
44 | }) as SelectChannelItem) | ||
39 | })) | 45 | })) |
40 | } | 46 | } |
41 | 47 | ||
diff --git a/client/src/app/shared/shared-main/account/account.model.ts b/client/src/app/shared/shared-main/account/account.model.ts index 6d9f0ee65..7b5611f35 100644 --- a/client/src/app/shared/shared-main/account/account.model.ts +++ b/client/src/app/shared/shared-main/account/account.model.ts | |||
@@ -4,8 +4,12 @@ import { Actor } from './actor.model' | |||
4 | export class Account extends Actor implements ServerAccount { | 4 | export class Account extends Actor implements ServerAccount { |
5 | displayName: string | 5 | displayName: string |
6 | description: string | 6 | description: string |
7 | |||
8 | updatedAt: Date | string | ||
9 | |||
7 | nameWithHost: string | 10 | nameWithHost: string |
8 | nameWithHostForced: string | 11 | nameWithHostForced: string |
12 | |||
9 | mutedByUser: boolean | 13 | mutedByUser: boolean |
10 | mutedByInstance: boolean | 14 | mutedByInstance: boolean |
11 | mutedServerByUser: boolean | 15 | mutedServerByUser: boolean |
@@ -30,6 +34,8 @@ export class Account extends Actor implements ServerAccount { | |||
30 | this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host) | 34 | this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host) |
31 | this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true) | 35 | this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true) |
32 | 36 | ||
37 | if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString()) | ||
38 | |||
33 | this.mutedByUser = false | 39 | this.mutedByUser = false |
34 | this.mutedByInstance = false | 40 | this.mutedByInstance = false |
35 | this.mutedServerByUser = false | 41 | this.mutedServerByUser = false |
diff --git a/client/src/app/shared/shared-main/account/actor.model.ts b/client/src/app/shared/shared-main/account/actor.model.ts index 6ba0bb09e..2fccc472a 100644 --- a/client/src/app/shared/shared-main/account/actor.model.ts +++ b/client/src/app/shared/shared-main/account/actor.model.ts | |||
@@ -12,7 +12,6 @@ export abstract class Actor implements ServerActor { | |||
12 | followersCount: number | 12 | followersCount: number |
13 | 13 | ||
14 | createdAt: Date | string | 14 | createdAt: Date | string |
15 | updatedAt: Date | string | ||
16 | 15 | ||
17 | avatar: ActorImage | 16 | avatar: ActorImage |
18 | 17 | ||
@@ -55,7 +54,6 @@ export abstract class Actor implements ServerActor { | |||
55 | this.followersCount = hash.followersCount | 54 | this.followersCount = hash.followersCount |
56 | 55 | ||
57 | if (hash.createdAt) this.createdAt = new Date(hash.createdAt.toString()) | 56 | if (hash.createdAt) this.createdAt = new Date(hash.createdAt.toString()) |
58 | if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString()) | ||
59 | 57 | ||
60 | this.avatar = hash.avatar | 58 | this.avatar = hash.avatar |
61 | this.isLocal = Actor.IS_LOCAL(this.host) | 59 | this.isLocal = Actor.IS_LOCAL(this.host) |
diff --git a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts index c40dd5311..a9dcf2fa2 100644 --- a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts +++ b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts | |||
@@ -16,6 +16,8 @@ export class VideoChannel extends Actor implements ServerVideoChannel { | |||
16 | banner: ActorImage | 16 | banner: ActorImage |
17 | bannerUrl: string | 17 | bannerUrl: string |
18 | 18 | ||
19 | updatedAt: Date | string | ||
20 | |||
19 | ownerAccount?: ServerAccount | 21 | ownerAccount?: ServerAccount |
20 | ownerBy?: string | 22 | ownerBy?: string |
21 | 23 | ||
@@ -59,6 +61,8 @@ export class VideoChannel extends Actor implements ServerVideoChannel { | |||
59 | 61 | ||
60 | this.videosCount = hash.videosCount | 62 | this.videosCount = hash.videosCount |
61 | 63 | ||
64 | if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString()) | ||
65 | |||
62 | if (hash.viewsPerDay) { | 66 | if (hash.viewsPerDay) { |
63 | this.viewsPerDay = hash.viewsPerDay.map(v => ({ ...v, date: new Date(v.date) })) | 67 | this.viewsPerDay = hash.viewsPerDay.map(v => ({ ...v, date: new Date(v.date) })) |
64 | } | 68 | } |
diff --git a/client/src/app/shared/shared-main/video-channel/video-channel.service.ts b/client/src/app/shared/shared-main/video-channel/video-channel.service.ts index e65261763..a89f1065a 100644 --- a/client/src/app/shared/shared-main/video-channel/video-channel.service.ts +++ b/client/src/app/shared/shared-main/video-channel/video-channel.service.ts | |||
@@ -40,23 +40,24 @@ export class VideoChannelService { | |||
40 | ) | 40 | ) |
41 | } | 41 | } |
42 | 42 | ||
43 | listAccountVideoChannels ( | 43 | listAccountVideoChannels (options: { |
44 | account: Account, | 44 | account: Account |
45 | componentPagination?: ComponentPaginationLight, | 45 | componentPagination?: ComponentPaginationLight |
46 | withStats = false, | 46 | withStats?: boolean |
47 | sort?: string | ||
47 | search?: string | 48 | search?: string |
48 | ): Observable<ResultList<VideoChannel>> { | 49 | }): Observable<ResultList<VideoChannel>> { |
50 | const { account, componentPagination, withStats = false, sort, search } = options | ||
51 | |||
49 | const pagination = componentPagination | 52 | const pagination = componentPagination |
50 | ? this.restService.componentPaginationToRestPagination(componentPagination) | 53 | ? this.restService.componentPaginationToRestPagination(componentPagination) |
51 | : { start: 0, count: 20 } | 54 | : { start: 0, count: 20 } |
52 | 55 | ||
53 | let params = new HttpParams() | 56 | let params = new HttpParams() |
54 | params = this.restService.addRestGetParams(params, pagination) | 57 | params = this.restService.addRestGetParams(params, pagination, sort) |
55 | params = params.set('withStats', withStats + '') | 58 | params = params.set('withStats', withStats + '') |
56 | 59 | ||
57 | if (search) { | 60 | if (search) params = params.set('search', search) |
58 | params = params.set('search', search) | ||
59 | } | ||
60 | 61 | ||
61 | const url = AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/video-channels' | 62 | const url = AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/video-channels' |
62 | return this.authHttp.get<ResultList<VideoChannelServer>>(url, { params }) | 63 | return this.authHttp.get<ResultList<VideoChannelServer>>(url, { params }) |