Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add insert at first channel position

Chocobozzz15e9236373c4
diff --git a/client/src/app/+manage/routes.ts b/client/src/app/+manage/routes.ts
index 569b47cab2..890452d41b 100644
--- a/client/src/app/+manage/routes.ts
+++ b/client/src/app/+manage/routes.ts
@@ -2,6 +2,9 @@ import { Routes } from '@angular/router'
import { VideoChannelCreateComponent } from '@app/shared/standalone-channels/video-channel-create.component'
import { VideoChannelUpdateComponent } from '@app/shared/standalone-channels/video-channel-update.component'
+// Keep these routes to have a non "/my-library" URL to manage video channels
+// This can be useful for admins/moderators for example
+
export default [
{
path: 'create',
diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts
index 4fe3a123fa..2f3e83fa40 100644
--- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts
+++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts
@@ -1,5 +1,5 @@
-import { NgClass, NgIf } from '@angular/common'
-import { Component, OnInit, inject } from '@angular/core'
+import { CommonModule, NgClass } from '@angular/common'
+import { Component, inject, OnInit } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { Router, RouterLink } from '@angular/router'
import { AuthService, Notifier, ServerService } from '@app/core'
@@ -12,9 +12,11 @@ import {
VIDEO_PLAYLIST_PRIVACY_VALIDATOR
} from '@app/shared/form-validators/video-playlist-validators'
import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
+import { PeertubeCheckboxComponent } from '@app/shared/shared-forms/peertube-checkbox.component'
import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'
import { VideoPlaylistCreate, VideoPlaylistPrivacy } from '@peertube/peertube-models'
+import { of, switchMap } from 'rxjs'
import { MarkdownTextareaComponent } from '../../shared/shared-forms/markdown-textarea.component'
import { PreviewUploadComponent } from '../../shared/shared-forms/preview-upload.component'
import { SelectChannelComponent } from '../../shared/shared-forms/select/select-channel.component'
@@ -26,7 +28,7 @@ import { MyVideoPlaylistEdit } from './my-video-playlist-edit'
templateUrl: './my-video-playlist-edit.component.html',
styleUrls: [ './my-video-playlist-edit.component.scss' ],
imports: [
- NgIf,
+ CommonModule,
RouterLink,
FormsModule,
ReactiveFormsModule,
@@ -36,7 +38,8 @@ import { MyVideoPlaylistEdit } from './my-video-playlist-edit'
MarkdownTextareaComponent,
SelectOptionsComponent,
SelectChannelComponent,
- AlertComponent
+ AlertComponent,
+ PeertubeCheckboxComponent
]
})
export class MyVideoPlaylistCreateComponent extends MyVideoPlaylistEdit implements OnInit {
@@ -55,6 +58,7 @@ export class MyVideoPlaylistCreateComponent extends MyVideoPlaylistEdit implemen
privacy: VIDEO_PLAYLIST_PRIVACY_VALIDATOR,
description: VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
videoChannelId: VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
+ insertAtFirstPosition: null,
thumbnailfile: null
})
@@ -88,6 +92,20 @@ export class MyVideoPlaylistCreateComponent extends MyVideoPlaylistEdit implemen
}
this.videoPlaylistService.createVideoPlaylist(videoPlaylistCreate)
+ .pipe(
+ switchMap(({ videoPlaylist: { id } }) => {
+ if (body.insertAtFirstPosition !== true || !body.videoChannelId) return of(true)
+
+ const channelName = this.userVideoChannels.find(c => c.id === body.videoChannelId)?.name
+
+ return this.videoPlaylistService.getVideoPlaylist(id)
+ .pipe(
+ switchMap(playlist => {
+ return this.videoPlaylistService.reorderPlaylistsOfChannel(channelName, playlist.videoChannelPosition, 0)
+ })
+ )
+ })
+ )
.subscribe({
next: () => {
this.notifier.success($localize`Playlist ${videoPlaylistCreate.displayName} created.`)
diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.html b/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.html
index 317af8ff60..367279ed0a 100644
--- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.html
+++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.html
@@ -69,6 +69,23 @@
<div *ngIf="formErrors['videoChannelId']" class="form-error" role="alert">{{ formErrors['videoChannelId'] }}</div>
</div>
+ @if (isCreation() && form.value['videoChannelId']) {
+ <div class="form-group">
+ <my-peertube-checkbox
+ inputName="insertAtFirstPosition"
+ formControlName="insertAtFirstPosition"
+ i18n-labelText
+ labelText="Insert at the first position in your channel's playlist list"
+ >
+ <ng-container ngProjectAs="description">
+ <span i18n>Playlists can be manually sorted in your channel.</span>
+ <br />
+ <span i18n>By default, new playlists are added at the end of the list.</span>
+ </ng-container>
+ </my-peertube-checkbox>
+ </div>
+ }
+
<input type="submit" class="peertube-button primary-button" value="{{ getFormButtonTitle() }}" [disabled]="!form.valid">
</form>
</div>
diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts
index aa59fa4970..816b598646 100644
--- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts
+++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts
@@ -1,5 +1,5 @@
import { NgClass, NgIf } from '@angular/common'
-import { Component, OnDestroy, OnInit, inject } from '@angular/core'
+import { Component, inject, OnDestroy, OnInit } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { ActivatedRoute, Router, RouterLink } from '@angular/router'
import { AuthService, Notifier, ServerService } from '@app/core'
@@ -12,6 +12,7 @@ import {
VIDEO_PLAYLIST_PRIVACY_VALIDATOR
} from '@app/shared/form-validators/video-playlist-validators'
import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
+import { PeertubeCheckboxComponent } from '@app/shared/shared-forms/peertube-checkbox.component'
import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'
import { VideoPlaylistUpdate } from '@peertube/peertube-models'
@@ -38,7 +39,8 @@ import { MyVideoPlaylistEdit } from './my-video-playlist-edit'
MarkdownTextareaComponent,
SelectOptionsComponent,
SelectChannelComponent,
- AlertComponent
+ AlertComponent,
+ PeertubeCheckboxComponent
]
})
export class MyVideoPlaylistUpdateComponent extends MyVideoPlaylistEdit implements OnInit, OnDestroy {