Skip to content

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

Save

Chocobozzz08576fe9b919
diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts b/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts
index e7d9dda7e2..c695f8e621 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts
@@ -88,6 +88,7 @@ type EmbedPrivacyForm = {
// ---------------------------------------------------------------------------
type LoadFromPublishOptions = Required<Pick<VideoCreate, 'channelId' | 'support'>> & Partial<Pick<VideoCreate, 'name'>> & {
+ channelDisplayName: string
user: AuthUser
}
@@ -180,6 +181,11 @@ export class VideoEdit {
private videoImport: Pick<VideoImportCreate, 'magnetUri' | 'torrentfile' | 'targetUrl'>
+ private initialMetadata: {
+ accountName: string
+ channelId: number
+ }
+
private metadata: Partial<{
id: number
uuid: string
@@ -195,12 +201,12 @@ export class VideoEdit {
blacklistedReason: string
publishedAt: Date
- ownerAccountId: number
- ownerAccountName: string
- ownerAccountDisplayName: string
-
live: Pick<LiveVideo, 'rtmpUrl' | 'rtmpsUrl' | 'streamKey'>
videoSource: VideoSource
+
+ accountName: string
+ channelName: string
+ channelDisplayName: string
}> = {}
private videoAttributes: {
@@ -221,9 +227,9 @@ export class VideoEdit {
blacklisted: boolean
blacklistedReason: string
- ownerAccountId: number
- ownerAccountName: string
- ownerAccountDisplayName: string
+ accountName: string
+ channelName: string
+ channelDisplayName: string
live?: Pick<LiveVideo, 'rtmpUrl' | 'rtmpsUrl' | 'streamKey'>
}
@@ -339,9 +345,12 @@ export class VideoEdit {
this.metadata.downloads = 0
this.metadata.likes = 0
- this.metadata.ownerAccountDisplayName = options.user.account.displayName
- this.metadata.ownerAccountName = options.user.account.name
- this.metadata.ownerAccountId = options.user.account.id
+ this.metadata.accountName = options.user.account.name
+ this.metadata.channelName = options.channelName
+ this.metadata.channelDisplayName = options.channelDisplayName
+
+ this.initialMetadata.accountName = this.metadata.accountName
+ this.initialMetadata.channelId = this.common.channelId
this.updateAfterChange()
}
@@ -466,9 +475,12 @@ export class VideoEdit {
this.metadata.isLive = video.isLive
- this.metadata.ownerAccountDisplayName = video.channel.ownerAccount.displayName
- this.metadata.ownerAccountName = video.channel.ownerAccount.name
- this.metadata.ownerAccountId = video.channel.ownerAccount.id
+ this.metadata.accountName = video.channel.ownerAccount.name
+ this.metadata.channelName = video.channel.name
+ this.metadata.channelDisplayName = video.channel.displayName
+
+ this.initialMetadata.accountName = this.metadata.accountName
+ this.initialMetadata.channelId = this.common.channelId
}
loadPluginDataDefaults (pluginDefaults: Record<string, string | boolean>) {
@@ -639,6 +651,16 @@ export class VideoEdit {
this.updateAfterChange()
}
+ loadChannelChange (options: {
+ name: string
+ displayName: string
+ ownerAccountName: string
+ }) {
+ this.metadata.channelName = options.name
+ this.metadata.channelDisplayName = options.displayName
+ this.metadata.accountName = options.ownerAccountName
+ }
+
toCommonFormPatch () {
const json: Required<CommonUpdateForm> = {
category: this.common.category,
@@ -969,6 +991,10 @@ export class VideoEdit {
return this.videoAttributes
}
+ getInitialAttributes () {
+ return this.initialMetadata
+ }
+
getChaptersEdit () {
return this.chapters
}
@@ -1175,9 +1201,9 @@ export class VideoEdit {
blacklisted: this.metadata.blacklisted,
blacklistedReason: this.metadata.blacklistedReason,
- ownerAccountId: this.metadata.ownerAccountId,
- ownerAccountName: this.metadata.ownerAccountName,
- ownerAccountDisplayName: this.metadata.ownerAccountDisplayName,
+ accountName: this.metadata.accountName,
+ channelName: this.metadata.channelName,
+ channelDisplayName: this.metadata.channelDisplayName,
live: this.metadata.live
}
@@ -1226,6 +1252,11 @@ export class VideoEdit {
onSave () {
this.isNewVideo = false
+
+ this.initialMetadata = {
+ accountName: this.metadata.accountName,
+ channelId: this.common.channelId
+ }
}
enableCheckPluginChanges () {
diff --git a/client/src/app/+videos-publish-manage/shared-manage/customization/video-customization.component.html b/client/src/app/+videos-publish-manage/shared-manage/customization/video-customization.component.html
index 9c4250ad1b..5d5e643cc3 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/customization/video-customization.component.html
+++ b/client/src/app/+videos-publish-manage/shared-manage/customization/video-customization.component.html
@@ -10,9 +10,8 @@
@if (videoEdit.getVideoSource()) {
<div class="form-group">
<label i18n for="filename">Filename</label>
- <div class="form-group-description" i18n>
- Name of the uploaded file.
- </div>
+ <div class="form-group-description" i18n>Name of the uploaded file.</div>
+
<input type="text" [disabled]="true" id="filename" class="form-control" [value]="videoEdit.getVideoSource().inputFilename" />
</div>
}
@@ -23,8 +22,8 @@
@if (hasPublicationDate()) {
<button i18n class="reset-button reset-button-small" (click)="resetField('originallyPublishedAt')">
- Reset
- </button>
+ Reset
+ </button>
}
</div>
@@ -40,7 +39,7 @@
[showTime]="true"
[hideOnDateTimeSelect]="true"
baseZIndex="20000"
- >
+ >
</p-datepicker>
@if (formErrors.originallyPublishedAt) {
@@ -54,12 +53,10 @@
<label i18n for="playerSettingsTheme">Player Theme</label>
<div class="form-group-description" i18n>Only used by the web player</div>
- <my-select-player-theme formControlName="theme" inputId="playerSettingsTheme" mode="video" [channel]="videoChannel">
- </my-select-player-theme>
+ <my-select-player-theme formControlName="theme" inputId="playerSettingsTheme" mode="video" [channel]="videoChannel"> </my-select-player-theme>
</div>
<my-peertube-checkbox inputName="downloadEnabled" formControlName="downloadEnabled" i18n-labelText labelText="Enable download"></my-peertube-checkbox>
</div>
-
</div>
</div>
diff --git a/client/src/app/+videos-publish-manage/shared-manage/customization/video-customization.component.ts b/client/src/app/+videos-publish-manage/shared-manage/customization/video-customization.component.ts
index dab9189877..1f2ee37520 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/customization/video-customization.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/customization/video-customization.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnDestroy, OnInit, inject, ChangeDetectionStrategy } from '@angular/core'
+import { ChangeDetectionStrategy, Component, OnDestroy, OnInit, inject } from '@angular/core'
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'
import { ServerService } from '@app/core'
import { BuildFormArgumentTyped } from '@app/shared/form-validators/form-validator.model'
@@ -67,11 +67,14 @@ export class VideoCustomizationComponent implements OnInit, OnDestroy {
ngOnInit () {
this.serverConfig = this.serverService.getHTMLConfig()
- const { videoEdit, userChannels } = this.manageController.getStore()
+ const { videoEdit } = this.manageController.getStore()
this.videoEdit = videoEdit
- const channelItem = userChannels.find(c => c.id === videoEdit.toCommonFormPatch().channelId)
- this.videoChannel = { name: channelItem.name, displayName: channelItem.label }
+ const attributes = this.videoEdit.getVideoAttributes()
+ this.videoChannel = {
+ name: attributes.channelName,
+ displayName: attributes.channelDisplayName
+ }
this.buildForm()
}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html
index c1f009d98d..09b7784437 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html
+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html
@@ -98,6 +98,7 @@
<my-select-channel-auto
class="d-block" inputId="adminChannel" formControlName="channelId"
[ownerAccount]="{ name: initialOwner.accountName }" [ownerChannel]="{ id: initialOwner.channelId }"
+ (onChannelChanged)="onAdminChannelChanged($event)"
></my-select-channel-auto>
</div>
diff --git a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts
index 492d8b9ec2..f6e39a6bd0 100644
--- a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts
@@ -194,8 +194,8 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {
this.forbidScheduledPublication = forbidScheduledPublication
this.initialOwner = {
- channelId: this.videoEdit.toCommonFormPatch().channelId,
- accountName: this.videoEdit.getVideoAttributes().ownerAccountName
+ channelId: this.videoEdit.getInitialAttributes().channelId,
+ accountName: this.videoEdit.getInitialAttributes().accountName
}
this.buildForm()
@@ -495,6 +495,10 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {
// ---------------------------------------------------------------------------
+ onAdminChannelChanged ({ channelId, channelDisplayName }) {
+ this.videoEdit.loadChannelChange({ channelId, channelDisplayName })
+ }
+
canBeDeletedOrTransferred () {
return !!this.videoEdit.getVideoAttributes().id
}
@@ -556,10 +560,4 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {
this.pendingOwnershipRequest = data[0]
})
}
-
- // ---------------------------------------------------------------------------
-
- isVideoOwner () {
- return this.videoEdit.getVideoAttributes().ownerAccountId === this.authService.getUser().account.id
- }
}
diff --git a/client/src/app/shared/shared-forms/select/select-channel-admin.component.ts b/client/src/app/shared/shared-forms/select/select-channel-admin.component.ts
index 89bf2ab82d..7704179c47 100644
--- a/client/src/app/shared/shared-forms/select/select-channel-admin.component.ts
+++ b/client/src/app/shared/shared-forms/select/select-channel-admin.component.ts
@@ -1,15 +1,20 @@
-import { ChangeDetectionStrategy, Component, forwardRef, inject, input, OnChanges, OnDestroy } from '@angular/core'
+import { ChangeDetectionStrategy, Component, forwardRef, inject, input, OnChanges, OnDestroy, output } from '@angular/core'
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'
import { AuthService, Notifier } from '@app/core'
import { VideoChannel } from '@app/shared/shared-main/channel/video-channel.model'
import { VideoChannelService } from '@app/shared/shared-main/channel/video-channel.service'
import { SearchService } from '@app/shared/shared-search/search.service'
+import { pick } from '@peertube/peertube-core-utils'
import { VideoChannel as VideoChannelServer } from '@peertube/peertube-models'
+import { SelectOptionsItem } from '@pt-types'
import { findAppropriateImageFileUrl } from '@root-helpers/images'
import { first, forkJoin, map, Subscription } from 'rxjs'
-import { SelectOptionsItem } from '../../../../types/select-options-item.model'
+import { ChannelMetadata } from './select-channel-metadata.model'
import { SelectOptionsComponent } from './select-options.component'
+interface ChannelOption extends SelectOptionsItem, ChannelMetadata {
+}
+
@Component({
selector: 'my-select-channel-admin',
template: `
@@ -52,10 +57,13 @@ export class SelectChannelAdminComponent implements ControlValueAccessor, OnChan
readonly inputId = input.required<string>()
readonly ownerAccountName = input.required<string>()
+ readonly channelChanged = output<ChannelMetadata>()
+
selectedId: number
- options: { label: string, value: string, items: SelectOptionsItem[] }[] = []
- baseOptions: { label: string, value: string, items: SelectOptionsItem[] }[] = []
+ options: { label: string, value: string, items: ChannelOption[] }[] = []
+
+ baseOptions: { label: string, value: string, items: ChannelOption[] }[] = []
loading = false
@@ -175,12 +183,17 @@ export class SelectChannelAdminComponent implements ControlValueAccessor, OnChan
onModelChange () {
this.propagateChange(this.selectedId)
+
+ const item = this.options.flatMap(o => o.items)
+ .find(c => c.id === this.selectedId)
+
+ this.channelChanged.emit(pick(item, [ 'ownerAccountName', 'channelDisplayName', 'channelName' ]))
}
private formatChannel (options: {
channel: VideoChannelServer
displayOwner: boolean
- }) {
+ }): ChannelOption {
const { channel, displayOwner } = options
return {
@@ -192,7 +205,11 @@ export class SelectChannelAdminComponent implements ControlValueAccessor, OnChan
imageUrl: channel.avatars.length
? findAppropriateImageFileUrl(channel.avatars, 21)
- : VideoChannel.GET_DEFAULT_AVATAR_URL(21)
+ : VideoChannel.GET_DEFAULT_AVATAR_URL(21),
+
+ ownerAccountName: channel.ownerAccount.name,
+ channelDisplayName: channel.displayName,
+ channelName: channel.name
}
}
}
diff --git a/client/src/app/shared/shared-forms/select/select-channel-auto.component.ts b/client/src/app/shared/shared-forms/select/select-channel-auto.component.ts
index ee6266fc47..a779f17b21 100644
--- a/client/src/app/shared/shared-forms/select/select-channel-auto.component.ts
+++ b/client/src/app/shared/shared-forms/select/select-channel-auto.component.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, Component, forwardRef, inject, input, OnChanges, OnDestroy } from '@angular/core'
+import { ChangeDetectionStrategy, Component, forwardRef, inject, input, OnChanges, OnDestroy, output } from '@angular/core'
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'
import { AuthService } from '@app/core'
import { buildUserChannelsForSelect } from '@app/helpers/utils/channel'
@@ -7,6 +7,7 @@ import { Account } from '@peertube/peertube-models'
import { first, Subscription } from 'rxjs'
import { SelectChannelItem } from '../../../../types/select-options-item.model'
import { SelectChannelAdminComponent } from './select-channel-admin.component'
+import { ChannelMetadata } from './select-channel-metadata.model'
import { SelectChannelUserComponent } from './select-channel-user.component'
/**
@@ -24,6 +25,7 @@ import { SelectChannelUserComponent } from './select-channel-user.component'
[ownerAccountName]="ownerAccount().name"
[(ngModel)]="selectedId"
(ngModelChange)="onModelChange()"
+ (channelChanged)="channelChanged.emit($event)"
></my-select-channel-admin>
} @else {
<my-select-channel-user
@@ -31,6 +33,7 @@ import { SelectChannelUserComponent } from './select-channel-user.component'
[items]="userChannels"
[(ngModel)]="selectedId"
(ngModelChange)="onModelChange()"
+ (channelChanged)="channelChanged.emit($event)"
></my-select-channel-user>
}
`,
@@ -51,6 +54,8 @@ export class SelectChannelAutoComponent implements ControlValueAccessor, OnChang
readonly ownerChannel = input.required<Pick<VideoChannel, 'id'>>()
readonly ownerAccount = input.required<Pick<Account, 'name'>>()
+ readonly channelChanged = output<ChannelMetadata>()
+
userChannels: SelectChannelItem[]
selectedId: number
shouldLoadAdminSelect: boolean
diff --git a/client/src/app/shared/shared-forms/select/select-channel-metadata.model.ts b/client/src/app/shared/shared-forms/select/select-channel-metadata.model.ts
new file mode 100644
index 0000000000..bffb7a3b5a
--- /dev/null
+++ b/client/src/app/shared/shared-forms/select/select-channel-metadata.model.ts
@@ -0,0 +1,5 @@
+export interface ChannelMetadata {
+ ownerAccountName: string
+ channelDisplayName: string
+ channelName: string
+}
diff --git a/client/src/app/shared/shared-forms/select/select-channel-user.component.ts b/client/src/app/shared/shared-forms/select/select-channel-user.component.ts
index c668526de1..00c891b576 100644
--- a/client/src/app/shared/shared-forms/select/select-channel-user.component.ts
+++ b/client/src/app/shared/shared-forms/select/select-channel-user.component.ts
@@ -43,6 +43,8 @@ export class SelectChannelUserComponent implements ControlValueAccessor, OnChang
readonly inputId = input.required<string>()
readonly items = input<SelectChannelItem[]>([])
+ readonly channelChanged = output<ChannelMetadata>()
+
channels: SelectOptionsItem[]
selectedId: number