Skip to content

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

Redesign manage my videos

Chocobozzzb295dd582022
diff --git a/.dprint.json b/.dprint.json
index 5ce527c55f..ffba5448a1 100644
--- a/.dprint.json
+++ b/.dprint.json
@@ -61,7 +61,8 @@
"exportDeclaration.forceMultiLine": "never",
"importDeclaration.forceMultiLine": "never",
"arrayExpression.spaceAround": true,
- "arrayPattern.spaceAround": true
+ "arrayPattern.spaceAround": true,
+ "importDeclaration.preferSingleLine": true
},
"json": {},
"markdown": {},
diff --git a/client/e2e/src/po/admin-config.po.ts b/client/e2e/src/po/admin-config.po.ts
index 778959c80f..92b586d8ec 100644
--- a/client/e2e/src/po/admin-config.po.ts
+++ b/client/e2e/src/po/admin-config.po.ts
@@ -1,19 +1,26 @@
-import { browserSleep, getCheckbox, go, isCheckboxSelected } from '../utils'
+import { browserSleep, go, setCheckboxEnabled } from '../utils'
export class AdminConfigPage {
-
- async navigateTo (tab: 'instance-homepage' | 'basic-configuration' | 'instance-information') {
+ async navigateTo (tab: 'instance-homepage' | 'basic-configuration' | 'instance-information' | 'live') {
const waitTitles = {
'instance-homepage': 'INSTANCE HOMEPAGE',
'basic-configuration': 'APPEARANCE',
- 'instance-information': 'INSTANCE'
+ 'instance-information': 'INSTANCE',
+ 'live': 'LIVE'
+ }
+
+ const url = '/admin/settings/config/edit-custom#' + tab
+
+ if (await browser.getUrl() !== url) {
+ await go('/admin/settings/config/edit-custom#' + tab)
}
- await go('/admin/settings/config/edit-custom#' + tab)
await $('h2=' + waitTitles[tab]).waitForDisplayed()
}
async updateNSFWSetting (newValue: 'do_not_list' | 'blur' | 'display') {
+ await this.navigateTo('instance-information')
+
const elem = $('#instanceDefaultNSFWPolicy')
await elem.waitForDisplayed()
@@ -23,35 +30,34 @@ export class AdminConfigPage {
return elem.selectByAttribute('value', newValue)
}
- updateHomepage (newValue: string) {
+ async updateHomepage (newValue: string) {
+ await this.navigateTo('instance-homepage')
+
return $('#instanceCustomHomepageContent').setValue(newValue)
}
async toggleSignup (enabled: boolean) {
- if (await isCheckboxSelected('signupEnabled') === enabled) return
-
- const checkbox = await getCheckbox('signupEnabled')
+ await this.navigateTo('basic-configuration')
- await checkbox.waitForClickable()
- await checkbox.click()
+ return setCheckboxEnabled('signupEnabled', enabled)
}
async toggleSignupApproval (required: boolean) {
- if (await isCheckboxSelected('signupRequiresApproval') === required) return
-
- const checkbox = await getCheckbox('signupRequiresApproval')
+ await this.navigateTo('basic-configuration')
- await checkbox.waitForClickable()
- await checkbox.click()
+ return setCheckboxEnabled('signupRequiresApproval', required)
}
async toggleSignupEmailVerification (required: boolean) {
- if (await isCheckboxSelected('signupRequiresEmailVerification') === required) return
+ await this.navigateTo('basic-configuration')
+
+ return setCheckboxEnabled('signupRequiresEmailVerification', required)
+ }
- const checkbox = await getCheckbox('signupRequiresEmailVerification')
+ async toggleLive (enabled: boolean) {
+ await this.navigateTo('live')
- await checkbox.waitForClickable()
- await checkbox.click()
+ return setCheckboxEnabled('liveEnabled', enabled)
}
async save () {
diff --git a/client/e2e/src/po/my-account.po.ts b/client/e2e/src/po/my-account.po.ts
index 1054c117be..3afbd81b97 100644
--- a/client/e2e/src/po/my-account.po.ts
+++ b/client/e2e/src/po/my-account.po.ts
@@ -1,7 +1,6 @@
import { getCheckbox, go, selectCustomSelect } from '../utils'
export class MyAccountPage {
-
navigateToMyVideos () {
return $('a[href="/my-library/videos"]').click()
}
@@ -54,7 +53,7 @@ export class MyAccountPage {
// My account Videos
async removeVideo (name: string) {
- const container = await this.getVideoElement(name)
+ const container = await this.getVideoRow(name)
await container.$('my-action-dropdown .dropdown-toggle').click()
@@ -76,8 +75,8 @@ export class MyAccountPage {
}
async countVideos (names: string[]) {
- const elements = await $$('.video').filter(async e => {
- const t = await e.$('.video-name').getText()
+ const elements = await $$('.video-cell-name .name').filter(async e => {
+ const t = await e.getText()
return names.some(n => t.includes(n))
})
@@ -137,22 +136,16 @@ export class MyAccountPage {
// My account Videos
- private async getVideoElement (name: string) {
- const video = async () => {
- const videos = await $$('.video').filter(async e => {
- const t = await e.$('.video-name').getText()
+ private async getVideoRow (name: string) {
+ let el = $('.name*=' + name)
- return t.includes(name)
- })
+ await el.waitForDisplayed()
- return videos[0]
+ while (await el.getTagName() !== 'tr') {
+ el = el.parentElement()
}
- await browser.waitUntil(async () => {
- return (await video()).isDisplayed()
- })
-
- return video()
+ return el
}
// My account playlists
diff --git a/client/e2e/src/po/video-manage.ts b/client/e2e/src/po/video-manage.ts
new file mode 100644
index 0000000000..c1d30c9e12
--- /dev/null
+++ b/client/e2e/src/po/video-manage.ts
@@ -0,0 +1,130 @@
+import { clickOnRadio, getCheckbox, go, isRadioSelected, selectCustomSelect } from '../utils'
+
+export abstract class VideoManage {
+ async clickOnSave () {
+ const button = this.getSaveButton()
+ await button.waitForClickable()
+ await button.click()
+
+ await this.waitForSaved()
+ }
+
+ async clickOnWatch () {
+ // Simulate the click, because the button opens a new tab
+ const button = $('.watch-save > my-button[icon=external-link] a')
+ await button.waitForClickable()
+
+ await go(await button.getAttribute('href'))
+ }
+
+ // ---------------------------------------------------------------------------
+
+ async setAsNSFW () {
+ await this.goOnPage('Moderation')
+
+ const checkbox = await getCheckbox('nsfw')
+ await checkbox.waitForClickable()
+
+ return checkbox.click()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ async setAsPublic () {
+ await this.goOnPage('Main information')
+
+ return selectCustomSelect('privacy', 'Public')
+ }
+
+ async setAsPrivate () {
+ await this.goOnPage('Main information')
+
+ return selectCustomSelect('privacy', 'Private')
+ }
+
+ async setAsPasswordProtected (videoPassword: string) {
+ await this.goOnPage('Main information')
+
+ selectCustomSelect('privacy', 'Password protected')
+
+ const videoPasswordInput = $('input#videoPassword')
+ await videoPasswordInput.waitForClickable()
+ await videoPasswordInput.clearValue()
+
+ return videoPasswordInput.setValue(videoPassword)
+ }
+
+ // ---------------------------------------------------------------------------
+
+ async scheduleUpload () {
+ await this.goOnPage('Main information')
+
+ selectCustomSelect('privacy', 'Scheduled')
+
+ const input = this.getScheduleInput()
+ await input.waitForClickable()
+ await input.click()
+
+ const nextDay = $('.p-datepicker-today + td > span')
+ await nextDay.waitForClickable()
+ await nextDay.click()
+ await nextDay.waitForDisplayed({ reverse: true })
+ }
+
+ getScheduleInput () {
+ return $('#schedulePublicationAt input')
+ }
+
+ // ---------------------------------------------------------------------------
+
+ async setNormalLive () {
+ await this.goOnPage('Live settings')
+
+ await clickOnRadio('permanentLiveFalse')
+ }
+
+ async setPermanentLive () {
+ await this.goOnPage('Live settings')
+
+ await clickOnRadio('permanentLiveTrue')
+ }
+
+ async getLiveState () {
+ await this.goOnPage('Live settings')
+
+ if (await isRadioSelected('#permanentLiveTrue')) return 'permanent'
+
+ return 'normal'
+ }
+
+ // ---------------------------------------------------------------------------
+
+ async refresh (videoName: string) {
+ await browser.refresh()
+ await browser.waitUntil(async () => {
+ const url = await browser.getUrl()
+
+ return url.includes('/videos/manage')
+ })
+
+ await browser.waitUntil(async () => {
+ return await $('#name').getValue() === videoName
+ })
+ }
+
+ // ---------------------------------------------------------------------------
+
+ protected getSaveButton () {
+ return $('.save-button > button:not([disabled])')
+ }
+
+ protected waitForSaved () {
+ return $('.save-button > button[disabled], my-manage-errors').waitForDisplayed()
+ }
+
+ protected async goOnPage (page: 'Main information' | 'Moderation' | 'Live settings') {
+ const el = $('my-video-manage-container .menu').$('*=' + page)
+ await el.waitForClickable()
+ await el.click()
+ }
+}
diff --git a/client/e2e/src/po/video-publish.po.ts b/client/e2e/src/po/video-publish.po.ts
new file mode 100644
index 0000000000..7f453e183e
--- /dev/null
+++ b/client/e2e/src/po/video-publish.po.ts
@@ -0,0 +1,61 @@
+import { join } from 'path'
+import { VideoManage } from './video-manage'
+
+export class VideoPublishPage extends VideoManage {
+ async navigateTo (tab?: 'Go live') {
+ const publishButton = await $('.publish-button > a')
+
+ await publishButton.waitForClickable()
+ await publishButton.click()
+
+ await $('.upload-video-container').waitForDisplayed()
+
+ if (tab) {
+ const el = $(`.nav-link*=${tab}`)
+ await el.waitForClickable()
+ await el.click()
+ }
+ }
+
+ // ---------------------------------------------------------------------------
+
+ async uploadVideo (fixtureName: 'video.mp4' | 'video2.mp4' | 'video3.mp4') {
+ const fileToUpload = join(__dirname, '../../fixtures/' + fixtureName)
+ const fileInputSelector = '.upload-video-container input[type=file]'
+ const parentFileInput = '.upload-video-container .button-file'
+
+ // Avoid sending keys on non visible element
+ await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
+ await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
+
+ await browser.pause(1000)
+
+ const elem = await $(fileInputSelector)
+ await elem.chooseFile(fileToUpload)
+
+ // Wait for the upload to finish
+ await this.getSaveButton().waitForClickable()
+ }
+
+ async publishLive () {
+ await $('#permanentLiveTrue').parentElement().click()
+
+ const submit = $('.upload-video-container .primary-button:not([disabled])')
+ await submit.waitForClickable()
+ await submit.click()
+
+ await this.getSaveButton().waitForClickable()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ async validSecondStep (videoName: string) {
+ await this.goOnPage('Main information')
+
+ const nameInput = $('input#name')
+ await nameInput.clearValue()
+ await nameInput.setValue(videoName)
+
+ await this.clickOnSave()
+ }
+}
diff --git a/client/e2e/src/po/video-update.po.ts b/client/e2e/src/po/video-update.po.ts
index 3ffb7ba577..979d9c3627 100644
--- a/client/e2e/src/po/video-update.po.ts
+++ b/client/e2e/src/po/video-update.po.ts
@@ -1,5 +1,6 @@
-export class VideoUpdatePage {
+import { VideoManage } from './video-manage'
+export class VideoUpdatePage extends VideoManage {
async updateName (videoName: string) {
const nameInput = $('input#name')
@@ -7,14 +8,4 @@ export class VideoUpdatePage {
await nameInput.clearValue()
await nameInput.setValue(videoName)
}
-
- async validUpdate () {
- const submitButton = await this.getSubmitButton()
-
- return submitButton.click()
- }
-
- private getSubmitButton () {
- return $('.submit-container .action-button')
- }
}
diff --git a/client/e2e/src/po/video-upload.po.ts b/client/e2e/src/po/video-upload.po.ts
deleted file mode 100644
index 0dd25ee94e..0000000000
--- a/client/e2e/src/po/video-upload.po.ts
+++ /dev/null
@@ -1,80 +0,0 @@
-import { join } from 'path'
-import { getCheckbox, selectCustomSelect } from '../utils'
-
-export class VideoUploadPage {
- async navigateTo () {
- const publishButton = await $('.publish-button > a')
-
- await publishButton.waitForClickable()
- await publishButton.click()
-
- await $('.upload-video-container').waitForDisplayed()
- }
-
- async uploadVideo (fixtureName: 'video.mp4' | 'video2.mp4' | 'video3.mp4') {
- const fileToUpload = join(__dirname, '../../fixtures/' + fixtureName)
- const fileInputSelector = '.upload-video-container input[type=file]'
- const parentFileInput = '.upload-video-container .button-file'
-
- // Avoid sending keys on non visible element
- await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
- await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
-
- await browser.pause(1000)
-
- const elem = await $(fileInputSelector)
- await elem.chooseFile(fileToUpload)
-
- // Wait for the upload to finish
- await browser.waitUntil(async () => {
- const warning = await $('=Publish will be available when upload is finished').isDisplayed()
- const progress = await $('.progress-container=100%').isDisplayed()
-
- return !warning && progress
- })
- }
-
- async setAsNSFW () {
- const checkbox = await getCheckbox('nsfw')
- await checkbox.waitForClickable()
-
- return checkbox.click()
- }
-
- async validSecondUploadStep (videoName: string) {
- const nameInput = $('input#name')
- await nameInput.clearValue()
- await nameInput.setValue(videoName)
-
- const button = this.getSecondStepSubmitButton()
- await button.waitForClickable()
-
- await button.click()
-
- return browser.waitUntil(async () => {
- return (await browser.getUrl()).includes('/w/')
- })
- }
-
- setAsPublic () {
- return selectCustomSelect('privacy', 'Public')
- }
-
- setAsPrivate () {
- return selectCustomSelect('privacy', 'Private')
- }
-
- async setAsPasswordProtected (videoPassword: string) {
- selectCustomSelect('privacy', 'Password protected')
-
- const videoPasswordInput = $('input#videoPassword')
- await videoPasswordInput.waitForClickable()
- await videoPasswordInput.clearValue()
-
- return videoPasswordInput.setValue(videoPassword)
- }
-
- private getSecondStepSubmitButton () {
- return $('.submit-container my-button')
- }
-}
diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts
index 0804c2545c..f664bd40a4 100644
--- a/client/e2e/src/po/video-watch.po.ts
+++ b/client/e2e/src/po/video-watch.po.ts
@@ -1,24 +1,16 @@
import { browserSleep, FIXTURE_URLS, go } from '../utils'
export class VideoWatchPage {
-
constructor (private isMobileDevice: boolean, private isSafari: boolean) {
-
}
- waitWatchVideoName (videoName: string) {
+ waitWatchVideoName (videoName: string, maxTime?: number) {
if (this.isSafari) return browserSleep(5000)
// On mobile we display the first node, on desktop the second one
- const index = this.isMobileDevice ? 0 : 1
-
return browser.waitUntil(async () => {
- if (!await $('.video-info .video-info-name').isExisting()) return false
-
- const elem = await $$('.video-info .video-info-name')[index]
-
- return (await elem.getText()).includes(videoName) && elem.isDisplayed()
- })
+ return (await this.getVideoName()) === videoName
+ }, { timeout: maxTime })
}
getVideoName () {
@@ -82,16 +74,17 @@ export class VideoWatchPage {
return go(FIXTURE_URLS.HLS_PLAYLIST_EMBED)
}
- async clickOnUpdate () {
+ async clickOnManage () {
await this.clickOnMoreDropdownIcon()
const items = await $$('.dropdown-menu.show .dropdown-item')
for (const item of items) {
- const href = await item.getAttribute('href')
+ const content = await item.getText()
- if (href?.includes('/update/')) {
+ if (content.includes('Manage')) {
await item.click()
+ await $('#name').waitForClickable()
return
}
}
@@ -123,12 +116,6 @@ export class VideoWatchPage {
return playlist().click()
}
- waitUntilVideoName (name: string, maxTime: number) {
- return browser.waitUntil(async () => {
- return (await this.getVideoName()) === name
- }, { timeout: maxTime })
- }
-
async clickOnMoreDropdownIcon () {
const dropdown = $('my-video-actions-dropdown .action-button')
await dropdown.click()
diff --git a/client/e2e/src/suites-all/videos.e2e-spec.ts b/client/e2e/src/suites-all/videos.e2e-spec.ts
index dcc8eefbfc..d0eaab3e19 100644
--- a/client/e2e/src/suites-all/videos.e2e-spec.ts
+++ b/client/e2e/src/suites-all/videos.e2e-spec.ts
@@ -3,7 +3,7 @@ import { MyAccountPage } from '../po/my-account.po'
import { PlayerPage } from '../po/player.po'
import { VideoListPage } from '../po/video-list.po'
import { VideoUpdatePage } from '../po/video-update.po'
-import { VideoUploadPage } from '../po/video-upload.po'
+import { VideoPublishPage } from '../po/video-publish.po'
import { VideoWatchPage } from '../po/video-watch.po'
import { FIXTURE_URLS, go, isIOS, isMobileDevice, isSafari, waitServerUp } from '../utils'
@@ -19,7 +19,7 @@ function isUploadUnsupported () {
describe('Videos all workflow', () => {
let videoWatchPage: VideoWatchPage
let videoListPage: VideoListPage
- let videoUploadPage: VideoUploadPage
+ let videoPublishPage: VideoPublishPage
let videoUpdatePage: VideoUpdatePage
let myAccountPage: MyAccountPage
let loginPage: LoginPage
@@ -46,7 +46,7 @@ describe('Videos all workflow', () => {
beforeEach(async () => {
videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
- videoUploadPage = new VideoUploadPage()
+ videoPublishPage = new VideoPublishPage()
videoUpdatePage = new VideoUpdatePage()
myAccountPage = new MyAccountPage()
loginPage = new LoginPage(isMobileDevice())
@@ -70,10 +70,10 @@ describe('Videos all workflow', () => {
it('Should upload a video', async () => {
if (isUploadUnsupported()) return
- await videoUploadPage.navigateTo()
+ await videoPublishPage.navigateTo()
- await videoUploadPage.uploadVideo('video.mp4')
- return videoUploadPage.validSecondUploadStep(videoName)
+ await videoPublishPage.uploadVideo('video.mp4')
+ await videoPublishPage.validSecondStep(videoName)
})
it('Should list videos', async () => {
@@ -124,12 +124,12 @@ describe('Videos all workflow', () => {
await go(videoWatchUrl)
- await videoWatchPage.clickOnUpdate()
+ await videoWatchPage.clickOnManage()
videoName += ' updated'
await videoUpdatePage.updateName(videoName)
-
- await videoUpdatePage.validUpdate()
+ await videoUpdatePage.clickOnSave()
+ await videoUpdatePage.clickOnWatch()
const name = await videoWatchPage.getVideoName()
expect(name).toEqual(videoName)
@@ -145,10 +145,11 @@ describe('Videos all workflow', () => {
await videoWatchPage.saveToPlaylist(playlistName)
await browser.pause(5000)
- await videoUploadPage.navigateTo()
+ await videoPublishPage.navigateTo()
- await videoUploadPage.uploadVideo('video2.mp4')
- await videoUploadPage.validSecondUploadStep(video2Name)
+ await videoPublishPage.uploadVideo('video2.mp4')
+ await videoPublishPage.validSecondStep(video2Name)
+ await videoPublishPage.clickOnWatch()
await videoWatchPage.clickOnSave()
await videoWatchPage.saveToPlaylist(playlistName)
@@ -173,7 +174,7 @@ describe('Videos all workflow', () => {
await myAccountPage.playPlaylist()
- await videoWatchPage.waitUntilVideoName(video2Name, 40 * 1000)
+ await videoWatchPage.waitWatchVideoName(video2Name, 40 * 1000)
})
it('Should watch the Web Video playlist in the embed', async () => {
diff --git a/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts b/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
index e839d132ec..436e51a7a5 100644
--- a/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
+++ b/client/e2e/src/suites-local/custom-server-defaults.e2e-spec.ts
@@ -1,10 +1,10 @@
import { LoginPage } from '../po/login.po'
-import { VideoUploadPage } from '../po/video-upload.po'
+import { VideoPublishPage } from '../po/video-publish.po'
import { VideoWatchPage } from '../po/video-watch.po'
import { getScreenshotPath, go, isMobileDevice, isSafari, waitServerUp } from '../utils'
describe('Custom server defaults', () => {
- let videoUploadPage: VideoUploadPage
+ let videoPublishPage: VideoPublishPage
let loginPage: LoginPage
let videoWatchPage: VideoWatchPage
@@ -12,7 +12,7 @@ describe('Custom server defaults', () => {
await waitServerUp()
loginPage = new LoginPage(isMobileDevice())
- videoUploadPage = new VideoUploadPage()
+ videoPublishPage = new VideoPublishPage()
videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
await browser.maximizeWindow()
@@ -24,10 +24,11 @@ describe('Custom server defaults', () => {
})
it('Should upload a video with custom default values', async function () {
- await videoUploadPage.navigateTo()
- await videoUploadPage.uploadVideo('video.mp4')
- await videoUploadPage.validSecondUploadStep('video')
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video.mp4')
+ await videoPublishPage.validSecondStep('video')
+ await videoPublishPage.clickOnWatch()
await videoWatchPage.waitWatchVideoName('video')
const videoUrl = await browser.getUrl()
@@ -66,11 +67,12 @@ describe('Custom server defaults', () => {
before(async () => {
await loginPage.loginAsRootUser()
- await videoUploadPage.navigateTo()
- await videoUploadPage.uploadVideo('video2.mp4')
- await videoUploadPage.setAsPublic()
- await videoUploadPage.validSecondUploadStep('video')
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video2.mp4')
+ await videoPublishPage.setAsPublic()
+ await videoPublishPage.validSecondStep('video')
+ await videoPublishPage.clickOnWatch()
await videoWatchPage.waitWatchVideoName('video')
videoUrl = await browser.getUrl()
diff --git a/client/e2e/src/suites-local/plugins.e2e-spec.ts b/client/e2e/src/suites-local/plugins.e2e-spec.ts
index b15dfdedb3..84a29ede68 100644
--- a/client/e2e/src/suites-local/plugins.e2e-spec.ts
+++ b/client/e2e/src/suites-local/plugins.e2e-spec.ts
@@ -1,10 +1,10 @@
import { AdminPluginPage } from '../po/admin-plugin.po'
import { LoginPage } from '../po/login.po'
-import { VideoUploadPage } from '../po/video-upload.po'
-import { getCheckbox, isMobileDevice, waitServerUp } from '../utils'
+import { VideoPublishPage } from '../po/video-publish.po'
+import { getCheckbox, getScreenshotPath, isMobileDevice, waitServerUp } from '../utils'
describe('Plugins', () => {
- let videoUploadPage: VideoUploadPage
+ let videoPublishPage: VideoPublishPage
let loginPage: LoginPage
let adminPluginPage: AdminPluginPage
@@ -12,11 +12,11 @@ describe('Plugins', () => {
return getCheckbox('hello-world-field-4')
}
- async function expectSubmitState ({ disabled }: { disabled: boolean }) {
- const disabledSubmit = await $('my-button [disabled]')
+ async function expectSubmitError (hasError: boolean) {
+ await videoPublishPage.clickOnSave()
- if (disabled) expect(await disabledSubmit.isDisplayed()).toBeTruthy()
- else expect(await disabledSubmit.isDisplayed()).toBeFalsy()
+ await $('.form-error*=Should be enabled').waitForDisplayed({ reverse: !hasError })
+ await $('li*=Should be enabled').waitForDisplayed({ reverse: !hasError })
}
before(async () => {
@@ -25,7 +25,7 @@ describe('Plugins', () => {
beforeEach(async () => {
loginPage = new LoginPage(isMobileDevice())
- videoUploadPage = new VideoUploadPage()
+ videoPublishPage = new VideoPublishPage()
adminPluginPage = new AdminPluginPage()
await browser.maximizeWindow()
@@ -41,15 +41,23 @@ describe('Plugins', () => {
})
it('Should have checkbox in video edit page', async () => {
- await videoUploadPage.navigateTo()
- await videoUploadPage.uploadVideo('video.mp4')
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video.mp4')
- await $('span=Super field 4 in main tab').waitForDisplayed()
+ const el = () => $('span=Super field 4 in main tab')
+ await el().waitForDisplayed()
+
+ // Only displayed if the video is public
+ await videoPublishPage.setAsPrivate()
+ await el().waitForDisplayed({ reverse: true })
+
+ await videoPublishPage.setAsPublic()
+ await el().waitForDisplayed()
const checkbox = await getPluginCheckbox()
expect(await checkbox.isDisplayed()).toBeTruthy()
- await expectSubmitState({ disabled: true })
+ await expectSubmitError(true)
})
it('Should check the checkbox and be able to submit the video', async function () {
@@ -58,7 +66,7 @@ describe('Plugins', () => {
await checkbox.waitForClickable()
await checkbox.click()
- await expectSubmitState({ disabled: false })
+ await expectSubmitError(false)
})
it('Should uncheck the checkbox and not be able to submit the video', async function () {
@@ -67,16 +75,16 @@ describe('Plugins', () => {
await checkbox.waitForClickable()
await checkbox.click()
- await expectSubmitState({ disabled: true })
-
- const error = await $('.form-error*=Should be enabled')
-
- expect(await error.isDisplayed()).toBeTruthy()
+ await expectSubmitError(true)
})
it('Should change the privacy and should hide the checkbox', async function () {
- await videoUploadPage.setAsPrivate()
+ await videoPublishPage.setAsPrivate()
+
+ await expectSubmitError(false)
+ })
- await expectSubmitState({ disabled: false })
+ after(async () => {
+ await browser.saveScreenshot(getScreenshotPath('after-test.png'))
})
})
diff --git a/client/e2e/src/suites-local/publish-live.e2e-spec.ts b/client/e2e/src/suites-local/publish-live.e2e-spec.ts
new file mode 100644
index 0000000000..f7d742ae21
--- /dev/null
+++ b/client/e2e/src/suites-local/publish-live.e2e-spec.ts
@@ -0,0 +1,61 @@
+import { AdminConfigPage } from '../po/admin-config.po'
+import { LoginPage } from '../po/login.po'
+import { VideoPublishPage } from '../po/video-publish.po'
+import { VideoWatchPage } from '../po/video-watch.po'
+import { getScreenshotPath, isMobileDevice, isSafari, waitServerUp } from '../utils'
+
+describe('Publish live', function () {
+ let videoPublishPage: VideoPublishPage
+ let loginPage: LoginPage
+ let adminConfigPage: AdminConfigPage
+ let videoWatchPage: VideoWatchPage
+
+ before(async () => {
+ await waitServerUp()
+
+ loginPage = new LoginPage(isMobileDevice())
+ videoPublishPage = new VideoPublishPage()
+ adminConfigPage = new AdminConfigPage()
+ videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
+
+ await browser.maximizeWindow()
+
+ await loginPage.loginAsRootUser()
+ })
+
+ it('Should enable live', async function () {
+ await adminConfigPage.toggleLive(true)
+ await adminConfigPage.save()
+ })
+
+ it('Should create a classic permanent live', async function () {
+ await videoPublishPage.navigateTo('Go live')
+
+ await videoPublishPage.publishLive()
+ await videoPublishPage.validSecondStep('Permanent live test')
+
+ expect(await videoPublishPage.getLiveState()).toEqual('permanent')
+
+ await videoPublishPage.clickOnWatch()
+
+ await videoWatchPage.waitWatchVideoName('Permanent live test')
+ })
+
+ it('Should create a permanent live and update it to a normal live', async function () {
+ await videoPublishPage.navigateTo('Go live')
+
+ await videoPublishPage.publishLive()
+ await videoPublishPage.setNormalLive()
+ await videoPublishPage.validSecondStep('Normal live test')
+ await videoPublishPage.clickOnWatch()
+
+ await videoWatchPage.waitWatchVideoName('Normal live test')
+ await videoWatchPage.clickOnManage()
+
+ expect(await videoPublishPage.getLiveState()).toEqual('normal')
+ })
+
+ after(async () => {
+ await browser.saveScreenshot(getScreenshotPath('after-test.png'))
+ })
+})
diff --git a/client/e2e/src/suites-local/publish.e2e-spec.ts b/client/e2e/src/suites-local/publish.e2e-spec.ts
new file mode 100644
index 0000000000..1bc70cd0f2
--- /dev/null
+++ b/client/e2e/src/suites-local/publish.e2e-spec.ts
@@ -0,0 +1,56 @@
+import { LoginPage } from '../po/login.po'
+import { VideoPublishPage } from '../po/video-publish.po'
+import { getScreenshotPath, isMobileDevice, waitServerUp } from '../utils'
+
+describe('Publish video', () => {
+ let videoPublishPage: VideoPublishPage
+ let loginPage: LoginPage
+
+ before(async () => {
+ await waitServerUp()
+
+ loginPage = new LoginPage(isMobileDevice())
+ videoPublishPage = new VideoPublishPage()
+
+ await browser.maximizeWindow()
+ })
+
+ describe('Common', function () {
+ before(async function () {
+ await loginPage.loginAsRootUser()
+ })
+
+ it('Should upload a video and on refresh being redirected to the manage page', async function () {
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video.mp4')
+ await videoPublishPage.validSecondStep('first video')
+
+ await videoPublishPage.refresh('first video')
+ })
+
+ it('Should upload a video and schedule upload date', async function () {
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video.mp4')
+
+ await videoPublishPage.scheduleUpload()
+ await videoPublishPage.validSecondStep('scheduled')
+
+ await videoPublishPage.refresh('scheduled')
+
+ // check if works? screenshot
+ expect(videoPublishPage.getScheduleInput()).toBeDisplayed()
+
+ const nextDay = new Date()
+ nextDay.setDate(nextDay.getDate() + 1)
+
+ const inputDate = new Date(await videoPublishPage.getScheduleInput().getValue())
+ expect(nextDay.getDate()).toEqual(inputDate.getDate())
+ expect(nextDay.getMonth()).toEqual(inputDate.getMonth())
+ expect(nextDay.getFullYear()).toEqual(inputDate.getFullYear())
+ })
+ })
+
+ after(async () => {
+ await browser.saveScreenshot(getScreenshotPath('after-test.png'))
+ })
+})
diff --git a/client/e2e/src/suites-local/signup.e2e-spec.ts b/client/e2e/src/suites-local/signup.e2e-spec.ts
index 1e55549b30..f01e50f825 100644
--- a/client/e2e/src/suites-local/signup.e2e-spec.ts
+++ b/client/e2e/src/suites-local/signup.e2e-spec.ts
@@ -75,7 +75,6 @@ describe('Signup', () => {
}) {
await loginPage.loginAsRootUser()
- await adminConfigPage.navigateTo('basic-configuration')
await adminConfigPage.toggleSignup(options.enabled)
if (options.enabled) {
@@ -116,9 +115,7 @@ describe('Signup', () => {
})
describe('Email verification disabled', function () {
-
describe('Direct registration', function () {
-
it('Should enable signup without approval', async () => {
await prepareSignup({ enabled: true, requiresApproval: false, requiresEmailVerification: false })
@@ -171,7 +168,6 @@ describe('Signup', () => {
})
describe('Registration with approval', function () {
-
it('Should enable signup with approval', async () => {
await prepareSignup({ enabled: true, requiresApproval: true, requiresEmailVerification: false })
@@ -252,7 +248,6 @@ describe('Signup', () => {
})
describe('Direct registration', function () {
-
it('Should enable signup without approval', async () => {
await prepareSignup({ enabled: true, requiresApproval: false, requiresEmailVerification: true })
@@ -320,7 +315,6 @@ describe('Signup', () => {
})
describe('Registration with approval', function () {
-
it('Should enable signup without approval', async () => {
await prepareSignup({ enabled: true, requiresApproval: true, requiresEmailVerification: true })
diff --git a/client/e2e/src/suites-local/user-settings.e2e-spec.ts b/client/e2e/src/suites-local/user-settings.e2e-spec.ts
index 3e982d26f2..61c3e350eb 100644
--- a/client/e2e/src/suites-local/user-settings.e2e-spec.ts
+++ b/client/e2e/src/suites-local/user-settings.e2e-spec.ts
@@ -1,12 +1,12 @@
import { AnonymousSettingsPage } from '../po/anonymous-settings.po'
import { LoginPage } from '../po/login.po'
import { MyAccountPage } from '../po/my-account.po'
-import { VideoUploadPage } from '../po/video-upload.po'
+import { VideoPublishPage } from '../po/video-publish.po'
import { VideoWatchPage } from '../po/video-watch.po'
import { go, isMobileDevice, isSafari, waitServerUp } from '../utils'
describe('User settings', () => {
- let videoUploadPage: VideoUploadPage
+ let videoPublishPage: VideoPublishPage
let loginPage: LoginPage
let videoWatchPage: VideoWatchPage
let myAccountPage: MyAccountPage
@@ -16,7 +16,7 @@ describe('User settings', () => {
await waitServerUp()
loginPage = new LoginPage(isMobileDevice())
- videoUploadPage = new VideoUploadPage()
+ videoPublishPage = new VideoPublishPage()
videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
myAccountPage = new MyAccountPage()
anonymousSettingsPage = new AnonymousSettingsPage()
@@ -42,10 +42,11 @@ describe('User settings', () => {
before(async () => {
await loginPage.loginAsRootUser()
- await videoUploadPage.navigateTo()
- await videoUploadPage.uploadVideo('video.mp4')
- await videoUploadPage.validSecondUploadStep('video')
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video.mp4')
+ await videoPublishPage.validSecondStep('video')
+ await videoPublishPage.clickOnWatch()
await videoWatchPage.waitWatchVideoName('video')
videoUrl = await browser.getUrl()
diff --git a/client/e2e/src/suites-local/video-password.e2e-spec.ts b/client/e2e/src/suites-local/video-password.e2e-spec.ts
index c9e4f68909..a3698dec01 100644
--- a/client/e2e/src/suites-local/video-password.e2e-spec.ts
+++ b/client/e2e/src/suites-local/video-password.e2e-spec.ts
@@ -2,12 +2,12 @@ import { LoginPage } from '../po/login.po'
import { MyAccountPage } from '../po/my-account.po'
import { PlayerPage } from '../po/player.po'
import { SignupPage } from '../po/signup.po'
-import { VideoUploadPage } from '../po/video-upload.po'
+import { VideoPublishPage } from '../po/video-publish.po'
import { VideoWatchPage } from '../po/video-watch.po'
import { getScreenshotPath, go, isMobileDevice, isSafari, waitServerUp } from '../utils'
describe('Password protected videos', () => {
- let videoUploadPage: VideoUploadPage
+ let videoPublishPage: VideoPublishPage
let loginPage: LoginPage
let videoWatchPage: VideoWatchPage
let signupPage: SignupPage
@@ -44,7 +44,7 @@ describe('Password protected videos', () => {
await waitServerUp()
loginPage = new LoginPage(isMobileDevice())
- videoUploadPage = new VideoUploadPage()
+ videoPublishPage = new VideoPublishPage()
videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
signupPage = new SignupPage()
playerPage = new PlayerPage()
@@ -59,9 +59,12 @@ describe('Password protected videos', () => {
})
it('Should login, upload a public video and save it to a playlist', async () => {
- await videoUploadPage.navigateTo()
- await videoUploadPage.uploadVideo('video.mp4')
- await videoUploadPage.validSecondUploadStep(publicVideoName1)
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video.mp4')
+ await videoPublishPage.validSecondStep(publicVideoName1)
+
+ await videoPublishPage.clickOnWatch()
+ await videoWatchPage.waitWatchVideoName(publicVideoName1)
await videoWatchPage.clickOnSave()
@@ -69,15 +72,15 @@ describe('Password protected videos', () => {
await videoWatchPage.saveToPlaylist(playlistName)
await browser.pause(5000)
-
})
it('Should upload a password protected video', async () => {
- await videoUploadPage.navigateTo()
- await videoUploadPage.uploadVideo('video2.mp4')
- await videoUploadPage.setAsPasswordProtected(videoPassword)
- await videoUploadPage.validSecondUploadStep(passwordProtectedVideoName)
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video2.mp4')
+ await videoPublishPage.setAsPasswordProtected(videoPassword)
+ await videoPublishPage.validSecondStep(passwordProtectedVideoName)
+ await videoPublishPage.clickOnWatch()
await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName)
passwordProtectedVideoUrl = await browser.getUrl()
@@ -89,11 +92,13 @@ describe('Password protected videos', () => {
})
it('Should upload a second public video and save it to playlist', async () => {
- await videoUploadPage.navigateTo()
+ await videoPublishPage.navigateTo()
- await videoUploadPage.uploadVideo('video3.mp4')
- await videoUploadPage.validSecondUploadStep(publicVideoName2)
+ await videoPublishPage.uploadVideo('video3.mp4')
+ await videoPublishPage.validSecondStep(publicVideoName2)
+ await videoPublishPage.clickOnWatch()
+ await videoWatchPage.waitWatchVideoName(publicVideoName2)
await videoWatchPage.clickOnSave()
await videoWatchPage.saveToPlaylist(playlistName)
})
@@ -143,11 +148,11 @@ describe('Password protected videos', () => {
await myAccountPage.clickOnPlaylist(playlistName)
await myAccountPage.playPlaylist()
- await videoWatchPage.waitUntilVideoName(publicVideoName1, 40 * 1000)
+ await videoWatchPage.waitWatchVideoName(publicVideoName1, 40 * 1000)
playlistUrl = await browser.getUrl()
- await videoWatchPage.waitUntilVideoName(passwordProtectedVideoName, 40 * 1000)
- await videoWatchPage.waitUntilVideoName(publicVideoName2, 40 * 1000)
+ await videoWatchPage.waitWatchVideoName(passwordProtectedVideoName, 40 * 1000)
+ await videoWatchPage.waitWatchVideoName(publicVideoName2, 40 * 1000)
})
after(async () => {
@@ -156,7 +161,6 @@ describe('Password protected videos', () => {
})
describe('Regular users', function () {
-
before(async () => {
await signupPage.fullSignup({
accountInfo: {
@@ -192,7 +196,7 @@ describe('Password protected videos', () => {
it('Should watch the playlist without password protected video', async () => {
await go(playlistUrl)
await playerPage.playVideo()
- await videoWatchPage.waitUntilVideoName(publicVideoName2, 40 * 1000)
+ await videoWatchPage.waitWatchVideoName(publicVideoName2, 40 * 1000)
})
after(async () => {
@@ -222,7 +226,7 @@ describe('Password protected videos', () => {
it('Should watch the playlist without password protected video', async () => {
await go(playlistUrl)
await playerPage.playVideo()
- await videoWatchPage.waitUntilVideoName(publicVideoName2, 40 * 1000)
+ await videoWatchPage.waitWatchVideoName(publicVideoName2, 40 * 1000)
})
})
diff --git a/client/e2e/src/suites-local/videos-list.e2e-spec.ts b/client/e2e/src/suites-local/videos-list.e2e-spec.ts
index 3e39049a77..b5e0cce941 100644
--- a/client/e2e/src/suites-local/videos-list.e2e-spec.ts
+++ b/client/e2e/src/suites-local/videos-list.e2e-spec.ts
@@ -3,14 +3,14 @@ import { LoginPage } from '../po/login.po'
import { MyAccountPage } from '../po/my-account.po'
import { VideoListPage } from '../po/video-list.po'
import { VideoSearchPage } from '../po/video-search.po'
-import { VideoUploadPage } from '../po/video-upload.po'
+import { VideoPublishPage } from '../po/video-publish.po'
import { VideoWatchPage } from '../po/video-watch.po'
import { NSFWPolicy } from '../types/common'
import { isMobileDevice, isSafari, waitServerUp } from '../utils'
describe('Videos list', () => {
let videoListPage: VideoListPage
- let videoUploadPage: VideoUploadPage
+ let videoPublishPage: VideoPublishPage
let adminConfigPage: AdminConfigPage
let loginPage: LoginPage
let myAccountPage: MyAccountPage
@@ -87,7 +87,6 @@ describe('Videos list', () => {
}
async function updateAdminNSFW (nsfw: NSFWPolicy) {
- await adminConfigPage.navigateTo('instance-information')
await adminConfigPage.updateNSFWSetting(nsfw)
await adminConfigPage.save()
}
@@ -105,7 +104,7 @@ describe('Videos list', () => {
videoListPage = new VideoListPage(isMobileDevice(), isSafari())
adminConfigPage = new AdminConfigPage()
loginPage = new LoginPage(isMobileDevice())
- videoUploadPage = new VideoUploadPage()
+ videoPublishPage = new VideoPublishPage()
myAccountPage = new MyAccountPage()
videoSearchPage = new VideoSearchPage()
videoWatchPage = new VideoWatchPage(isMobileDevice(), isSafari())
@@ -119,20 +118,19 @@ describe('Videos list', () => {
})
it('Should set the homepage', async () => {
- await adminConfigPage.navigateTo('instance-homepage')
await adminConfigPage.updateHomepage('<peertube-videos-list data-sort="-publishedAt"></peertube-videos-list>')
await adminConfigPage.save()
})
it('Should upload 2 videos (NSFW and classic videos)', async () => {
- await videoUploadPage.navigateTo()
- await videoUploadPage.uploadVideo('video.mp4')
- await videoUploadPage.setAsNSFW()
- await videoUploadPage.validSecondUploadStep(nsfwVideo)
-
- await videoUploadPage.navigateTo()
- await videoUploadPage.uploadVideo('video2.mp4')
- await videoUploadPage.validSecondUploadStep(normalVideo)
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video.mp4')
+ await videoPublishPage.setAsNSFW()
+ await videoPublishPage.validSecondStep(nsfwVideo)
+
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video2.mp4')
+ await videoPublishPage.validSecondStep(normalVideo)
})
it('Should logout', async function () {
@@ -140,7 +138,6 @@ describe('Videos list', () => {
})
describe('Anonymous users', function () {
-
it('Should correctly handle do not list', async () => {
await loginPage.loginAsRootUser()
await updateAdminNSFW('do_not_list')
@@ -170,7 +167,6 @@ describe('Videos list', () => {
})
describe('Logged in users', function () {
-
before(async () => {
await loginPage.loginAsRootUser()
})
@@ -199,13 +195,13 @@ describe('Videos list', () => {
})
describe('Default upload values', function () {
-
it('Should have default video values', async function () {
await loginPage.loginAsRootUser()
- await videoUploadPage.navigateTo()
- await videoUploadPage.uploadVideo('video3.mp4')
- await videoUploadPage.validSecondUploadStep('video')
+ await videoPublishPage.navigateTo()
+ await videoPublishPage.uploadVideo('video3.mp4')
+ await videoPublishPage.validSecondStep('video')
+ await videoPublishPage.clickOnWatch()
await videoWatchPage.waitWatchVideoName('video')
expect(await videoWatchPage.getPrivacy()).toBe('Public')
diff --git a/client/e2e/src/utils/elements.ts b/client/e2e/src/utils/elements.ts
index cca69bea75..842f40ded8 100644
--- a/client/e2e/src/utils/elements.ts
+++ b/client/e2e/src/utils/elements.ts
@@ -1,15 +1,41 @@
-async function getCheckbox (name: string) {
+export async function getCheckbox (name: string) {
const input = $(`my-peertube-checkbox input[id=${name}]`)
await input.waitForExist()
return input.parentElement()
}
-function isCheckboxSelected (name: string) {
+export function isCheckboxSelected (name: string) {
return $(`input[id=${name}]`).isSelected()
}
-async function selectCustomSelect (id: string, valueLabel: string) {
+export async function setCheckboxEnabled (name: string, enabled: boolean) {
+ if (await isCheckboxSelected(name) === enabled) return
+
+ const checkbox = await getCheckbox(name)
+
+ await checkbox.waitForClickable()
+ await checkbox.click()
+}
+
+// ---------------------------------------------------------------------------
+
+export async function isRadioSelected (name: string) {
+ await $(`input[id=${name}] + label`).waitForClickable()
+
+ return $(`input[id=${name}]`).isSelected()
+}
+
+export async function clickOnRadio (name: string) {
+ const label = $(`input[id=${name}] + label`)
+
+ await label.waitForClickable()
+ await label.click()
+}
+
+// ---------------------------------------------------------------------------
+
+export async function selectCustomSelect (id: string, valueLabel: string) {
const wrapper = $(`[formcontrolname=${id}] span[role=combobox]`)
await wrapper.waitForClickable()
@@ -26,7 +52,7 @@ async function selectCustomSelect (id: string, valueLabel: string) {
return option.click()
}
-async function findParentElement (
+export async function findParentElement (
el: WebdriverIO.Element,
finder: (el: WebdriverIO.Element) => Promise<boolean>
) {
@@ -34,10 +60,3 @@ async function findParentElement (
return findParentElement(await el.parentElement(), finder)
}
-
-export {
- getCheckbox,
- isCheckboxSelected,
- selectCustomSelect,
- findParentElement
-}
diff --git a/client/e2e/wdio.local-test.conf.ts b/client/e2e/wdio.local-test.conf.ts
index e0ae1d24a6..fcc04bd495 100644
--- a/client/e2e/wdio.local-test.conf.ts
+++ b/client/e2e/wdio.local-test.conf.ts
@@ -32,6 +32,15 @@ module.exports = {
prefs
}
}
+ // {
+ // 'browserName': 'firefox',
+ // 'moz:firefoxOptions': {
+ // binary: '/usr/bin/firefox-developer-edition',
+ // args: [ '--headless', windowSizeArg ],
+
+ // prefs
+ // }
+ // }
],
services: [ 'shared-store' ],
diff --git a/client/package.json b/client/package.json
index bee49065bb..eaff0d07e4 100644
--- a/client/package.json
+++ b/client/package.json
@@ -117,6 +117,7 @@
"tinykeys": "^2.1.0",
"ts-node": "^10.9.2",
"tslib": "^2.4.0",
+ "type-fest": "^4.37.0",
"typescript": "~5.7.3",
"video.js": "^7.19.2",
"vite": "^6.0.11",
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
index b28d2e7e08..0d8a590007 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
@@ -439,23 +439,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
this.router.navigate([], { fragment: this.activeNav })
}
- grabAllErrors (errorObjectArg?: any) {
- const errorObject = errorObjectArg || this.formErrors
-
- let acc: string[] = []
-
- for (const key of Object.keys(errorObject)) {
- const value = errorObject[key]
- if (!value) continue
-
- if (typeof value === 'string') {
- acc.push(value)
- } else {
- acc = acc.concat(this.grabAllErrors(value))
- }
- }
-
- return acc
+ grabAllErrors () {
+ return this.formReactiveService.grabAllErrors(this.formErrors)
}
private updateForm () {
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.html b/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.html
index 7f694bfef9..0633dc44a7 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.html
+++ b/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.html
@@ -19,7 +19,7 @@
inputId="instanceCustomHomepageContent" formControlName="content"
[customMarkdownRenderer]="getCustomMarkdownRenderer()" [debounceTime]="500"
[formError]="formErrors()['instanceCustomHomepage.content']"
- dir="ltr"
+ dir="ltr" monospace="true"
></my-markdown-textarea>
<div *ngIf="formErrors().instanceCustomHomepage.content" class="form-error" role="alert">{{ formErrors().instanceCustomHomepage.content }}</div>
diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html
index e8f811c2f2..fb16203f86 100644
--- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html
+++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html
@@ -46,10 +46,13 @@
</td>
<td>
- <my-video-cell [video]="videoBlock.video">
- <span name>
- <my-global-icon *ngIf="videoBlock.type === 2" i18n-title title="The video was blocked due to automatic blocking of new videos" iconName="robot"></my-global-icon>
- </span>
+ <my-video-cell [video]="videoBlock.video" size="small">
+ <div>
+ <span
+ *ngIf="videoBlock.type === 2"
+ i18n-title title="The video was blocked due to automatic blocking of new videos" class="pt-badge badge-info" i18n
+ >Auto block</span>
+ </div>
</my-video-cell>
</td>
diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
index b9300a45d2..708775a7aa 100644
--- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
+++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
@@ -14,7 +14,6 @@ import { TableModule } from 'primeng/table'
import { switchMap } from 'rxjs/operators'
import { environment } from 'src/environments/environment'
import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../../shared/shared-forms/advanced-input-filter.component'
-import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
import { ActionDropdownComponent, DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'
import { AutoColspanDirective } from '../../../shared/shared-main/common/auto-colspan.directive'
import { EmbedComponent } from '../../../shared/shared-main/video/embed.component'
@@ -26,7 +25,6 @@ import { VideoCellComponent } from '../../../shared/shared-tables/video-cell.com
templateUrl: './video-block-list.component.html',
styleUrls: [ '../../../shared/shared-moderation/moderation.scss' ],
imports: [
- GlobalIconComponent,
TableModule,
SharedModule,
AdvancedInputFilterComponent,
diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.ts b/client/src/app/+admin/overview/users/user-list/user-list.component.ts
index 9c73514920..80bd015942 100644
--- a/client/src/app/+admin/overview/users/user-list/user-list.component.ts
+++ b/client/src/app/+admin/overview/users/user-list/user-list.component.ts
@@ -12,7 +12,7 @@ import {
RestPagination,
RestTable
} from '@app/core'
-import { formatICU, getAPIHost } from '@app/helpers'
+import { formatICU, getBackendHost } from '@app/helpers'
import { Actor } from '@app/shared/shared-main/account/actor.model'
import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'
import { ProgressBarComponent } from '@app/shared/shared-main/common/progress-bar.component'
@@ -373,10 +373,10 @@ export class UserListComponent extends RestTable<User> implements OnInit, OnDest
}
private loadMutedStatus () {
- this.blocklist.getStatus({ accounts: this.users.map(u => u.username + '@' + getAPIHost()) })
+ this.blocklist.getStatus({ accounts: this.users.map(u => u.username + '@' + getBackendHost()) })
.subscribe(blockStatus => {
for (const user of this.users) {
- user.accountMutedStatus.mutedByInstance = blockStatus.accounts[user.username + '@' + getAPIHost()].blockedByServer
+ user.accountMutedStatus.mutedByInstance = blockStatus.accounts[user.username + '@' + getBackendHost()].blockedByServer
}
})
}
diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html
index 87ccc54419..cfecc2d4a9 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.html
+++ b/client/src/app/+admin/overview/videos/video-list.component.html
@@ -61,7 +61,7 @@
</td>
<td>
- <my-video-cell [video]="video"></my-video-cell>
+ <my-video-cell [video]="video" size="small"></my-video-cell>
</td>
<td>
@@ -72,7 +72,7 @@
<span class="pt-badge badge-purple" i18n>Remote</span>
}
- <span [ngClass]="getPrivacyBadgeClass(video)" class="pt-badge">{{ video.privacy.label }}</span>
+ <my-video-privacy-badge [video]="video"></my-video-privacy-badge>
<span *ngIf="video.nsfw" class="pt-badge badge-red" i18n>NSFW</span>
diff --git a/client/src/app/+admin/overview/videos/video-list.component.scss b/client/src/app/+admin/overview/videos/video-list.component.scss
index b80d3ddb9c..0d2b0fe209 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.scss
+++ b/client/src/app/+admin/overview/videos/video-list.component.scss
@@ -7,7 +7,8 @@ my-embed {
width: 50%;
}
-.pt-badge {
+.pt-badge,
+my-video-privacy-badge {
@include margin-right(5px);
}
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts
index 347015fec2..4060ea1b50 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.ts
+++ b/client/src/app/+admin/overview/videos/video-list.component.ts
@@ -13,7 +13,7 @@ import { VideoBlockComponent } from '@app/shared/shared-moderation/video-block.c
import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
import { getAllFiles } from '@peertube/peertube-core-utils'
-import { FileStorage, UserRight, VideoFile, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@peertube/peertube-models'
+import { FileStorage, UserRight, VideoFile, VideoState, VideoStreamingPlaylistType } from '@peertube/peertube-models'
import { videoRequiresFileToken } from '@root-helpers/video'
import { SharedModule, SortMeta } from 'primeng/api'
import { TableModule, TableRowExpandEvent } from 'primeng/table'
@@ -31,6 +31,7 @@ import {
VideoActionsDisplayType,
VideoActionsDropdownComponent
} from '../../../shared/shared-video-miniature/video-actions-dropdown.component'
+import { VideoPrivacyBadgeComponent } from '../../../shared/shared-video/video-privacy-badge.component'
import { VideoAdminService } from './video-admin.service'
@Component({
@@ -56,7 +57,8 @@ import { VideoAdminService } from './video-admin.service'
VideoBlockComponent,
PTDatePipe,
RouterLink,
- BytesPipe
+ BytesPipe,
+ VideoPrivacyBadgeComponent
]
})
export class VideoListComponent extends RestTable<Video> implements OnInit {
@@ -180,12 +182,6 @@ export class VideoListComponent extends RestTable<Video> implements OnInit {
return 'VideoListComponent'
}
- getPrivacyBadgeClass (video: Video) {
- if (video.privacy.id === VideoPrivacy.PUBLIC) return 'badge-green'
-
- return 'badge-yellow'
- }
-
isUnpublished (video: Video) {
return video.state.id !== VideoState.LIVE_ENDED && video.state.id !== VideoState.PUBLISHED
}
diff --git a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.html b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.html
index 709ba83aaf..f0b5090e39 100644
--- a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.html
+++ b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.html
@@ -6,7 +6,7 @@
</h2>
<form *ngIf="hasRegisteredSettings()" (ngSubmit)="formValidated()" [formGroup]="form">
- <div class="form-group" *ngFor="let setting of registeredSettings" [id]="getWrapperId(setting)">
+ <div *ngFor="let setting of registeredSettings" [id]="getWrapperId(setting)">
<my-dynamic-form-field [hidden]="isSettingHidden(setting)" [form]="form" [setting]="setting" [formErrors]="formErrors"></my-dynamic-form-field>
</div>
diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html
index 7a5e0a52d7..65792d2b69 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html
+++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.html
@@ -30,7 +30,7 @@
<my-help helpType="markdownText" supportRelMe="true"></my-help>
<my-markdown-textarea
- inputId="description" formControlName="description" class="form-control"
+ inputId="description" formControlName="description"
markdownType="enhanced" [formError]="formErrors['description']" withEmoji="true" withHtml="true"
></my-markdown-textarea>
diff --git a/client/src/app/+my-library/my-channel-space.component.html b/client/src/app/+my-library/my-channel-space.component.html
new file mode 100644
index 0000000000..e162c95802
--- /dev/null
+++ b/client/src/app/+my-library/my-channel-space.component.html
@@ -0,0 +1,12 @@
+<div class="root">
+
+ <div class="margin-content">
+ <a i18n class="visually-hidden-focusable skip-to-content-sub-menu" href="#my-channel-space-content" (click)="$event.preventDefault(); myChannelSpaceContent.focus()">Skip the sub menu</a>
+
+ <my-horizontal-menu h1Icon="channel" i18n-h1 h1="My channels" [menuEntries]="menuEntries"></my-horizontal-menu>
+ </div>
+
+ <div #myChannelSpaceContent tabindex="-1" id="my-channel-space-content" class="margin-content pb-5 outline-0">
+ <router-outlet></router-outlet>
+ </div>
+</div>
diff --git a/client/src/app/+my-library/my-channel-space.component.ts b/client/src/app/+my-library/my-channel-space.component.ts
new file mode 100644
index 0000000000..697f10e082
--- /dev/null
+++ b/client/src/app/+my-library/my-channel-space.component.ts
@@ -0,0 +1,48 @@
+import { Component, OnInit, inject } from '@angular/core'
+import { RouterOutlet } from '@angular/router'
+import { ServerService } from '@app/core'
+import { HorizontalMenuComponent, HorizontalMenuEntry } from '@app/shared/shared-main/menu/horizontal-menu.component'
+import { HTMLServerConfig } from '@peertube/peertube-models'
+
+@Component({
+ templateUrl: './my-channel-space.component.html',
+ imports: [ RouterOutlet, HorizontalMenuComponent ]
+})
+export class MyChannelSpaceComponent implements OnInit {
+ private serverService = inject(ServerService)
+
+ menuEntries: HorizontalMenuEntry[] = []
+
+ private serverConfig: HTMLServerConfig
+
+ ngOnInit (): void {
+ this.serverConfig = this.serverService.getHTMLConfig()
+
+ this.buildMenu()
+ }
+
+ private buildMenu () {
+ this.menuEntries = [
+ {
+ label: $localize`Manage my channels`,
+ routerLink: '/my-library/video-channels'
+ },
+ {
+ label: $localize`Followers`,
+ routerLink: '/my-library/followers'
+ },
+ {
+ label: $localize`Synchronizations`,
+ routerLink: '/my-library/video-channel-syncs',
+ isDisplayed: () => this.isChannelSyncEnabled()
+ }
+ ]
+ }
+
+ private isChannelSyncEnabled () {
+ const config = this.serverConfig.import
+
+ return this.serverConfig.import.videoChannelSynchronization.enabled &&
+ (config.videos.http.enabled || config.videos.torrent.enabled)
+ }
+}
diff --git a/client/src/app/+my-library/my-ownership/my-ownership.component.html b/client/src/app/+my-library/my-ownership/my-ownership.component.html
index 6969ca99fd..26c335752d 100644
--- a/client/src/app/+my-library/my-ownership/my-ownership.component.html
+++ b/client/src/app/+my-library/my-ownership/my-ownership.component.html
@@ -36,7 +36,7 @@
</td>
<td>
- <my-video-cell [video]="videoChangeOwnership.video"></my-video-cell>
+ <my-video-cell [video]="videoChangeOwnership.video" size="small"></my-video-cell>
</td>
<td>{{ videoChangeOwnership.createdAt | ptDate: 'short' }}</td>
diff --git a/client/src/app/+my-library/my-video-space.component.html b/client/src/app/+my-library/my-video-space.component.html
index edd7a6cc0d..c6674ae111 100644
--- a/client/src/app/+my-library/my-video-space.component.html
+++ b/client/src/app/+my-library/my-video-space.component.html
@@ -3,7 +3,7 @@
<div class="margin-content">
<a i18n class="visually-hidden-focusable skip-to-content-sub-menu" href="#my-video-space-content" (click)="$event.preventDefault(); myVideoSpaceContent.focus()">Skip the sub menu</a>
- <my-horizontal-menu i18n-h1 h1="My video space" [menuEntries]="menuEntries"></my-horizontal-menu>
+ <my-horizontal-menu h1Icon="videos" i18n-h1 h1="My videos" [menuEntries]="menuEntries"></my-horizontal-menu>
</div>
<div #myVideoSpaceContent tabindex="-1" id="my-video-space-content" class="margin-content pb-5 outline-0">
diff --git a/client/src/app/+my-library/my-video-space.component.ts b/client/src/app/+my-library/my-video-space.component.ts
index d88bd90a5a..bc824bbc66 100644
--- a/client/src/app/+my-library/my-video-space.component.ts
+++ b/client/src/app/+my-library/my-video-space.component.ts
@@ -21,67 +21,53 @@ export class MyVideoSpaceComponent implements OnInit {
this.buildMenu()
}
- isVideoImportEnabled () {
- const importConfig = this.serverConfig.import.videos
-
- return importConfig.http.enabled || importConfig.torrent.enabled
- }
-
private buildMenu () {
this.menuEntries = [
{
- label: $localize`Channels`,
- routerLink: '/my-library/video-channels',
+ label: $localize`Manage my videos`,
+ routerLink: '/my-library/videos'
+ },
+
+ {
+ label: $localize`Comments`,
+ routerLink: '/my-library/comments-on-my-videos',
children: [
{
- label: $localize`Manage`,
- routerLink: '/my-library/video-channels'
+ label: $localize`Comments on my videos`,
+ routerLink: '/my-library/comments-on-my-videos'
},
{
- label: $localize`Followers`,
- routerLink: '/my-library/followers'
+ label: $localize`Watched words`,
+ routerLink: '/my-library/watched-words/list'
},
{
- label: $localize`Synchronizations`,
- routerLink: '/my-library/video-channel-syncs'
+ label: $localize`Auto tag policies`,
+ routerLink: '/my-library/auto-tag-policies'
}
]
},
{
- label: $localize`Videos`,
- routerLink: '/my-library/videos',
+ label: $localize`Settings`,
+ routerLink: '/my-library/video-imports',
children: [
- {
- label: $localize`Manage`,
- routerLink: '/my-library/videos'
- },
-
{
label: $localize`Imports`,
routerLink: '/my-library/video-imports',
isDisplayed: () => this.isVideoImportEnabled()
},
-
{
label: $localize`Ownership changes`,
routerLink: '/my-library/ownership'
- },
-
- {
- label: $localize`Comments`,
- routerLink: '/my-library/comments-on-my-videos'
- },
- {
- label: $localize`Watched words`,
- routerLink: '/my-library/watched-words/list'
- },
- {
- label: $localize`Auto tag policies`,
- routerLink: '/my-library/auto-tag-policies'
}
]
}
]
}
+
+ private isVideoImportEnabled () {
+ const config = this.serverConfig.import.videos
+
+ return config.http.enabled || config.torrent.enabled
+ }
}
diff --git a/client/src/app/+my-library/my-videos/my-videos.component.html b/client/src/app/+my-library/my-videos/my-videos.component.html
index c944a61404..77906c008d 100644
--- a/client/src/app/+my-library/my-videos/my-videos.component.html
+++ b/client/src/app/+my-library/my-videos/my-videos.component.html
@@ -1,45 +1,199 @@
-<div class="videos-header d-flex justify-content-between align-items-end gap-2 flex-wrap">
- <my-advanced-input-filter [emitOnInit]="false" [filters]="inputFilters" (search)="onSearch($event)"></my-advanced-input-filter>
-
- <span class="total-items" *ngIf="pagination.totalItems"> {{ getTotalTitle() }}</span>
-
- <div class="peertube-select-container">
- <select [(ngModel)]="sort" (ngModelChange)="onChangeSortColumn()" class="form-control" i18n-ariaLabel aria-label="Sort by">
- <option value="-publishedAt" i18n>Last published first</option>
- <option value="-createdAt" i18n>Last created first</option>
- <option value="-views" i18n>Most viewed first</option>
- <option value="-likes" i18n>Most liked first</option>
- <option value="-duration" i18n>Longest first</option>
- </select>
- </div>
+<div class="channel-filters">
+ <div class="channels-label" i18n>Per channel:</div>
+
+ @for (channel of channels; track channel) {
+ <my-channel-toggle [channel]="channel" [(ngModel)]="channel.selected" (ngModelChange)="onFilter()"></my-channel-toggle>
+ }
</div>
-<my-videos-selection
- [videosContainedInPlaylists]="videosContainedInPlaylists"
- [pagination]="pagination"
- [(selection)]="selection"
- [(videos)]="videos"
- [miniatureDisplayOptions]="miniatureDisplayOptions"
- [titlePage]="titlePage"
- [getVideosObservableFunction]="getVideosObservableFunction"
- [user]="user"
- [disabled]="disabled"
- #videosSelection
+<p-table
+ [value]="videos" [paginator]="totalRecords > 0" [totalRecords]="totalRecords" [rows]="rowsPerPage" [first]="pagination.start"
+ [rowsPerPageOptions]="rowsPerPageOptions" [sortField]="sort.field" [sortOrder]="sort.order" dataKey="id" [resizableColumns]="true"
+ [(selection)]="selectedRows" [lazy]="true" (onLazyLoad)="loadLazy($event)" [lazyLoadOnInit]="false" [selectionPageOnly]="true"
+ [showCurrentPageReport]="true" [currentPageReportTemplate]="getPaginationTemplate()"
+ [expandedRowKeys]="expandedRows" [ngClass]="{ loading: loading }"
+ class="new-p-table sticky-p-table cell-wrap"
>
- <ng-template ptTemplate="globalButtons">
- <my-delete-button class="delete-selection" (click)="deleteSelectedVideos()"></my-delete-button>
- </ng-template>
+ <ng-template pTemplate="caption">
+ <div class="caption">
+ <div class="left-buttons">
+ @if (isInSelectionMode()) {
+ <my-action-dropdown
+ i18n-label label="Batch actions" theme="primary"
+ [actions]="bulkActions" [entry]="selectedRows"
+ >
+ </my-action-dropdown>
+ } @else {
+ <strong i18n [hidden]="loading">
+ { totalRecords, plural, =0 {No videos} =1 {1 video} other {{{ totalRecords | myNumberFormatter }} videos}}
+ </strong>
+ }
+ </div>
+
+ <div class="ms-auto right-form">
+ <div class="d-flex align-items-center">
+ <label class="label-inline d-none d-inline-block-mw" for="table-search" i18n>Search</label>
+
+ <my-advanced-input-filter inputId="table-search" icon="true" i18n-placeholder placeholder="Search your videos" (search)="onSearch($event)"></my-advanced-input-filter>
+ </div>
+
+ <div class="d-flex align-items-center">
+ <label class="label-inline" for="table-filter" i18n>Filter</label>
- <ng-template ptTemplate="rowButtons" let-video>
- <div class="action-button">
- <my-edit-button label [ptRouterLink]="[ '/videos', 'update', video.shortUUID ]"></my-edit-button>
+ <my-select-checkbox
+ inputId="table-filter"
+ showToggleAll="false"
+ showClear="true"
+
+ [availableItems]="filterItems"
+ [selectableGroup]="false"
+ [(ngModel)]="selectedFilterItems"
+ i18n-placeholder placeholder="All videos"
+ (ngModelChange)="onFilter()"
+ >
+ </my-select-checkbox>
+ </div>
+ </div>
- <my-video-actions-dropdown
- [video]="video" [displayOptions]="videoDropdownDisplayOptions" [moreActions]="moreVideoActions"
- buttonStyled="true" buttonDirection="horizontal" (videoRemoved)="onVideoRemoved(video)"
- ></my-video-actions-dropdown>
</div>
</ng-template>
-</my-videos-selection>
+
+ <ng-template pTemplate="sorticon" let-sortOrder>
+ @if (sortOrder === 1) {
+ <my-button class="ms-2" small="true" active="true" rounded="true" theme="tertiary" icon="chevron-up"></my-button>
+ } @else if (sortOrder === -1) {
+ <my-button class="ms-2" small="true" active="true" rounded="true" theme="tertiary" icon="chevron-down"></my-button>
+ } @else if (sortOrder === 0) {
+ <my-button class="ms-2" small="true" rounded="true" theme="tertiary" icon="chevron-down"></my-button>
+ }
+ </ng-template>
+
+ <ng-template pTemplate="paginatorright" let-item>
+ <ng-container i18n>videos per page</ng-container>
+ </ng-template>
+
+ <ng-template pTemplate="header">
+ <tr>
+ <th scope="col" width="25px" class="checkbox-cell">
+ <p-tableHeaderCheckbox ariaLabel="Select all rows" i18n-ariaLabel></p-tableHeaderCheckbox>
+ </th>
+
+ <th scope="col" *ngIf="isSelected('duration')" [ngbTooltip]="sortTooltip" container="body" pSortableColumn="duration" i18n>{{ getColumn('duration').label }} <p-sortIcon field="duration"></p-sortIcon></th>
+ <th scope="col" *ngIf="isSelected('name')" [ngbTooltip]="sortTooltip" container="body" pSortableColumn="name" i18n>{{ getColumn('name').label }} <p-sortIcon field="name"></p-sortIcon></th>
+ <th scope="col" *ngIf="isSelected('privacy')" i18n>{{ getColumn('privacy').label }}</th>
+ <th scope="col" *ngIf="isSelected('sensitive')" i18n>{{ getColumn('sensitive').label }}</th>
+ <th scope="col" *ngIf="isSelected('playlists')" i18n>{{ getColumn('playlists').label }}</th>
+ <th scope="col" *ngIf="isSelected('insights')" [ngbTooltip]="sortTooltip" container="body" pSortableColumn="views" i18n>{{ getColumn('insights').label }} <p-sortIcon field="views"></p-sortIcon></th>
+ <th scope="col" *ngIf="isSelected('published')" i18n [ngbTooltip]="sortTooltip" container="body" pSortableColumn="publishedAt">{{ getColumn('published').label }} <p-sortIcon field="publishedAt"></p-sortIcon></th>
+ <th scope="col" *ngIf="isSelected('state')" i18n>{{ getColumn('state').label }}</th>
+
+ <th scope="col" width="250px" class="action-head">
+ <div class="d-flex align-items-center justify-content-between">
+ <span i18>Actions</span>
+
+ <span class="c-hand column-toggle" >
+ <div ngbDropdown placement="bottom-left auto" container="body" autoClose="outside">
+ <my-button theme="tertiary" icon="columns" ngbDropdownToggle i18n-title title="Open table configuration"></my-button>
+
+ <div ngbDropdownMenu class="p-3">
+ <div class="form-group">
+ <div class="muted small mb-2" i18n>Column displayed:</div>
+
+ @for (column of columns; track column) {
+ <div class="ms-1 mb-1">
+ <my-peertube-checkbox
+ [inputName]="'column-' + column.id" [(ngModel)]="column.selected"
+ i18n-labelText [labelText]="column.label"
+ (ngModelChange)="saveSelectedColumns()"
+ ></my-peertube-checkbox>
+ </div>
+ }
+ </div>
+ </div>
+ </div>
+ </span>
+ </div>
+ </th>
+ </tr>
+ </ng-template>
+
+ <ng-template pTemplate="body" let-video>
+
+ <tr [pSelectableRow]="video">
+ <td class="checkbox-cell">
+ <p-tableCheckbox [value]="video" ariaLabel="Select this row" i18n-ariaLabel></p-tableCheckbox>
+ </td>
+
+ <td *ngIf="isSelected('duration')">
+ <my-video-cell [video]="video" thumbnail="true" title="false"></my-video-cell>
+ </td>
+
+ <td *ngIf="isSelected('name')">
+ <my-video-cell class="video-cell-name" [video]="video" thumbnail="false" title="true"></my-video-cell>
+ </td>
+
+ <td *ngIf="isSelected('privacy')">
+ <my-video-privacy-badge [video]="video"></my-video-privacy-badge>
+
+ <span *ngIf="video.blacklisted" class="pt-badge badge-red ms-1" i18n>Blocked</span>
+ </td>
+
+ <td *ngIf="isSelected('sensitive')">
+ <span *ngIf="video.nsfw" class="pt-badge badge-yellow" i18n>NSFW</span>
+ </td>
+
+ <td *ngIf="isSelected('playlists')">
+ <div class="badges">
+ <a *ngFor="let playlist of (videosContainedInPlaylists[video.id] || [])" class="pt-badge badge-secondary" [routerLink]="['/w/p/', playlist.playlistShortUUID]">
+ {{ playlist.playlistDisplayName }}
+ </a>
+ </div>
+ </td>
+
+ <td *ngIf="isSelected('insights')">
+ <a class="pt" [routerLink]="[ '/videos/manage', video.shortUUID, 'stats' ]" i18n-title title="Navigate to the video stats page">
+ <ng-container i18n>{video.views, plural, =0 {No views} =1 {1 view} other {{{ video.views | myNumberFormatter }} views}}</ng-container>
+
+ <br />
+
+ @if (video.isLive) {
+ <ng-container i18n>{video.viewers, plural, =0 {No viewers} =1 {1 viewer} other {{{ video.views | myNumberFormatter }} viewers}}</ng-container>
+ }
+ </a>
+ </td>
+
+ <td *ngIf="isSelected('published')">
+ {{ video.publishedAt | ptDate: 'short' }}
+ </td>
+
+ <td *ngIf="isSelected('state')">
+ <my-video-state-badge [video]="video"></my-video-state-badge>
+ </td>
+
+ <td class="action-cell">
+ <div class="d-flex justify-content-end">
+ <my-button class="me-3" i18n-label label="Manage" [ptRouterLink]="[ '/videos', 'manage', video.shortUUID ]" theme="secondary" icon="film" responsiveLabel="true"></my-button>
+
+ <my-video-actions-dropdown
+ placement="bottom auto" buttonDirection="horizontal" buttonStyled="true" [video]="video" [displayOptions]="videoActionsOptions"
+ (videoRemoved)="reloadData()" (videoFilesRemoved)="reloadData()" (transcodingCreated)="reloadData()"
+ ></my-video-actions-dropdown>
+ </div>
+ </td>
+
+ </tr>
+ </ng-template>
+
+ <ng-template pTemplate="emptymessage">
+ <tr>
+ <td myAutoColspan>
+ <div class="no-results">
+ <ng-container *ngIf="search" i18n>No video found matching current filters.</ng-container>
+ <ng-container *ngIf="!search" i18n>You don't have any videos published yet.</ng-container>
+ </div>
+ </td>
+ </tr>
+ </ng-template>
+</p-table>
<my-video-change-ownership #videoChangeOwnershipModal></my-video-change-ownership>
diff --git a/client/src/app/+my-library/my-videos/my-videos.component.scss b/client/src/app/+my-library/my-videos/my-videos.component.scss
index 7093348869..c60eddc2c5 100644
--- a/client/src/app/+my-library/my-videos/my-videos.component.scss
+++ b/client/src/app/+my-library/my-videos/my-videos.component.scss
@@ -1,30 +1,71 @@
@use '_variables' as *;
@use '_mixins' as *;
-@use '_form-mixins' as *;
-input[type=text] {
- @include peertube-input-text(300px);
+my-select-checkbox {
+ min-width: 250px;
}
-.peertube-select-container {
- @include peertube-select-container(auto);
+.pt-badge {
+ @include margin-right(5px);
}
-.action-button {
+.video-info > div {
display: flex;
- align-self: flex-end;
- min-width: 200px;
- justify-content: flex-end;
- @include margin-left(10px);
+ my-global-icon {
+ position: relative;
+ top: -2px;
+
+ @include global-icon-size(16px);
+ @include margin-left(3px);
+ }
+}
+
+.right-form {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 1.5rem;
}
-my-edit-button {
- @include margin-right(10px);
+td {
+ padding-top: 0.75rem;
+ padding-bottom: 0.75rem;
+}
+
+.channel-filters {
+ display: flex;
+ align-items: center;
+ padding-bottom: 1rem;
+ border-bottom: 1px solid $separator-border-color;
+ margin-bottom: 1rem;
+ gap: 1rem;
+ overflow: hidden;
+
+ &:hover {
+ overflow: auto;
+ }
+
+ .channels-label {
+ color: pvar(--fg-200);
+ font-weight: $font-bold;
+ white-space: nowrap;
+ }
+}
+
+p-table {
+ max-height: calc(100vh - #{pvar(--header-height)} - 300px);
+}
+
+@media screen and (min-width: $small-view) {
+ .video-cell-name {
+ width: 300px;
+ display: block;
+ }
}
-@include on-small-main-col {
- .action-button {
- margin: 1rem auto 0;
+@media screen and (max-width: $small-view) {
+ my-video-cell {
+ max-width: 120px;
+ display: block;
}
}
diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.ts
index 835a9d433f..c680e249ae 100644
--- a/client/src/app/+my-library/my-videos/my-videos.component.ts
+++ b/client/src/app/+my-library/my-videos/my-videos.component.ts
@@ -1,91 +1,118 @@
-import { NgIf } from '@angular/common'
-import { Component, OnInit, inject, viewChild } from '@angular/core'
+import { CommonModule, NgClass, NgIf } from '@angular/common'
+import { Component, inject, OnDestroy, OnInit, viewChild } from '@angular/core'
import { FormsModule } from '@angular/forms'
-import { ActivatedRoute, Router } from '@angular/router'
+import { ActivatedRoute, Router, RouterLink } from '@angular/router'
import {
AuthService,
- ComponentPagination,
+ AuthUser,
ConfirmService,
+ LocalStorageService,
Notifier,
- ScreenService,
- ServerService,
- updatePaginationOnDelete,
- User
+ PeerTubeRouterService,
+ RestPagination,
+ RestTable,
+ ServerService
} from '@app/core'
-import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook'
-import { formatICU, immutableAssign } from '@app/helpers'
-import { DropdownAction } from '@app/shared/shared-main/buttons/action-dropdown.component'
-import { DeleteButtonComponent } from '@app/shared/shared-main/buttons/delete-button.component'
+import { HeaderService } from '@app/header/header.service'
+import { formatICU } from '@app/helpers'
+import { AutoColspanDirective } from '@app/shared/shared-main/common/auto-colspan.directive'
import { Video } from '@app/shared/shared-main/video/video.model'
import { VideoService } from '@app/shared/shared-main/video/video.service'
-import { LiveStreamInformationComponent } from '@app/shared/shared-video-live/live-stream-information.component'
-import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature/video-miniature.component'
-import { SelectionType, VideosSelectionComponent } from '@app/shared/shared-video-miniature/videos-selection.component'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'
-import { VideoChannel, VideoExistInPlaylist, VideosExistInPlaylists, VideoSortField } from '@peertube/peertube-models'
-import { uniqBy } from 'lodash-es'
-import { concat, Observable } from 'rxjs'
-import { tap, toArray } from 'rxjs/operators'
-import { AdvancedInputFilter, AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'
-
-import { EditButtonComponent } from '../../shared/shared-main/buttons/edit-button.component'
-import { PeerTubeTemplateDirective } from '../../shared/shared-main/common/peertube-template.directive'
+import { ChannelToggleComponent } from '@app/shared/standalone-channels/channel-toggle.component'
+import { NgbDropdownModule, NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
+import { arrayify } from '@peertube/peertube-core-utils'
+import {
+ UserRight,
+ VideoChannel,
+ VideoExistInPlaylist,
+ VideoPrivacy,
+ VideoPrivacyType,
+ VideosExistInPlaylists
+} from '@peertube/peertube-models'
+import { logger } from '@root-helpers/logger'
+import uniqBy from 'lodash-es/uniqBy'
+import { SharedModule, SortMeta } from 'primeng/api'
+import { TableModule } from 'primeng/table'
+import { finalize } from 'rxjs/operators'
+import { SelectOptionsItem } from 'src/types'
+import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'
+import { PeertubeCheckboxComponent } from '../../shared/shared-forms/peertube-checkbox.component'
+import { SelectCheckboxComponent } from '../../shared/shared-forms/select/select-checkbox.component'
+import { ActionDropdownComponent, DropdownAction } from '../../shared/shared-main/buttons/action-dropdown.component'
+import { ButtonComponent } from '../../shared/shared-main/buttons/button.component'
+import { PTDatePipe } from '../../shared/shared-main/common/date.pipe'
+import { NumberFormatterPipe } from '../../shared/shared-main/common/number-formatter.pipe'
+import { VideoCellComponent } from '../../shared/shared-tables/video-cell.component'
import {
VideoActionsDisplayType,
VideoActionsDropdownComponent
} from '../../shared/shared-video-miniature/video-actions-dropdown.component'
+import { VideoPrivacyBadgeComponent } from '../../shared/shared-video/video-privacy-badge.component'
+import { VideoStateBadgeComponent } from '../../shared/shared-video/video-state-badge.component'
import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component'
+type Column = 'duration' | 'name' | 'privacy' | 'sensitive' | 'playlists' | 'insights' | 'published' | 'state'
+type CommonFilter = 'live' | 'vod' | 'private' | 'internal' | 'unlisted' | 'password-protected' | 'public'
+
@Component({
+ selector: 'my-videos',
templateUrl: './my-videos.component.html',
styleUrls: [ './my-videos.component.scss' ],
imports: [
- DeleteButtonComponent,
+ CommonModule,
+ FormsModule,
+ TableModule,
+ NgClass,
+ SharedModule,
NgIf,
+ ActionDropdownComponent,
AdvancedInputFilterComponent,
- FormsModule,
- VideosSelectionComponent,
- PeerTubeTemplateDirective,
- EditButtonComponent,
+ ButtonComponent,
+ NgbTooltip,
VideoActionsDropdownComponent,
- VideoChangeOwnershipComponent
+ VideoCellComponent,
+ RouterLink,
+ NumberFormatterPipe,
+ VideoChangeOwnershipComponent,
+ VideoPrivacyBadgeComponent,
+ VideoStateBadgeComponent,
+ NgbDropdownModule,
+ PeertubeCheckboxComponent,
+ ChannelToggleComponent,
+ AutoColspanDirective,
+ SelectCheckboxComponent,
+ PTDatePipe
]
})
-export class MyVideosComponent implements OnInit, DisableForReuseHook {
- protected router = inject(Router)
- protected serverService = inject(ServerService)
+export class MyVideosComponent extends RestTable<Video> implements OnInit, OnDestroy {
protected route = inject(ActivatedRoute)
- protected authService = inject(AuthService)
- protected notifier = inject(Notifier)
- protected screenService = inject(ScreenService)
+ protected router = inject(Router)
private confirmService = inject(ConfirmService)
+ private auth = inject(AuthService)
+ private notifier = inject(Notifier)
private videoService = inject(VideoService)
private playlistService = inject(VideoPlaylistService)
+ private server = inject(ServerService)
+ private peertubeLocalStorage = inject(LocalStorageService)
+ private peertubeRouter = inject(PeerTubeRouterService)
+ private headerService = inject(HeaderService)
+
+ private static readonly LS_SELECTED_COLUMNS_KEY = 'user-my-videos-selected-columns'
- readonly videosSelection = viewChild<VideosSelectionComponent>('videosSelection')
readonly videoChangeOwnershipModal = viewChild<VideoChangeOwnershipComponent>('videoChangeOwnershipModal')
- readonly liveStreamInformationModal = viewChild<LiveStreamInformationComponent>('liveStreamInformationModal')
+
+ videos: Video[] = []
+
+ totalRecords = 0
+ sort: SortMeta = { field: 'publishedAt', order: -1 }
+ pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
videosContainedInPlaylists: VideosExistInPlaylists = {}
- titlePage: string
- selection: SelectionType = {}
- pagination: ComponentPagination = {
- currentPage: 1,
- itemsPerPage: 10,
- totalItems: null
- }
- miniatureDisplayOptions: MiniatureDisplayOptions = {
- date: true,
- views: true,
- by: true,
- privacyLabel: false,
- privacyText: true,
- state: true,
- blacklistInfo: true,
- forceChannelInBy: true,
- nsfw: true
- }
- videoDropdownDisplayOptions: VideoActionsDisplayType = {
+
+ bulkActions: DropdownAction<Video[]>[][] = []
+
+ videoActionsOptions: VideoActionsDisplayType = {
playlist: true,
download: true,
update: false,
@@ -102,97 +129,214 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook {
}
moreVideoActions: DropdownAction<{ video: Video }>[][] = []
+ loading = true
- videos: Video[] = []
- getVideosObservableFunction = this.getVideosObservable.bind(this)
-
- sort: VideoSortField = '-publishedAt'
+ user: AuthUser
+ channels: (VideoChannel & { selected: boolean })[] = []
- user: User
+ filterItems: SelectOptionsItem<CommonFilter>[] = []
+ selectedFilterItems: CommonFilter[] = []
- inputFilters: AdvancedInputFilter[] = []
+ columns: { id: Column, label: string, selected: boolean }[] = []
- disabled = false
-
- private search: string
- private userChannels: VideoChannel[] = []
-
- constructor () {
- this.titlePage = $localize`My videos`
+ get serverConfig () {
+ return this.server.getHTMLConfig()
}
ngOnInit () {
- this.buildActions()
+ this.initialize()
- this.user = this.authService.getUser()
+ this.headerService.setSearchHidden(true)
- if (this.route.snapshot.queryParams['search']) {
- this.search = this.route.snapshot.queryParams['search']
- }
-
- this.user = this.authService.getUser()
- this.userChannels = this.user.videoChannels
+ this.user = this.auth.getUser()
- const channelFilters = [ ...this.userChannels ]
- .sort((a, b) => a.displayName.localeCompare(b.displayName))
- .map(c => {
- return {
- value: 'channel:' + c.name,
- label: c.displayName
- }
- })
+ this.columns = [
+ { id: 'duration', label: $localize`Duration`, selected: true },
+ { id: 'name', label: $localize`Name`, selected: true },
+ { id: 'privacy', label: $localize`Privacy`, selected: true },
+ { id: 'sensitive', label: $localize`Sensitive`, selected: true },
+ { id: 'playlists', label: $localize`Playlists`, selected: true },
+ { id: 'insights', label: $localize`Insights`, selected: true },
+ { id: 'published', label: $localize`Published`, selected: true },
+ { id: 'state', label: $localize`State`, selected: true }
+ ]
- this.inputFilters = [
+ this.filterItems = [
{
- title: $localize`Advanced filters`,
- children: [
- {
- value: 'isLive:true',
- label: $localize`Only live videos`
- }
- ]
+ id: 'live',
+ label: $localize`Lives`
},
-
{
- title: $localize`Channel filters`,
- children: channelFilters
+ id: 'vod',
+ label: $localize`VOD`
+ },
+ {
+ id: 'public',
+ label: $localize`Public videos`
+ },
+ {
+ id: 'internal',
+ label: $localize`Internal videos`
+ },
+ {
+ id: 'unlisted',
+ label: $localize`Unlisted videos`
+ },
+ {
+ id: 'password-protected',
+ label: $localize`Password protected videos`
+ },
+ {
+ id: 'private',
+ label: $localize`Private videos`
}
]
+
+ this.parseQueryParams()
+ this.buildActions()
+ this.loadSelectedColumns()
+ }
+
+ ngOnDestroy () {
+ this.headerService.setSearchHidden(false)
+ }
+
+ private parseQueryParams () {
+ const queryParams = this.route.snapshot.queryParams as {
+ channelNameOneOf?: string[]
+ privacyOneOf?: string[]
+ isLive: string
+ }
+
+ {
+ const enabledChannels = queryParams.channelNameOneOf
+ ? new Set(arrayify(queryParams.channelNameOneOf))
+ : new Set<string>()
+
+ this.user = this.auth.getUser()
+ this.channels = this.user.videoChannels.map(c => ({
+ ...c,
+
+ selected: enabledChannels.has(c.name)
+ }))
+ }
+
+ {
+ if (queryParams.isLive === 'true') this.selectedFilterItems.push('live')
+ if (queryParams.isLive === 'false') this.selectedFilterItems.push('vod')
+
+ const enabledPrivacies = queryParams.privacyOneOf
+ ? new Set(arrayify(queryParams.privacyOneOf).map(t => parseInt(t) as VideoPrivacyType))
+ : new Set<VideoPrivacyType>()
+
+ if (enabledPrivacies.has(VideoPrivacy.PUBLIC)) this.selectedFilterItems.push('public')
+ if (enabledPrivacies.has(VideoPrivacy.INTERNAL)) this.selectedFilterItems.push('internal')
+ if (enabledPrivacies.has(VideoPrivacy.UNLISTED)) this.selectedFilterItems.push('unlisted')
+ if (enabledPrivacies.has(VideoPrivacy.PASSWORD_PROTECTED)) this.selectedFilterItems.push('password-protected')
+ if (enabledPrivacies.has(VideoPrivacy.PRIVATE)) this.selectedFilterItems.push('private')
+ }
}
- onSearch (search: string) {
- this.search = search
- this.reloadData()
+ getIdentifier () {
+ return 'MyVideosComponent'
}
- reloadData () {
- this.videosSelection().reloadVideos()
+ // ---------------------------------------------------------------------------
+
+ isSelected (id: Column) {
+ return this.columns.some(c => c.id === id && c.selected)
}
- onChangeSortColumn () {
- this.videosSelection().reloadVideos()
+ getColumn (id: Column) {
+ return this.columns.find(c => c.id === id)
}
- disableForReuse () {
- this.disabled = true
+ private loadSelectedColumns () {
+ const enabledString = this.peertubeLocalStorage.getItem(MyVideosComponent.LS_SELECTED_COLUMNS_KEY)
+
+ if (!enabledString) return
+ try {
+ const enabled = JSON.parse(enabledString)
+
+ for (const column of this.columns) {
+ column.selected = enabled.includes(column.id)
+ }
+ } catch (err) {
+ logger.error('Cannot load selected columns.', err)
+ }
}
- enabledForReuse () {
- this.disabled = false
+ saveSelectedColumns () {
+ const enabled = this.columns.filter(c => c.selected).map(c => c.id)
+
+ this.peertubeLocalStorage.setItem(MyVideosComponent.LS_SELECTED_COLUMNS_KEY, JSON.stringify(enabled))
+ }
+
+ onFilter () {
+ const channelNameOneOf = this.channels.filter(c => c.selected).map(c => c.name)
+
+ const newParams = {
+ ...this.route.snapshot.queryParams,
+ ...this.buildCommonVideoFilters(),
+
+ channelNameOneOf
+ }
+
+ this.peertubeRouter.silentNavigate([ '.' ], newParams, this.route)
+ this.resetAndReload()
}
- getVideosObservable (page: number) {
- const newPagination = immutableAssign(this.pagination, { currentPage: page })
+ private buildCommonVideoFilters () {
+ const selectedFilterSet = new Set(this.selectedFilterItems)
- return this.videoService.getMyVideos({
- videoPagination: newPagination,
+ let isLive: boolean
+ if (selectedFilterSet.has('live') && !selectedFilterSet.has('vod')) {
+ isLive = true
+ } else if (!selectedFilterSet.has('live') && selectedFilterSet.has('vod')) {
+ isLive = false
+ }
+
+ const privacyOneOf: VideoPrivacyType[] = []
+ if (selectedFilterSet.has('public')) privacyOneOf.push(VideoPrivacy.PUBLIC)
+ if (selectedFilterSet.has('internal')) privacyOneOf.push(VideoPrivacy.INTERNAL)
+ if (selectedFilterSet.has('unlisted')) privacyOneOf.push(VideoPrivacy.UNLISTED)
+ if (selectedFilterSet.has('password-protected')) privacyOneOf.push(VideoPrivacy.PASSWORD_PROTECTED)
+ if (selectedFilterSet.has('private')) privacyOneOf.push(VideoPrivacy.PRIVATE)
+
+ return {
+ isLive,
+ privacyOneOf
+ }
+ }
+
+ // ---------------------------------------------------------------------------
+
+ protected reloadDataInternal () {
+ this.loading = true
+
+ const channelNameOneOf = this.channels.filter(c => c.selected).map(c => c.name)
+
+ return this.videoService.listMyVideos({
+ restPagination: this.pagination,
sort: this.sort,
- userChannels: this.userChannels,
- search: this.search
- }).pipe(
- tap(res => this.pagination.totalItems = res.total),
- tap(({ data }) => this.fetchVideosContainedInPlaylists(data))
- )
+ search: this.search,
+
+ channelNameOneOf: channelNameOneOf.length !== 0
+ ? channelNameOneOf
+ : undefined,
+
+ ...this.buildCommonVideoFilters()
+ }).pipe(finalize(() => this.loading = false))
+ .subscribe({
+ next: resultList => {
+ this.videos = resultList.data
+ this.totalRecords = resultList.total
+
+ this.fetchVideosContainedInPlaylists(resultList.data)
+ },
+
+ error: err => this.notifier.error(err.message)
+ })
}
private fetchVideosContainedInPlaylists (videos: Video[]) {
@@ -205,67 +349,36 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook {
})
}
- async deleteSelectedVideos () {
- const toDeleteVideosIds = Object.entries(this.selection)
- .filter(([ _k, v ]) => v === true)
- .map(([ k, _v ]) => parseInt(k, 10))
-
- const res = await this.confirmService.confirm(
- formatICU(
- $localize`Do you really want to delete {length, plural, =1 {this video} other {{length} videos}}?`,
- { length: toDeleteVideosIds.length }
- ),
- $localize`Delete`
+ async removeVideos (videos: Video[]) {
+ const message = formatICU(
+ $localize`Are you sure you want to delete {count, plural, =1 {this video} other {these {count} videos}}?`,
+ { count: videos.length }
)
- if (res === false) return
-
- const observables: Observable<any>[] = []
- for (const videoId of toDeleteVideosIds) {
- const o = this.videoService.removeVideo(videoId)
- .pipe(tap(() => this.removeVideoFromArray(videoId)))
- observables.push(o)
- }
+ const res = await this.confirmService.confirm(message, $localize`Delete`)
+ if (res === false) return
- concat(...observables)
- .pipe(toArray())
+ this.videoService.removeVideo(videos.map(v => v.id))
.subscribe({
next: () => {
this.notifier.success(
formatICU(
- $localize`{length, plural, =1 {Video has been deleted} other {{length} videos have been deleted}}`,
- { length: toDeleteVideosIds.length }
+ $localize`Deleted {count, plural, =1 {1 video} other {{count} videos}}.`,
+ { count: videos.length }
)
)
- this.selection = {}
+ this.reloadData()
},
error: err => this.notifier.error(err.message)
})
}
- onVideoRemoved (video: Video) {
- this.removeVideoFromArray(video.id)
- }
-
changeOwnership (video: Video) {
this.videoChangeOwnershipModal().show(video)
}
- getTotalTitle () {
- return formatICU(
- $localize`${this.pagination.totalItems} {total, plural, =1 {video} other {videos}}`,
- { total: this.pagination.totalItems }
- )
- }
-
- private removeVideoFromArray (id: number) {
- this.videos = this.videos.filter(v => v.id !== id)
-
- updatePaginationOnDelete(this.pagination)
- }
-
private buildActions () {
this.moreVideoActions = [
[
@@ -276,5 +389,16 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook {
}
]
]
+
+ this.bulkActions = [
+ [
+ {
+ label: $localize`Delete`,
+ handler: videos => this.removeVideos(videos),
+ isDisplayed: () => this.user.hasRight(UserRight.REMOVE_ANY_VIDEO),
+ iconName: 'delete'
+ }
+ ]
+ ]
}
}
diff --git a/client/src/app/+my-library/routes.ts b/client/src/app/+my-library/routes.ts
index 5c8d3781a7..eec6c0a1b3 100644
--- a/client/src/app/+my-library/routes.ts
+++ b/client/src/app/+my-library/routes.ts
@@ -2,6 +2,7 @@ import { Route, Routes, UrlSegment } from '@angular/router'
import { userResolver } from '@app/core/routing/user.resolver'
import { AbuseService } from '@app/shared/shared-moderation/abuse.service'
import { BlocklistService } from '@app/shared/shared-moderation/blocklist.service'
+import { BulkService } from '@app/shared/shared-moderation/bulk.service'
import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'
import { UserSubscriptionService } from '@app/shared/shared-user-subscription/user-subscription.service'
import { VideoCommentService } from '@app/shared/shared-video-comment/video-comment.service'
@@ -27,7 +28,7 @@ import { MyVideoPlaylistsComponent } from './my-video-playlists/my-video-playlis
import { MyVideoSpaceComponent } from './my-video-space.component'
import { MyVideosComponent } from './my-videos/my-videos.component'
import { MyWatchedWordsListComponent } from './my-watched-words-list/my-watched-words-list.component'
-import { BulkService } from '@app/shared/shared-moderation/bulk.service'
+import { MyChannelSpaceComponent } from './my-channel-space.component'
const commonConfig = {
path: '',
@@ -50,55 +51,6 @@ const commonConfig = {
}
const videoSpaceRoutes = [
- // ---------------------------------------------------------------------------
- // Channels
- // ---------------------------------------------------------------------------
-
- {
- path: '',
- redirectTo: 'video-channels',
- pathMatch: 'full'
- },
-
- {
- path: 'video-channels',
- loadChildren: () => import('./+my-video-channels/routes')
- },
-
- {
- path: 'followers',
- component: MyFollowersComponent,
- data: {
- meta: {
- title: $localize`My followers`
- }
- }
- },
-
- {
- path: 'video-channel-syncs',
- component: MyVideoChannelSyncsComponent,
- data: {
- meta: {
- title: $localize`My synchronizations`
- }
- }
- },
-
- {
- path: 'video-channel-syncs/create',
- component: VideoChannelSyncEditComponent,
- data: {
- meta: {
- title: $localize`Create new synchronization`
- }
- }
- },
-
- // ---------------------------------------------------------------------------
- // Videos
- // ---------------------------------------------------------------------------
-
{
path: 'videos/comments',
redirectTo: 'comments-on-my-videos',
@@ -168,8 +120,50 @@ const videoSpaceRoutes = [
}
] satisfies Routes
-const libraryRoutes = [
+const channelSpaceRoutes = [
+ {
+ path: '',
+ redirectTo: 'video-channels',
+ pathMatch: 'full'
+ },
+ {
+ path: 'video-channels',
+ loadChildren: () => import('./+my-video-channels/routes')
+ },
+
+ {
+ path: 'followers',
+ component: MyFollowersComponent,
+ data: {
+ meta: {
+ title: $localize`My followers`
+ }
+ }
+ },
+
+ {
+ path: 'video-channel-syncs',
+ component: MyVideoChannelSyncsComponent,
+ data: {
+ meta: {
+ title: $localize`My synchronizations`
+ }
+ }
+ },
+
+ {
+ path: 'video-channel-syncs/create',
+ component: VideoChannelSyncEditComponent,
+ data: {
+ meta: {
+ title: $localize`Create new synchronization`
+ }
+ }
+ }
+] satisfies Routes
+
+const libraryRoutes = [
// ---------------------------------------------------------------------------
// Playlists
// ---------------------------------------------------------------------------
@@ -248,6 +242,14 @@ function isVideoSpaceRoute (segments: UrlSegment[]) {
return videoSpaceRoutes.some(r => r.path === rootPath || r.path.startsWith(`${rootPath}/`))
}
+function isChannelSpaceRoute (segments: UrlSegment[]) {
+ if (segments.length === 0) return false
+
+ const rootPath = segments[0].path
+
+ return channelSpaceRoutes.some(r => r.path === rootPath || r.path.startsWith(`${rootPath}/`))
+}
+
export default [
{
...commonConfig,
@@ -264,10 +266,22 @@ export default [
{
...commonConfig,
+ component: MyChannelSpaceComponent,
+ canMatch: [
+ (_route: Route, segments: UrlSegment[]) => {
+ return isChannelSpaceRoute(segments)
+ }
+ ],
+
+ children: channelSpaceRoutes
+ },
+ {
+ ...commonConfig,
+
component: MyLibraryComponent,
canMatch: [
(_route: Route, segments: UrlSegment[]) => {
- return !isVideoSpaceRoute(segments)
+ return !isVideoSpaceRoute(segments) && !isChannelSpaceRoute(segments)
}
],
children: libraryRoutes
diff --git a/client/src/app/+stats/routes.ts b/client/src/app/+stats/routes.ts
deleted file mode 100644
index 316e9f2d7a..0000000000
--- a/client/src/app/+stats/routes.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { Routes } from '@angular/router'
-import { LoginGuard } from '@app/core'
-import { VideoStatsComponent, VideoStatsService } from './video'
-import { VideoResolver } from '@app/shared/shared-main/video/video.resolver'
-import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
-
-export default [
- {
- path: 'videos/:videoId',
- canActivate: [ LoginGuard ],
- component: VideoStatsComponent,
- data: {
- meta: {
- title: $localize`Video stats`
- }
- },
- providers: [
- LiveVideoService,
- VideoStatsService,
- VideoResolver
- ],
- resolve: {
- video: VideoResolver
- }
- }
-] satisfies Routes
diff --git a/client/src/app/+stats/video/index.ts b/client/src/app/+stats/video/index.ts
deleted file mode 100644
index e948d4f4ee..0000000000
--- a/client/src/app/+stats/video/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './video-stats.component'
-export * from './video-stats.service'
diff --git a/client/src/app/+stats/video/video-stats.component.html b/client/src/app/+stats/video/video-stats.component.html
deleted file mode 100644
index 9fcfb7ef93..0000000000
--- a/client/src/app/+stats/video/video-stats.component.html
+++ /dev/null
@@ -1,75 +0,0 @@
-<div class="margin-content">
- <h1 class="title-page">
- <my-global-icon iconName="stats"></my-global-icon>
-
- <ng-container i18n>{{ video.name }} statistics</ng-container>
- </h1>
-
- <div class="stats-embed">
- <div class="global-stats">
- <div *ngFor="let card of globalStatsCards" class="card stats-card">
- <div class="label">
- {{ card.label }}
-
- <my-help *ngIf="card.help">
- <ng-template ptTemplate="customHtml">{{ card.help }}</ng-template>
- </my-help>
- </div>
- <div class="value">{{ card.value }}</div>
- <div *ngIf="card.moreInfo" class="more-info">{{ card.moreInfo }}</div>
- </div>
- </div>
-
- <my-embed [video]="video"></my-embed>
- </div>
-
- <div class="stats-with-date">
-
- <div class="overall-stats">
- <h2>{{ getViewersStatsTitle() }}</h2>
-
- <div class="date-filter-wrapper">
- <label class="visually-hidden" for="date-filter">Filter viewers stats by date</label>
- <my-select-options inputId="date-filter" [(ngModel)]="currentDateFilter" (ngModelChange)="onDateFilterChange()" [items]="dateFilters"></my-select-options>
- </div>
-
- <div class="cards">
- <div *ngFor="let card of overallStatCards" class="card stats-card">
- <div class="label">{{ card.label }}</div>
- <div class="value">{{ card.value }}</div>
- <div *ngIf="card.moreInfo" class="more-info">{{ card.moreInfo }}</div>
- </div>
- </div>
- </div>
-
- <div class="timeserie">
- <div ngbNav #nav="ngbNav" [activeId]="activeGraphId" (activeIdChange)="onChartChange($event)" class="nav-tabs">
-
- <ng-container *ngFor="let availableChart of availableCharts" [ngbNavItem]="availableChart.id">
- <a ngbNavLink>
- <span>{{ availableChart.label }}</span>
- </a>
-
- <ng-template ngbNavContent>
- <div class="chart-container">
- <p-chart
- *ngIf="chartOptions[availableChart.id]"
- [height]="chartHeight" [width]="chartWidth"
- [type]="chartOptions[availableChart.id].type" [options]="chartOptions[availableChart.id].options" [data]="chartOptions[availableChart.id].data"
- [plugins]="chartPlugins"
- ></p-chart>
- </div>
-
- <div class="zoom-container">
- <span *ngIf="!hasZoom() && availableChart.zoomEnabled" i18n class="description">You can select a part of the graph to zoom in</span>
-
- <my-button i18n *ngIf="hasZoom()" (click)="resetZoom()">Reset zoom</my-button>
- </div>
- </ng-template>
- </ng-container>
- </div>
-
- <div [ngbNavOutlet]="nav"></div>
- </div>
- </div>
-</div>
diff --git a/client/src/app/+videos/video-list/index.ts b/client/src/app/+video-list/index.ts
similarity index 100%
rename from client/src/app/+videos/video-list/index.ts
rename to client/src/app/+video-list/index.ts
diff --git a/client/src/app/+videos/video-list/overview/index.ts b/client/src/app/+video-list/overview/index.ts
similarity index 100%
rename from client/src/app/+videos/video-list/overview/index.ts
rename to client/src/app/+video-list/overview/index.ts
diff --git a/client/src/app/+videos/video-list/overview/overview.service.ts b/client/src/app/+video-list/overview/overview.service.ts
similarity index 95%
rename from client/src/app/+videos/video-list/overview/overview.service.ts
rename to client/src/app/+video-list/overview/overview.service.ts
index bec0554ed8..3fee793b62 100644
--- a/client/src/app/+videos/video-list/overview/overview.service.ts
+++ b/client/src/app/+video-list/overview/overview.service.ts
@@ -1,14 +1,14 @@
-import { forkJoin, Observable, of } from 'rxjs'
-import { catchError, map, switchMap, tap } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
-import { Injectable, inject } from '@angular/core'
+import { inject, Injectable } from '@angular/core'
import { RestExtractor, ServerService } from '@app/core'
import { immutableAssign } from '@app/helpers'
+import { VideoService } from '@app/shared/shared-main/video/video.service'
import { objectKeysTyped, peertubeTranslate } from '@peertube/peertube-core-utils'
import { VideosOverview as VideosOverviewServer } from '@peertube/peertube-models'
-import { environment } from '../../../../environments/environment'
+import { forkJoin, Observable, of } from 'rxjs'
+import { catchError, map, switchMap, tap } from 'rxjs/operators'
+import { environment } from '../../../environments/environment'
import { VideosOverview } from './videos-overview.model'
-import { VideoService } from '@app/shared/shared-main/video/video.service'
@Injectable()
export class OverviewService {
diff --git a/client/src/app/+videos/video-list/overview/video-overview.component.html b/client/src/app/+video-list/overview/video-overview.component.html
similarity index 100%
rename from client/src/app/+videos/video-list/overview/video-overview.component.html
rename to client/src/app/+video-list/overview/video-overview.component.html
diff --git a/client/src/app/+videos/video-list/overview/video-overview.component.scss b/client/src/app/+video-list/overview/video-overview.component.scss
similarity index 100%
rename from client/src/app/+videos/video-list/overview/video-overview.component.scss
rename to client/src/app/+video-list/overview/video-overview.component.scss
diff --git a/client/src/app/+videos/video-list/overview/video-overview.component.ts b/client/src/app/+video-list/overview/video-overview.component.ts
similarity index 95%
rename from client/src/app/+videos/video-list/overview/video-overview.component.ts
rename to client/src/app/+video-list/overview/video-overview.component.ts
index b1b7fc117a..849c3bdffb 100644
--- a/client/src/app/+videos/video-list/overview/video-overview.component.ts
+++ b/client/src/app/+video-list/overview/video-overview.component.ts
@@ -4,10 +4,10 @@ import { RouterLink } from '@angular/router'
import { DisableForReuseHook, Notifier, User, UserService } from '@app/core'
import { ActorAvatarComponent, ActorAvatarInput } from '@app/shared/shared-actor-image/actor-avatar.component'
import { ButtonComponent } from '@app/shared/shared-main/buttons/button.component'
+import { InfiniteScrollerDirective } from '@app/shared/shared-main/common/infinite-scroller.directive'
import { Video } from '@app/shared/shared-main/video/video.model'
+import { VideoMiniatureComponent } from '@app/shared/shared-video-miniature/video-miniature.component'
import { Subject, Subscription, switchMap } from 'rxjs'
-import { InfiniteScrollerDirective } from '../../../shared/shared-main/common/infinite-scroller.directive'
-import { VideoMiniatureComponent } from '../../../shared/shared-video-miniature/video-miniature.component'
import { OverviewService } from './overview.service'
@Component({
diff --git a/client/src/app/+videos/video-list/overview/videos-overview.model.ts b/client/src/app/+video-list/overview/videos-overview.model.ts
similarity index 100%
rename from client/src/app/+videos/video-list/overview/videos-overview.model.ts
rename to client/src/app/+video-list/overview/videos-overview.model.ts
diff --git a/client/src/app/+videos/routes.ts b/client/src/app/+video-list/routes.ts
similarity index 90%
rename from client/src/app/+videos/routes.ts
rename to client/src/app/+video-list/routes.ts
index d1bf29b72d..445f2c3bac 100644
--- a/client/src/app/+videos/routes.ts
+++ b/client/src/app/+video-list/routes.ts
@@ -6,9 +6,9 @@ import { BlocklistService } from '@app/shared/shared-moderation/blocklist.servic
import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'
import { UserSubscriptionService } from '@app/shared/shared-user-subscription/user-subscription.service'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'
-import { OverviewService, VideosListAllComponent } from './video-list'
-import { VideoOverviewComponent } from './video-list/overview/video-overview.component'
-import { VideoUserSubscriptionsComponent } from './video-list/video-user-subscriptions.component'
+import { OverviewService, VideosListAllComponent } from '.'
+import { VideoOverviewComponent } from './overview/video-overview.component'
+import { VideoUserSubscriptionsComponent } from './video-user-subscriptions.component'
export default [
{
diff --git a/client/src/app/+videos/video-list/video-user-subscriptions.component.html b/client/src/app/+video-list/video-user-subscriptions.component.html
similarity index 100%
rename from client/src/app/+videos/video-list/video-user-subscriptions.component.html
rename to client/src/app/+video-list/video-user-subscriptions.component.html
diff --git a/client/src/app/+videos/video-list/video-user-subscriptions.component.ts b/client/src/app/+video-list/video-user-subscriptions.component.ts
similarity index 96%
rename from client/src/app/+videos/video-list/video-user-subscriptions.component.ts
rename to client/src/app/+video-list/video-user-subscriptions.component.ts
index d1331c5eaa..4c2946b0c5 100644
--- a/client/src/app/+videos/video-list/video-user-subscriptions.component.ts
+++ b/client/src/app/+video-list/video-user-subscriptions.component.ts
@@ -1,13 +1,13 @@
-import { firstValueFrom } from 'rxjs'
-import { switchMap, tap } from 'rxjs/operators'
import { Component, inject } from '@angular/core'
import { AuthService, ComponentPaginationLight, DisableForReuseHook, ScopedTokensService } from '@app/core'
import { HooksService } from '@app/core/plugins/hooks.service'
-import { VideoSortField } from '@peertube/peertube-models'
-import { VideosListComponent } from '../../shared/shared-video-miniature/videos-list.component'
import { VideoService } from '@app/shared/shared-main/video/video.service'
import { UserSubscriptionService } from '@app/shared/shared-user-subscription/user-subscription.service'
import { VideoFilters } from '@app/shared/shared-video-miniature/video-filters.model'
+import { VideosListComponent } from '@app/shared/shared-video-miniature/videos-list.component'
+import { VideoSortField } from '@peertube/peertube-models'
+import { firstValueFrom } from 'rxjs'
+import { switchMap, tap } from 'rxjs/operators'
@Component({
selector: 'my-videos-user-subscriptions',
diff --git a/client/src/app/+videos/video-list/videos-list-all.component.html b/client/src/app/+video-list/videos-list-all.component.html
similarity index 100%
rename from client/src/app/+videos/video-list/videos-list-all.component.html
rename to client/src/app/+video-list/videos-list-all.component.html
diff --git a/client/src/app/+videos/video-list/videos-list-all.component.ts b/client/src/app/+video-list/videos-list-all.component.ts
similarity index 97%
rename from client/src/app/+videos/video-list/videos-list-all.component.ts
rename to client/src/app/+video-list/videos-list-all.component.ts
index fbafdd47b8..f58e29c02f 100644
--- a/client/src/app/+videos/video-list/videos-list-all.component.ts
+++ b/client/src/app/+video-list/videos-list-all.component.ts
@@ -4,9 +4,9 @@ import { ComponentPaginationLight, DisableForReuseHook, MetaService } from '@app
import { HooksService } from '@app/core/plugins/hooks.service'
import { VideoService } from '@app/shared/shared-main/video/video.service'
import { VideoFilterScope, VideoFilters } from '@app/shared/shared-video-miniature/video-filters.model'
+import { VideosListComponent } from '@app/shared/shared-video-miniature/videos-list.component'
import { VideoSortField } from '@peertube/peertube-models'
import { Subscription } from 'rxjs'
-import { VideosListComponent } from '../../shared/shared-video-miniature/videos-list.component'
@Component({
templateUrl: './videos-list-all.component.html',
diff --git a/client/src/app/+video-studio/edit/index.ts b/client/src/app/+video-studio/edit/index.ts
deleted file mode 100644
index 15b57e1c83..0000000000
--- a/client/src/app/+video-studio/edit/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './video-studio-edit.component'
diff --git a/client/src/app/+video-studio/edit/video-studio-edit.component.ts b/client/src/app/+video-studio/edit/video-studio-edit.component.ts
deleted file mode 100644
index 8b3fb553bc..0000000000
--- a/client/src/app/+video-studio/edit/video-studio-edit.component.ts
+++ /dev/null
@@ -1,221 +0,0 @@
-import { Component, OnInit, inject } from '@angular/core'
-import { ActivatedRoute, Router } from '@angular/router'
-import { ConfirmService, Notifier, ServerService } from '@app/core'
-import { FormReactive } from '@app/shared/shared-forms/form-reactive'
-import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
-import { LoadingBarService } from '@ngx-loading-bar/core'
-import { logger } from '@root-helpers/logger'
-import { secondsToTime } from '@peertube/peertube-core-utils'
-import { VideoStudioTask, VideoStudioTaskCut } from '@peertube/peertube-models'
-import { VideoStudioService } from '../shared'
-import { NgIf, NgFor } from '@angular/common'
-import { EmbedComponent } from '../../shared/shared-main/video/embed.component'
-import { ButtonComponent } from '../../shared/shared-main/buttons/button.component'
-import { ReactiveFileComponent } from '../../shared/shared-forms/reactive-file.component'
-import { TimestampInputComponent } from '../../shared/shared-forms/timestamp-input.component'
-import { FormsModule, ReactiveFormsModule } from '@angular/forms'
-import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
-import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'
-
-@Component({
- selector: 'my-video-studio-edit',
- templateUrl: './video-studio-edit.component.html',
- styleUrls: [ './video-studio-edit.component.scss' ],
- imports: [
- FormsModule,
- ReactiveFormsModule,
- TimestampInputComponent,
- ReactiveFileComponent,
- ButtonComponent,
- EmbedComponent,
- NgIf,
- NgFor,
- GlobalIconComponent
- ]
-})
-export class VideoStudioEditComponent extends FormReactive implements OnInit {
- protected formReactiveService = inject(FormReactiveService)
- private serverService = inject(ServerService)
- private notifier = inject(Notifier)
- private router = inject(Router)
- private route = inject(ActivatedRoute)
- private videoStudioService = inject(VideoStudioService)
- private loadingBar = inject(LoadingBarService)
- private confirmService = inject(ConfirmService)
-
- isRunningEdit = false
-
- video: VideoDetails
-
- ngOnInit () {
- this.video = this.route.snapshot.data.video
-
- const defaultValues = {
- cut: {
- start: 0,
- end: this.video.duration
- }
- }
-
- this.buildForm({
- 'cut': {
- start: null,
- end: null
- },
- 'add-intro': {
- file: null
- },
- 'add-outro': {
- file: null
- },
- 'add-watermark': {
- file: null
- }
- }, defaultValues)
- }
-
- get videoExtensions () {
- return this.serverService.getHTMLConfig().video.file.extensions
- }
-
- get imageExtensions () {
- return this.serverService.getHTMLConfig().video.image.extensions
- }
-
- async runEdit () {
- if (this.isRunningEdit) return
- if (!this.form.valid) return
- if (this.noEdit()) return
-
- const title = $localize`Are you sure you want to edit "${this.video.name}"?`
- const listHTML = this.getTasksSummary().map(t => `<li>${t}</li>`).join('')
-
- const confirmHTML =
- // eslint-disable-next-line max-len
- $localize`The current video will be overwritten by this edited video and <strong>you won't be able to recover it</strong>.<br /><br />` +
- $localize`As a reminder, the following tasks will be executed: <ol>${listHTML}</ol>`
-
- if (await this.confirmService.confirm(confirmHTML, title) !== true) return
-
- this.isRunningEdit = true
-
- const tasks = this.buildTasks()
-
- this.loadingBar.useRef().start()
-
- return this.videoStudioService.editVideo(this.video.uuid, tasks)
- .subscribe({
- next: () => {
- this.notifier.success($localize`Editing tasks created.`)
-
- // Don't redirect to old video version watch page that could be confusing for users
- this.router.navigateByUrl('/my-library/videos')
- },
-
- error: err => {
- this.loadingBar.useRef().complete()
- this.isRunningEdit = false
- this.notifier.error(err.message)
- logger.error(err)
- }
- })
- }
-
- getIntroOutroTooltip () {
- return $localize`(extensions: ${this.videoExtensions.join(', ')})`
- }
-
- getWatermarkTooltip () {
- return $localize`(extensions: ${this.imageExtensions.join(', ')})`
- }
-
- noEdit () {
- return this.buildTasks().length === 0
- }
-
- getTasksSummary () {
- const tasks = this.buildTasks()
-
- return tasks.map(t => {
- if (t.name === 'add-intro') {
- return $localize`"${this.getFilename(t.options.file)}" will be added at the beginning of the video`
- }
-
- if (t.name === 'add-outro') {
- return $localize`"${this.getFilename(t.options.file)}" will be added at the end of the video`
- }
-
- if (t.name === 'add-watermark') {
- return $localize`"${this.getFilename(t.options.file)}" image watermark will be added to the video`
- }
-
- if (t.name === 'cut') {
- const { start, end } = t.options
-
- if (start !== undefined && end !== undefined) {
- return $localize`Video will begin at ${secondsToTime(start)} and stop at ${secondsToTime(end)}`
- }
-
- if (start !== undefined) {
- return $localize`Video will begin at ${secondsToTime(start)}`
- }
-
- if (end !== undefined) {
- return $localize`Video will stop at ${secondsToTime(end)}`
- }
- }
-
- return ''
- })
- }
-
- private getFilename (obj: any) {
- return obj.name
- }
-
- private buildTasks () {
- const tasks: VideoStudioTask[] = []
- const value = this.form.value
-
- const cut = value['cut']
- if (cut['start'] !== 0 || cut['end'] !== this.video.duration) {
- const options: VideoStudioTaskCut['options'] = {}
- if (cut['start'] !== 0) options.start = cut['start']
- if (cut['end'] !== this.video.duration) options.end = cut['end']
-
- tasks.push({
- name: 'cut',
- options
- })
- }
-
- if (value['add-intro']?.['file']) {
- tasks.push({
- name: 'add-intro',
- options: {
- file: value['add-intro']['file']
- }
- })
- }
-
- if (value['add-outro']?.['file']) {
- tasks.push({
- name: 'add-outro',
- options: {
- file: value['add-outro']['file']
- }
- })
- }
-
- if (value['add-watermark']?.['file']) {
- tasks.push({
- name: 'add-watermark',
- options: {
- file: value['add-watermark']['file']
- }
- })
- }
-
- return tasks
- }
-}
diff --git a/client/src/app/+video-studio/routes.ts b/client/src/app/+video-studio/routes.ts
deleted file mode 100644
index 3c56174ccd..0000000000
--- a/client/src/app/+video-studio/routes.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Routes } from '@angular/router'
-import { LoginGuard } from '@app/core'
-import { VideoStudioEditComponent } from './edit'
-import { VideoStudioService } from './shared'
-import { VideoResolver } from '@app/shared/shared-main/video/video.resolver'
-
-export default [
- {
- path: '',
- canActivateChild: [ LoginGuard ],
- providers: [ VideoStudioService ],
- children: [
- {
- path: 'edit/:videoId',
- component: VideoStudioEditComponent,
- data: {
- meta: {
- title: $localize`Studio`
- }
- },
- resolve: {
- video: VideoResolver
- }
- }
- ]
- }
-] satisfies Routes
diff --git a/client/src/app/+video-studio/shared/index.ts b/client/src/app/+video-studio/shared/index.ts
deleted file mode 100644
index 9940ac6a9f..0000000000
--- a/client/src/app/+video-studio/shared/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './video-studio.service'
diff --git a/client/src/app/+video-watch/player-styles.component.scss b/client/src/app/+video-watch/player-styles.component.scss
new file mode 100644
index 0000000000..4e97105493
--- /dev/null
+++ b/client/src/app/+video-watch/player-styles.component.scss
@@ -0,0 +1 @@
+@use '../../standalone/player/build/peertube-player.css';
diff --git a/client/src/app/+videos/+video-watch/player-styles.component.ts b/client/src/app/+video-watch/player-styles.component.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/player-styles.component.ts
rename to client/src/app/+video-watch/player-styles.component.ts
diff --git a/client/src/app/+videos/+video-watch/routes.ts b/client/src/app/+video-watch/routes.ts
similarity index 97%
rename from client/src/app/+videos/+video-watch/routes.ts
rename to client/src/app/+video-watch/routes.ts
index 10b24475ae..daa245f93c 100644
--- a/client/src/app/+videos/+video-watch/routes.ts
+++ b/client/src/app/+video-watch/routes.ts
@@ -8,7 +8,7 @@ import { UserAdminService } from '@app/shared/shared-users/user-admin.service'
import { VideoCommentService } from '@app/shared/shared-video-comment/video-comment.service'
import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'
-import { OverviewService } from '../video-list'
+import { OverviewService } from '../+video-list'
import { VideoRecommendationService } from './shared'
import { VideoWatchComponent } from './video-watch.component'
import { BulkService } from '@app/shared/shared-moderation/bulk.service'
diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.html b/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.html
rename to client/src/app/+video-watch/shared/action-buttons/action-buttons.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.scss b/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.scss
rename to client/src/app/+video-watch/shared/action-buttons/action-buttons.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts b/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.ts
similarity index 92%
rename from client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts
rename to client/src/app/+video-watch/shared/action-buttons/action-buttons.component.ts
index 157693bc12..17f352d9dd 100644
--- a/client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts
+++ b/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.ts
@@ -1,19 +1,16 @@
import { NgClass, NgIf, NgStyle } from '@angular/common'
import { Component, OnChanges, inject, input, output, viewChild } from '@angular/core'
import { RedirectService, ScreenService } from '@app/core'
+import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'
import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
import { VideoShareComponent } from '@app/shared/shared-share-modal/video-share.component'
import { SupportModalComponent } from '@app/shared/shared-support-modal/support-modal.component'
import { VideoDownloadComponent } from '@app/shared/shared-video-miniature/download/video-download.component'
+import { VideoActionsDisplayType, VideoActionsDropdownComponent } from '@app/shared/shared-video-miniature/video-actions-dropdown.component'
+import { VideoAddToPlaylistComponent } from '@app/shared/shared-video-playlist/video-add-to-playlist.component'
import { VideoPlaylist } from '@app/shared/shared-video-playlist/video-playlist.model'
import { NgbDropdown, NgbDropdownMenu, NgbDropdownToggle, NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
import { UserVideoRateType, VideoCaption, VideoPrivacy } from '@peertube/peertube-models'
-import { GlobalIconComponent } from '../../../../shared/shared-icons/global-icon.component'
-import {
- VideoActionsDisplayType,
- VideoActionsDropdownComponent
-} from '../../../../shared/shared-video-miniature/video-actions-dropdown.component'
-import { VideoAddToPlaylistComponent } from '../../../../shared/shared-video-playlist/video-add-to-playlist.component'
import { VideoRateComponent } from './video-rate.component'
@Component({
diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/index.ts b/client/src/app/+video-watch/shared/action-buttons/index.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/action-buttons/index.ts
rename to client/src/app/+video-watch/shared/action-buttons/index.ts
diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.html b/client/src/app/+video-watch/shared/action-buttons/video-rate.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.html
rename to client/src/app/+video-watch/shared/action-buttons/video-rate.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.scss b/client/src/app/+video-watch/shared/action-buttons/video-rate.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.scss
rename to client/src/app/+video-watch/shared/action-buttons/video-rate.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts b/client/src/app/+video-watch/shared/action-buttons/video-rate.component.ts
similarity index 96%
rename from client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts
rename to client/src/app/+video-watch/shared/action-buttons/video-rate.component.ts
index d6bae8733d..f0870adbe4 100644
--- a/client/src/app/+videos/+video-watch/shared/action-buttons/video-rate.component.ts
+++ b/client/src/app/+video-watch/shared/action-buttons/video-rate.component.ts
@@ -1,12 +1,12 @@
-import { Observable } from 'rxjs'
-import { Component, OnChanges, OnDestroy, OnInit, inject, input, output } from '@angular/core'
-import { Notifier, ScreenService, Hotkey, HotkeysService } from '@app/core'
-import { UserVideoRateType } from '@peertube/peertube-models'
-import { GlobalIconComponent } from '../../../../shared/shared-icons/global-icon.component'
import { NgClass, NgIf } from '@angular/common'
-import { NgbPopover, NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
-import { VideoService } from '@app/shared/shared-main/video/video.service'
+import { Component, OnChanges, OnDestroy, OnInit, inject, input, output } from '@angular/core'
+import { Hotkey, HotkeysService, Notifier, ScreenService } from '@app/core'
+import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'
import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
+import { VideoService } from '@app/shared/shared-main/video/video.service'
+import { NgbPopover, NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
+import { UserVideoRateType } from '@peertube/peertube-models'
+import { Observable } from 'rxjs'
@Component({
selector: 'my-video-rate',
diff --git a/client/src/app/+videos/+video-watch/shared/comment/index.ts b/client/src/app/+video-watch/shared/comment/index.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/comment/index.ts
rename to client/src/app/+video-watch/shared/comment/index.ts
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html b/client/src/app/+video-watch/shared/comment/video-comment-add.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.html
rename to client/src/app/+video-watch/shared/comment/video-comment-add.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.scss b/client/src/app/+video-watch/shared/comment/video-comment-add.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.scss
rename to client/src/app/+video-watch/shared/comment/video-comment-add.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts b/client/src/app/+video-watch/shared/comment/video-comment-add.component.ts
similarity index 90%
rename from client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts
rename to client/src/app/+video-watch/shared/comment/video-comment-add.component.ts
index 6c78ba90b4..29ebafe7d8 100644
--- a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts
+++ b/client/src/app/+video-watch/shared/comment/video-comment-add.component.ts
@@ -1,23 +1,23 @@
import { getLocaleDirection, NgClass, NgFor, NgIf } from '@angular/common'
-import { Component, ElementRef, LOCALE_ID, OnChanges, OnInit, SimpleChanges, inject, input, output, viewChild } from '@angular/core'
+import { Component, ElementRef, inject, input, LOCALE_ID, OnChanges, OnInit, output, SimpleChanges, viewChild } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { Notifier, User } from '@app/core'
import { VIDEO_COMMENT_TEXT_VALIDATOR } from '@app/shared/form-validators/video-comment-validators'
+import { ActorAvatarComponent } from '@app/shared/shared-actor-image/actor-avatar.component'
import { FormReactive } from '@app/shared/shared-forms/form-reactive'
import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
+import { TextareaAutoResizeDirective } from '@app/shared/shared-forms/textarea-autoresize.directive'
+import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'
+import { HelpComponent } from '@app/shared/shared-main/buttons/help.component'
+import { PeerTubeTemplateDirective } from '@app/shared/shared-main/common/peertube-template.directive'
import { LoginLinkComponent } from '@app/shared/shared-main/users/login-link.component'
import { Video } from '@app/shared/shared-main/video/video.model'
+import { RemoteSubscribeComponent } from '@app/shared/shared-user-subscription/remote-subscribe.component'
import { VideoComment } from '@app/shared/shared-video-comment/video-comment.model'
import { VideoCommentService } from '@app/shared/shared-video-comment/video-comment.service'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { VideoCommentCreate } from '@peertube/peertube-models'
import { Observable } from 'rxjs'
-import { ActorAvatarComponent } from '../../../../shared/shared-actor-image/actor-avatar.component'
-import { TextareaAutoResizeDirective } from '../../../../shared/shared-forms/textarea-autoresize.directive'
-import { GlobalIconComponent } from '../../../../shared/shared-icons/global-icon.component'
-import { HelpComponent } from '../../../../shared/shared-main/buttons/help.component'
-import { PeerTubeTemplateDirective } from '../../../../shared/shared-main/common/peertube-template.directive'
-import { RemoteSubscribeComponent } from '../../../../shared/shared-user-subscription/remote-subscribe.component'
@Component({
selector: 'my-video-comment-add',
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.html b/client/src/app/+video-watch/shared/comment/video-comment.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/comment/video-comment.component.html
rename to client/src/app/+video-watch/shared/comment/video-comment.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.scss b/client/src/app/+video-watch/shared/comment/video-comment.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/comment/video-comment.component.scss
rename to client/src/app/+video-watch/shared/comment/video-comment.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.ts b/client/src/app/+video-watch/shared/comment/video-comment.component.ts
similarity index 96%
rename from client/src/app/+videos/+video-watch/shared/comment/video-comment.component.ts
rename to client/src/app/+video-watch/shared/comment/video-comment.component.ts
index cd8e927158..03bc48478e 100644
--- a/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.ts
+++ b/client/src/app/+video-watch/shared/comment/video-comment.component.ts
@@ -3,16 +3,16 @@ import { Component, OnChanges, OnInit, inject, input, model, output, viewChild }
import { RouterLink } from '@angular/router'
import { MarkdownService, Notifier, UserService } from '@app/core'
import { AuthService } from '@app/core/auth'
+import { ActorAvatarComponent } from '@app/shared/shared-actor-image/actor-avatar.component'
import { Account } from '@app/shared/shared-main/account/account.model'
import { DropdownAction } from '@app/shared/shared-main/buttons/action-dropdown.component'
+import { FromNowPipe } from '@app/shared/shared-main/date/from-now.pipe'
import { Video } from '@app/shared/shared-main/video/video.model'
import { CommentReportComponent } from '@app/shared/shared-moderation/report-modals/comment-report.component'
+import { UserModerationDropdownComponent } from '@app/shared/shared-moderation/user-moderation-dropdown.component'
import { VideoCommentThreadTree } from '@app/shared/shared-video-comment/video-comment-thread-tree.model'
import { VideoComment } from '@app/shared/shared-video-comment/video-comment.model'
import { User, UserRight } from '@peertube/peertube-models'
-import { ActorAvatarComponent } from '../../../../shared/shared-actor-image/actor-avatar.component'
-import { FromNowPipe } from '../../../../shared/shared-main/date/from-now.pipe'
-import { UserModerationDropdownComponent } from '../../../../shared/shared-moderation/user-moderation-dropdown.component'
import { TimestampRouteTransformerDirective } from '../timestamp-route-transformer.directive'
import { VideoCommentAddComponent } from './video-comment-add.component'
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.html b/client/src/app/+video-watch/shared/comment/video-comments.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/comment/video-comments.component.html
rename to client/src/app/+video-watch/shared/comment/video-comments.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.scss b/client/src/app/+video-watch/shared/comment/video-comments.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/comment/video-comments.component.scss
rename to client/src/app/+video-watch/shared/comment/video-comments.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts b/client/src/app/+video-watch/shared/comment/video-comments.component.ts
similarity index 96%
rename from client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts
rename to client/src/app/+video-watch/shared/comment/video-comments.component.ts
index f3ea38c358..b7dc6801b8 100644
--- a/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts
+++ b/client/src/app/+video-watch/shared/comment/video-comments.component.ts
@@ -1,8 +1,11 @@
import { NgFor, NgIf } from '@angular/common'
-import { Component, ElementRef, OnChanges, OnDestroy, OnInit, SimpleChanges, inject, input, output, viewChild } from '@angular/core'
+import { Component, ElementRef, inject, input, OnChanges, OnDestroy, OnInit, output, SimpleChanges, viewChild } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
import { AuthService, ComponentPagination, ConfirmService, hasMoreItems, Notifier, PluginService, User } from '@app/core'
import { HooksService } from '@app/core/plugins/hooks.service'
+import { InfiniteScrollerDirective } from '@app/shared/shared-main/common/infinite-scroller.directive'
+import { LoaderComponent } from '@app/shared/shared-main/common/loader.component'
+import { FeedComponent } from '@app/shared/shared-main/feeds/feed.component'
import { Syndication } from '@app/shared/shared-main/feeds/syndication.model'
import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
import { VideoCommentThreadTree } from '@app/shared/shared-video-comment/video-comment-thread-tree.model'
@@ -11,9 +14,6 @@ import { VideoCommentService } from '@app/shared/shared-video-comment/video-comm
import { NgbDropdown, NgbDropdownButtonItem, NgbDropdownItem, NgbDropdownMenu, NgbDropdownToggle } from '@ng-bootstrap/ng-bootstrap'
import { PeerTubeProblemDocument, ServerErrorCode, VideoCommentPolicy } from '@peertube/peertube-models'
import { lastValueFrom, Subject, Subscription } from 'rxjs'
-import { InfiniteScrollerDirective } from '../../../../shared/shared-main/common/infinite-scroller.directive'
-import { LoaderComponent } from '../../../../shared/shared-main/common/loader.component'
-import { FeedComponent } from '../../../../shared/shared-main/feeds/feed.component'
import { VideoCommentAddComponent } from './video-comment-add.component'
import { VideoCommentComponent } from './video-comment.component'
diff --git a/client/src/app/+videos/+video-watch/shared/index.ts b/client/src/app/+video-watch/shared/index.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/index.ts
rename to client/src/app/+video-watch/shared/index.ts
diff --git a/client/src/app/+videos/+video-watch/shared/information/index.ts b/client/src/app/+video-watch/shared/information/index.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/information/index.ts
rename to client/src/app/+video-watch/shared/information/index.ts
diff --git a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html b/client/src/app/+video-watch/shared/information/privacy-concerns.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html
rename to client/src/app/+video-watch/shared/information/privacy-concerns.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.scss b/client/src/app/+video-watch/shared/information/privacy-concerns.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.scss
rename to client/src/app/+video-watch/shared/information/privacy-concerns.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts b/client/src/app/+video-watch/shared/information/privacy-concerns.component.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
rename to client/src/app/+video-watch/shared/information/privacy-concerns.component.ts
diff --git a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html b/client/src/app/+video-watch/shared/information/video-alert.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/information/video-alert.component.html
rename to client/src/app/+video-watch/shared/information/video-alert.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts b/client/src/app/+video-watch/shared/information/video-alert.component.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts
rename to client/src/app/+video-watch/shared/information/video-alert.component.ts
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/index.ts b/client/src/app/+video-watch/shared/metadata/index.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/metadata/index.ts
rename to client/src/app/+video-watch/shared/metadata/index.ts
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html b/client/src/app/+video-watch/shared/metadata/video-attributes.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html
rename to client/src/app/+video-watch/shared/metadata/video-attributes.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.scss b/client/src/app/+video-watch/shared/metadata/video-attributes.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.scss
rename to client/src/app/+video-watch/shared/metadata/video-attributes.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts b/client/src/app/+video-watch/shared/metadata/video-attributes.component.ts
similarity index 93%
rename from client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts
rename to client/src/app/+video-watch/shared/metadata/video-attributes.component.ts
index 26bd234101..ec5d4d6055 100644
--- a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts
+++ b/client/src/app/+video-watch/shared/metadata/video-attributes.component.ts
@@ -2,10 +2,10 @@ import { NgFor, NgIf } from '@angular/common'
import { Component, OnChanges, inject, input } from '@angular/core'
import { RouterLink } from '@angular/router'
import { HooksService } from '@app/core'
+import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'
import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'
import { TimeDurationFormatterPipe } from '@app/shared/shared-main/date/time-duration-formatter.pipe'
import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
-import { GlobalIconComponent } from '../../../../shared/shared-icons/global-icon.component'
type PluginMetadata = {
label: string
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-avatar-channel.component.html b/client/src/app/+video-watch/shared/metadata/video-avatar-channel.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/metadata/video-avatar-channel.component.html
rename to client/src/app/+video-watch/shared/metadata/video-avatar-channel.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-avatar-channel.component.scss b/client/src/app/+video-watch/shared/metadata/video-avatar-channel.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/metadata/video-avatar-channel.component.scss
rename to client/src/app/+video-watch/shared/metadata/video-avatar-channel.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-avatar-channel.component.ts b/client/src/app/+video-watch/shared/metadata/video-avatar-channel.component.ts
similarity index 89%
rename from client/src/app/+videos/+video-watch/shared/metadata/video-avatar-channel.component.ts
rename to client/src/app/+video-watch/shared/metadata/video-avatar-channel.component.ts
index 0bd53afa72..119e4b94a1 100644
--- a/client/src/app/+videos/+video-watch/shared/metadata/video-avatar-channel.component.ts
+++ b/client/src/app/+video-watch/shared/metadata/video-avatar-channel.component.ts
@@ -1,6 +1,6 @@
-import { Component, OnInit, input } from '@angular/core'
-import { ActorAvatarComponent } from '../../../../shared/shared-actor-image/actor-avatar.component'
import { NgIf } from '@angular/common'
+import { Component, OnInit, input } from '@angular/core'
+import { ActorAvatarComponent } from '@app/shared/shared-actor-image/actor-avatar.component'
import { Video } from '@app/shared/shared-main/video/video.model'
@Component({
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html b/client/src/app/+video-watch/shared/metadata/video-description.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html
rename to client/src/app/+video-watch/shared/metadata/video-description.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.scss b/client/src/app/+video-watch/shared/metadata/video-description.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/metadata/video-description.component.scss
rename to client/src/app/+video-watch/shared/metadata/video-description.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts b/client/src/app/+video-watch/shared/metadata/video-description.component.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts
rename to client/src/app/+video-watch/shared/metadata/video-description.component.ts
diff --git a/client/src/app/+videos/+video-watch/shared/player-widgets/player-widget.component.scss b/client/src/app/+video-watch/shared/player-widgets/player-widget.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/player-widgets/player-widget.component.scss
rename to client/src/app/+video-watch/shared/player-widgets/player-widget.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.html b/client/src/app/+video-watch/shared/player-widgets/video-transcription.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.html
rename to client/src/app/+video-watch/shared/player-widgets/video-transcription.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.scss b/client/src/app/+video-watch/shared/player-widgets/video-transcription.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.scss
rename to client/src/app/+video-watch/shared/player-widgets/video-transcription.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.ts b/client/src/app/+video-watch/shared/player-widgets/video-transcription.component.ts
similarity index 95%
rename from client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.ts
rename to client/src/app/+video-watch/shared/player-widgets/video-transcription.component.ts
index 9003d7f69e..12bd594e83 100644
--- a/client/src/app/+videos/+video-watch/shared/player-widgets/video-transcription.component.ts
+++ b/client/src/app/+video-watch/shared/player-widgets/video-transcription.component.ts
@@ -1,9 +1,11 @@
import { NgClass, NgFor } from '@angular/common'
-import { Component, ElementRef, HostListener, OnChanges, OnInit, SimpleChanges, inject, input, output, viewChild } from '@angular/core'
+import { Component, ElementRef, HostListener, inject, input, OnChanges, OnInit, output, SimpleChanges, viewChild } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { Notifier } from '@app/core'
import { durationToString, isInViewport } from '@app/helpers'
import { SelectOptionsComponent } from '@app/shared/shared-forms/select/select-options.component'
+import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'
+import { Nl2BrPipe } from '@app/shared/shared-main/common/nl2br.pipe'
import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
import { NgbCollapse } from '@ng-bootstrap/ng-bootstrap'
import { Video, VideoCaption } from '@peertube/peertube-models'
@@ -11,8 +13,6 @@ import { parse } from '@plussub/srt-vtt-parser'
import debug from 'debug'
import { debounceTime, distinctUntilChanged, Subject } from 'rxjs'
import { SelectOptionsItem } from 'src/types'
-import { GlobalIconComponent } from '../../../../shared/shared-icons/global-icon.component'
-import { Nl2BrPipe } from '../../../../shared/shared-main/common/nl2br.pipe'
const debugLogger = debug('peertube:watch:VideoTranscriptionComponent')
diff --git a/client/src/app/+videos/+video-watch/shared/player-widgets/video-watch-playlist.component.html b/client/src/app/+video-watch/shared/player-widgets/video-watch-playlist.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/player-widgets/video-watch-playlist.component.html
rename to client/src/app/+video-watch/shared/player-widgets/video-watch-playlist.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/player-widgets/video-watch-playlist.component.scss b/client/src/app/+video-watch/shared/player-widgets/video-watch-playlist.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/player-widgets/video-watch-playlist.component.scss
rename to client/src/app/+video-watch/shared/player-widgets/video-watch-playlist.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/player-widgets/video-watch-playlist.component.ts b/client/src/app/+video-watch/shared/player-widgets/video-watch-playlist.component.ts
similarity index 96%
rename from client/src/app/+videos/+video-watch/shared/player-widgets/video-watch-playlist.component.ts
rename to client/src/app/+video-watch/shared/player-widgets/video-watch-playlist.component.ts
index dbf1d4690f..bccf9e1850 100644
--- a/client/src/app/+videos/+video-watch/shared/player-widgets/video-watch-playlist.component.ts
+++ b/client/src/app/+video-watch/shared/player-widgets/video-watch-playlist.component.ts
@@ -11,6 +11,9 @@ import {
UserService
} from '@app/core'
import { isInViewport } from '@app/helpers'
+import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'
+import { InfiniteScrollerDirective } from '@app/shared/shared-main/common/infinite-scroller.directive'
+import { VideoPlaylistElementMiniatureComponent } from '@app/shared/shared-video-playlist/video-playlist-element-miniature.component'
import { VideoPlaylistElement } from '@app/shared/shared-video-playlist/video-playlist-element.model'
import { VideoPlaylist } from '@app/shared/shared-video-playlist/video-playlist.model'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'
@@ -18,9 +21,6 @@ import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
import { VideoPlaylistPrivacy } from '@peertube/peertube-models'
import { getBoolOrDefault } from '@root-helpers/local-storage-utils'
import { peertubeSessionStorage } from '@root-helpers/peertube-web-storage'
-import { GlobalIconComponent } from '../../../../shared/shared-icons/global-icon.component'
-import { InfiniteScrollerDirective } from '../../../../shared/shared-main/common/infinite-scroller.directive'
-import { VideoPlaylistElementMiniatureComponent } from '../../../../shared/shared-video-playlist/video-playlist-element-miniature.component'
@Component({
selector: 'my-video-watch-playlist',
diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/index.ts b/client/src/app/+video-watch/shared/recommendations/index.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/recommendations/index.ts
rename to client/src/app/+video-watch/shared/recommendations/index.ts
diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html b/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html
rename to client/src/app/+video-watch/shared/recommendations/recommended-videos.component.html
diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.scss b/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.scss
rename to client/src/app/+video-watch/shared/recommendations/recommended-videos.component.scss
diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts b/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.ts
similarity index 95%
rename from client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts
rename to client/src/app/+video-watch/shared/recommendations/recommended-videos.component.ts
index 475b18a60d..8bd9c191c3 100644
--- a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts
+++ b/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.ts
@@ -2,13 +2,13 @@ import { NgClass, NgFor, NgIf } from '@angular/common'
import { Component, OnChanges, OnDestroy, OnInit, inject, input, output } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { AuthService, Notifier, User, UserService } from '@app/core'
+import { InputSwitchComponent } from '@app/shared/shared-forms/input-switch.component'
import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
import { Video } from '@app/shared/shared-main/video/video.model'
+import { MiniatureDisplayOptions, VideoMiniatureComponent } from '@app/shared/shared-video-miniature/video-miniature.component'
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
import { VideoPlaylist } from '@peertube/peertube-models'
import { Subscription, startWith, switchMap } from 'rxjs'
-import { InputSwitchComponent } from '../../../../shared/shared-forms/input-switch.component'
-import { MiniatureDisplayOptions, VideoMiniatureComponent } from '../../../../shared/shared-video-miniature/video-miniature.component'
import { VideoRecommendationService } from './video-recommendation.service'
@Component({
diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/video-recommendation.service.ts b/client/src/app/+video-watch/shared/recommendations/video-recommendation.service.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/recommendations/video-recommendation.service.ts
rename to client/src/app/+video-watch/shared/recommendations/video-recommendation.service.ts
diff --git a/client/src/app/+videos/+video-watch/shared/timestamp-route-transformer.directive.ts b/client/src/app/+video-watch/shared/timestamp-route-transformer.directive.ts
similarity index 100%
rename from client/src/app/+videos/+video-watch/shared/timestamp-route-transformer.directive.ts
rename to client/src/app/+video-watch/shared/timestamp-route-transformer.directive.ts
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.html b/client/src/app/+video-watch/video-watch.component.html
similarity index 100%
rename from client/src/app/+videos/+video-watch/video-watch.component.html
rename to client/src/app/+video-watch/video-watch.component.html
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.scss b/client/src/app/+video-watch/video-watch.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-watch/video-watch.component.scss
rename to client/src/app/+video-watch/video-watch.component.scss
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+video-watch/video-watch.component.ts
similarity index 98%
rename from client/src/app/+videos/+video-watch/video-watch.component.ts
rename to client/src/app/+video-watch/video-watch.component.ts
index 194d63815d..3cdf983066 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/+video-watch/video-watch.component.ts
@@ -1,5 +1,5 @@
import { NgClass, NgIf, NgTemplateOutlet, PlatformLocation } from '@angular/common'
-import { Component, ElementRef, LOCALE_ID, NgZone, OnDestroy, OnInit, inject, viewChild } from '@angular/core'
+import { Component, ElementRef, inject, LOCALE_ID, NgZone, OnDestroy, OnInit, viewChild } from '@angular/core'
import { ActivatedRoute, Params, Router, RouterLink } from '@angular/router'
import {
AuthService,
@@ -18,7 +18,7 @@ import {
UserService
} from '@app/core'
import { HooksService } from '@app/core/plugins/hooks.service'
-import { getOriginUrl, isXPercentInViewport, scrollToTop, toBoolean } from '@app/helpers'
+import { getAPIUrl, getOriginUrl, isXPercentInViewport, scrollToTop, toBoolean } from '@app/helpers'
import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
import { VideoChapterService } from '@app/shared/shared-main/video/video-chapter.service'
import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
@@ -58,10 +58,10 @@ import { logger } from '@root-helpers/logger'
import { isP2PEnabled, videoRequiresFileToken, videoRequiresUserAuth } from '@root-helpers/video'
import debug from 'debug'
import { forkJoin, map, Observable, of, Subscription, switchMap } from 'rxjs'
-import { environment } from '../../../environments/environment'
-import { DateToggleComponent } from '../../shared/shared-main/date/date-toggle.component'
-import { PluginPlaceholderComponent } from '../../shared/shared-main/plugins/plugin-placeholder.component'
-import { VideoViewsCounterComponent } from '../../shared/shared-video/video-views-counter.component'
+import { environment } from '../../environments/environment'
+import { DateToggleComponent } from '../shared/shared-main/date/date-toggle.component'
+import { PluginPlaceholderComponent } from '../shared/shared-main/plugins/plugin-placeholder.component'
+import { VideoViewsCounterComponent } from '../shared/shared-video/video-views-counter.component'
import { PlayerStylesComponent } from './player-styles.component'
import { ActionButtonsComponent } from './shared/action-buttons/action-buttons.component'
import { VideoCommentsComponent } from './shared/comment/video-comments.component'
@@ -709,7 +709,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
authorizationHeader: () => this.authService.getRequestHeaderValue(),
- serverUrl: environment.originServerUrl || window.location.origin,
+ serverUrl: getAPIUrl(),
stunServers: this.serverConfig.webrtc.stunServers,
errorNotifier: (message: string) => this.notifier.error(message),
diff --git a/client/src/app/+videos-publish-manage/+video-manage/routes.ts b/client/src/app/+videos-publish-manage/+video-manage/routes.ts
new file mode 100644
index 0000000000..12354bdde5
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-manage/routes.ts
@@ -0,0 +1,29 @@
+import { Routes } from '@angular/router'
+import { CanDeactivateGuard, LoginGuard } from '@app/core'
+import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
+import { I18nPrimengCalendarService } from '../shared-manage/common/i18n-primeng-calendar.service'
+import { VideoUploadService } from '../shared-manage/common/video-upload.service'
+import { manageRoutes } from '../shared-manage/routes'
+import { VideoStudioService } from '../shared-manage/studio/video-studio.service'
+import { VideoManageComponent } from './video-manage.component'
+import { VideoManageResolver } from './video-manage.resolver'
+
+export default [
+ {
+ path: '',
+ component: VideoManageComponent,
+ canActivate: [ LoginGuard ],
+ canDeactivate: [ CanDeactivateGuard ],
+ providers: [
+ VideoManageResolver,
+ LiveVideoService,
+ I18nPrimengCalendarService,
+ VideoUploadService,
+ VideoStudioService
+ ],
+ resolve: {
+ resolverData: VideoManageResolver
+ },
+ children: manageRoutes
+ }
+] satisfies Routes
diff --git a/client/src/app/+videos-publish-manage/+video-manage/video-manage.component.html b/client/src/app/+videos-publish-manage/+video-manage/video-manage.component.html
new file mode 100644
index 0000000000..23ae5bec72
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-manage/video-manage.component.html
@@ -0,0 +1,6 @@
+<div class="margin-content">
+ <my-video-manage-container
+ *ngIf="loaded"
+ canUpdate="true" canWatch="true" cancelLink="/my-library/videos" (videoUpdated)="onVideoUpdated()"
+ ></my-video-manage-container>
+</div>
diff --git a/client/src/app/+videos-publish-manage/+video-manage/video-manage.component.ts b/client/src/app/+videos-publish-manage/+video-manage/video-manage.component.ts
new file mode 100644
index 0000000000..275ecec339
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-manage/video-manage.component.ts
@@ -0,0 +1,81 @@
+import { CommonModule } from '@angular/common'
+import { Component, HostListener, inject, OnDestroy, OnInit } from '@angular/core'
+import { FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { ActivatedRoute } from '@angular/router'
+import { CanComponentDeactivate, Notifier, ServerService } from '@app/core'
+import { VideoEdit } from '../shared-manage/common/video-edit.model'
+import { VideoManageContainerComponent } from '../shared-manage/video-manage-container.component'
+import { VideoManageController } from '../shared-manage/video-manage-controller.service'
+import { VideoManageResolverData } from './video-manage.resolver'
+
+@Component({
+ selector: 'my-video-manage',
+ templateUrl: './video-manage.component.html',
+ imports: [
+ CommonModule,
+ FormsModule,
+ ReactiveFormsModule,
+ VideoManageContainerComponent
+ ],
+ providers: [ VideoManageController ]
+})
+export class VideoManageComponent implements OnInit, OnDestroy, CanComponentDeactivate {
+ private route = inject(ActivatedRoute)
+ private serverService = inject(ServerService)
+ private notifier = inject(Notifier)
+
+ private manageController = inject(VideoManageController)
+
+ isUpdatingVideo = false
+ loaded = false
+
+ async ngOnInit () {
+ const data = this.route.snapshot.data.resolverData as VideoManageResolverData
+ const { video, userChannels, captions, chapters, videoSource, live, videoPasswords, userQuota, privacies } = data
+
+ const videoEdit = await VideoEdit.createFromAPI(this.serverService.getHTMLConfig(), {
+ video,
+ captions,
+ chapters,
+ live,
+ videoSource,
+ videoPasswords: videoPasswords.map(p => p.password)
+ })
+
+ this.manageController.setStore({
+ videoEdit,
+ userQuota,
+ userChannels,
+ privacies
+ })
+
+ this.manageController.setConfig({ manageType: 'update', serverConfig: this.serverService.getHTMLConfig() })
+
+ this.loaded = true
+ }
+
+ ngOnDestroy () {
+ this.manageController.cancelUploadIfNeeded()
+ }
+
+ onVideoUpdated () {
+ this.notifier.success($localize`Video updated.`)
+ }
+
+ @HostListener('window:beforeunload', [ '$event' ])
+ onUnload (event: any) {
+ const { text, canDeactivate } = this.canDeactivate()
+
+ if (canDeactivate) return
+
+ event.returnValue = text
+ return text
+ }
+
+ canDeactivate (): { canDeactivate: boolean, text?: string } {
+ return {
+ canDeactivate: !this.manageController.hasPendingChanges(),
+ text: $localize`You have unsaved changes. Are you sure you want to leave?`
+ }
+ }
+}
diff --git a/client/src/app/+videos/+video-edit/video-update.resolver.ts b/client/src/app/+videos-publish-manage/+video-manage/video-manage.resolver.ts
similarity index 58%
rename from client/src/app/+videos/+video-edit/video-update.resolver.ts
rename to client/src/app/+videos-publish-manage/+video-manage/video-manage.resolver.ts
index 3bac9b2f30..c3a2a0415a 100644
--- a/client/src/app/+videos/+video-edit/video-update.resolver.ts
+++ b/client/src/app/+videos-publish-manage/+video-manage/video-manage.resolver.ts
@@ -1,45 +1,74 @@
-import { forkJoin, of } from 'rxjs'
-import { map, switchMap } from 'rxjs/operators'
import { Injectable, inject } from '@angular/core'
import { ActivatedRouteSnapshot } from '@angular/router'
-import { AuthService } from '@app/core'
+import { AuthService, ServerService, UserService } from '@app/core'
import { listUserChannelsForSelect } from '@app/helpers'
-import { VideoPrivacy } from '@peertube/peertube-models'
-import { VideoService } from '@app/shared/shared-main/video/video.service'
-import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
import { VideoChapterService } from '@app/shared/shared-main/video/video-chapter.service'
+import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
import { VideoPasswordService } from '@app/shared/shared-main/video/video-password.service'
+import { VideoService } from '@app/shared/shared-main/video/video.service'
import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
+import {
+ LiveVideo,
+ UserVideoQuota,
+ VideoCaption,
+ VideoChapter,
+ VideoConstant,
+ VideoPassword,
+ VideoPrivacy,
+ VideoPrivacyType,
+ VideoSource
+} from '@peertube/peertube-models'
+import { forkJoin, of } from 'rxjs'
+import { map, switchMap } from 'rxjs/operators'
+import { SelectChannelItem } from '../../../types'
+
+export type VideoManageResolverData = {
+ video: VideoDetails
+ videoSource: VideoSource
+ userChannels: SelectChannelItem[]
+ captions: VideoCaption[]
+ chapters: VideoChapter[]
+ live: LiveVideo
+ videoPasswords: VideoPassword[]
+ userQuota: UserVideoQuota
+ privacies: VideoConstant<VideoPrivacyType>[]
+}
@Injectable()
-export class VideoUpdateResolver {
+export class VideoManageResolver {
private videoService = inject(VideoService)
private liveVideoService = inject(LiveVideoService)
private authService = inject(AuthService)
private videoCaptionService = inject(VideoCaptionService)
private videoChapterService = inject(VideoChapterService)
private videoPasswordService = inject(VideoPasswordService)
+ private userService = inject(UserService)
+ private serverService = inject(ServerService)
resolve (route: ActivatedRouteSnapshot) {
const uuid: string = route.params['uuid']
return this.videoService.getVideo({ videoId: uuid })
.pipe(
- switchMap(video => forkJoin(this.buildVideoObservables(video))),
- map(([ video, videoSource, videoChannels, videoCaptions, videoChapters, liveVideo, videoPassword ]) => ({
- video,
- videoChannels,
- videoCaptions,
- videoChapters,
- videoSource,
- liveVideo,
- videoPassword
- }))
+ switchMap(video => forkJoin(this.buildObservables(video))),
+ map(([ video, videoSource, userChannels, captions, chapters, live, videoPasswords, userQuota, privacies ]) =>
+ ({
+ video,
+ userChannels,
+ captions,
+ chapters,
+ videoSource,
+ live,
+ videoPasswords,
+ userQuota,
+ privacies
+ }) as VideoManageResolverData
+ )
)
}
- private buildVideoObservables (video: VideoDetails) {
+ private buildObservables (video: VideoDetails) {
return [
of(video),
@@ -65,7 +94,11 @@ export class VideoUpdateResolver {
video.privacy.id === VideoPrivacy.PASSWORD_PROTECTED
? this.videoPasswordService.getVideoPasswords({ videoUUID: video.uuid })
- : of(undefined)
+ : of([]),
+
+ this.userService.getMyVideoQuotaUsed(),
+
+ this.serverService.getVideoPrivacies()
]
}
}
diff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.html b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.html
new file mode 100644
index 0000000000..54d8029f4e
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.html
@@ -0,0 +1,47 @@
+@if (firstStep) {
+ <div class="upload-video-container" myDragDrop (fileDropped)="setTorrentFile($event)">
+ <div class="first-step-block">
+ <my-global-icon class="upload-icon" iconName="upload" aria-hidden="true"></my-global-icon>
+
+ <div class="button-file primary-button form-control" [ngbTooltip]="'(extensions: .torrent)'">
+ <span i18n>Select the torrent to import</span>
+ <input
+ aria-label="Select the torrent to import" i18n-aria-label
+ #torrentfileInput type="file" name="torrentfile" id="torrentfile" accept=".torrent" (change)="fileChange()"
+ />
+ </div>
+
+ <div class="torrent-or-magnet" i18n-data-content data-content="OR"></div>
+
+ <div class="form-group form-group-magnet-uri">
+ <label i18n for="magnetUri">Paste magnet URI</label>
+ <my-help>
+ <ng-template ptTemplate="customHtml">
+ <ng-container i18n>
+ You can import any torrent file that points to a media file.
+ You should make sure you have diffusion rights over the content it points to, otherwise it could cause legal trouble to yourself and your instance.
+ </ng-container>
+ </ng-template>
+ </my-help>
+
+ <input type="text" id="magnetUri" [(ngModel)]="firstStepMagnetUri" class="form-control" />
+ </div>
+
+ <div class="form-group">
+ <label i18n for="first-step-channel">Channel</label>
+ <my-select-channel inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel>
+ </div>
+
+ <input
+ type="button" i18n-value value="Import" class="peertube-button primary-button"
+ [disabled]="!isMagnetUrlValid() || isImportingVideo" (click)="importVideo()"
+ />
+ </div>
+ </div>
+} @else {
+ <my-video-manage-container canUpdate="true" canWatch="false" cancelLink="/my-library/videos" (videoUpdated)="onVideoUpdated()">
+ <my-alert type="primary" i18n>
+ Congratulations, the video will be imported with BitTorrent! You can already add information about this video.
+ </my-alert>
+ </my-video-manage-container>
+}
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.scss b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.scss
rename to client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.scss
diff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts
new file mode 100644
index 0000000000..c80350d66d
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts
@@ -0,0 +1,166 @@
+import { AfterViewInit, Component, ElementRef, OnInit, inject, input, output, viewChild } from '@angular/core'
+import { FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { ActivatedRoute } from '@angular/router'
+import { VideoEdit } from '@app/+videos-publish-manage/shared-manage/common/video-edit.model'
+import { VideoManageController } from '@app/+videos-publish-manage/shared-manage/video-manage-controller.service'
+import { CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
+import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
+import { VideoImportService } from '@app/shared/shared-main/video/video-import.service'
+import { VideoService } from '@app/shared/shared-main/video/video.service'
+import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
+import { LoadingBarService } from '@ngx-loading-bar/core'
+import { PeerTubeProblemDocument, ServerErrorCode, UserVideoQuota, VideoPrivacyType } from '@peertube/peertube-models'
+import debug from 'debug'
+import { switchMap } from 'rxjs'
+import { SelectChannelItem } from 'src/types'
+import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { HelpComponent } from '../../../shared/shared-main/buttons/help.component'
+import { PeerTubeTemplateDirective } from '../../../shared/shared-main/common/peertube-template.directive'
+import { VideoManageContainerComponent } from '../../shared-manage/video-manage-container.component'
+import { DragDropDirective } from '../shared/drag-drop.directive'
+
+const debugLogger = debug('peertube:video-publish')
+
+@Component({
+ selector: 'my-video-import-torrent',
+ templateUrl: './video-import-torrent.component.html',
+ styleUrls: [
+ '../shared/common-publish.scss',
+ './video-import-torrent.component.scss'
+ ],
+ imports: [
+ GlobalIconComponent,
+ NgbTooltip,
+ HelpComponent,
+ PeerTubeTemplateDirective,
+ FormsModule,
+ DragDropDirective,
+ SelectChannelComponent,
+ ReactiveFormsModule,
+ AlertComponent,
+ VideoManageContainerComponent
+ ]
+})
+export class VideoImportTorrentComponent implements OnInit, AfterViewInit, CanComponentDeactivate {
+ private loadingBar = inject(LoadingBarService)
+ private notifier = inject(Notifier)
+ private videoService = inject(VideoService)
+ private videoImportService = inject(VideoImportService)
+ private hooks = inject(HooksService)
+ private serverService = inject(ServerService)
+ private manageController = inject(VideoManageController)
+ private route = inject(ActivatedRoute)
+
+ readonly userChannels = input.required<SelectChannelItem[]>()
+ readonly userQuota = input.required<UserVideoQuota>()
+ readonly highestPrivacy = input.required<VideoPrivacyType>()
+
+ readonly firstStepDone = output<string>()
+ readonly firstStepError = output()
+
+ readonly torrentfileInput = viewChild<ElementRef<HTMLInputElement>>('torrentfileInput')
+
+ firstStep = true
+ firstStepChannelId: number
+ firstStepMagnetUri = ''
+
+ isImportingVideo = false
+
+ ngOnInit (): void {
+ this.firstStepChannelId = this.userChannels()[0].id
+ }
+
+ ngAfterViewInit () {
+ this.hooks.runAction('action:video-torrent-import.init', 'video-edit')
+ }
+
+ canDeactivate () {
+ if (this.firstStep) return { canDeactivate: true }
+
+ let text = ''
+
+ if (this.manageController.hasPendingChanges()) {
+ text = $localize`Your video is being imported. But there are unsaved changes: are you sure you want to leave this page?`
+ }
+
+ return { canDeactivate: !text, text }
+ }
+
+ onVideoUpdated () {
+ this.notifier.success($localize`Changes saved.`)
+ }
+
+ reset () {
+ this.firstStep = true
+ this.isImportingVideo = false
+ this.firstStepMagnetUri = ''
+ }
+
+ isMagnetUrlValid () {
+ return !!this.firstStepMagnetUri
+ }
+
+ fileChange () {
+ const torrentfile = this.torrentfileInput().nativeElement.files[0]
+ if (!torrentfile) return
+
+ this.importVideo(torrentfile)
+ }
+
+ setTorrentFile (files: FileList) {
+ this.torrentfileInput().nativeElement.files = files
+ this.fileChange()
+ }
+
+ importVideo (torrentfile?: Blob) {
+ if (this.isImportingVideo) return
+ this.isImportingVideo = true
+
+ const serverConfig = this.serverService.getHTMLConfig()
+
+ const videoEdit = VideoEdit.createFromImport(serverConfig, {
+ torrentfile,
+ magnetUri: this.firstStepMagnetUri,
+ channelId: this.firstStepChannelId,
+ support: this.userChannels().find(c => c.id === this.firstStepChannelId).support ?? ''
+ })
+ this.manageController.setConfig({ manageType: 'import-torrent', serverConfig: this.serverService.getHTMLConfig() })
+ this.manageController.setVideoEdit(videoEdit)
+
+ this.loadingBar.useRef().start()
+
+ this.videoImportService.importVideo(videoEdit.toVideoImportCreate(this.highestPrivacy()))
+ .pipe(switchMap(({ video }) => this.videoService.getVideo({ videoId: video.uuid })))
+ .subscribe({
+ next: async video => {
+ await videoEdit.loadFromAPI({ video })
+
+ this.loadingBar.useRef().complete()
+
+ debugLogger(`Torrent/magnet import created`)
+
+ this.manageController.silentRedirectOnManage(videoEdit.getVideoAttributes().shortUUID, this.route)
+
+ this.firstStep = false
+ this.isImportingVideo = false
+ this.firstStepDone.emit(videoEdit.getVideoAttributes().name)
+ },
+
+ error: err => {
+ this.loadingBar.useRef().complete()
+ this.firstStepError.emit()
+
+ let message = err.message
+ const error = err.body as PeerTubeProblemDocument
+
+ if (error?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) {
+ message = $localize`Torrents with only 1 file are supported.`
+ }
+
+ this.notifier.error(message)
+ this.isImportingVideo = false
+ }
+ })
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.html b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.html
new file mode 100644
index 0000000000..839d4c182c
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.html
@@ -0,0 +1,45 @@
+@if (firstStep) {
+ <div class="upload-video-container">
+ <div class="first-step-block">
+ <my-global-icon class="upload-icon" iconName="upload" aria-hidden="true"></my-global-icon>
+
+ <div class="form-group">
+ <label i18n for="targetUrl">URL</label>
+
+ <my-help>
+ <ng-template ptTemplate="customHtml">
+ <ng-container i18n>
+ You can import any URL <a href='https://rg3.github.io/youtube-dl/supportedsites.html' target='_blank' rel='noopener noreferrer'>supported by youtube-dl</a>
+ or URL that points to a media file.
+ You should make sure you have diffusion rights over the content it points to, otherwise it could cause legal trouble to yourself and your instance.
+ </ng-container>
+ </ng-template>
+ </my-help>
+
+ <input type="text" id="targetUrl" [(ngModel)]="targetUrl" class="form-control" />
+
+ <div *ngIf="isChannelSyncEnabled()" class="form-group-description" i18n>
+ You can also synchronize a remote channel in <a class="text-decoration-underline" routerLink="/my-library/video-channel-syncs">your library</a>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label i18n for="first-step-channel">Channel</label>
+ <my-select-channel inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel>
+ </div>
+
+ <input
+ type="button" i18n-value value="Import" class="peertube-button primary-button"
+ [disabled]="!isTargetUrlValid() || isImportingVideo" (click)="importVideo()"
+ />
+ </div>
+ </div>
+} @else {
+ <my-video-manage-container canUpdate="true" canWatch="false" cancelLink="/my-library/videos" (videoUpdated)="onVideoUpdated()">
+ <my-alert type="primary" i18n>
+ Congratulations, the video behind {{ targetUrl }} is being imported! You can already add information about this video.
+ </my-alert>
+ </my-video-manage-container>
+}
+
+
diff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts
new file mode 100644
index 0000000000..acb396f489
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts
@@ -0,0 +1,156 @@
+import { NgIf } from '@angular/common'
+import { AfterViewInit, Component, OnInit, inject, input, output } from '@angular/core'
+import { FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { ActivatedRoute, RouterLink } from '@angular/router'
+import { VideoEdit } from '@app/+videos-publish-manage/shared-manage/common/video-edit.model'
+import { VideoManageController } from '@app/+videos-publish-manage/shared-manage/video-manage-controller.service'
+import { CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
+import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
+import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
+import { VideoChapterService } from '@app/shared/shared-main/video/video-chapter.service'
+import { VideoImportService } from '@app/shared/shared-main/video/video-import.service'
+import { VideoService } from '@app/shared/shared-main/video/video.service'
+import { LoadingBarService } from '@ngx-loading-bar/core'
+import { UserVideoQuota, VideoPrivacyType } from '@peertube/peertube-models'
+import debug from 'debug'
+import { forkJoin } from 'rxjs'
+import { map, switchMap } from 'rxjs/operators'
+import { SelectChannelItem } from 'src/types'
+import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { HelpComponent } from '../../../shared/shared-main/buttons/help.component'
+import { PeerTubeTemplateDirective } from '../../../shared/shared-main/common/peertube-template.directive'
+import { VideoManageContainerComponent } from '../../shared-manage/video-manage-container.component'
+
+const debugLogger = debug('peertube:video-publish')
+
+@Component({
+ selector: 'my-video-import-url',
+ templateUrl: './video-import-url.component.html',
+ styleUrls: [ '../shared/common-publish.scss' ],
+ imports: [
+ NgIf,
+ GlobalIconComponent,
+ HelpComponent,
+ PeerTubeTemplateDirective,
+ FormsModule,
+ RouterLink,
+ SelectChannelComponent,
+ ReactiveFormsModule,
+ AlertComponent,
+ VideoManageContainerComponent
+ ]
+})
+export class VideoImportUrlComponent implements OnInit, AfterViewInit, CanComponentDeactivate {
+ private loadingBar = inject(LoadingBarService)
+ private notifier = inject(Notifier)
+ private videoService = inject(VideoService)
+ private videoImportService = inject(VideoImportService)
+ private hooks = inject(HooksService)
+ private serverService = inject(ServerService)
+ private manageController = inject(VideoManageController)
+ private route = inject(ActivatedRoute)
+ private chapterService = inject(VideoChapterService)
+ private captionService = inject(VideoCaptionService)
+
+ readonly userChannels = input.required<SelectChannelItem[]>()
+ readonly userQuota = input.required<UserVideoQuota>()
+ readonly highestPrivacy = input.required<VideoPrivacyType>()
+
+ readonly firstStepDone = output<string>()
+ readonly firstStepError = output()
+
+ targetUrl = ''
+
+ firstStep = true
+ firstStepChannelId: number
+
+ isImportingVideo = false
+
+ ngOnInit () {
+ this.firstStepChannelId = this.userChannels()[0].id
+ }
+
+ ngAfterViewInit () {
+ this.hooks.runAction('action:video-url-import.init', 'video-edit')
+ }
+
+ canDeactivate () {
+ if (this.firstStep) return { canDeactivate: true }
+
+ let text = ''
+
+ if (this.manageController.hasPendingChanges()) {
+ text = $localize`Your video is being imported. But there are unsaved changes: are you sure you want to leave this page?`
+ }
+
+ return { canDeactivate: !text, text }
+ }
+
+ onVideoUpdated () {
+ this.notifier.success($localize`Changes saved.`)
+ }
+
+ reset () {
+ this.firstStep = true
+ this.isImportingVideo = false
+ }
+
+ isTargetUrlValid () {
+ return this.targetUrl?.match(/https?:\/\//)
+ }
+
+ isChannelSyncEnabled () {
+ return this.serverService.getHTMLConfig().import.videoChannelSynchronization.enabled
+ }
+
+ importVideo () {
+ if (this.isImportingVideo) return
+ this.isImportingVideo = true
+
+ const serverConfig = this.serverService.getHTMLConfig()
+
+ const videoEdit = VideoEdit.createFromImport(serverConfig, {
+ targetUrl: this.targetUrl,
+ channelId: this.firstStepChannelId,
+ support: this.userChannels().find(c => c.id === this.firstStepChannelId).support ?? ''
+ })
+ this.manageController.setConfig({ manageType: 'import-url', serverConfig: this.serverService.getHTMLConfig() })
+ this.manageController.setVideoEdit(videoEdit)
+
+ this.loadingBar.useRef().start()
+
+ this.videoImportService.importVideo(videoEdit.toVideoImportCreate(this.highestPrivacy()))
+ .pipe(
+ switchMap(previous => {
+ return forkJoin([
+ this.captionService.listCaptions(previous.video.uuid),
+ this.chapterService.getChapters({ videoId: previous.video.uuid }),
+ this.videoService.getVideo({ videoId: previous.video.uuid })
+ ]).pipe(map(([ { data: captions }, { chapters }, video ]) => ({ captions, chapters, video })))
+ })
+ )
+ .subscribe({
+ next: async ({ video, captions, chapters }) => {
+ await videoEdit.loadFromAPI({ video, captions, chapters })
+
+ this.loadingBar.useRef().complete()
+
+ debugLogger(`URL import created`)
+
+ this.manageController.silentRedirectOnManage(videoEdit.getVideoAttributes().shortUUID, this.route)
+
+ this.firstStep = false
+ this.isImportingVideo = false
+ this.firstStepDone.emit(videoEdit.getVideoAttributes().name)
+ },
+
+ error: err => {
+ this.loadingBar.useRef().complete()
+ this.isImportingVideo = false
+ this.firstStepError.emit()
+ this.notifier.error(err.message)
+ }
+ })
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.html b/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.html
new file mode 100644
index 0000000000..2c2987afbf
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.html
@@ -0,0 +1,37 @@
+@if (firstStep) {
+ <div class="upload-video-container">
+ <div class="first-step-block">
+ <my-global-icon class="upload-icon" iconName="upload" aria-hidden="true"></my-global-icon>
+
+ <div class="form-group">
+ <label i18n for="first-step-channel">Channel</label>
+ <my-select-channel inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel>
+ </div>
+
+ <div class="form-group live-type">
+ <div class="peertube-radio-container">
+ <input type="radio" id="permanentLiveFalse" [(ngModel)]="firstStepPermanentLive" [value]="false">
+ <label i18n for="permanentLiveFalse" class="radio">Normal live</label>
+
+ <span class="form-group-description">{{ getNormalLiveDescription() }}</span>
+ </div>
+
+ <div class="peertube-radio-container">
+ <input type="radio" id="permanentLiveTrue" [(ngModel)]="firstStepPermanentLive" [value]="true">
+ <label i18n for="permanentLiveTrue" class="radio">Permanent/recurring live</label>
+
+ <span class="form-group-description" i18n>{{ getPermanentLiveDescription() }}</span>
+ </div>
+ </div>
+
+ <input
+ class="peertube-button primary-button"
+ [disabled]="firstStepPermanentLive !== true && firstStepPermanentLive !== false"
+ type="button" i18n-value value="Go Live" (click)="goLive()"
+ />
+ </div>
+ </div>
+} @else {
+ <my-video-manage-container canUpdate="true" canWatch="true" cancelLink="/my-library/videos" (videoUpdated)="onVideoUpdated()">
+ </my-video-manage-container>
+}
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.scss b/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.scss
rename to client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.scss
diff --git a/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.ts b/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.ts
new file mode 100644
index 0000000000..03e3243d8e
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.ts
@@ -0,0 +1,159 @@
+import { AfterViewInit, Component, OnInit, inject, input, output } from '@angular/core'
+import { FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { ActivatedRoute } from '@angular/router'
+import { VideoEdit } from '@app/+videos-publish-manage/shared-manage/common/video-edit.model'
+import { VideoManageController } from '@app/+videos-publish-manage/shared-manage/video-manage-controller.service'
+import { CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
+import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
+import { LiveVideoLatencyMode, PeerTubeProblemDocument, ServerErrorCode, UserVideoQuota, VideoPrivacyType } from '@peertube/peertube-models'
+import debug from 'debug'
+import { map, switchMap } from 'rxjs'
+import { SelectChannelItem } from 'src/types'
+import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { VideoManageContainerComponent } from '../../shared-manage/video-manage-container.component'
+
+const debugLogger = debug('peertube:video-publish')
+
+@Component({
+ selector: 'my-video-go-live',
+ templateUrl: './video-go-live.component.html',
+ styleUrls: [
+ '../shared/common-publish.scss',
+ './video-go-live.component.scss'
+ ],
+ imports: [
+ GlobalIconComponent,
+ SelectChannelComponent,
+ FormsModule,
+ ReactiveFormsModule,
+ VideoManageContainerComponent
+ ]
+})
+export class VideoGoLiveComponent implements OnInit, AfterViewInit, CanComponentDeactivate {
+ private notifier = inject(Notifier)
+ private serverService = inject(ServerService)
+ private liveVideoService = inject(LiveVideoService)
+ private hooks = inject(HooksService)
+ private manageController = inject(VideoManageController)
+ private route = inject(ActivatedRoute)
+
+ readonly userChannels = input.required<SelectChannelItem[]>()
+ readonly userQuota = input.required<UserVideoQuota>()
+ readonly highestPrivacy = input.required<VideoPrivacyType>()
+
+ readonly firstStepDone = output<string>()
+ readonly firstStepError = output()
+
+ firstStep = true
+ firstStepChannelId: number
+ firstStepPermanentLive: boolean
+
+ private isGoingLive = false
+
+ ngOnInit () {
+ this.firstStepChannelId = this.userChannels()[0].id
+ }
+
+ ngAfterViewInit () {
+ this.hooks.runAction('action:go-live.init', 'video-edit')
+ }
+
+ canDeactivate () {
+ if (this.firstStep) return { canDeactivate: true }
+
+ let text = ''
+
+ if (this.manageController.hasPendingChanges()) {
+ text = $localize`Your live is waiting in your library. But there are unsaved changes: are you sure you want to leave this page?`
+ }
+
+ return { canDeactivate: !text, text }
+ }
+
+ reset () {
+ this.firstStep = true
+ this.isGoingLive = false
+ }
+
+ goLive () {
+ if (this.isGoingLive) return
+ this.isGoingLive = true
+
+ const serverConfig = this.serverService.getHTMLConfig()
+
+ const videoEdit = VideoEdit.createFromLive(serverConfig, {
+ name: $localize`Live`,
+ channelId: this.firstStepChannelId,
+ support: this.userChannels().find(c => c.id === this.firstStepChannelId).support ?? '',
+ permanentLive: this.firstStepPermanentLive,
+ latencyMode: LiveVideoLatencyMode.DEFAULT,
+ saveReplay: this.isReplayAllowed(),
+ replaySettings: { privacy: this.highestPrivacy() }
+ })
+ this.manageController.setConfig({ manageType: 'go-live', serverConfig: this.serverService.getHTMLConfig() })
+ this.manageController.setVideoEdit(videoEdit)
+
+ this.liveVideoService.goLive(videoEdit.toLiveCreate(this.highestPrivacy()))
+ .pipe(
+ switchMap(({ video }) => {
+ return this.liveVideoService.getVideoLive(video.uuid)
+ .pipe(map(live => ({ live, video })))
+ })
+ )
+ .subscribe({
+ next: async ({ video: { id, uuid, shortUUID }, live }) => {
+ videoEdit.loadAfterPublish({ video: { id, uuid, shortUUID } })
+ await videoEdit.loadFromAPI({ live })
+
+ debugLogger(`Live published`)
+
+ this.manageController.silentRedirectOnManage(shortUUID, this.route)
+
+ this.firstStep = false
+ this.isGoingLive = false
+ this.firstStepDone.emit(videoEdit.getVideoAttributes().name)
+ },
+
+ error: err => {
+ this.firstStepError.emit()
+
+ let message = err.message
+ const error = err.body as PeerTubeProblemDocument
+
+ if (error?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) {
+ message = $localize`Cannot create live because this platform have too many created lives`
+ } else if (error?.code === ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED) {
+ message = $localize`Cannot create live because you created too many lives`
+ }
+
+ this.notifier.error(message)
+ this.isGoingLive = false
+ }
+ })
+ }
+
+ onVideoUpdated () {
+ this.notifier.success($localize`Changes saved.`)
+ }
+
+ getNormalLiveDescription () {
+ if (this.isReplayAllowed()) {
+ return $localize`Stream only once, replay will replace your live`
+ }
+
+ return $localize`Stream only once`
+ }
+
+ getPermanentLiveDescription () {
+ if (this.isReplayAllowed()) {
+ return $localize`Stream multiple times, replays will be separate videos`
+ }
+
+ return $localize`Stream multiple times using the same URL`
+ }
+
+ private isReplayAllowed () {
+ return this.serverService.getHTMLConfig().live.allowReplay
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/+video-publish/routes.ts b/client/src/app/+videos-publish-manage/+video-publish/routes.ts
new file mode 100644
index 0000000000..054ca02453
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-publish/routes.ts
@@ -0,0 +1,55 @@
+import { RedirectCommand, Router, Routes } from '@angular/router'
+import { CanDeactivateGuard, LoginGuard } from '@app/core'
+import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
+import { I18nPrimengCalendarService } from '../shared-manage/common/i18n-primeng-calendar.service'
+import { VideoUploadService } from '../shared-manage/common/video-upload.service'
+import { manageRoutes } from '../shared-manage/routes'
+import { VideoStudioService } from '../shared-manage/studio/video-studio.service'
+import { VideoManageController } from '../shared-manage/video-manage-controller.service'
+import { VideoPublishComponent } from './video-publish.component'
+import { VideoPublishResolver } from './video-publish.resolver'
+import { inject } from '@angular/core'
+import debug from 'debug'
+
+const debugLogger = debug('peertube:video-publish')
+
+export default [
+ {
+ path: '',
+ component: VideoPublishComponent,
+ canActivate: [
+ LoginGuard,
+
+ () => {
+ const publishedId = new URLSearchParams(window.location.search).get('publishedId')
+ const router = inject(Router)
+
+ if (publishedId) {
+ const match = window.location.pathname.match(/^\/videos\/publish\/(.*)$/)
+ const suffixUrl = match
+ ? `/${match[1]}`
+ : ''
+
+ debugLogger('Redirecting to video manage page', { publishedId, match, suffixUrl })
+
+ return new RedirectCommand(router.parseUrl(`/videos/manage/${publishedId}${suffixUrl}`))
+ }
+
+ return true
+ }
+ ],
+ canDeactivate: [ CanDeactivateGuard ],
+ providers: [
+ VideoPublishResolver,
+ VideoManageController,
+ LiveVideoService,
+ I18nPrimengCalendarService,
+ VideoUploadService,
+ VideoStudioService
+ ],
+ resolve: {
+ resolverData: VideoPublishResolver
+ },
+ children: manageRoutes
+ }
+] satisfies Routes
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-send.scss b/client/src/app/+videos-publish-manage/+video-publish/shared/common-publish.scss
similarity index 100%
rename from client/src/app/+videos/+video-edit/video-add-components/video-send.scss
rename to client/src/app/+videos-publish-manage/+video-publish/shared/common-publish.scss
diff --git a/client/src/app/+videos/+video-edit/video-add-components/drag-drop.directive.ts b/client/src/app/+videos-publish-manage/+video-publish/shared/drag-drop.directive.ts
similarity index 100%
rename from client/src/app/+videos/+video-edit/video-add-components/drag-drop.directive.ts
rename to client/src/app/+videos-publish-manage/+video-publish/shared/drag-drop.directive.ts
diff --git a/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.html b/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.html
new file mode 100644
index 0000000000..44602bbb89
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.html
@@ -0,0 +1,55 @@
+@if (firstStep) {
+ <div class="upload-video-container" myDragDrop (fileDropped)="onFileDropped($event)">
+ <div class="first-step-block">
+ <my-global-icon class="upload-icon" iconName="upload" aria-hidden="true"></my-global-icon>
+
+ <div class="button-file primary-button form-control" [ngbTooltip]="'(extensions: ' + getVideoExtensions() + ')'">
+ <span i18n>Select the file to upload</span>
+ <input
+ aria-label="Select the file to upload"
+ i18n-aria-label
+ #videoFileInput
+ [accept]="getVideoExtensions()"
+ (change)="onFileChange($event)"
+ id="videofile"
+ type="file"
+ />
+ </div>
+
+ <div class="form-group form-group-channel">
+ <label i18n for="first-step-channel">Channel</label>
+ <my-select-channel inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel>
+ </div>
+
+ <ng-container *ngIf="uploadingAudioFile">
+ <div class="form-group audio-preview">
+ <label i18n for="previewfileUpload">Video background image</label>
+
+ <div i18n class="audio-image-info">
+ Image that will be merged with your audio file.
+ <br />
+ The chosen image will be definitive and cannot be modified.
+ </div>
+
+ <my-preview-upload
+ i18n-inputLabel inputLabel="Edit" inputName="previewfileUpload" [(ngModel)]="audioPreviewFile"
+ previewWidth="360px" previewHeight="200px"
+ ></my-preview-upload>
+ </div>
+
+ <div class="form-group upload-audio-button">
+ <my-button theme="primary" [label]="getAudioUploadLabel()" icon="upload" (click)="uploadAudio()"></my-button>
+ </div>
+ </ng-container>
+ </div>
+ </div>
+} @else {
+ <my-video-manage-container
+ [canUpdate]="hasUploadedFile()" [canWatch]="hasUploadedFile()"
+ (videoUpdated)="onVideoUpdated()" [cancelLink]="getCancelLink()"
+ >
+ @if (hasUploadedFile() && !getUploadError()) {
+ <my-alert type="primary" i18n>Congratulations! Your video is now available in your private library.</my-alert>
+ }
+ </my-video-manage-container>
+}
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.scss b/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-edit/video-add-components/video-upload.component.scss
rename to client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.scss
diff --git a/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.ts b/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.ts
new file mode 100644
index 0000000000..846bc5dfe8
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.ts
@@ -0,0 +1,250 @@
+import { NgIf } from '@angular/common'
+import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, inject, input, output, viewChild } from '@angular/core'
+import { FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { ActivatedRoute, Router } from '@angular/router'
+import { VideoEdit } from '@app/+videos-publish-manage/shared-manage/common/video-edit.model'
+import { VideoUploadService } from '@app/+videos-publish-manage/shared-manage/common/video-upload.service'
+import { VideoManageController } from '@app/+videos-publish-manage/shared-manage/video-manage-controller.service'
+import { CanComponentDeactivate, CanDeactivateGuard, HooksService, MetaService, Notifier, ServerService } from '@app/core'
+import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
+import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
+import { UserVideoQuota, VideoPrivacyType } from '@peertube/peertube-models'
+import debug from 'debug'
+import { truncate } from 'lodash-es'
+import { Subscription } from 'rxjs'
+import { SelectChannelItem } from 'src/types'
+import { PreviewUploadComponent } from '../../../shared/shared-forms/preview-upload.component'
+import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'
+import { VideoManageContainerComponent } from '../../shared-manage/video-manage-container.component'
+import { DragDropDirective } from '../shared/drag-drop.directive'
+
+const debugLogger = debug('peertube:video-publish')
+
+@Component({
+ selector: 'my-video-upload',
+ templateUrl: './video-upload.component.html',
+ styleUrls: [
+ '../shared/common-publish.scss',
+ './video-upload.component.scss'
+ ],
+ imports: [
+ NgIf,
+ DragDropDirective,
+ GlobalIconComponent,
+ NgbTooltip,
+ SelectChannelComponent,
+ FormsModule,
+ PreviewUploadComponent,
+ ButtonComponent,
+ ReactiveFormsModule,
+ AlertComponent,
+ VideoManageContainerComponent
+ ]
+})
+export class VideoUploadComponent implements OnInit, OnDestroy, AfterViewInit, CanComponentDeactivate {
+ private notifier = inject(Notifier)
+ private serverService = inject(ServerService)
+ private hooks = inject(HooksService)
+ private metaService = inject(MetaService)
+ private route = inject(ActivatedRoute)
+ private videoUploadService = inject(VideoUploadService)
+ private manageController = inject(VideoManageController)
+ private router = inject(Router)
+ private canDeactivateGuard = inject(CanDeactivateGuard)
+
+ readonly userChannels = input.required<SelectChannelItem[]>()
+ readonly userQuota = input.required<UserVideoQuota>()
+ readonly highestPrivacy = input.required<VideoPrivacyType>()
+
+ readonly firstStepDone = output<string>()
+ readonly firstStepError = output()
+ readonly videoFileInput = viewChild<ElementRef<HTMLInputElement>>('videoFileInput')
+
+ uploadingAudioFile = false
+ audioPreviewFile: File
+
+ firstStep = true
+ firstStepChannelId: number
+
+ hasFirstUpdated = false
+
+ private videoEdit: VideoEdit
+ private uploadEventsSubscription: Subscription
+
+ ngOnInit () {
+ this.uploadEventsSubscription = this.manageController.getUploadEventsObs()
+ .subscribe(state => {
+ if (state.status === 'cancelled') {
+ debugLogger('Upload cancelled', state)
+
+ this.firstStepError.emit()
+ this.firstStep = true
+ this.manageController.silentRedirectOnAbortUpload(this.route)
+
+ return
+ }
+
+ if (state.status === 'complete') {
+ const { id, uuid, shortUUID } = state.response.video
+
+ this.videoEdit.loadAfterPublish({ video: { id, uuid, shortUUID } })
+
+ debugLogger(`Upload complete`, state)
+
+ this.manageController.silentRedirectOnManage(shortUUID, this.route)
+ return
+ }
+
+ this.updateTitle()
+ })
+
+ this.firstStepChannelId = this.userChannels()[0].id
+ }
+
+ ngAfterViewInit () {
+ this.hooks.runAction('action:video-upload.init', 'video-edit')
+ }
+
+ ngOnDestroy () {
+ this.uploadEventsSubscription?.unsubscribe()
+ this.manageController.cancelUploadIfNeeded()
+ }
+
+ canDeactivate () {
+ if (this.firstStep) return { canDeactivate: true }
+
+ let text = ''
+
+ if (this.hasUploadedFile() !== true) {
+ text = $localize`Your video is not uploaded yet, are you sure you want to leave this page?`
+ } else if (this.manageController.hasPendingChanges()) {
+ text = $localize`Your video was uploaded to your library. But there are unsaved changes: are you sure you want to leave this page?`
+ }
+
+ return { canDeactivate: !text, text }
+ }
+
+ updateTitle () {
+ if (this.hasUploadedFile()) {
+ this.metaService.setTitle($localize`Publish`)
+ } else if (this.uploadingAudioFile || !this.firstStep) {
+ this.metaService.setTitle(`${this.manageController.getUploadPercents()}% - Publish`)
+ } else {
+ this.metaService.update(this.route.snapshot.data['meta'])
+ }
+ }
+
+ getVideoExtensions () {
+ return this.videoUploadService.getVideoExtensions().join(', ')
+ }
+
+ onFileDropped (files: FileList) {
+ const videoFileInput = this.videoFileInput()
+ videoFileInput.nativeElement.files = files
+
+ this.onFileChange({ target: videoFileInput.nativeElement })
+ }
+
+ onFileChange (event: Event | { target: HTMLInputElement }) {
+ this.resetUploadState()
+
+ const file = (event.target as HTMLInputElement).files[0]
+ if (!file) return
+
+ if (!this.manageController.checkUserQuota(file)) return
+
+ if (this.videoUploadService.isAudioFile(file.name)) {
+ this.uploadingAudioFile = true
+ return
+ }
+
+ this.firstStep = false
+
+ this.uploadFile(file)
+ }
+
+ private resetUploadState () {
+ this.firstStep = true
+ this.videoEdit = undefined
+ this.uploadingAudioFile = false
+ }
+
+ uploadAudio () {
+ this.uploadFile(this.getInputVideoFile(), this.audioPreviewFile)
+ }
+
+ getAudioUploadLabel () {
+ const videoFile = this.getInputVideoFile()
+ if (!videoFile) return $localize`Upload`
+
+ return $localize`Upload ${videoFile.name}`
+ }
+
+ onVideoUpdated () {
+ this.notifier.success($localize`Changes saved.`)
+ }
+
+ getUploadError () {
+ return this.manageController.getUploadError()
+ }
+
+ hasUploadedFile () {
+ if (!this.videoEdit) return false
+
+ return !!this.videoEdit.getVideoAttributes().id
+ }
+
+ getCancelLink () {
+ if (this.hasUploadedFile()) {
+ return '/my-library/videos'
+ }
+
+ return '/videos/publish'
+ }
+
+ reset () {
+ this.resetUploadState()
+ this.manageController.cancelUploadIfNeeded()
+ this.updateTitle()
+ }
+
+ private getInputVideoFile () {
+ return this.videoFileInput().nativeElement.files[0]
+ }
+
+ private uploadFile (file: File, previewfile?: File) {
+ const serverConfig = this.serverService.getHTMLConfig()
+
+ this.videoEdit = VideoEdit.createFromUpload(serverConfig, {
+ name: this.buildVideoFilename(file.name),
+ channelId: this.firstStepChannelId,
+ support: this.userChannels().find(c => c.id === this.firstStepChannelId).support ?? ''
+ })
+
+ this.manageController.setConfig({ manageType: 'upload', serverConfig: this.serverService.getHTMLConfig() })
+ this.manageController.setVideoEdit(this.videoEdit)
+ this.manageController.uploadNewVideo({ privacy: this.highestPrivacy(), file, previewfile })
+ this.manageController.silentRedirectOnUploading(this.route)
+
+ this.firstStep = false
+ this.firstStepDone.emit(this.videoEdit.getVideoAttributes().name)
+
+ this.updateTitle()
+ }
+
+ private buildVideoFilename (filename: string) {
+ const nameWithoutExtension = filename.replace(/\.[^/.]+$/, '')
+ let name = nameWithoutExtension.length < 3
+ ? filename
+ : nameWithoutExtension
+
+ const videoNameMaxSize = 110
+ if (name.length > videoNameMaxSize) {
+ name = truncate(name, { length: videoNameMaxSize, omission: '' })
+ }
+
+ return name
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/+video-publish/video-publish.component.html b/client/src/app/+videos-publish-manage/+video-publish/video-publish.component.html
new file mode 100644
index 0000000000..ec5a6916c4
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-publish/video-publish.component.html
@@ -0,0 +1,114 @@
+<ng-template #helpButtons>
+ @if (isContactFormEnabled) {
+ <a i18n routerLink="/about/contact" class="peertube-button-link primary-button mt-3 me-3">Contact us</a>
+ }
+
+ <a i18n routerLink="/about/instance" class="peertube-button-link primary-button mt-3">Read instance rules for help</a>
+</ng-template>
+
+<ng-template #infoMessages>
+ @if (user.isAutoBlocked(serverConfig)) {
+ <my-alert class="upload-message auto-blocked" type="primary">
+ <div>{{ uploadMessages?.autoBlock }}</div>
+
+ <ng-template [ngTemplateOutlet]="helpButtons"></ng-template>
+ </my-alert>
+ }
+
+ @if (isRootUser()) {
+ <my-alert class="upload-message root-user root-user root-user" type="warning">
+ <div i18n>We recommend you to not use the <strong>root</strong> user to publish your videos, since it's the super-admin account of your instance.</div>
+
+ <div i18n>Instead, <a class="text-decoration-underline alert-link" routerLink="/admin/overview/users">create a dedicated account</a> to upload your videos.</div>
+ </my-alert>
+ } @else {
+ <my-channels-setup-message></my-channels-setup-message>
+ }
+
+ <my-user-quota></my-user-quota>
+
+ @if (hasNoQuotaLeft || hasNoQuotaLeftDaily) {
+ <my-alert class="upload-message quota-left" type="warning">
+ <div *ngIf="hasNoQuotaLeft">{{ uploadMessages?.quotaLeft }}</div>
+ <div *ngIf="hasNoQuotaLeftDaily">{{ uploadMessages?.quotaLeftDaily }}</div>
+
+ <ng-template [ngTemplateOutlet]="helpButtons"></ng-template>
+ </my-alert>
+ }
+</ng-template>
+
+@if (user.hasUploadDisabled()) {
+ <div class="margin-content">
+ <my-alert class="upload-message upload-disabled" type="warning">
+ <div>{{ uploadMessages?.noQuota }}</div>
+
+ <ng-template [ngTemplateOutlet]="helpButtons"></ng-template>
+ </my-alert>
+
+ <div class="upload-image">
+ <img src="/client/assets/images/mascot/defeated.svg" alt="defeated mascot">
+ </div>
+ </div>
+} @else {
+ <div class="margin-content">
+ @if (!isInSecondStep()) {
+ <ng-template [ngTemplateOutlet]="infoMessages"></ng-template>
+ }
+
+ <div ngbNav #nav="ngbNav" class="nav-tabs video-add-nav" [activeId]="activeNav" (activeIdChange)="onNavChange($event)" [ngClass]="{ 'hide-nav': isInSecondStep() }">
+ <ng-container ngbNavItem="upload">
+ <a ngbNavLink>
+ <span i18n>Upload a file</span>
+ </a>
+
+ <ng-template ngbNavContent>
+ <my-video-upload
+ #videoUpload (firstStepDone)="onFirstStepDone('upload', $event)" (firstStepError)="onError()"
+ [userChannels]="userChannels" [userQuota]="userQuota" [highestPrivacy]="highestPrivacy"
+ ></my-video-upload>
+ </ng-template>
+ </ng-container>
+
+ <ng-container ngbNavItem="import-url" *ngIf="isVideoImportHttpEnabled()">
+ <a ngbNavLink>
+ <span i18n>Import with URL</span>
+ </a>
+
+ <ng-template ngbNavContent>
+ <my-video-import-url
+ #videoImportUrl (firstStepDone)="onFirstStepDone('import-url', $event)" (firstStepError)="onError()"
+ [userChannels]="userChannels" [userQuota]="userQuota" [highestPrivacy]="highestPrivacy"
+ ></my-video-import-url>
+ </ng-template>
+ </ng-container>
+
+ <ng-container ngbNavItem="import-torrent" *ngIf="isVideoImportTorrentEnabled()">
+ <a ngbNavLink>
+ <span i18n>Import with torrent</span>
+ </a>
+
+ <ng-template ngbNavContent>
+ <my-video-import-torrent
+ #videoImportTorrent (firstStepDone)="onFirstStepDone('import-torrent', $event)" (firstStepError)="onError()"
+ [userChannels]="userChannels" [userQuota]="userQuota" [highestPrivacy]="highestPrivacy"
+ ></my-video-import-torrent>
+ </ng-template>
+ </ng-container>
+
+ <ng-container ngbNavItem="go-live" *ngIf="isVideoLiveEnabled()">
+ <a ngbNavLink>
+ <span i18n>Go live</span>
+ </a>
+
+ <ng-template ngbNavContent>
+ <my-video-go-live
+ #videoGoLive (firstStepDone)="onFirstStepDone('go-live', $event)" (firstStepError)="onError()"
+ [userChannels]="userChannels" [userQuota]="userQuota" [highestPrivacy]="highestPrivacy"
+ ></my-video-go-live>
+ </ng-template>
+ </ng-container>
+ </div>
+
+ <div class="nav-content" [ngbNavOutlet]="nav"></div>
+ </div>
+}
diff --git a/client/src/app/+videos/+video-edit/video-add.component.scss b/client/src/app/+videos-publish-manage/+video-publish/video-publish.component.scss
similarity index 92%
rename from client/src/app/+videos/+video-edit/video-add.component.scss
rename to client/src/app/+videos-publish-manage/+video-publish/video-publish.component.scss
index d49e626b6d..b32af6a1bb 100644
--- a/client/src/app/+videos/+video-edit/video-add.component.scss
+++ b/client/src/app/+videos-publish-manage/+video-publish/video-publish.component.scss
@@ -23,18 +23,11 @@ $nav-link-height: 40px;
text-align: center;
img {
- margin-top: 10px;
+ margin-top: 2rem;
margin-bottom: 75px;
width: 220px;
height: auto;
}
-
- @media screen and (max-height: 600px) {
- img {
- margin-top: 5px;
- width: 160px;
- }
- }
}
:host ::ng-deep .video-add-nav {
diff --git a/client/src/app/+videos/+video-edit/video-add.component.ts b/client/src/app/+videos-publish-manage/+video-publish/video-publish.component.ts
similarity index 54%
rename from client/src/app/+videos/+video-edit/video-add.component.ts
rename to client/src/app/+videos-publish-manage/+video-publish/video-publish.component.ts
index 432460643b..30b214610b 100644
--- a/client/src/app/+videos/+video-edit/video-add.component.ts
+++ b/client/src/app/+videos-publish-manage/+video-publish/video-publish.component.ts
@@ -5,25 +5,30 @@ import {
AuthService,
AuthUser,
CanComponentDeactivate,
+ CanDeactivateGuard,
HooksService,
- ServerService,
- UserService
+ PeerTubeRouterService,
+ ServerService
} from '@app/core'
import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
+import { VideoService } from '@app/shared/shared-main/video/video.service'
import { NgbNav, NgbNavContent, NgbNavItem, NgbNavLink, NgbNavLinkBase, NgbNavOutlet } from '@ng-bootstrap/ng-bootstrap'
-import { HTMLServerConfig } from '@peertube/peertube-models'
+import { HTMLServerConfig, UserVideoQuota, VideoConstant, VideoPrivacyType } from '@peertube/peertube-models'
+import { SelectChannelItem } from 'src/types'
import { ChannelsSetupMessageComponent } from '../../shared/shared-main/channel/channels-setup-message.component'
import { UserQuotaComponent } from '../../shared/shared-main/users/user-quota.component'
-import { VideoEditType } from './shared/video-edit.type'
-import { VideoGoLiveComponent } from './video-add-components/video-go-live.component'
-import { VideoImportTorrentComponent } from './video-add-components/video-import-torrent.component'
-import { VideoImportUrlComponent } from './video-add-components/video-import-url.component'
-import { VideoUploadComponent } from './video-add-components/video-upload.component'
+import { VideoManageType } from '../shared-manage/common/video-manage.type'
+import { VideoManageController } from '../shared-manage/video-manage-controller.service'
+import { VideoImportTorrentComponent } from './import/video-import-torrent.component'
+import { VideoImportUrlComponent } from './import/video-import-url.component'
+import { VideoGoLiveComponent } from './live/video-go-live.component'
+import { VideoUploadComponent } from './upload/video-upload.component'
+import { VideoPublishResolverData } from './video-publish.resolver'
@Component({
- selector: 'my-videos-add',
- templateUrl: './video-add.component.html',
- styleUrls: [ './video-add.component.scss' ],
+ selector: 'my-video-publish',
+ templateUrl: './video-publish.component.html',
+ styleUrls: [ './video-publish.component.scss' ],
imports: [
NgIf,
RouterLink,
@@ -36,21 +41,25 @@ import { VideoUploadComponent } from './video-add-components/video-upload.compon
NgbNavLink,
NgbNavLinkBase,
NgbNavContent,
- VideoUploadComponent,
- VideoImportUrlComponent,
- VideoImportTorrentComponent,
- VideoGoLiveComponent,
NgbNavOutlet,
- AlertComponent
- ]
+ AlertComponent,
+ VideoGoLiveComponent,
+ VideoImportTorrentComponent,
+ VideoImportUrlComponent,
+ VideoUploadComponent
+ ],
+ providers: [ VideoManageController ]
})
-export class VideoAddComponent implements OnInit, CanComponentDeactivate {
+export class VideoPublishComponent implements OnInit, CanComponentDeactivate {
private auth = inject(AuthService)
- private userService = inject(UserService)
private hooks = inject(HooksService)
private serverService = inject(ServerService)
private route = inject(ActivatedRoute)
private router = inject(Router)
+ private manageController = inject(VideoManageController)
+ private videoService = inject(VideoService)
+ private canDeactivateGuard = inject(CanDeactivateGuard)
+ private peertubeRouter = inject(PeerTubeRouterService)
readonly videoUpload = viewChild<VideoUploadComponent>('videoUpload')
readonly videoImportUrl = viewChild<VideoImportUrlComponent>('videoImportUrl')
@@ -59,7 +68,7 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate {
user: AuthUser = null
- secondStepType: VideoEditType
+ secondStepType: VideoManageType
videoName: string
activeNav: string
@@ -75,48 +84,101 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate {
hasNoQuotaLeftDaily = false
serverConfig: HTMLServerConfig
+ highestPrivacy: VideoPrivacyType
+
+ userChannels: SelectChannelItem[]
+ userQuota: UserVideoQuota
+ privacies: VideoConstant<VideoPrivacyType>[]
+
+ private publishedIdQuery: string
+ private uploadingQuery: string
get isContactFormEnabled () {
return this.serverConfig.email.enabled && this.serverConfig.contactForm.enabled
}
- get userInformationLoaded () {
- return this.auth.userInformationLoaded
- }
-
ngOnInit () {
+ const data = this.route.snapshot.data.resolverData as VideoPublishResolverData
+ const { videoChannels, userQuota, privacies } = data
+
+ this.userChannels = videoChannels
+ this.userQuota = userQuota
+ this.privacies = privacies
+
this.user = this.auth.getUser()
this.serverConfig = this.serverService.getHTMLConfig()
+ this.highestPrivacy = this.videoService.getHighestAvailablePrivacy(privacies)
if (this.route.snapshot.fragment) {
- this.onNavChange(this.route.snapshot.fragment)
+ this.onNavChange(this.route.snapshot.fragment as VideoManageType)
}
this.buildUploadMessages()
- this.userService.getMyVideoQuotaUsed()
- .subscribe(data => {
- // videoQuota left lower than 10%
- if (data.videoQuotaUsed > this.user.videoQuota * 0.9) {
- this.hasNoQuotaLeft = true
- }
+ // videoQuota left lower than 10%
+ if (this.user.videoQuota !== -1 && userQuota.videoQuotaUsed > this.user.videoQuota * 0.9) {
+ this.hasNoQuotaLeft = true
+ }
- // unlimited videoQuota
- if (this.user.videoQuota === -1) {
- this.hasNoQuotaLeft = false
- }
+ // videoQuotaDaily left lower than 10%
+ if (this.user.videoQuotaDaily !== -1 && userQuota.videoQuotaUsedDaily > this.user.videoQuotaDaily * 0.9) {
+ this.hasNoQuotaLeftDaily = true
+ }
- // videoQuotaDaily left lower than 10%
- if (data.videoQuotaUsedDaily > this.user.videoQuotaDaily * 0.9) {
- this.hasNoQuotaLeftDaily = true
- }
+ this.reset()
+
+ this.route.queryParams.subscribe(params => {
+ if (params.publishedId) {
+ this.publishedIdQuery = params.publishedId
+ } else if (params.uploading) {
+ this.uploadingQuery = params.uploading
+ } else if (this.publishedIdQuery || this.uploadingQuery) {
+ this.tryToReset()
+ }
+ })
+ }
- // unlimited videoQuotaDaily
- if (this.user.videoQuotaDaily === -1) {
- this.hasNoQuotaLeftDaily = false
+ private async tryToReset () {
+ const components = [
+ this.videoUpload(),
+ this.videoImportUrl(),
+ this.videoImportTorrent(),
+ this.videoGoLive()
+ ]
+
+ for (const component of components) {
+ if (!component) continue
+
+ // Restore old URL
+ if (!await this.canDeactivateGuard.canDeactivate(component)) {
+ if (this.publishedIdQuery) {
+ this.manageController.silentRedirectOnManage(this.publishedIdQuery, this.route)
+ } else if (this.uploadingQuery) {
+ this.manageController.silentRedirectOnUploading(this.route)
}
- })
+
+ return
+ }
+
+ component.reset()
+ }
+
+ this.reset()
+ }
+
+ private reset () {
+ this.secondStepType = undefined
+ this.videoName = undefined
+ this.publishedIdQuery = undefined
+ this.uploadingQuery = undefined
+
+ this.manageController.setStore({
+ userChannels: this.userChannels,
+ userQuota: this.userQuota,
+ privacies: this.privacies,
+ videoEdit: undefined
+ })
}
private async buildUploadMessages () {
@@ -142,13 +204,18 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate {
this.uploadMessages = await this.hooks.wrapObject(uploadMessages, 'common', 'filter:upload.messages.create.result')
}
- onNavChange (newActiveNav: string) {
+ onNavChange (newActiveNav: VideoManageType) {
this.activeNav = newActiveNav
+ this.manageController.setConfig({
+ manageType: newActiveNav,
+ serverConfig: this.serverConfig
+ })
+
this.router.navigate([], { fragment: this.activeNav })
}
- onFirstStepDone (type: VideoEditType, videoName: string) {
+ onFirstStepDone (type: VideoManageType, videoName: string) {
this.secondStepType = type
this.videoName = videoName
}
diff --git a/client/src/app/+videos-publish-manage/+video-publish/video-publish.resolver.ts b/client/src/app/+videos-publish-manage/+video-publish/video-publish.resolver.ts
new file mode 100644
index 0000000000..c3d7eaeae5
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/+video-publish/video-publish.resolver.ts
@@ -0,0 +1,28 @@
+import { Injectable, inject } from '@angular/core'
+import { AuthService, ServerService, UserService } from '@app/core'
+import { listUserChannelsForSelect } from '@app/helpers'
+import { UserVideoQuota, VideoConstant, VideoPrivacyType } from '@peertube/peertube-models'
+import { forkJoin } from 'rxjs'
+import { map } from 'rxjs/operators'
+import { SelectChannelItem } from '../../../types'
+
+export type VideoPublishResolverData = {
+ videoChannels: SelectChannelItem[]
+ userQuota: UserVideoQuota
+ privacies: VideoConstant<VideoPrivacyType>[]
+}
+
+@Injectable()
+export class VideoPublishResolver {
+ private authService = inject(AuthService)
+ private serverService = inject(ServerService)
+ private userService = inject(UserService)
+
+ resolve () {
+ return forkJoin([
+ listUserChannelsForSelect(this.authService),
+ this.userService.getMyVideoQuotaUsed(),
+ this.serverService.getVideoPrivacies()
+ ]).pipe(map(([ videoChannels, userQuota, privacies ]) => ({ videoChannels, userQuota, privacies } as VideoPublishResolverData)))
+ }
+}
diff --git a/client/src/app/+videos/+video-edit/shared/caption/video-caption-add-modal.component.html b/client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-add-modal.component.html
similarity index 100%
rename from client/src/app/+videos/+video-edit/shared/caption/video-caption-add-modal.component.html
rename to client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-add-modal.component.html
diff --git a/client/src/app/+videos/+video-edit/shared/caption/video-caption-add-modal.component.scss b/client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-add-modal.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-edit/shared/caption/video-caption-add-modal.component.scss
rename to client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-add-modal.component.scss
diff --git a/client/src/app/+videos/+video-edit/shared/caption/video-caption-add-modal.component.ts b/client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-add-modal.component.ts
similarity index 90%
rename from client/src/app/+videos/+video-edit/shared/caption/video-caption-add-modal.component.ts
rename to client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-add-modal.component.ts
index 3dd722a13f..8642a05060 100644
--- a/client/src/app/+videos/+video-edit/shared/caption/video-caption-add-modal.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-add-modal.component.ts
@@ -6,11 +6,11 @@ import { VIDEO_CAPTION_FILE_VALIDATOR, VIDEO_CAPTION_LANGUAGE_VALIDATOR } from '
import { FormReactive } from '@app/shared/shared-forms/form-reactive'
import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
import { SelectOptionsComponent } from '@app/shared/shared-forms/select/select-options.component'
-import { VideoCaptionEdit } from '@app/shared/shared-main/video-caption/video-caption-edit.model'
+import { VideoCaptionEdit } from '@app/+videos-publish-manage/shared-manage/common/video-caption-edit.model'
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { HTMLServerConfig, VideoConstant } from '@peertube/peertube-models'
-import { ReactiveFileComponent } from '../../../../shared/shared-forms/reactive-file.component'
-import { GlobalIconComponent } from '../../../../shared/shared-icons/global-icon.component'
+import { ReactiveFileComponent } from '../../../shared/shared-forms/reactive-file.component'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
@Component({
selector: 'my-video-caption-add-modal',
diff --git a/client/src/app/+videos/+video-edit/shared/caption/video-caption-edit-modal.component.html b/client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-edit-modal.component.html
similarity index 82%
rename from client/src/app/+videos/+video-edit/shared/caption/video-caption-edit-modal.component.html
rename to client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-edit-modal.component.html
index 85d09b743f..b6e1990fc1 100644
--- a/client/src/app/+videos/+video-edit/shared/caption/video-caption-edit-modal.component.html
+++ b/client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-edit-modal.component.html
@@ -11,9 +11,9 @@
<div class="row">
- <my-embed *ngIf="publishedVideo" #embed class="col-md-12 col-xl-6 mb-3" [video]="publishedVideo" enableAPI="true"></my-embed>
+ <my-embed *ngIf="videoEdit.isPublishedVOD()" #embed class="col-md-12 col-xl-6 mb-3" [video]="videoEdit.getVideoAttributes()" enableAPI="true"></my-embed>
- <div [ngClass]="publishedVideo ? 'col-xl-6 col-md-12' : ''">
+ <div [ngClass]="videoEdit.isPublishedVOD() ? 'col-xl-6 col-md-12' : ''">
<div class="d-flex justify-content-between align-items-center mb-3 ms-2">
<my-peertube-checkbox
@@ -52,12 +52,15 @@
<label class="visually-hidden" i18n for="segmentStart">Segment start timestamp</label>
<my-timestamp-input
- class="me-1"
- inputName="segmentStart" enableBorder="true" [maxTimestamp]="publishedVideo.duration * 1000" mask="99:99:99.999"
+ class="me-1" inputName="segmentStart" enableBorder="true"
+ [maxTimestamp]="(videoEdit.getVideoAttributes().duration || 0) * 1000" mask="99:99:99.999"
[(ngModel)]="segment.startMs" [parser]="timestampParser" [formatter]="timestampFormatter"
></my-timestamp-input>
- <my-button *ngIf="publishedVideo" icon="clock-arrow-down" i18n-title title="Use video current time as start time" (click)="videoTimeForSegmentStart(segment)">
+ <my-button
+ *ngIf="videoEdit.isPublishedVOD()" icon="clock-arrow-down"
+ i18n-title title="Use video current time as start time" (click)="videoTimeForSegmentStart(segment)"
+ >
</my-button>
</div>
@@ -67,12 +70,15 @@
<label class="visually-hidden" i18n for="segmentEnd">Segment end timestamp</label>
<my-timestamp-input
- class="me-1"
- inputName="segmentEnd" enableBorder="true" [maxTimestamp]="publishedVideo.duration * 1000" mask="99:99:99.999"
+ class="me-1" inputName="segmentEnd" enableBorder="true"
+ [maxTimestamp]="(videoEdit.getVideoAttributes().duration || 0) * 1000" mask="99:99:99.999"
[(ngModel)]="segment.endMs" [parser]="timestampParser" [formatter]="timestampFormatter"
></my-timestamp-input>
- <my-button *ngIf="publishedVideo" icon="clock-arrow-down" i18n-title title="Use video current time as end time" (click)="videoTimeForSegmentEnd(segment)">
+ <my-button
+ *ngIf="videoEdit.isPublishedVOD()" icon="clock-arrow-down"
+ i18n-title title="Use video current time as end time" (click)="videoTimeForSegmentEnd(segment)"
+ >
</my-button>
</div>
</div>
diff --git a/client/src/app/+videos/+video-edit/shared/caption/video-caption-edit-modal.component.scss b/client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-edit-modal.component.scss
similarity index 100%
rename from client/src/app/+videos/+video-edit/shared/caption/video-caption-edit-modal.component.scss
rename to client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-edit-modal.component.scss
diff --git a/client/src/app/+videos/+video-edit/shared/caption/video-caption-edit-modal.component.ts b/client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-edit-modal.component.ts
similarity index 92%
rename from client/src/app/+videos/+video-edit/shared/caption/video-caption-edit-modal.component.ts
rename to client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-edit-modal.component.ts
index bca5411d6f..eea98296f0 100644
--- a/client/src/app/+videos/+video-edit/shared/caption/video-caption-edit-modal.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/captions/video-caption-edit-modal.component.ts
@@ -6,19 +6,20 @@ import { FormReactive } from '@app/shared/shared-forms/form-reactive'
import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
import { PeertubeCheckboxComponent } from '@app/shared/shared-forms/peertube-checkbox.component'
import { TimestampInputComponent } from '@app/shared/shared-forms/timestamp-input.component'
-import { VideoCaptionEdit, VideoCaptionWithPathEdit } from '@app/shared/shared-main/video-caption/video-caption-edit.model'
+import { VideoCaptionEdit, VideoCaptionWithPathEdit } from '@app/+videos-publish-manage/shared-manage/common/video-caption-edit.model'
import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
import { EmbedComponent } from '@app/shared/shared-main/video/embed.component'
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { millisecondsToVttTime, sortBy, timeToInt } from '@peertube/peertube-core-utils'
-import { HTMLServerConfig, Video, VideoConstant } from '@peertube/peertube-models'
+import { HTMLServerConfig, VideoConstant } from '@peertube/peertube-models'
import { parse } from '@plussub/srt-vtt-parser'
-import { PeerTubePlayer } from '../../../../../standalone/embed-player-api/player'
-import { ConfirmService, Notifier, ServerService } from '../../../../core'
-import { GlobalIconComponent } from '../../../../shared/shared-icons/global-icon.component'
-import { ButtonComponent } from '../../../../shared/shared-main/buttons/button.component'
-import { DeleteButtonComponent } from '../../../../shared/shared-main/buttons/delete-button.component'
-import { EditButtonComponent } from '../../../../shared/shared-main/buttons/edit-button.component'
+import { PeerTubePlayer } from '../../../../standalone/embed-player-api/player'
+import { ConfirmService, Notifier, ServerService } from '../../../core'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'
+import { DeleteButtonComponent } from '../../../shared/shared-main/buttons/delete-button.component'
+import { EditButtonComponent } from '../../../shared/shared-main/buttons/edit-button.component'
+import { VideoEdit } from '../common/video-edit.model'
type Segment = {
id: string
@@ -84,7 +85,7 @@ export class VideoCaptionEditModalComponent extends FormReactive implements OnIn
// Show options
videoCaption: VideoCaptionWithPathEdit
serverConfig: HTMLServerConfig
- publishedVideo: Video
+ videoEdit: VideoEdit
captionEdited: (caption: VideoCaptionEdit) => any
ngOnInit () {
@@ -98,12 +99,12 @@ export class VideoCaptionEditModalComponent extends FormReactive implements OnIn
show (options: {
videoCaption: VideoCaptionWithPathEdit
serverConfig: HTMLServerConfig
- publishedVideo: Video
+ videoEdit: VideoEdit
captionEdited: (caption: VideoCaptionEdit) => any
}) {
this.videoCaption = options.videoCaption
this.serverConfig = options.serverConfig
- this.publishedVideo = options.publishedVideo
+ this.videoEdit = options.videoEdit
this.captionEdited = options.captionEdited
this.openedModal = this.modalService.open(this.modal(), {
@@ -126,7 +127,7 @@ export class VideoCaptionEditModalComponent extends FormReactive implements OnIn
hide () {
this.videoCaption = undefined
this.serverConfig = undefined
- this.publishedVideo = undefined
+ this.videoEdit = undefined
this.captionEdited = undefined
this.openedModal.close()
diff --git a/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.html b/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.html
new file mode 100644
index 0000000000..2b481c07f6
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.html
@@ -0,0 +1,79 @@
+<h2>
+ <my-global-icon iconName="captions"></my-global-icon>
+
+ <ng-container i18n>Captions</ng-container>
+</h2>
+
+@if (isLive()) {
+ <my-alert type="primary" i18n>Captions are not available on a live.</my-alert>
+} @else {
+ <div class="captions">
+ <my-alert type="primary" *ngIf="displayTranscriptionInfo && isTranscriptionEnabled() && !hasCaptions()" i18n>
+ Subtitles will be automatically generated from your video.
+ </my-alert>
+
+ <div class="form-group" *ngFor="let videoCaption of videoEdit.getCaptionsEdit()">
+
+ <div class="caption-entry">
+
+ @if (videoCaption.action) {
+ <span class="caption-entry-label">{{ getCaptionLabel(videoCaption) }}</span>
+
+ @switch (videoCaption.action) {
+ @case ('CREATE') {
+ <div i18n class="caption-entry-state green">Will be created on update</div>
+ } @case ('UPDATE') {
+ <div i18n class="caption-entry-state green">Will be edited on update</div>
+ } @case ('REMOVE') {
+ <div i18n class="caption-entry-state red">Will be deleted on update</div>
+ }
+ }
+
+ @if (videoCaption.action === 'CREATE' || videoCaption.action === 'UPDATE') {
+ <my-edit-button class="me-2" i18n-label label="Edit" (click)="openEditCaptionModal(videoCaption)"></my-edit-button>
+ }
+
+ <my-button i18n (click)="deleteCaption(videoCaption)" icon="undo">
+ @switch (videoCaption.action) {
+ @case ('CREATE') {
+ Cancel creation
+ } @case ('UPDATE') {
+ Cancel editing
+ } @case ('REMOVE') {
+ Cancel deletion
+ }
+ }
+ </my-button>
+ } @else {
+ <a
+ i18n-title title="See the subtitle file" class="caption-entry-label" target="_blank" rel="noopener noreferrer"
+ [href]="videoCaption.fileUrl"
+ >{{ getCaptionLabel(videoCaption) }}</a>
+
+ <div i18n class="caption-entry-state">Uploaded on {{ videoCaption.updatedAt | ptDate }} &#10004;</div>
+
+ <my-edit-button i18n-label label="Edit" class="me-2" (click)="openEditCaptionModal(videoCaption)"></my-edit-button>
+ <my-delete-button label (click)="deleteCaption(videoCaption)"></my-delete-button>
+ }
+ </div>
+ </div>
+
+ <div i18n class="no-caption" *ngIf="videoEdit.getCaptionsEdit()?.length === 0">
+ No captions for now.
+ </div>
+
+ <div class="mt-3 mb-3">
+ <button (click)="openAddCaptionModal()" class="peertube-create-button">
+ <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>
+ <ng-container i18n>Add a caption</ng-container>
+ </button>
+ </div>
+
+ </div>
+}
+
+<my-video-caption-add-modal
+ #videoCaptionAddModal [existingCaptions]="getExistingCaptions()" [serverConfig]="serverConfig" (captionAdded)="onCaptionEdited($event)"
+></my-video-caption-add-modal>
+
+<my-video-caption-edit-modal #videoCaptionEditModal></my-video-caption-edit-modal>
diff --git a/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.scss b/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.scss
new file mode 100644
index 0000000000..674b0233ad
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.scss
@@ -0,0 +1,37 @@
+@use '_variables' as *;
+@use '_mixins' as *;
+@use '_form-mixins' as *;
+
+.caption-entry {
+ display: flex;
+ min-height: 40px;
+ align-items: center;
+ flex-wrap: wrap;
+
+ a.caption-entry-label {
+ color: pvar(--fg);
+
+ @include disable-default-a-behaviour;
+
+ &:hover {
+ opacity: 0.8;
+ }
+ }
+
+ .caption-entry-label {
+ font-weight: bold;
+ min-width: 100px;
+
+ @include margin-right(20px);
+ }
+
+ .caption-entry-state {
+ min-width: 250px;
+
+ @include margin-right(15px);
+ }
+}
+
+.no-caption {
+ text-align: center;
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.ts b/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.ts
new file mode 100644
index 0000000000..f03a550141
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/captions/video-captions.component.ts
@@ -0,0 +1,162 @@
+import { NgFor, NgIf } from '@angular/common'
+import { Component, OnInit, inject, viewChild } from '@angular/core'
+import { FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { ServerService } from '@app/core'
+import { removeElementFromArray } from '@app/helpers'
+import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
+import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'
+import { VideoCaptionEdit, VideoCaptionWithPathEdit } from '@app/+videos-publish-manage/shared-manage/common/video-caption-edit.model'
+import { HTMLServerConfig, VideoConstant } from '@peertube/peertube-models'
+import debug from 'debug'
+import { CalendarModule } from 'primeng/calendar'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'
+import { DeleteButtonComponent } from '../../../shared/shared-main/buttons/delete-button.component'
+import { EditButtonComponent } from '../../../shared/shared-main/buttons/edit-button.component'
+import { VideoEdit } from '../common/video-edit.model'
+import { VideoManageController } from '../video-manage-controller.service'
+import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component'
+import { VideoCaptionEditModalComponent } from './video-caption-edit-modal.component'
+
+const debugLogger = debug('peertube:video-manage')
+
+@Component({
+ selector: 'my-video-captions',
+ styleUrls: [
+ '../common/video-manage-page-common.scss',
+ './video-captions.component.scss'
+ ],
+ templateUrl: './video-captions.component.html',
+ imports: [
+ FormsModule,
+ ReactiveFormsModule,
+ NgIf,
+ CalendarModule,
+ NgFor,
+ GlobalIconComponent,
+ DeleteButtonComponent,
+ VideoCaptionAddModalComponent,
+ PTDatePipe,
+ EditButtonComponent,
+ ButtonComponent,
+ AlertComponent,
+ VideoCaptionEditModalComponent
+ ]
+})
+export class VideoCaptionsComponent implements OnInit {
+ private serverService = inject(ServerService)
+ private manageController = inject(VideoManageController)
+
+ readonly videoCaptionAddModal = viewChild<VideoCaptionAddModalComponent>('videoCaptionAddModal')
+ readonly videoCaptionEditModal = viewChild<VideoCaptionEditModalComponent>('videoCaptionEditModal')
+
+ serverConfig: HTMLServerConfig
+
+ displayTranscriptionInfo: boolean
+ videoEdit: VideoEdit
+
+ videoLanguages: VideoConstant<string>[] = []
+
+ private initialVideoCaptions: string[] = []
+
+ ngOnInit () {
+ this.serverConfig = this.serverService.getHTMLConfig()
+
+ const { displayTranscriptionInfo } = this.manageController.getConfig()
+ this.displayTranscriptionInfo = displayTranscriptionInfo
+
+ const { videoEdit } = this.manageController.getStore()
+ this.videoEdit = videoEdit
+
+ this.initialVideoCaptions = this.videoEdit.getCaptionsEdit().map(c => c.language.id)
+ }
+
+ // ---------------------------------------------------------------------------
+
+ getCaptionLabel (caption: VideoCaptionWithPathEdit) {
+ if (caption.automaticallyGenerated) {
+ return $localize`${caption.language.label} (auto-generated)`
+ }
+
+ return caption.language.label
+ }
+
+ getExistingCaptions () {
+ return this.videoEdit
+ .getCaptionsEdit()
+ .filter(c => c.action !== 'REMOVE')
+ .map(c => c.language.id)
+ }
+
+ onCaptionEdited (caption: VideoCaptionEdit) {
+ const captionsEdit = this.videoEdit.getCaptionsEdit()
+
+ const existingCaption = captionsEdit
+ .find(c => c.language.id === caption.language.id)
+
+ // Replace existing caption
+ if (existingCaption) {
+ Object.assign(existingCaption, caption)
+ } else {
+ captionsEdit.push(
+ Object.assign(caption, { action: 'CREATE' as 'CREATE' })
+ )
+ }
+
+ this.sortVideoCaptions()
+
+ debugLogger('Caption edited', caption)
+ }
+
+ deleteCaption (caption: VideoCaptionEdit) {
+ // Caption recovers his former state
+ if (caption.action && this.initialVideoCaptions.includes(caption.language.id)) {
+ caption.action = undefined
+ return
+ }
+
+ // This caption is not on the server, just remove it from our array
+ if (caption.action === 'CREATE' || caption.action === 'UPDATE') {
+ removeElementFromArray(this.videoEdit.getCaptionsEdit(), caption)
+ return
+ }
+
+ caption.action = 'REMOVE' as 'REMOVE'
+
+ debugLogger('Caption deleted', caption)
+ }
+
+ openAddCaptionModal () {
+ this.videoCaptionAddModal().show()
+ }
+
+ openEditCaptionModal (videoCaption: VideoCaptionWithPathEdit) {
+ this.videoCaptionEditModal().show({
+ videoCaption,
+ serverConfig: this.serverConfig,
+ videoEdit: this.videoEdit,
+ captionEdited: caption => this.onCaptionEdited(caption)
+ })
+ }
+
+ isTranscriptionEnabled () {
+ return this.serverConfig.videoTranscription.enabled
+ }
+
+ hasCaptions () {
+ return this.getExistingCaptions().length !== 0
+ }
+
+ private sortVideoCaptions () {
+ this.videoEdit.getCaptionsEdit().sort((v1, v2) => {
+ if (v1.language.label < v2.language.label) return -1
+ if (v1.language.label === v2.language.label) return 0
+
+ return 1
+ })
+ }
+
+ isLive () {
+ return this.videoEdit.getVideoAttributes().isLive
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/chapters/video-chapters.component.html b/client/src/app/+videos-publish-manage/shared-manage/chapters/video-chapters.component.html
new file mode 100644
index 0000000000..6c619c7980
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/chapters/video-chapters.component.html
@@ -0,0 +1,62 @@
+<h2>
+ <my-global-icon iconName="chapters"></my-global-icon>
+
+ <ng-container i18n>Chapters</ng-container>
+</h2>
+
+@if (isLive()) {
+ <my-alert type="primary" i18n>Chapters are not available on a live.</my-alert>
+} @else {
+ <div [formGroup]="form">
+ <div class="row mb-5">
+ <div class="chapters col-md-12 col-xl-6" formArrayName="chapters">
+ <my-alert type="primary" i18n>
+ Chapters can also be set in the video description.
+
+ Check the format <a href="https://docs.joinpeertube.org/use/create-upload-video#chapters" target="_blank" class="alert-link">in the PeerTube documentation</a>
+ </my-alert>
+
+ <ng-container *ngFor="let chapterControl of getChaptersFormArray().controls; let i = index">
+ <div class="chapter" [formGroupName]="i">
+ <!-- Row 1 -->
+ <div></div>
+
+ <label i18n [ngClass]="{ 'hide-chapter-label': i !== 0 }" [for]="'timecode[' + i + ']'">Timecode</label>
+
+ <label i18n [ngClass]="{ 'hide-chapter-label': i !== 0 }" [for]="'title[' + i + ']'">Chapter name</label>
+
+ <div></div>
+
+ <!-- Row 2 -->
+ <div class="position">{{ i + 1 }}</div>
+
+ <my-timestamp-input
+ class="d-block" enableBorder="true" [inputName]="'timecode[' + i + ']'"
+ [maxTimestamp]="videoEdit.getVideoAttributes().duration || null" formControlName="timecode"
+ ></my-timestamp-input>
+
+ <div>
+ <input
+ [ngClass]="{ 'input-error': formErrors.chapters[i].title }"
+ type="text" [id]="'title[' + i + ']'" [name]="'title[' + i + ']'" formControlName="title"
+ />
+
+ <div [ngClass]="{ 'opacity-0': !formErrors.chapters[i].title }" class="form-error" role="alert">
+ <span class="opacity-0">t</span> <!-- Ensure we have reserve a correct height -->
+ {{ formErrors.chapters[i].title }}
+ </div>
+ </div>
+
+ <my-delete-button *ngIf="!isLastChapterControl(i)" (click)="deleteChapterControl(i)"></my-delete-button>
+ </div>
+ </ng-container>
+
+ <div *ngIf="getChapterArrayErrors()" class="form-error" role="alert">
+ {{ getChapterArrayErrors() }}
+ </div>
+ </div>
+
+ <my-embed *ngIf="videoEdit.isPublishedVOD()" class="col-md-12 col-xl-6" [video]="videoEdit.getVideoAttributes()" [version]="getEmbedVersion()"></my-embed>
+ </div>
+ </div>
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/chapters/video-chapters.component.scss b/client/src/app/+videos-publish-manage/shared-manage/chapters/video-chapters.component.scss
new file mode 100644
index 0000000000..df9b0280a2
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/chapters/video-chapters.component.scss
@@ -0,0 +1,25 @@
+@use '_variables' as *;
+@use '_mixins' as *;
+@use '_form-mixins' as *;
+
+.chapter {
+ display: grid;
+ grid-template-columns: auto auto minmax(150px, 350px) 1fr;
+ grid-template-rows: auto auto;
+ column-gap: 1rem;
+
+ .position {
+ height: 38px;
+ min-width: 16px;
+ display: flex;
+ align-items: center;
+ }
+
+ my-delete-button {
+ width: fit-content;
+ }
+
+ .form-error {
+ margin-top: 0;
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/chapters/video-chapters.component.ts b/client/src/app/+videos-publish-manage/shared-manage/chapters/video-chapters.component.ts
new file mode 100644
index 0000000000..41046dd922
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/chapters/video-chapters.component.ts
@@ -0,0 +1,186 @@
+import { NgClass, NgFor, NgIf } from '@angular/common'
+import { Component, OnDestroy, OnInit, inject } from '@angular/core'
+import { FormArray, FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'
+import { VIDEO_CHAPTERS_ARRAY_VALIDATOR, VIDEO_CHAPTER_TITLE_VALIDATOR } from '@app/shared/form-validators/video-chapter-validators'
+import { FormReactiveErrors, FormReactiveService, FormReactiveValidationMessages } from '@app/shared/shared-forms/form-reactive.service'
+import { FormValidatorService } from '@app/shared/shared-forms/form-validator.service'
+import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
+import debug from 'debug'
+import { CalendarModule } from 'primeng/calendar'
+import { Subscription } from 'rxjs'
+import { TimestampInputComponent } from '../../../shared/shared-forms/timestamp-input.component'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { DeleteButtonComponent } from '../../../shared/shared-main/buttons/delete-button.component'
+import { EmbedComponent } from '../../../shared/shared-main/video/embed.component'
+import { VideoEdit } from '../common/video-edit.model'
+import { VideoManageController } from '../video-manage-controller.service'
+
+const debugLogger = debug('peertube:video-manage')
+
+type ChapterForm = {
+ timecode: FormControl<number>
+ title: FormControl<string>
+}
+
+type Form = {
+ chapters: FormArray<FormGroup<ChapterForm>>
+}
+
+@Component({
+ selector: 'my-video-chapters',
+ styleUrls: [
+ '../common/video-manage-page-common.scss',
+ './video-chapters.component.scss'
+ ],
+ templateUrl: './video-chapters.component.html',
+ imports: [
+ FormsModule,
+ ReactiveFormsModule,
+ NgIf,
+ CalendarModule,
+ NgFor,
+ NgClass,
+ TimestampInputComponent,
+ DeleteButtonComponent,
+ EmbedComponent,
+ AlertComponent,
+ GlobalIconComponent
+ ]
+})
+export class VideoChaptersComponent implements OnInit, OnDestroy {
+ private formValidatorService = inject(FormValidatorService)
+ private formReactiveService = inject(FormReactiveService)
+ private manageController = inject(VideoManageController)
+
+ form: FormGroup<Form>
+ formErrors: FormReactiveErrors & { chapters?: { title: string }[] } = {}
+ validationMessages: FormReactiveValidationMessages = {}
+
+ videoEdit: VideoEdit
+
+ private updatedSub: Subscription
+
+ ngOnInit () {
+ const { videoEdit } = this.manageController.getStore()
+ this.videoEdit = videoEdit
+
+ this.buildForm()
+ }
+
+ private buildForm () {
+ const { form, formErrors, validationMessages } = this.formReactiveService.buildForm<Form>({}, {})
+ this.form = form
+ this.formErrors = formErrors
+ this.validationMessages = validationMessages
+
+ this.form.addControl('chapters', new FormArray([], VIDEO_CHAPTERS_ARRAY_VALIDATOR.VALIDATORS))
+ this.addNewChapterControl()
+
+ form.get('chapters').valueChanges.subscribe(chapters => {
+ const lastChapter = chapters[chapters.length - 1]
+
+ if (lastChapter.title || lastChapter.timecode) {
+ this.addNewChapterControl()
+ }
+ })
+
+ this.patchChapters()
+
+ this.form.valueChanges.subscribe(() => {
+ const chapterErrors = {
+ chapters: !this.form.valid
+ ? $localize`Some chapters are invalid`
+ : undefined
+ }
+
+ this.manageController.setFormError($localize`Chapters`, 'chapters', chapterErrors)
+
+ const formValues = this.form.value
+ debugLogger('Updating form values', formValues)
+
+ this.videoEdit.getChaptersEdit().loadFromForm(formValues)
+ })
+
+ this.formReactiveService.markAllAsDirty(this.form.controls)
+
+ this.updatedSub = this.manageController.getUpdatedObs().subscribe(() => {
+ this.patchChapters()
+ })
+ }
+
+ ngOnDestroy () {
+ this.updatedSub?.unsubscribe()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ addNewChapterControl () {
+ const chaptersFormArray = this.getChaptersFormArray()
+ const controls = chaptersFormArray.controls
+
+ if (controls.length !== 0) {
+ const lastControl = chaptersFormArray.controls[controls.length - 1]
+ lastControl.get('title').addValidators(Validators.required)
+ }
+
+ this.formValidatorService.addControlInFormArray({
+ controlName: 'chapters',
+ formArray: chaptersFormArray,
+ formErrors: this.formErrors,
+ validationMessages: this.validationMessages,
+ formToBuild: {
+ timecode: null,
+ title: VIDEO_CHAPTER_TITLE_VALIDATOR
+ },
+ defaultValues: {
+ timecode: 0
+ }
+ })
+ }
+
+ getChaptersFormArray () {
+ return this.form.controls.chapters
+ }
+
+ deleteChapterControl (index: number) {
+ this.formValidatorService.removeControlFromFormArray({
+ controlName: 'chapters',
+ formArray: this.getChaptersFormArray(),
+ formErrors: this.formErrors,
+ validationMessages: this.validationMessages,
+ index
+ })
+ }
+
+ isLastChapterControl (index: number) {
+ return this.getChaptersFormArray().length - 1 === index
+ }
+
+ getChapterArrayErrors () {
+ if (!this.getChaptersFormArray().errors) return ''
+
+ return Object.values(this.getChaptersFormArray().errors).join('. ')
+ }
+
+ private patchChapters () {
+ const chaptersEdit = this.videoEdit.getChaptersEdit()
+
+ const totalChapters = chaptersEdit.getChaptersForUpdate().length
+ const totalControls = this.getChaptersFormArray().length
+
+ // Add missing controls. We use <= because we need the "empty control" to add another chapter
+ for (let i = 0; i <= totalChapters - totalControls; i++) {
+ this.addNewChapterControl()
+ }
+
+ this.form.patchValue(chaptersEdit.toFormPatch())
+ }
+
+ isLive () {
+ return this.videoEdit.getVideoAttributes().isLive
+ }
+
+ getEmbedVersion () {
+ return this.manageController.getEmbedVersion()
+ }
+}
diff --git a/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts b/client/src/app/+videos-publish-manage/shared-manage/common/i18n-primeng-calendar.service.ts
similarity index 96%
rename from client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts
rename to client/src/app/+videos-publish-manage/shared-manage/common/i18n-primeng-calendar.service.ts
index f85a434062..98c93b0c1b 100644
--- a/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/i18n-primeng-calendar.service.ts
@@ -83,4 +83,8 @@ export class I18nPrimengCalendarService {
getDateFormat () {
return $localize`:Date format in this locale.:yy-mm-dd`
}
+
+ getVideoPublicationYearRange () {
+ return '1880:' + (new Date()).getFullYear()
+ }
}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/manage-errors.component.html b/client/src/app/+videos-publish-manage/shared-manage/common/manage-errors.component.html
new file mode 100644
index 0000000000..96f780898d
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/manage-errors.component.html
@@ -0,0 +1,15 @@
+<my-alert type="warning">
+ <div i18n>There are errors in your video settings.</div>
+
+ @for (errorRoot of getAllErrors(); track errorRoot) {
+ <div class="mt-3">
+ <a i18n class="alert-link" [routerLink]="errorRoot.path">{{ errorRoot.page }} page</a>
+
+ <ul class="mb-0">
+ @for (error of errorRoot.errors; track error) {
+ <li>{{ error }}</li>
+ }
+ </ul>
+ </div>
+ }
+</my-alert>
diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/manage-errors.component.ts b/client/src/app/+videos-publish-manage/shared-manage/common/manage-errors.component.ts
new file mode 100644
index 0000000000..7fc6b6a77b
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/manage-errors.component.ts
@@ -0,0 +1,17 @@
+import { Component, inject } from '@angular/core'
+import { VideoManageController } from '../video-manage-controller.service'
+import { AlertComponent } from '../../../shared/shared-main/common/alert.component'
+import { RouterModule } from '@angular/router'
+
+@Component({
+ selector: 'my-manage-errors',
+ templateUrl: 'manage-errors.component.html',
+ imports: [ RouterModule, AlertComponent ]
+})
+export class ManageErrorsComponent {
+ private readonly manageController = inject(VideoManageController)
+
+ getAllErrors () {
+ return this.manageController.getFormErrors()
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/thumbnail-manager.component.html b/client/src/app/+videos-publish-manage/shared-manage/common/thumbnail-manager.component.html
new file mode 100644
index 0000000000..3d058d1af0
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/thumbnail-manager.component.html
@@ -0,0 +1,54 @@
+<div class="root" myDragDrop (fileDropped)="onFileDropped($event)">
+
+ @if (selectingFromVideo) {
+ <my-embed #embed [video]="videoEdit().getVideoAttributes()" enableAPI="true" mute="true" autoplay="true"></my-embed>
+
+ <div class="mt-3">
+ <button i18n type="button" class="peertube-button primary-button me-2" (click)="selectFrame()">Use this frame</button>
+
+ <button i18n type="button" i18n class="peertube-button secondary-button" (click)="resetSelectFromVideo()">Cancel</button>
+ </div>
+ } @else {
+ <div class="preview-container">
+ @if (imageSrc) {
+ <img [src]="imageSrc" alt="Current thumbnail" i18n-alt />
+
+ <div class="muted-2 fs-8 mt-1">Current thumbnail</div>
+ } @else {
+ <div class="no-image">
+ <svg width="28" height="20" viewBox="0 0 28 20" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <path d="M6.07133 1.61298L24.1845 4.56992C25.1509 4.72768 25.8511 5.6793 25.6766 6.74787L24.0362 16.7967C23.8617 17.8652 22.8953 18.5448 21.9289 18.387L3.81571 15.4301C2.84933 15.2723 2.14915 14.3207 2.32359 13.2521L3.96404 3.20333C4.13848 2.13476 5.10494 1.45522 6.07133 1.61298Z" stroke="currentColor" stroke-width="2"/>
+ <path d="M11.5786 6.21294L10.4508 13.1215L16.9362 10.6345L11.5786 6.21294Z" fill="currentColor"/>
+ </svg>
+ </div>
+ }
+ </div>
+
+ <div class="mt-3">
+ <div class="muted-1">
+ <strong>Drag and drop your thumbnail here</strong> or click on the button below to modify it:
+ </div>
+
+ <div class="muted-2 fs-7">
+ <div i18n>In {{ videoImageExtensions }} formats, {{ maxVideoImageSizeInBytes }} maximum.</div>
+ <div i18n>Recommended size: 1280x720px.</div>
+ </div>
+
+ <div class="d-flex flex-wrap mt-4 justify-content-center gap-3">
+ <my-reactive-file
+ class="d-inline-block me-3"
+ inputName="uploadNewThumbnail" i18n-inputLabel inputLabel="Upload" [extensions]="videoImageExtensions"
+ [maxFileSize]="maxVideoImageSize" placement="right" (fileChanged)="onFileChanged($event)"
+ theme="secondary" icon="upload"
+ >
+ </my-reactive-file>
+
+ @if (canSelectFromVideo()) {
+ <my-button icon="film" theme="secondary" i18n (click)="selectFromVideo()">
+ Select from video
+ </my-button>
+ }
+ </div>
+ </div>
+ }
+</div>
diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/thumbnail-manager.component.scss b/client/src/app/+videos-publish-manage/shared-manage/common/thumbnail-manager.component.scss
new file mode 100644
index 0000000000..1f8d15597a
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/thumbnail-manager.component.scss
@@ -0,0 +1,47 @@
+@use 'sass:math';
+@use '_variables' as *;
+@use '_mixins' as *;
+
+.root {
+ min-height: 260px;
+ text-align: center;
+ padding: 2rem 1.5rem;
+ border-radius: 4px;
+ border: 1px dashed pvar(--secondary-icon-color);
+
+ @include on-mobile-main-col {
+ border: 0;
+ }
+}
+
+img {
+ width: $video-thumbnail-width;
+ height: $video-thumbnail-height;
+ border-radius: 4px;
+}
+
+.no-image {
+ color: pvar(--bg-secondary-450);
+
+ svg {
+ width: 100px;
+ height: 100px;
+ }
+}
+
+my-embed {
+ max-width: 500px;
+ width: 500px;
+
+ max-height: 280px;
+ height: 280px;
+}
+
+.root.dragover {
+ background-color: pvar(--bg-secondary-400);
+ border-color: pvar(--primary);
+
+ .no-image {
+ color: pvar(--primary);
+ }
+}
diff --git a/client/src/app/+videos/+video-edit/shared/thumbnail-manager/thumbnail-manager.component.ts b/client/src/app/+videos-publish-manage/shared-manage/common/thumbnail-manager.component.ts
similarity index 80%
rename from client/src/app/+videos/+video-edit/shared/thumbnail-manager/thumbnail-manager.component.ts
rename to client/src/app/+videos-publish-manage/shared-manage/common/thumbnail-manager.component.ts
index ea1098de00..ee50d65c69 100644
--- a/client/src/app/+videos/+video-edit/shared/thumbnail-manager/thumbnail-manager.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/thumbnail-manager.component.ts
@@ -1,21 +1,22 @@
import { CommonModule } from '@angular/common'
import { Component, OnInit, forwardRef, inject, input, viewChild } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
-import {
- ServerService
-} from '@app/core'
+import { DragDropDirective } from '@app/+videos-publish-manage/+video-publish/shared/drag-drop.directive'
+import { ServerService } from '@app/core'
import { ReactiveFileComponent } from '@app/shared/shared-forms/reactive-file.component'
import { BytesPipe } from '@app/shared/shared-main/common/bytes.pipe'
-import { EmbedComponent, EmbedVideoInput } from '@app/shared/shared-main/video/embed.component'
-import { HTMLServerConfig, Video, VideoState } from '@peertube/peertube-models'
+import { EmbedComponent } from '@app/shared/shared-main/video/embed.component'
+import { HTMLServerConfig, VideoState } from '@peertube/peertube-models'
import { imageToDataURL } from '@root-helpers/images'
-import { PeerTubePlayer } from '../../../../../standalone/embed-player-api/player'
+import { PeerTubePlayer } from '../../../../standalone/embed-player-api/player'
+import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'
+import { VideoEdit } from './video-edit.model'
@Component({
selector: 'my-thumbnail-manager',
styleUrls: [ './thumbnail-manager.component.scss' ],
templateUrl: './thumbnail-manager.component.html',
- imports: [ CommonModule, ReactiveFileComponent, EmbedComponent ],
+ imports: [ CommonModule, ReactiveFileComponent, EmbedComponent, DragDropDirective, ButtonComponent ],
providers: [
{
provide: NG_VALUE_ACCESSOR,
@@ -29,11 +30,10 @@ export class ThumbnailManagerComponent implements OnInit, ControlValueAccessor {
readonly embed = viewChild<EmbedComponent>('embed')
- readonly video = input<EmbedVideoInput & Pick<Video, 'isLive' | 'state'>>(undefined)
+ readonly videoEdit = input.required<VideoEdit>()
imageSrc: string
allowedExtensionsMessage = ''
- maxSizeText: string
serverConfig: HTMLServerConfig
bytesPipe: BytesPipe
@@ -45,7 +45,6 @@ export class ThumbnailManagerComponent implements OnInit, ControlValueAccessor {
constructor () {
this.bytesPipe = new BytesPipe()
- this.maxSizeText = $localize`max size`
}
// ---------------------------------------------------------------------------
@@ -65,12 +64,12 @@ export class ThumbnailManagerComponent implements OnInit, ControlValueAccessor {
}
canSelectFromVideo () {
- const video = this.video()
- return video && !video.isLive && video.state.id === VideoState.PUBLISHED
- }
+ const videoEdit = this.videoEdit()
+ if (!videoEdit) return
+
+ const attrs = videoEdit.getVideoAttributes()
- getReactiveFileButtonTooltip () {
- return $localize`(extensions: ${this.videoImageExtensions}, ${this.maxSizeText}\: ${this.maxVideoImageSizeInBytes})`
+ return !attrs.isLive && attrs.state === VideoState.PUBLISHED
}
ngOnInit () {
@@ -86,11 +85,15 @@ export class ThumbnailManagerComponent implements OnInit, ControlValueAccessor {
this.updatePreview()
}
+ onFileDropped (files: FileList) {
+ return this.onFileChanged(files[0])
+ }
+
propagateChange = (_: any) => {
// empty
}
- writeValue (file: any) {
+ writeValue (file: Blob) {
this.imageFile = file
this.updatePreview()
}
@@ -152,7 +155,7 @@ export class ThumbnailManagerComponent implements OnInit, ControlValueAccessor {
}
// Credit: https://stackoverflow.com/a/7261048/1030669
- dataURItoBlob (dataURI: string) {
+ private dataURItoBlob (dataURI: string) {
const byteString = atob(dataURI.split(',')[1])
const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
diff --git a/client/src/app/+videos/+video-edit/shared/uploaderx-form-data.ts b/client/src/app/+videos-publish-manage/shared-manage/common/uploaderx-form-data.ts
similarity index 100%
rename from client/src/app/+videos/+video-edit/shared/uploaderx-form-data.ts
rename to client/src/app/+videos-publish-manage/shared-manage/common/uploaderx-form-data.ts
diff --git a/client/src/app/shared/shared-main/video-caption/video-caption-edit.model.ts b/client/src/app/+videos-publish-manage/shared-manage/common/video-caption-edit.model.ts
similarity index 100%
rename from client/src/app/shared/shared-main/video-caption/video-caption-edit.model.ts
rename to client/src/app/+videos-publish-manage/shared-manage/common/video-caption-edit.model.ts
diff --git a/client/src/app/shared/shared-main/video/video-chapters-edit.model.ts b/client/src/app/+videos-publish-manage/shared-manage/common/video-chapters-edit.model.ts
similarity index 76%
rename from client/src/app/shared/shared-main/video/video-chapters-edit.model.ts
rename to client/src/app/+videos-publish-manage/shared-manage/common/video-chapters-edit.model.ts
index 6d7496ed64..df0ea8d25b 100644
--- a/client/src/app/shared/shared-main/video/video-chapters-edit.model.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/video-chapters-edit.model.ts
@@ -3,8 +3,7 @@ import { VideoChapter } from '@peertube/peertube-models'
export class VideoChaptersEdit {
private chaptersFromAPI: VideoChapter[] = []
-
- private chapters: VideoChapter[]
+ private chapters: VideoChapter[] = []
loadFromAPI (chapters: VideoChapter[]) {
this.chapters = chapters || []
@@ -12,7 +11,7 @@ export class VideoChaptersEdit {
this.chaptersFromAPI = chapters
}
- patch (values: { [ id: string ]: any }) {
+ loadFromForm (values: { chapters?: { timecode?: number, title?: string }[] }) {
const chapters = values.chapters || []
this.chapters = chapters.map((c: any) => {
@@ -31,13 +30,7 @@ export class VideoChaptersEdit {
return this.chapters.filter(c => !!c.title)
}
- hasDuplicateValues () {
- const timecodes = this.chapters.map(c => c.timecode)
-
- return new Set(timecodes).size !== this.chapters.length
- }
-
- shouldUpdateAPI () {
+ hasChanges () {
return simpleObjectsDeepEqual(sortBy(this.getChaptersForUpdate(), 'timecode'), this.chaptersFromAPI) !== true
}
}
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
new file mode 100644
index 0000000000..28a2520a13
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts
@@ -0,0 +1,884 @@
+import { getOriginUrl } from '@app/helpers'
+import { exists, omit, pick, secondsToTime } from '@peertube/peertube-core-utils'
+import {
+ HTMLServerConfig,
+ LiveVideo,
+ LiveVideoCreate,
+ LiveVideoUpdate,
+ VideoCaption,
+ VideoChapter,
+ VideoCreate,
+ VideoDetails,
+ VideoImportCreate,
+ VideoPrivacy,
+ VideoPrivacyType,
+ VideoScheduleUpdate,
+ VideoSource,
+ VideoState,
+ VideoStateType,
+ VideoStudioTask,
+ VideoStudioTaskCut,
+ VideoUpdate
+} from '@peertube/peertube-models'
+import { logger } from '@root-helpers/logger'
+import debug from 'debug'
+import { Jsonify, SharedUnionFieldsDeep } from 'type-fest'
+import { VideoCaptionWithPathEdit } from './video-caption-edit.model'
+import { VideoChaptersEdit } from './video-chapters-edit.model'
+
+const debugLogger = debug('peertube:video-manage:video-edit')
+
+export type VideoEditPrivacyType = VideoPrivacyType | typeof VideoEdit.SPECIAL_SCHEDULED_PRIVACY
+
+type CommonUpdateForm =
+ & Omit<VideoUpdate, 'privacy' | 'videoPasswords' | 'thumbnailfile' | 'scheduleUpdate' | 'commentsEnabled' | 'originallyPublishedAt'>
+ & {
+ schedulePublicationAt?: Date
+ originallyPublishedAt?: Date
+ privacy?: VideoEditPrivacyType
+ videoPassword?: string
+ }
+
+type LiveUpdateForm = Omit<LiveVideoUpdate, 'replaySettings'> & {
+ replayPrivacy?: VideoPrivacyType
+ liveStreamKey?: string
+}
+
+type ReplaceFileForm = {
+ replaceFile?: File
+}
+
+type StudioForm = {
+ 'cut'?: { start?: number, end?: number }
+ 'add-intro'?: { file?: File }
+ 'add-outro'?: { file?: File }
+ 'add-watermark'?: { file?: File }
+}
+
+// ---------------------------------------------------------------------------
+
+type LoadFromPublishOptions = Required<Pick<VideoCreate, 'channelId' | 'support'>> & Partial<Pick<VideoCreate, 'name'>>
+
+type CreateFromUploadOptions = LoadFromPublishOptions & Required<Pick<VideoCreate, 'name'>>
+
+type CreateFromImportOptions = LoadFromPublishOptions & Pick<VideoImportCreate, 'magnetUri' | 'torrentfile' | 'targetUrl'>
+
+type CreateFromLiveOptions =
+ & CreateFromUploadOptions
+ & Required<Pick<LiveVideoCreate, 'permanentLive' | 'latencyMode' | 'saveReplay' | 'replaySettings'>>
+
+type UpdateFromAPIOptions = {
+ video?: Pick<
+ VideoDetails,
+ | 'id'
+ | 'uuid'
+ | 'shortUUID'
+ | 'name'
+ | 'channel'
+ | 'privacy'
+ | 'category'
+ | 'licence'
+ | 'language'
+ | 'description'
+ | 'tags'
+ | 'nsfw'
+ | 'waitTranscoding'
+ | 'support'
+ | 'commentsPolicy'
+ | 'downloadEnabled'
+ | 'pluginData'
+ | 'scheduledUpdate'
+ | 'originallyPublishedAt'
+ | 'duration'
+ | 'likes'
+ | 'aspectRatio'
+ | 'views'
+ | 'blacklisted'
+ | 'previewPath'
+ | 'state'
+ | 'isLive'
+ >
+ live?: LiveVideo
+ chapters?: VideoChapter[]
+ captions?: VideoCaption[]
+ videoPasswords?: string[]
+ videoSource?: VideoSource
+}
+
+// ---------------------------------------------------------------------------
+
+type CommonUpdate = Omit<VideoUpdate, 'thumbnailfile' | 'originallyPublishedAt' | 'scheduleUpdate'> & {
+ originallyPublishedAt?: string
+ scheduleUpdate?: {
+ updateAt: string
+ privacy?: VideoScheduleUpdate['privacy']
+ }
+}
+
+export class VideoEdit {
+ static readonly SPECIAL_SCHEDULED_PRIVACY = -1
+
+ private common: CommonUpdate = {}
+ private captions: VideoCaptionWithPathEdit[] = []
+ private chapters: VideoChaptersEdit = new VideoChaptersEdit()
+ private live: LiveVideoUpdate
+ private replaceFile: File
+ private studioTasks: VideoStudioTask[] = []
+
+ private videoImport: Pick<VideoImportCreate, 'magnetUri' | 'torrentfile' | 'targetUrl'>
+
+ private metadata: Partial<{
+ id: number
+ uuid: string
+ shortUUID: string
+ state: VideoStateType
+ isLive: boolean
+ views: number
+ aspectRatio: number
+ duration: number
+ likes: number
+ blacklisted: boolean
+
+ live: Pick<LiveVideo, 'rtmpUrl' | 'rtmpsUrl' | 'streamKey'>
+ videoSource: VideoSource
+ }> = {}
+
+ private videoAttributes: {
+ id: number
+ shortUUID: string
+ uuid: string
+ name: string
+ state: VideoStateType
+ privacy: VideoEditPrivacyType
+ isLive: boolean
+ aspectRatio: number
+ duration: number
+ views: number
+ likes: number
+
+ blacklisted: boolean
+
+ live?: Pick<LiveVideo, 'rtmpUrl' | 'rtmpsUrl' | 'streamKey'>
+ }
+
+ private saveStore: {
+ common?: CommonUpdate
+ previewfile?: {
+ size: number
+ }
+ live?: LiveVideoUpdate
+ } = {}
+
+ private serverConfig: HTMLServerConfig
+
+ private constructor (serverConfig: HTMLServerConfig) {
+ this.serverConfig = serverConfig
+ }
+
+ // ---------------------------------------------------------------------------
+
+ static createFromUpload (serverConfig: HTMLServerConfig, options: CreateFromUploadOptions) {
+ const videoEdit = new VideoEdit(serverConfig)
+ videoEdit.loadFromPublish(options, false)
+
+ return videoEdit
+ }
+
+ // ---------------------------------------------------------------------------
+
+ static createFromImport (serverConfig: HTMLServerConfig, options: CreateFromImportOptions) {
+ const videoEdit = new VideoEdit(serverConfig)
+ videoEdit.loadFromImport(options)
+
+ return videoEdit
+ }
+
+ private loadFromImport (options: CreateFromImportOptions) {
+ this.loadFromPublish(options, false)
+
+ this.videoImport = {
+ targetUrl: options.targetUrl,
+ magnetUri: options.magnetUri,
+ torrentfile: options.torrentfile
+ }
+
+ this.updateAfterChange()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ static createFromLive (serverConfig: HTMLServerConfig, options: CreateFromLiveOptions) {
+ const videoEdit = new VideoEdit(serverConfig)
+ videoEdit.loadFromLive(options)
+
+ return videoEdit
+ }
+
+ private loadFromLive (options: CreateFromLiveOptions) {
+ this.loadFromPublish(options, true)
+
+ this.live = {
+ latencyMode: options.latencyMode,
+ permanentLive: options.permanentLive,
+
+ saveReplay: options.saveReplay,
+ replaySettings: options.replaySettings
+ ? { privacy: options.replaySettings.privacy }
+ : undefined
+ }
+
+ this.updateAfterChange()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ private loadFromPublish (options: LoadFromPublishOptions, isLive: boolean) {
+ const serverDefaults = this.serverConfig.defaults
+
+ this.common.name = options.name
+ this.common.channelId = options.channelId
+ this.metadata.isLive = isLive
+
+ this.common.privacy = serverDefaults.publish.privacy
+ this.common.downloadEnabled = serverDefaults.publish.downloadEnabled
+ this.common.licence = serverDefaults.publish.licence
+ this.common.commentsPolicy = serverDefaults.publish.commentsPolicy
+ this.common.nsfw = this.serverConfig.instance.isNSFW
+
+ this.common.waitTranscoding = true
+ this.common.tags = []
+ this.common.pluginData = {}
+
+ this.metadata.views = 0
+ this.metadata.likes = 0
+
+ this.updateAfterChange()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ static async createFromAPI (serverConfig: HTMLServerConfig, options: UpdateFromAPIOptions) {
+ const videoEdit = new VideoEdit(serverConfig)
+ await videoEdit.loadFromAPI(options)
+
+ return videoEdit
+ }
+
+ async loadFromAPI (options: UpdateFromAPIOptions) {
+ const { video, videoPasswords, live, chapters, captions, videoSource } = options
+
+ debugLogger('Load from API', options)
+
+ this.loadVideo({ video, videoPasswords, saveInStore: true })
+ this.loadLive(live)
+
+ if (captions !== undefined) {
+ this.captions = captions
+ }
+
+ if (chapters !== undefined) {
+ this.chapters = new VideoChaptersEdit()
+ if (chapters) this.chapters.loadFromAPI(chapters)
+ }
+
+ if (videoSource !== undefined) {
+ this.metadata.videoSource = videoSource
+ }
+
+ await this.loadPreview(video)
+
+ this.updateAfterChange()
+ }
+
+ private loadVideo (options: {
+ video: UpdateFromAPIOptions['video']
+ videoPasswords?: string[]
+ saveInStore: boolean
+ }) {
+ const { video, saveInStore, videoPasswords = [] } = options
+
+ if (video === undefined) return
+
+ const buildObj: () => CommonUpdate = () => {
+ return {
+ ...this.common,
+
+ name: video.name || '',
+ privacy: video.privacy?.id ?? null,
+ channelId: video.channel?.id ?? null,
+ category: video.category?.id ?? null,
+ licence: video.licence?.id ?? null,
+ language: video.language?.id ?? null,
+ description: video.description ?? '',
+ tags: video.tags ?? [],
+ nsfw: video.nsfw ?? null,
+ waitTranscoding: video.waitTranscoding ?? null,
+ support: video.support ?? '',
+ commentsPolicy: video.commentsPolicy?.id ?? null,
+
+ downloadEnabled: video.downloadEnabled ?? null,
+
+ pluginData: video.pluginData ?? {},
+
+ scheduleUpdate: video.scheduledUpdate
+ ? { updateAt: new Date(video.scheduledUpdate.updateAt).toISOString(), privacy: video.scheduledUpdate.privacy }
+ : null,
+
+ originallyPublishedAt: video.originallyPublishedAt
+ ? new Date(video.originallyPublishedAt).toISOString()
+ : null,
+
+ videoPasswords: videoPasswords ?? []
+ }
+ }
+
+ this.common = buildObj()
+
+ if (saveInStore) {
+ this.saveStore.common = buildObj()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ this.metadata.id = video.id
+ this.metadata.uuid = video.uuid
+ this.metadata.shortUUID = video.shortUUID
+
+ this.metadata.state = video.state.id
+ this.metadata.duration = video.duration
+ this.metadata.views = video.views
+ this.metadata.likes = video.likes
+ this.metadata.aspectRatio = video.aspectRatio
+ this.metadata.blacklisted = video.blacklisted
+
+ this.metadata.isLive = video.isLive
+ }
+
+ private async loadPreview (video: UpdateFromAPIOptions['video']) {
+ if (!video?.previewPath) return
+
+ try {
+ const response = await fetch(getOriginUrl() + video.previewPath)
+
+ this.common.previewfile = await response.blob()
+ this.saveStore.previewfile = { size: this.common.previewfile.size }
+ } catch (err) {
+ logger.error('Failed to fetch video preview', err)
+ }
+ }
+
+ private loadLive (live: UpdateFromAPIOptions['live']) {
+ if (live === undefined) {
+ this.metadata.isLive = false
+ return
+ }
+
+ const buildObj = () => {
+ return {
+ permanentLive: live.permanentLive,
+ latencyMode: live.latencyMode,
+ saveReplay: live.saveReplay,
+
+ replaySettings: live.replaySettings
+ ? { privacy: live.replaySettings.privacy }
+ : undefined
+ }
+ }
+
+ this.metadata.isLive = true
+ this.live = buildObj()
+ this.saveStore.live = buildObj()
+
+ this.metadata.live = pick(live, [ 'rtmpUrl', 'rtmpsUrl', 'streamKey' ])
+ }
+
+ loadAfterPublish (options: {
+ video: Pick<VideoDetails, 'id' | 'uuid' | 'shortUUID'>
+ }) {
+ this.metadata.id = options.video.id
+ this.metadata.uuid = options.video.uuid
+ this.metadata.shortUUID = options.video.shortUUID
+
+ this.updateAfterChange()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ loadFromCommonForm (values: CommonUpdateForm) {
+ if (values.name !== undefined) this.common.name = values.name
+ if (values.channelId !== undefined) this.common.channelId = values.channelId
+ if (values.category !== undefined) this.common.category = values.category
+ if (values.licence !== undefined) this.common.licence = values.licence
+ if (values.language !== undefined) this.common.language = values.language
+ if (values.description !== undefined) this.common.description = values.description
+ if (values.tags !== undefined) this.common.tags = values.tags
+ if (values.nsfw !== undefined) this.common.nsfw = values.nsfw
+ if (values.waitTranscoding !== undefined) this.common.waitTranscoding = values.waitTranscoding
+ if (values.support !== undefined) this.common.support = values.support
+ if (values.commentsPolicy !== undefined) this.common.commentsPolicy = values.commentsPolicy
+ if (values.downloadEnabled !== undefined) this.common.downloadEnabled = values.downloadEnabled
+ if (values.previewfile !== undefined) this.common.previewfile = values.previewfile
+ if (values.pluginData !== undefined) this.common.pluginData = values.pluginData
+
+ if (values.videoPassword !== undefined) {
+ this.common.videoPasswords = values.privacy === VideoPrivacy.PASSWORD_PROTECTED && values.videoPassword
+ ? [ values.videoPassword ]
+ : []
+ }
+
+ if (values.privacy !== undefined) {
+ // If schedule publication, the video is private and will be changed to public privacy
+ if (values.privacy === VideoEdit.SPECIAL_SCHEDULED_PRIVACY) {
+ const updateAt = new Date(values.schedulePublicationAt)
+ updateAt.setSeconds(0)
+
+ this.common.privacy = VideoPrivacy.PRIVATE
+
+ this.common.scheduleUpdate = {
+ updateAt: values.schedulePublicationAt
+ ? updateAt.toISOString()
+ : undefined,
+ privacy: VideoPrivacy.PUBLIC
+ }
+ } else {
+ this.common.privacy = values.privacy
+ this.common.scheduleUpdate = null
+ }
+ }
+
+ // Convert originallyPublishedAt to string so that function objectToFormData() works correctly
+ if (values.originallyPublishedAt !== undefined) {
+ this.common.originallyPublishedAt = values.originallyPublishedAt
+ ? new Date(values.originallyPublishedAt).toISOString()
+ : null
+ }
+
+ this.updateAfterChange()
+ }
+
+ toCommonFormPatch () {
+ const json: Required<CommonUpdateForm> = {
+ category: this.common.category,
+ licence: this.common.licence,
+ language: this.common.language,
+ description: this.common.description,
+ support: this.common.support,
+ name: this.common.name,
+ tags: this.common.tags,
+ nsfw: this.common.nsfw,
+ commentsPolicy: this.common.commentsPolicy,
+ waitTranscoding: this.common.waitTranscoding,
+ channelId: this.common.channelId,
+ privacy: this.common.privacy,
+
+ pluginData: this.common.pluginData,
+
+ previewfile: this.common.previewfile,
+
+ videoPassword: this.common.videoPasswords && this.common.videoPasswords.length !== 0
+ ? this.common.videoPasswords[0]
+ : null,
+
+ downloadEnabled: this.common.downloadEnabled,
+
+ originallyPublishedAt: this.common.originallyPublishedAt
+ ? new Date(this.common.originallyPublishedAt)
+ : null,
+
+ schedulePublicationAt: undefined
+ }
+
+ // Special case if we scheduled an update
+ if (this.common.scheduleUpdate) {
+ Object.assign(json, {
+ privacy: VideoEdit.SPECIAL_SCHEDULED_PRIVACY,
+ schedulePublicationAt: new Date(this.common.scheduleUpdate.updateAt.toString())
+ })
+ }
+
+ return json
+ }
+
+ toVideoUpdate (): Required<Omit<VideoUpdate, 'commentsEnabled'>> {
+ return {
+ ...this.toVideoCreateOrUpdate(),
+
+ pluginData: this.common.pluginData
+ }
+ }
+
+ toVideoCreate (overriddenPrivacy: VideoPrivacyType): Required<Omit<VideoCreate, 'commentsEnabled' | 'generateTranscription'>> {
+ return {
+ ...this.toVideoCreateOrUpdate(),
+
+ privacy: overriddenPrivacy
+ }
+ }
+
+ private toVideoCreateOrUpdate (): Required<Omit<SharedUnionFieldsDeep<VideoCreate | VideoUpdate>, 'commentsEnabled'>> {
+ return {
+ name: this.common.name,
+ category: this.common.category || null,
+ licence: this.common.licence || null,
+ language: this.common.language || null,
+ support: this.common.support || null,
+ description: this.common.description || null,
+ channelId: this.common.channelId,
+ privacy: this.common.privacy,
+
+ videoPasswords: this.common.privacy === VideoPrivacy.PASSWORD_PROTECTED
+ ? this.common.videoPasswords
+ : undefined,
+
+ tags: this.common.tags,
+ nsfw: this.common.nsfw,
+ waitTranscoding: this.common.waitTranscoding,
+ commentsPolicy: this.common.commentsPolicy,
+ downloadEnabled: this.common.downloadEnabled,
+ thumbnailfile: this.common.previewfile,
+ previewfile: this.common.previewfile,
+ scheduleUpdate: this.common.scheduleUpdate || null,
+ originallyPublishedAt: this.common.originallyPublishedAt || null
+ }
+ }
+
+ // ---------------------------------------------------------------------------
+
+ loadFromLiveForm (values: LiveUpdateForm) {
+ if (values.permanentLive !== undefined) this.live.permanentLive = values.permanentLive
+ if (values.latencyMode !== undefined) this.live.latencyMode = values.latencyMode
+ if (values.saveReplay !== undefined) this.live.saveReplay = values.saveReplay
+
+ if (values.replayPrivacy !== undefined) {
+ this.live.replaySettings = values.replayPrivacy
+ ? { privacy: values.replayPrivacy }
+ : undefined
+ }
+
+ this.updateAfterChange()
+ }
+
+ toLiveFormPatch (): Required<LiveUpdateForm> {
+ return {
+ liveStreamKey: this.metadata.live.streamKey,
+ permanentLive: this.live.permanentLive,
+ latencyMode: this.live.latencyMode,
+ saveReplay: this.live.saveReplay,
+
+ replayPrivacy: this.live.replaySettings
+ ? this.live.replaySettings.privacy
+ : VideoPrivacy.PRIVATE
+ }
+ }
+
+ toLiveUpdate (): LiveVideoUpdate {
+ return {
+ permanentLive: this.live.permanentLive,
+ saveReplay: this.live.saveReplay,
+ replaySettings: this.live.saveReplay
+ ? this.live.replaySettings
+ : undefined,
+ latencyMode: this.live.latencyMode
+ }
+ }
+
+ toLiveCreate (overriddenPrivacy: VideoPrivacyType): LiveVideoCreate {
+ return {
+ ...this.toVideoCreate(overriddenPrivacy),
+
+ permanentLive: this.live.permanentLive,
+ latencyMode: this.live.latencyMode,
+ saveReplay: this.live.saveReplay,
+ replaySettings: this.live.replaySettings
+ }
+ }
+
+ // ---------------------------------------------------------------------------
+
+ toVideoImportCreate (overriddenPrivacy: VideoPrivacyType): VideoImportCreate {
+ const base: VideoImportCreate = this.toVideoCreate(overriddenPrivacy)
+
+ if (this.videoImport.targetUrl) base.targetUrl = this.videoImport.targetUrl
+ if (this.videoImport.magnetUri) base.magnetUri = this.videoImport.magnetUri
+ if (this.videoImport.torrentfile) base.torrentfile = this.videoImport.torrentfile
+
+ return base
+ }
+
+ // ---------------------------------------------------------------------------
+
+ loadFromReplaceFileForm (values: ReplaceFileForm) {
+ this.replaceFile = values.replaceFile
+
+ this.updateAfterChange()
+ }
+
+ toReplaceFileFormPatch (): Required<ReplaceFileForm> {
+ return { replaceFile: this.replaceFile }
+ }
+
+ resetReplaceFile () {
+ this.replaceFile = undefined
+ }
+
+ // ---------------------------------------------------------------------------
+
+ loadFromStudioForm (values: StudioForm) {
+ const duration = this.getVideoAttributes().duration
+ this.studioTasks = []
+
+ const cut = values.cut
+ if ((exists(cut.start) && cut.start !== 0) || (exists(cut.end) && cut.end !== duration)) {
+ const options: VideoStudioTaskCut['options'] = {}
+
+ if (exists(cut.start) && cut.start !== 0) options.start = cut.start
+ if (exists(cut.end) && cut.end !== duration) options.end = cut.end
+
+ this.studioTasks.push({ name: 'cut', options })
+ }
+
+ if (values['add-intro']?.['file']) {
+ this.studioTasks.push({
+ name: 'add-intro',
+ options: {
+ file: values['add-intro']['file']
+ }
+ })
+ }
+
+ if (values['add-outro']?.['file']) {
+ this.studioTasks.push({
+ name: 'add-outro',
+ options: {
+ file: values['add-outro']['file']
+ }
+ })
+ }
+
+ if (values['add-watermark']?.['file']) {
+ this.studioTasks.push({
+ name: 'add-watermark',
+ options: {
+ file: values['add-watermark']['file']
+ }
+ })
+ }
+ }
+
+ toStudioFormPatch (): Required<StudioForm> {
+ const cut = this.studioTasks.find(t => t.name === 'cut')
+ const addIntro = this.studioTasks.find(t => t.name === 'add-intro')
+ const addOutro = this.studioTasks.find(t => t.name === 'add-outro')
+ const addWatermark = this.studioTasks.find(t => t.name === 'add-watermark')
+
+ return {
+ 'cut': {
+ start: cut?.options?.start ?? 0,
+ end: cut?.options?.end ?? this.metadata.duration
+ },
+ 'add-intro': { file: addIntro?.options?.file as File ?? null },
+ 'add-outro': { file: addOutro?.options?.file as File },
+ 'add-watermark': { file: addWatermark?.options?.file as File }
+ }
+ }
+
+ resetStudio () {
+ this.studioTasks = []
+ }
+
+ // ---------------------------------------------------------------------------
+
+ getVideoSource () {
+ return this.metadata.videoSource
+ }
+
+ getLive () {
+ return this.metadata.live
+ }
+
+ getVideoAttributes () {
+ return this.videoAttributes
+ }
+
+ getChaptersEdit () {
+ return this.chapters
+ }
+
+ getReplaceFile (): File {
+ return this.replaceFile
+ }
+
+ getCaptionsEdit () {
+ return this.captions
+ }
+
+ getStudioTasks () {
+ return this.studioTasks
+ }
+
+ getStudioTasksSummary () {
+ return this.getStudioTasks().map(t => {
+ if (t.name === 'add-intro') {
+ return $localize`"${(t.options.file as File).name}" will be added at the beginning of the video`
+ }
+
+ if (t.name === 'add-outro') {
+ return $localize`"${(t.options.file as File).name}" will be added at the end of the video`
+ }
+
+ if (t.name === 'add-watermark') {
+ return $localize`"${(t.options.file as File).name}" image watermark will be added to the video`
+ }
+
+ if (t.name === 'cut') {
+ const { start, end } = t.options
+
+ if (start !== undefined && end !== undefined) {
+ return $localize`Video will begin at ${secondsToTime(start)} and stop at ${secondsToTime(end)}`
+ }
+
+ if (start !== undefined) {
+ return $localize`Video will begin at ${secondsToTime(start)}`
+ }
+
+ if (end !== undefined) {
+ return $localize`Video will stop at ${secondsToTime(end)}`
+ }
+ }
+
+ return ''
+ })
+ }
+
+ // ---------------------------------------------------------------------------
+
+ hasCommonChanges () {
+ if (!this.saveStore.common) return true
+
+ let changes = !this.areSameObjects(omit(this.common, [ 'previewfile' ]), omit(this.saveStore.common, [ 'previewfile' ]))
+
+ // Compare preview file
+ if (changes !== true && (this.common.previewfile || this.saveStore.previewfile)) {
+ changes = this.common.previewfile?.size !== this.saveStore.previewfile?.size
+ }
+
+ debugLogger('Check if has common changes', {
+ changes,
+ common: this.common,
+ saveCommon: this.saveStore.common,
+ savePreview: this.saveStore.previewfile
+ })
+
+ return changes
+ }
+
+ hasCaptionChanges () {
+ const changes = this.captions.some(caption => !!caption.action)
+
+ debugLogger('Check if caption has changes', { captions: this.captions, changes })
+
+ return changes
+ }
+
+ hasChaptersChanges () {
+ const changes = this.chapters.hasChanges()
+
+ debugLogger('Check if chapters has changes', { chapters: this.chapters, changes })
+
+ return changes
+ }
+
+ hasLiveChanges () {
+ if (!this.live) return false
+ if (!this.saveStore.live) return true
+
+ const changes = !this.areSameObjects(this.live, this.saveStore.live)
+
+ debugLogger('Check if live has changes', { live: this.live, saveLive: this.saveStore.live, changes })
+
+ return changes
+ }
+
+ hasReplaceFile () {
+ const changes = !!this.replaceFile
+
+ debugLogger('Check if replace file has changes', { replaceFile: this.replaceFile, changes })
+
+ return changes
+ }
+
+ hasStudioTasks () {
+ const changes = this.studioTasks.length !== 0
+
+ debugLogger('Check if studio has changes', { studioTasks: this.studioTasks, changes })
+
+ return changes
+ }
+
+ // ---------------------------------------------------------------------------
+
+ hasPendingChanges () {
+ return this.hasCaptionChanges() ||
+ this.hasLiveChanges() ||
+ this.hasReplaceFile() ||
+ this.hasStudioTasks() ||
+ this.hasChaptersChanges() ||
+ this.hasCommonChanges()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ isPublishedVOD () {
+ return !this.metadata.isLive && this.metadata.state === VideoState.PUBLISHED
+ }
+
+ private updateAfterChange () {
+ this.videoAttributes = {
+ id: this.metadata.id,
+ shortUUID: this.metadata.shortUUID,
+ uuid: this.metadata.uuid,
+ name: this.common.name,
+ state: this.metadata.state,
+ privacy: this.common.privacy,
+ isLive: this.metadata.isLive,
+ aspectRatio: this.metadata.aspectRatio,
+ views: this.metadata.views,
+ likes: this.metadata.likes,
+ duration: this.metadata.duration,
+ blacklisted: this.metadata.blacklisted,
+
+ live: this.metadata.live
+ }
+ }
+
+ // ---------------------------------------------------------------------------
+
+ areSameObjects<T, U> (a: Jsonify<T>, b: Jsonify<U>) {
+ // Allow '' === null
+ if (typeof a === 'string') return a === b || !a && b === null
+ if (typeof b === 'string') return a === b || !b && a === null
+
+ // Allow null === undefined
+ if (a === undefined) return !exists(b)
+ if (b === undefined) return !exists(a)
+
+ if (a as any === b as any) return true
+
+ if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {
+ return false
+ }
+
+ const keysA = Object.keys(a)
+ const keysB = Object.keys(b)
+
+ if (keysA.length !== keysB.length) return false
+
+ for (const key of keysA) {
+ if (!keysB.includes(key)) return false
+
+ if (!this.areSameObjects((a as any)[key], (b as any)[key])) return false
+ }
+
+ return true
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/video-manage-page-common.scss b/client/src/app/+videos-publish-manage/shared-manage/common/video-manage-page-common.scss
new file mode 100644
index 0000000000..530e9061c7
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/video-manage-page-common.scss
@@ -0,0 +1,86 @@
+@use '_variables' as *;
+@use '_mixins' as *;
+@use '_form-mixins' as *;
+
+h2 {
+ font-weight: $font-bold;
+ color: pvar(--fg-350);
+ line-height: 1;
+
+ @include font-size(2rem);
+ @include rfs(2rem, margin-bottom);
+
+ my-global-icon {
+ @include global-icon-size(28px);
+ @include margin-right(0.5rem);
+ }
+
+ @include on-small-main-col {
+ text-align: center;
+ }
+}
+
+.peertube-select-container {
+ @include peertube-select-container(auto);
+}
+
+my-peertube-checkbox {
+ display: block;
+ margin-bottom: 1rem;
+}
+
+my-timestamp-input {
+ width: 100px;
+}
+
+input[type=text] {
+ display: block;
+
+ @include peertube-input-text(100%);
+}
+
+p-calendar {
+ display: block;
+
+ ::ng-deep {
+ .p-calendar {
+ width: 100%;
+ }
+ }
+}
+
+.form-columns {
+ display: grid;
+ grid-template-columns: fit-content(66%) 1fr;
+
+ @include rfs(40px, grid-gap);
+
+ &.disabled {
+ opacity: 0.6;
+ pointer-events: none;
+ }
+
+ &.reverse {
+ > *:nth-child(1) {
+ order: 1;
+ }
+
+ > *:nth-child(2) {
+ order: -1;
+ }
+ }
+
+ @media screen and (max-width: 1000px) {
+ grid-template-columns: 1fr;
+ }
+}
+
+.plugin-fields {
+ display: flex;
+ flex-wrap: wrap;
+ column-gap: 2.5rem;
+
+ > *:nth-child(2n + 1) {
+ width: 66%
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/video-manage.type.ts b/client/src/app/+videos-publish-manage/shared-manage/common/video-manage.type.ts
new file mode 100644
index 0000000000..eb9a95deb8
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/video-manage.type.ts
@@ -0,0 +1 @@
+export type VideoManageType = 'update' | 'upload' | 'import-url' | 'import-torrent' | 'go-live'
diff --git a/client/src/app/+videos/+video-edit/shared/video-upload.service.ts b/client/src/app/+videos-publish-manage/shared-manage/common/video-upload.service.ts
similarity index 97%
rename from client/src/app/+videos/+video-edit/shared/video-upload.service.ts
rename to client/src/app/+videos-publish-manage/shared-manage/common/video-upload.service.ts
index b53f2edcad..a67389e49c 100644
--- a/client/src/app/+videos/+video-edit/shared/video-upload.service.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/common/video-upload.service.ts
@@ -44,7 +44,7 @@ export class VideoUploadService {
// ---------------------------------------------------------------------------
- getNewUploadxOptions (): UploadxOptions {
+ getNewVideoUploadxOptions (): UploadxOptions {
return this.getUploadxOptions(
VideoService.BASE_VIDEO_URL + '/upload-resumable',
UploaderXFormData
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
new file mode 100644
index 0000000000..91f422165d
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/customization/video-customization.component.html
@@ -0,0 +1,51 @@
+<h2>
+ <my-global-icon iconName="cog"></my-global-icon>
+
+ <ng-container i18n>Customization</ng-container>
+</h2>
+
+<div [formGroup]="form">
+ <div class="form-columns">
+ <div>
+ <div *ngIf="videoEdit.getVideoSource()" class="form-group">
+ <label i18n for="filename">Filename</label>
+
+ <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().filename" />
+ </div>
+
+ <div class="form-group originally-published-at">
+ <div class="label-container">
+ <label i18n for="originallyPublishedAt">Original publication date</label>
+
+ <button i18n class="reset-button reset-button-small" (click)="resetField('originallyPublishedAt')" *ngIf="hasPublicationDate()">
+ Reset
+ </button>
+ </div>
+
+ <div class="form-group-description" i18n>
+ This is the date when the content was originally published (e.g. the release date for a film)
+ </div>
+
+ <p-calendar
+ inputId="originallyPublishedAt" formControlName="originallyPublishedAt" [dateFormat]="calendarDateFormat" [firstDayOfWeek]="0"
+ [showTime]="true" [hideOnDateTimeSelect]="true" [monthNavigator]="true" [yearNavigator]="true" [yearRange]="myYearRange"
+ baseZIndex="20000"
+ >
+ </p-calendar>
+
+ <div *ngIf="formErrors.originallyPublishedAt" class="form-error" role="alert">
+ {{ formErrors.originallyPublishedAt }}
+ </div>
+ </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
new file mode 100644
index 0000000000..52dbce6c26
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/customization/video-customization.component.ts
@@ -0,0 +1,119 @@
+import { NgIf } from '@angular/common'
+import { Component, OnDestroy, OnInit, inject } from '@angular/core'
+import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { ServerService } from '@app/core'
+import { BuildFormArgument } from '@app/shared/form-validators/form-validator.model'
+import { VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR } from '@app/shared/form-validators/video-validators'
+import { FormReactiveErrors, FormReactiveService, FormReactiveValidationMessages } from '@app/shared/shared-forms/form-reactive.service'
+import { HTMLServerConfig } from '@peertube/peertube-models'
+import debug from 'debug'
+import { CalendarModule } from 'primeng/calendar'
+import { Subscription } from 'rxjs'
+import { PeertubeCheckboxComponent } from '../../../shared/shared-forms/peertube-checkbox.component'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { I18nPrimengCalendarService } from '../common/i18n-primeng-calendar.service'
+import { VideoEdit } from '../common/video-edit.model'
+import { VideoManageController } from '../video-manage-controller.service'
+
+const debugLogger = debug('peertube:video-manage')
+
+type Form = {
+ downloadEnabled: FormControl<boolean>
+ originallyPublishedAt: FormControl<Date>
+}
+
+@Component({
+ selector: 'my-video-customization',
+ styleUrls: [
+ '../common/video-manage-page-common.scss'
+ ],
+ templateUrl: './video-customization.component.html',
+ imports: [
+ FormsModule,
+ ReactiveFormsModule,
+ NgIf,
+ CalendarModule,
+ PeertubeCheckboxComponent,
+ GlobalIconComponent
+ ]
+})
+export class VideoCustomizationComponent implements OnInit, OnDestroy {
+ private formReactiveService = inject(FormReactiveService)
+ private serverService = inject(ServerService)
+ private i18nPrimengCalendarService = inject(I18nPrimengCalendarService)
+ private manageController = inject(VideoManageController)
+
+ form: FormGroup<Form>
+ formErrors: FormReactiveErrors = {}
+ validationMessages: FormReactiveValidationMessages = {}
+
+ videoEdit: VideoEdit
+
+ calendarDateFormat: string
+ myYearRange: string
+
+ serverConfig: HTMLServerConfig
+
+ private updatedSub: Subscription
+
+ constructor () {
+ this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat()
+ this.myYearRange = this.i18nPrimengCalendarService.getVideoPublicationYearRange()
+ }
+
+ ngOnInit () {
+ this.serverConfig = this.serverService.getHTMLConfig()
+
+ const { videoEdit } = this.manageController.getStore()
+ this.videoEdit = videoEdit
+
+ this.buildForm()
+ }
+
+ private buildForm () {
+ const defaultValues = this.videoEdit.toCommonFormPatch()
+ const obj: BuildFormArgument = {
+ downloadEnabled: null,
+ originallyPublishedAt: VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR
+ }
+
+ const {
+ form,
+ formErrors,
+ validationMessages
+ } = this.formReactiveService.buildForm<Form>(obj, defaultValues)
+
+ this.form = form
+ this.formErrors = formErrors
+ this.validationMessages = validationMessages
+
+ this.form.valueChanges.subscribe(() => {
+ this.manageController.setFormError($localize`Customization`, 'customization', this.formErrors)
+
+ const formValues = this.form.value
+ debugLogger('Updating form values', formValues)
+
+ this.videoEdit.loadFromCommonForm(formValues)
+ })
+
+ this.formReactiveService.markAllAsDirty(this.form.controls)
+
+ this.updatedSub = this.manageController.getUpdatedObs().subscribe(() => {
+ this.form.patchValue(this.videoEdit.toCommonFormPatch())
+ })
+ }
+
+ ngOnDestroy () {
+ this.updatedSub?.unsubscribe()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ hasPublicationDate () {
+ return !!this.form.value.originallyPublishedAt
+ }
+
+ resetField (name: string) {
+ this.form.patchValue({ [name]: null })
+ }
+}
diff --git a/client/src/app/shared/shared-video-live/live-documentation-link.component.html b/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-documentation-link.component.html
similarity index 100%
rename from client/src/app/shared/shared-video-live/live-documentation-link.component.html
rename to client/src/app/+videos-publish-manage/shared-manage/live-settings/live-documentation-link.component.html
diff --git a/client/src/app/shared/shared-video-live/live-documentation-link.component.ts b/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-documentation-link.component.ts
similarity index 100%
rename from client/src/app/shared/shared-video-live/live-documentation-link.component.ts
rename to client/src/app/+videos-publish-manage/shared-manage/live-settings/live-documentation-link.component.ts
diff --git a/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.html b/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.html
new file mode 100644
index 0000000000..5a879bec7f
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.html
@@ -0,0 +1,14 @@
+<div class="journal" *ngIf="latestLiveSessions.length !== 0">
+ <div class="label" i18n>Latest live sessions</div>
+
+ <div class="journal-session d-flex align-items-center flex-wrap mb-2" *ngFor="let session of latestLiveSessions">
+ <span i18n class="pt-badge badge-success me-2" *ngIf="!getErrorLabel(session)">Success</span>
+ <span class="pt-badge badge-danger me-2" *ngIf="getErrorLabel(session)">{{ getErrorLabel(session) }}</span>
+
+ <span i18n>Started on <strong>{{ session.startDate | ptDate:'medium' }}</strong></span>
+ <span i18n *ngIf="session.endDate">Ended on <strong>{{ session.endDate | ptDate:'medium' }}</strong></span>
+
+ <a i18n *ngIf="session.replayVideo" [routerLink]="getVideoUrl(session.replayVideo)" target="_blank">Go to replay</a>
+ <span i18n *ngIf="isReplayBeingProcessed(session)">Replay is being processed...</span>
+ </div>
+</div>
diff --git a/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.scss b/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.scss
new file mode 100644
index 0000000000..66e1c02062
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.scss
@@ -0,0 +1,9 @@
+@use '_variables' as *;
+@use '_mixins' as *;
+
+.journal-session {
+ span:not(.pt-badge, :last-child)::after {
+ margin: 3px;
+ content: '•';
+ }
+}
diff --git a/client/src/app/shared/shared-video-live/live-stream-information.component.ts b/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.ts
similarity index 52%
rename from client/src/app/shared/shared-video-live/live-stream-information.component.ts
rename to client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.ts
index 4b3b13ffa6..8fa94b9bf8 100644
--- a/client/src/app/shared/shared-video-live/live-stream-information.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/live-settings/live-stream-information.component.ts
@@ -1,52 +1,31 @@
-import { NgFor, NgIf } from '@angular/common'
-import { Component, ElementRef, inject, viewChild } from '@angular/core'
+import { CommonModule } from '@angular/common'
+import { Component, inject, input, OnInit } from '@angular/core'
import { RouterLink } from '@angular/router'
import { Video } from '@app/shared/shared-main/video/video.model'
-import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
-import { LiveVideo, LiveVideoError, LiveVideoErrorType, LiveVideoSession } from '@peertube/peertube-models'
-import { InputTextComponent } from '../shared-forms/input-text.component'
-import { GlobalIconComponent } from '../shared-icons/global-icon.component'
-import { EditButtonComponent } from '../shared-main/buttons/edit-button.component'
-import { AlertComponent } from '../shared-main/common/alert.component'
-import { PTDatePipe } from '../shared-main/common/date.pipe'
-import { LiveDocumentationLinkComponent } from './live-documentation-link.component'
-import { LiveVideoService } from './live-video.service'
+import { LiveVideoError, LiveVideoErrorType, LiveVideoSession } from '@peertube/peertube-models'
+import { PTDatePipe } from '../../../shared/shared-main/common/date.pipe'
+import { LiveVideoService } from '../../../shared/shared-video-live/live-video.service'
@Component({
selector: 'my-live-stream-information',
templateUrl: './live-stream-information.component.html',
styleUrls: [ './live-stream-information.component.scss' ],
imports: [
- GlobalIconComponent,
- NgIf,
- LiveDocumentationLinkComponent,
- InputTextComponent,
- NgFor,
+ CommonModule,
RouterLink,
- EditButtonComponent,
- PTDatePipe,
- AlertComponent
+ PTDatePipe
],
providers: [ LiveVideoService ]
})
-export class LiveStreamInformationComponent {
- private modalService = inject(NgbModal)
+export class LiveStreamInformationComponent implements OnInit {
private liveVideoService = inject(LiveVideoService)
- readonly modal = viewChild<ElementRef>('modal')
-
- video: Video
- live: LiveVideo
+ video = input.required<Pick<Video, 'id' | 'shortUUID'>>()
latestLiveSessions: LiveVideoSession[] = []
- show (video: Video) {
- this.video = video
- this.live = undefined
-
- this.loadLiveInfo(video)
-
- this.modalService
- .open(this.modal(), { centered: true })
+ ngOnInit () {
+ this.liveVideoService.listSessions(this.video().id)
+ .subscribe(({ data }) => this.latestLiveSessions = data.reverse())
}
getVideoUrl (video: { shortUUID: string }) {
@@ -77,12 +56,4 @@ export class LiveStreamInformationComponent {
return session.saveReplay && !session.endingProcessed
}
-
- private loadLiveInfo (video: Video) {
- this.liveVideoService.getVideoLive(video.id)
- .subscribe(live => this.live = live)
-
- this.liveVideoService.listSessions(video.id)
- .subscribe(({ data }) => this.latestLiveSessions = data.reverse().slice(0, 5))
- }
}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/live-settings/video-live-settings.component.html b/client/src/app/+videos-publish-manage/shared-manage/live-settings/video-live-settings.component.html
new file mode 100644
index 0000000000..3664bb2225
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/live-settings/video-live-settings.component.html
@@ -0,0 +1,98 @@
+<h2>
+ <my-global-icon iconName="live"></my-global-icon>
+
+ <ng-container i18n>Live settings</ng-container>
+</h2>
+
+@if (!isLive()) {
+ <my-alert type="danger" i18n>{{ getVideoName() }} is not a live.</my-alert>
+} @else if (hasEnded()) {
+ <my-alert type="primary" i18n>Your live has ended.</my-alert>
+} @else {
+ <div [formGroup]="form">
+
+ <my-alert class="d-block mb-4" type="primary">
+ @if (isStreaming()) {
+ <ng-container i18n>Live configuration is unavailable because you are streaming in this live.</ng-container>
+ } @else {
+ <my-live-documentation-link></my-live-documentation-link>
+
+ <div class="mt-3" i18n *ngIf="getMaxLiveDuration() >= 0">
+ Max live duration configured on {{ getInstanceName() }} is {{ getMaxLiveDuration() | myTimeDurationFormatter }}.
+ If your live reaches this limit, it will be automatically terminated.
+ </div>
+ }
+ </my-alert>
+
+ <div class="form-columns reverse" [ngClass]="{ disabled: isStreaming() }">
+ <div>
+ <div *ngIf="getLive().rtmpUrl" class="form-group">
+ <label for="liveVideoRTMPUrl" i18n>Live RTMP Url</label>
+ <my-input-text inputId="liveVideoRTMPUrl" [value]="getLive().rtmpUrl" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-text>
+ </div>
+
+ <div *ngIf="getLive().rtmpsUrl" class="form-group">
+ <label for="liveVideoRTMPSUrl" i18n>Live RTMPS Url</label>
+ <my-input-text inputId="liveVideoRTMPSUrl" [value]="getLive().rtmpsUrl" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-text>
+ </div>
+
+ <div class="form-group">
+ <label for="liveVideoStreamKey" i18n>Live stream key</label>
+ <my-input-text inputId="liveVideoStreamKey" [value]="getLive().streamKey" [withCopy]="true" [readonly]="true"></my-input-text>
+
+ <div class="form-group-description" i18n>⚠️ Never share your stream key with anyone.</div>
+ </div>
+
+ <my-live-stream-information [video]="videoEdit.getVideoAttributes()"></my-live-stream-information>
+ </div>
+
+ <div>
+ <div class="form-group">
+ <div class="peertube-radio-container">
+ <input type="radio" formControlName="permanentLive" id="permanentLiveFalse" [value]="false">
+ <label i18n for="permanentLiveFalse" class="radio">This is a normal live</label>
+
+ <span class="form-group-description" i18n>
+ You can stream only once in a normal live. If you enable replay, it will be saved under the same URL as your live
+ </span>
+ </div>
+
+ <div class="peertube-radio-container">
+ <input type="radio" formControlName="permanentLive" id="permanentLiveTrue" [value]="true">
+ <label i18n for="permanentLiveTrue" class="radio">This is a permanent/recurring live</label>
+
+ <span class="form-group-description" i18n>
+ You can stream multiple times in a permanent/recurring live. If you enable replays, they will be saved as separate videos
+ </span>
+ </div>
+ </div>
+
+ <div class="form-group" *ngIf="isSaveReplayAllowed()">
+ <my-peertube-checkbox inputName="liveVideoSaveReplay" formControlName="saveReplay">
+ <ng-template ptTemplate="label">
+ <ng-container i18n>Automatically publish a replay when your live ends</ng-container>
+ </ng-template>
+
+ <ng-container ngProjectAs="description">
+ <span i18n>⚠️ If you enable this option, your live will be terminated if you exceed your video quota</span>
+ </ng-container>
+ </my-peertube-checkbox>
+ </div>
+
+ <div class="form-group mx-4" *ngIf="isSaveReplayEnabled()">
+ <label i18n for="replayPrivacy">Privacy of the new replay</label>
+ <my-select-options inputId="replayPrivacy" [items]="replayPrivacies" formControlName="replayPrivacy"></my-select-options>
+ </div>
+
+ <div class="form-group" *ngIf="isLatencyModeEnabled()">
+ <label i18n for="latencyMode">Latency mode</label>
+ <my-select-options inputId="latencyMode" [items]="latencyModes" formControlName="latencyMode" clearable="true"></my-select-options>
+
+ <div *ngIf="formErrors.latencyMode" class="form-error" role="alert">
+ {{ formErrors.latencyMode }}
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/live-settings/video-live-settings.component.ts b/client/src/app/+videos-publish-manage/shared-manage/live-settings/video-live-settings.component.ts
new file mode 100644
index 0000000000..aa634b1f28
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/live-settings/video-live-settings.component.ts
@@ -0,0 +1,201 @@
+import { CommonModule } from '@angular/common'
+import { Component, OnDestroy, OnInit, inject } from '@angular/core'
+import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { ServerService } from '@app/core'
+import { BuildFormArgument } from '@app/shared/form-validators/form-validator.model'
+import { FormReactiveErrors, FormReactiveService, FormReactiveValidationMessages } from '@app/shared/shared-forms/form-reactive.service'
+import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
+import { VideoService } from '@app/shared/shared-main/video/video.service'
+import {
+ HTMLServerConfig,
+ LiveVideoLatencyMode,
+ LiveVideoLatencyModeType,
+ VideoConstant,
+ VideoPrivacy,
+ VideoPrivacyType,
+ VideoState
+} from '@peertube/peertube-models'
+import debug from 'debug'
+import { CalendarModule } from 'primeng/calendar'
+import { Subscription } from 'rxjs'
+import { SelectOptionsItem } from 'src/types/select-options-item.model'
+import { InputTextComponent } from '../../../shared/shared-forms/input-text.component'
+import { PeertubeCheckboxComponent } from '../../../shared/shared-forms/peertube-checkbox.component'
+import { SelectOptionsComponent } from '../../../shared/shared-forms/select/select-options.component'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { PeerTubeTemplateDirective } from '../../../shared/shared-main/common/peertube-template.directive'
+import { TimeDurationFormatterPipe } from '../../../shared/shared-main/date/time-duration-formatter.pipe'
+import { VideoEdit } from '../common/video-edit.model'
+import { VideoManageController } from '../video-manage-controller.service'
+import { LiveDocumentationLinkComponent } from './live-documentation-link.component'
+import { LiveStreamInformationComponent } from './live-stream-information.component'
+
+const debugLogger = debug('peertube:video-manage')
+
+type Form = {
+ liveStreamKey: FormControl<string>
+ permanentLive: FormControl<boolean>
+ latencyMode: FormControl<LiveVideoLatencyModeType>
+ saveReplay: FormControl<boolean>
+ replayPrivacy: FormControl<VideoPrivacyType>
+}
+
+@Component({
+ selector: 'my-video-live-settings',
+ styleUrls: [
+ '../common/video-manage-page-common.scss'
+ ],
+ templateUrl: './video-live-settings.component.html',
+ imports: [
+ CommonModule,
+ FormsModule,
+ ReactiveFormsModule,
+ PeerTubeTemplateDirective,
+ SelectOptionsComponent,
+ InputTextComponent,
+ CalendarModule,
+ PeertubeCheckboxComponent,
+ LiveDocumentationLinkComponent,
+ AlertComponent,
+ TimeDurationFormatterPipe,
+ GlobalIconComponent,
+ LiveStreamInformationComponent
+ ]
+})
+export class VideoLiveSettingsComponent implements OnInit, OnDestroy {
+ private formReactiveService = inject(FormReactiveService)
+ private videoService = inject(VideoService)
+ private serverService = inject(ServerService)
+ private manageController = inject(VideoManageController)
+
+ form: FormGroup<Form>
+ formErrors: FormReactiveErrors = {}
+ validationMessages: FormReactiveValidationMessages = {}
+
+ videoEdit: VideoEdit
+
+ replayPrivacies: VideoConstant<VideoPrivacyType>[] = []
+
+ latencyModes: SelectOptionsItem[] = [
+ {
+ id: LiveVideoLatencyMode.SMALL_LATENCY,
+ label: $localize`Small latency`,
+ description: $localize`Reduce latency to ~15s disabling P2P`
+ },
+ {
+ id: LiveVideoLatencyMode.DEFAULT,
+ label: $localize`Default`,
+ description: $localize`Average latency of 30s`
+ },
+ {
+ id: LiveVideoLatencyMode.HIGH_LATENCY,
+ label: $localize`High latency`,
+ description: $localize`Average latency of 60s increasing P2P ratio`
+ }
+ ]
+
+ serverConfig: HTMLServerConfig
+
+ private updatedSub: Subscription
+
+ ngOnInit () {
+ this.serverConfig = this.serverService.getHTMLConfig()
+
+ const { videoEdit } = this.manageController.getStore()
+ this.videoEdit = videoEdit
+
+ this.buildForm()
+
+ this.serverService.getVideoPrivacies()
+ .subscribe(privacies => {
+ this.replayPrivacies = this.videoService.explainedPrivacyLabels(privacies)
+ .videoPrivacies
+ .filter(privacy => privacy.id !== VideoPrivacy.PASSWORD_PROTECTED)
+ })
+ }
+
+ ngOnDestroy () {
+ this.updatedSub?.unsubscribe()
+ }
+
+ private buildForm () {
+ const defaultValues = this.videoEdit.toLiveFormPatch()
+
+ const obj: BuildFormArgument = {
+ liveStreamKey: null,
+ permanentLive: null,
+ latencyMode: null,
+ saveReplay: null,
+ replayPrivacy: null
+ }
+
+ const {
+ form,
+ formErrors,
+ validationMessages
+ } = this.formReactiveService.buildForm<Form>(obj, defaultValues)
+
+ this.form = form
+ this.formErrors = formErrors
+ this.validationMessages = validationMessages
+
+ this.form.valueChanges.subscribe(() => {
+ this.manageController.setFormError($localize`Live settings`, 'live-settings', this.formErrors)
+
+ const formValues = this.form.value
+ debugLogger('Updating form values', formValues)
+
+ this.videoEdit.loadFromLiveForm(formValues)
+ })
+
+ this.formReactiveService.markAllAsDirty(this.form.controls)
+
+ this.updatedSub = this.manageController.getUpdatedObs().subscribe(() => {
+ this.form.patchValue(this.videoEdit.toLiveFormPatch())
+ })
+ }
+
+ isSaveReplayAllowed () {
+ return this.serverConfig.live.allowReplay
+ }
+
+ isSaveReplayEnabled () {
+ return this.form.value.saveReplay === true
+ }
+
+ isPermanentLiveEnabled () {
+ return this.form.value.permanentLive === true
+ }
+
+ isLatencyModeEnabled () {
+ return this.serverConfig.live.latencySetting.enabled
+ }
+
+ isLive () {
+ return this.videoEdit.getVideoAttributes().isLive
+ }
+
+ hasEnded () {
+ return this.videoEdit.getVideoAttributes().state === VideoState.LIVE_ENDED
+ }
+
+ isStreaming () {
+ return this.videoEdit.getVideoAttributes().state === VideoState.PUBLISHED
+ }
+
+ getLive () {
+ return this.videoEdit.getVideoAttributes().live
+ }
+
+ getVideoName () {
+ return this.videoEdit.getVideoAttributes().name
+ }
+
+ getMaxLiveDuration () {
+ return this.serverConfig.live.maxDuration / 1000
+ }
+
+ getInstanceName () {
+ return this.serverConfig.instance.name
+ }
+}
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
new file mode 100644
index 0000000000..48d946b4e7
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html
@@ -0,0 +1,169 @@
+<h2>
+ <my-global-icon iconName="film"></my-global-icon>
+
+ <ng-container i18n>Main information</ng-container>
+</h2>
+
+<div [formGroup]="form">
+
+ <ng-template #pluginSettingTemplate let-pluginSetting>
+ <div [hidden]="isPluginFieldHidden(pluginSetting)">
+ <my-dynamic-form-field [form]="pluginDataFormGroup" [formErrors]="formErrors['pluginData']" [setting]="pluginSetting.commonOptions"></my-dynamic-form-field>
+ </div>
+ </ng-template>
+
+ <div class="form-columns">
+ <div>
+ <div class="form-group">
+ <label i18n for="name">Video title</label>
+ <input type="text" id="name" class="form-control" formControlName="name" />
+ <div *ngIf="formErrors.name" class="form-error" role="alert">{{ formErrors.name }}</div>
+ </div>
+
+ <div class="form-group">
+ <label i18n for="description">Description</label>
+
+ <div class="form-group-description">
+ <div i18n>
+ You can format your description using the <my-markdown-hint helpType="markdownText">Markdown Language</my-markdown-hint>:
+ </div>
+
+ <ul>
+ <li i18n>For example, to put <strong>text in bold</strong> (**text in bold**) or <em>text in italic</em> (*text in italic*)</li>
+ <li i18n>You can also create a link to a specific timecode of the video (e.g. <span class="fake-link">00:05</span> by simply writing 00:05) or <span class="fake-link">a classic link</span> ([title of my link](https://example.com))</li>
+ </ul>
+ </div>
+
+ <my-markdown-textarea
+ inputId="description"
+ formControlName="description" [markdownVideo]="videoEdit.getVideoAttributes()"
+ [formError]="formErrors.description" withEmoji="true"
+ ></my-markdown-textarea>
+ </div>
+
+ <div class="form-group">
+ <label for="label-tags" i18n class="label-tags">Tags</label>
+ <div class="form-group-description">
+ <ng-container i18n>Maximum of 5 tags to suggest relevant recommendations.</ng-container>
+ </div>
+
+ <my-select-tags inputId="label-tags" formControlName="tags" class="d-block w-100"></my-select-tags>
+ <div *ngIf="formErrors.tags" class="form-error" role="alert">{{ formErrors.tags }}</div>
+ </div>
+
+ <div class="form-group">
+ <label i18n for="licence">Licence</label>
+
+ <div class="form-group-description" i18n>
+ <a href="https://chooser-beta.creativecommons.org/" target="_blank" rel="noopener noreferrer">Choose</a> the appropriate licence for your work.
+ </div>
+
+ <my-select-options inputId="licence" [items]="videoLicences" formControlName="licence" clearable="true"></my-select-options>
+
+ <div *ngIf="formErrors.licence" class="form-error" role="alert">
+ {{ formErrors.licence }}
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label i18n for="support">Support button</label>
+
+ <div class="form-group-description" i18n>
+ This is text that helps people watching your video <strong>understand how to support you</strong>. You can use <my-markdown-hint helpType="markdownText">Markdown Language</my-markdown-hint>, including <strong>links to your fundraising tools</strong>.
+ </div>
+
+ <my-markdown-textarea
+ inputId="support" formControlName="support" markdownType="enhanced"
+ [formError]="formErrors['support']" withPreview="false"
+ ></my-markdown-textarea>
+
+ <div class="form-group-description" i18n>
+ Do you want to use the same text for all your videos? You can define <strong>a default text and support button</strong> in your <a [routerLink]="getChannelUpdateUrl()" target="_blank" rel="noopener noreferrer">channel settings</a>.
+ </div>
+ </div>
+ </div>
+
+ <div>
+ <div class="form-group">
+ <label i18n for="channel">Channel</label>
+ <my-select-channel class="d-block" inputId="channel" [items]="userChannels" formControlName="channelId"></my-select-channel>
+ </div>
+
+ <div class="form-group">
+ <label i18n for="previewfile">Thumbnail</label>
+
+ <my-thumbnail-manager id="previewfile" formControlName="previewfile" [videoEdit]="videoEdit"></my-thumbnail-manager>
+ </div>
+
+ <div class="form-group">
+ <label i18n for="privacy">Privacy</label>
+ <my-select-options inputId="privacy" [items]="videoPrivacies" formControlName="privacy"></my-select-options>
+
+ <div *ngIf="formErrors.privacy" class="form-error" role="alert">
+ {{ formErrors.privacy }}
+ </div>
+ </div>
+
+ <div *ngIf="passwordProtectionSelected" class="form-group">
+ <label i18n for="videoPassword">Password</label>
+ <my-input-text formControlName="videoPassword" inputId="videoPassword" [withCopy]="true" [formError]="formErrors['videoPassword']"></my-input-text>
+ </div>
+
+ <div *ngIf="schedulePublicationSelected" class="form-group">
+ <label i18n for="schedulePublicationAt">Schedule publication ({{ calendarTimezone }})</label>
+ <p-calendar
+ id="schedulePublicationAt" formControlName="schedulePublicationAt" [dateFormat]="calendarDateFormat"
+ [firstDayOfWeek]="0" [minDate]="minScheduledDate" [showTime]="true" [hideOnDateTimeSelect]="true"
+ baseZIndex="20000"
+ >
+ </p-calendar>
+
+ <div *ngIf="formErrors.schedulePublicationAt" class="form-error" role="alert">
+ {{ formErrors.schedulePublicationAt }}
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label i18n for="category">Category</label>
+ <my-select-options inputId="category" [items]="videoCategories" formControlName="category" clearable="true"></my-select-options>
+
+ <div *ngIf="formErrors.category" class="form-error" role="alert">
+ {{ formErrors.category }}
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label i18n for="language">Language</label>
+ <my-select-options
+ inputId="language" [items]="videoLanguages" formControlName="language"
+ clearable="true" filter="true" virtualScroll="true"
+ ></my-select-options>
+
+ <div *ngIf="formErrors.language" class="form-error" role="alert">
+ {{ formErrors.language }}
+ </div>
+ </div>
+
+ <my-peertube-checkbox *ngIf="!hideWaitTranscoding" inputName="waitTranscoding" formControlName="waitTranscoding" helpPlacement="bottom-right">
+ <ng-template ptTemplate="label">
+ <ng-container i18n>Publish video after transcoding</ng-container>
+ </ng-template>
+
+ <ng-template ptTemplate="help">
+ <ng-container i18n>The video may be unplayable during the transcoding process. It's the reason why we prefer to publish publicly the video after transcoding.</ng-container>
+ </ng-template>
+ </my-peertube-checkbox>
+ </div>
+</div>
+
+<div class="plugin-fields">
+ <ng-container
+ *ngFor="let pluginSetting of getPluginsFields('main')"
+ [ngTemplateOutlet]="pluginSettingTemplate" [ngTemplateOutletContext]="{ $implicit: pluginSetting }"
+ ></ng-container>
+
+ <ng-container
+ *ngFor="let pluginSetting of getPluginsFields('plugin-settings')"
+ [ngTemplateOutlet]="pluginSettingTemplate" [ngTemplateOutletContext]="{ $implicit: pluginSetting }"
+ ></ng-container>
+</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
new file mode 100644
index 0000000000..2ae4a86b20
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts
@@ -0,0 +1,462 @@
+import { CommonModule } from '@angular/common'
+import { ChangeDetectorRef, Component, inject, NgZone, OnDestroy, OnInit } from '@angular/core'
+import { AbstractControl, FormArray, FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'
+import { RouterLink } from '@angular/router'
+import { HooksService, PluginService, ServerService } from '@app/core'
+import { BuildFormArgument, BuildFormValidator } from '@app/shared/form-validators/form-validator.model'
+import {
+ VIDEO_CATEGORY_VALIDATOR,
+ VIDEO_CHANNEL_VALIDATOR,
+ VIDEO_DESCRIPTION_VALIDATOR,
+ VIDEO_LANGUAGE_VALIDATOR,
+ VIDEO_LICENCE_VALIDATOR,
+ VIDEO_NAME_VALIDATOR,
+ VIDEO_PASSWORD_VALIDATOR,
+ VIDEO_PRIVACY_VALIDATOR,
+ VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR,
+ VIDEO_SUPPORT_VALIDATOR,
+ VIDEO_TAGS_ARRAY_VALIDATOR
+} from '@app/shared/form-validators/video-validators'
+import { DynamicFormFieldComponent } from '@app/shared/shared-forms/dynamic-form-field.component'
+import { FormReactiveErrors, FormReactiveService, FormReactiveValidationMessages } from '@app/shared/shared-forms/form-reactive.service'
+import { FormValidatorService } from '@app/shared/shared-forms/form-validator.service'
+import { InputTextComponent } from '@app/shared/shared-forms/input-text.component'
+import { MarkdownTextareaComponent } from '@app/shared/shared-forms/markdown-textarea.component'
+import { PeertubeCheckboxComponent } from '@app/shared/shared-forms/peertube-checkbox.component'
+import { SelectChannelComponent } from '@app/shared/shared-forms/select/select-channel.component'
+import { SelectOptionsComponent } from '@app/shared/shared-forms/select/select-options.component'
+import { SelectTagsComponent } from '@app/shared/shared-forms/select/select-tags.component'
+import { PeerTubeTemplateDirective } from '@app/shared/shared-main/common/peertube-template.directive'
+import { InstanceService } from '@app/shared/shared-main/instance/instance.service'
+import { VideoService } from '@app/shared/shared-main/video/video.service'
+import {
+ HTMLServerConfig,
+ RegisterClientFormFieldOptions,
+ RegisterClientVideoFieldOptions,
+ VideoConstant,
+ VideoPrivacy,
+ VideoPrivacyType
+} from '@peertube/peertube-models'
+import { logger } from '@root-helpers/logger'
+import { PluginInfo } from '@root-helpers/plugins-manager'
+import debug from 'debug'
+import { CalendarModule } from 'primeng/calendar'
+import { forkJoin, Subscription } from 'rxjs'
+import { map } from 'rxjs/operators'
+import { SelectChannelItem } from 'src/types/select-options-item.model'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { MarkdownHintComponent } from '../../../shared/shared-main/text/markdown-hint.component'
+import { I18nPrimengCalendarService } from '../common/i18n-primeng-calendar.service'
+import { ThumbnailManagerComponent } from '../common/thumbnail-manager.component'
+import { VideoEdit, VideoEditPrivacyType } from '../common/video-edit.model'
+import { VideoManageType } from '../common/video-manage.type'
+import { VideoManageController } from '../video-manage-controller.service'
+
+const debugLogger = debug('peertube:video-manage')
+
+type PluginField = {
+ pluginInfo: PluginInfo
+ commonOptions: RegisterClientFormFieldOptions
+ videoFormOptions: RegisterClientVideoFieldOptions
+}
+
+type Form = {
+ name: FormControl<string>
+ privacy: FormControl<VideoEditPrivacyType>
+ videoPassword: FormControl<string>
+ channelId: FormControl<number>
+ waitTranscoding: FormControl<boolean>
+ category: FormControl<number>
+ licence: FormControl<number>
+ language: FormControl<string>
+ description: FormControl<string>
+ tags: FormArray<FormControl<string>>
+ previewfile: FormControl<Blob>
+ support: FormControl<string>
+ schedulePublicationAt: FormControl<Date>
+ pluginData: FormGroup<any>
+}
+
+@Component({
+ selector: 'my-video-main-info',
+ styleUrls: [
+ '../common/video-manage-page-common.scss'
+ ],
+ templateUrl: './video-main-info.component.html',
+ imports: [
+ CommonModule,
+ FormsModule,
+ ReactiveFormsModule,
+ DynamicFormFieldComponent,
+ PeerTubeTemplateDirective,
+ SelectTagsComponent,
+ MarkdownTextareaComponent,
+ SelectChannelComponent,
+ SelectOptionsComponent,
+ InputTextComponent,
+ CalendarModule,
+ PeertubeCheckboxComponent,
+ ThumbnailManagerComponent,
+ GlobalIconComponent,
+ MarkdownHintComponent,
+ RouterLink
+ ]
+})
+export class VideoMainInfoComponent implements OnInit, OnDestroy {
+ private formValidatorService = inject(FormValidatorService)
+ private formReactiveService = inject(FormReactiveService)
+ private videoService = inject(VideoService)
+ private serverService = inject(ServerService)
+ private pluginService = inject(PluginService)
+ private instanceService = inject(InstanceService)
+ private i18nPrimengCalendarService = inject(I18nPrimengCalendarService)
+ private ngZone = inject(NgZone)
+ private hooks = inject(HooksService)
+ private cd = inject(ChangeDetectorRef)
+ private manageController = inject(VideoManageController)
+
+ form: FormGroup<Form>
+ formErrors: FormReactiveErrors = {}
+ validationMessages: FormReactiveValidationMessages = {}
+
+ forbidScheduledPublication: boolean
+ hideWaitTranscoding: boolean
+
+ videoPrivacies: VideoConstant<VideoEditPrivacyType>[] = []
+ videoCategories: VideoConstant<number>[] = []
+ videoLicences: VideoConstant<number>[] = []
+ videoLanguages: VideoConstant<string>[] = []
+
+ pluginDataFormGroup: FormGroup
+
+ schedulePublicationSelected = false
+ passwordProtectionSelected = false
+
+ calendarLocale: any = {}
+ minScheduledDate = new Date()
+
+ calendarTimezone: string
+ calendarDateFormat: string
+ myYearRange: string
+
+ serverConfig: HTMLServerConfig
+
+ pluginFields: PluginField[] = []
+
+ manageType: VideoManageType
+
+ firstPatchDone = false
+
+ userChannels: SelectChannelItem[] = []
+ privacies: VideoPrivacyType[] = []
+ videoEdit: VideoEdit
+
+ private schedulerInterval: any
+ private updatedSub: Subscription
+
+ constructor () {
+ this.calendarTimezone = this.i18nPrimengCalendarService.getTimezone()
+ this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat()
+ this.myYearRange = this.i18nPrimengCalendarService.getVideoPublicationYearRange()
+ }
+
+ ngOnInit () {
+ this.serverConfig = this.serverService.getHTMLConfig()
+
+ const { videoEdit, userChannels } = this.manageController.getStore()
+ this.videoEdit = videoEdit
+ this.userChannels = userChannels
+
+ const { manageType, hideWaitTranscoding, forbidScheduledPublication } = this.manageController.getConfig()
+ this.manageType = manageType
+ this.hideWaitTranscoding = hideWaitTranscoding
+ this.forbidScheduledPublication = forbidScheduledPublication
+
+ this.buildForm()
+
+ this.pluginService.ensurePluginsAreLoaded('video-edit')
+ .then(() => this.updatePluginFields())
+
+ this.serverService.getVideoCategories()
+ .subscribe(res => this.videoCategories = res)
+
+ this.serverService.getVideoLicences()
+ .subscribe(res => this.videoLicences = res)
+
+ this.buildLanguages()
+ this.buildPrivacies()
+
+ this.ngZone.runOutsideAngular(() => {
+ this.schedulerInterval = setInterval(() => this.minScheduledDate = new Date(), 1000 * 60) // Update every minute
+ })
+
+ const updateFormForPlugins = (values: any) => {
+ this.form.patchValue(values)
+ this.cd.detectChanges()
+ }
+ this.hooks.runAction('action:video-edit.init', 'video-edit', { type: this.manageType, updateForm: updateFormForPlugins })
+
+ this.form.valueChanges.subscribe(() => {
+ const formValues = this.form.value
+
+ this.hooks.runAction('action:video-edit.form.updated', 'video-edit', { type: this.manageType, formValues })
+
+ this.manageController.setFormError($localize`Main information`, '.', this.formErrors)
+
+ debugLogger('Updating form values', formValues)
+
+ this.videoEdit.loadFromCommonForm(formValues)
+ })
+
+ this.formReactiveService.markAllAsDirty(this.form.controls)
+
+ this.updatedSub = this.manageController.getUpdatedObs().subscribe(() => {
+ this.form.patchValue(this.videoEdit.toCommonFormPatch())
+ })
+
+ this.manageController.registerSaveHook(async () => {
+ await this.formReactiveService.waitPendingCheck(this.form)
+ this.formReactiveService.forceCheck(this.form, this.formErrors, this.validationMessages)
+ this.manageController.setFormError($localize`Main information`, '.', this.formErrors)
+ })
+ }
+
+ ngOnDestroy () {
+ if (this.schedulerInterval) clearInterval(this.schedulerInterval)
+
+ this.updatedSub?.unsubscribe()
+ this.manageController.unregisterSaveHook()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ private buildLanguages () {
+ forkJoin([
+ this.instanceService.getAbout(),
+ this.serverService.getVideoLanguages()
+ ]).pipe(map(([ about, languages ]) => ({ about, languages })))
+ .subscribe(({ about, languages }) => {
+ this.videoLanguages = [
+ ...languages.filter(l => about.instance.languages.includes(l.id)),
+
+ languages.find(l => l.id === 'zxx'),
+
+ ...languages.filter(l => !about.instance.languages.includes(l.id) && l.id !== 'zxx')
+ ]
+ })
+ }
+
+ private buildPrivacies () {
+ const { privacies } = this.manageController.getStore()
+ this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies).videoPrivacies
+
+ // Can't schedule publication if private privacy is not available (could be deleted by a plugin)
+ const hasPrivatePrivacy = this.videoPrivacies.some(p => p.id === VideoPrivacy.PRIVATE)
+ if (this.forbidScheduledPublication || !hasPrivatePrivacy) return
+
+ this.videoPrivacies.push({
+ id: VideoEdit.SPECIAL_SCHEDULED_PRIVACY,
+ label: $localize`Scheduled`,
+ description: $localize`Hide the video until a specific date`
+ })
+ }
+
+ private buildForm () {
+ const defaultValues = this.videoEdit.toCommonFormPatch()
+ const obj: BuildFormArgument = {
+ name: VIDEO_NAME_VALIDATOR,
+ privacy: VIDEO_PRIVACY_VALIDATOR,
+ videoPassword: VIDEO_PASSWORD_VALIDATOR,
+ channelId: VIDEO_CHANNEL_VALIDATOR,
+ waitTranscoding: null,
+ category: VIDEO_CATEGORY_VALIDATOR,
+ licence: VIDEO_LICENCE_VALIDATOR,
+ language: VIDEO_LANGUAGE_VALIDATOR,
+ description: VIDEO_DESCRIPTION_VALIDATOR,
+ tags: VIDEO_TAGS_ARRAY_VALIDATOR,
+ previewfile: null,
+ support: VIDEO_SUPPORT_VALIDATOR,
+ schedulePublicationAt: VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR
+ }
+
+ const {
+ form,
+ formErrors,
+ validationMessages
+ } = this.formReactiveService.buildForm<Form>(obj, defaultValues)
+
+ this.form = form
+ this.formErrors = formErrors
+ this.validationMessages = validationMessages
+
+ this.updateScheduleRelatedControls(defaultValues.privacy, true)
+
+ this.trackChannelChange()
+ this.trackPrivacyChange()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ getChannelUpdateUrl () {
+ const channelId = this.form.value.channelId
+ const channel = this.userChannels.find(c => c.id === channelId)
+
+ if (!channel) return ''
+
+ return [ '/my-library/video-channels/update/', channel.name ]
+ }
+
+ // ---------------------------------------------------------------------------
+
+ isPluginFieldHidden (pluginField: PluginField) {
+ if (typeof pluginField.commonOptions.hidden !== 'function') return false
+
+ return pluginField.commonOptions.hidden({
+ formValues: this.form.value,
+ videoToUpdate: this.videoEdit,
+ liveVideo: this.videoEdit.getLive()
+ })
+ }
+
+ getPluginsFields (tab: 'main' | 'plugin-settings') {
+ return this.pluginFields.filter(p => {
+ const wanted = p.videoFormOptions.tab ?? 'plugin-settings'
+
+ return wanted === tab
+ })
+ }
+
+ private async updatePluginFields () {
+ this.pluginFields = this.pluginService.getRegisteredVideoFormFields(this.manageType)
+ if (this.pluginFields.length === 0) return
+
+ const { pluginData } = this.videoEdit.toCommonFormPatch()
+
+ const pluginObj: { [id: string]: BuildFormValidator } = {}
+ const pluginValidationMessages: FormReactiveValidationMessages = {}
+ const pluginFormErrors: FormReactiveErrors = {}
+ const pluginDefaults: Record<string, string | boolean> = {}
+
+ for (const setting of this.pluginFields) {
+ await this.pluginService.translateSetting(setting.pluginInfo.plugin.npmName, setting.commonOptions)
+
+ // Not a form input, just a HTML tag
+ if (setting.commonOptions.type === 'html') continue
+
+ const validator = async (control: AbstractControl) => {
+ if (!setting.commonOptions.error) return null
+
+ const error = await setting.commonOptions.error({ formValues: this.form.value, value: control.value })
+
+ return error?.error ? { [setting.commonOptions.name]: error.text } : null
+ }
+
+ const name = setting.commonOptions.name
+
+ pluginObj[name] = {
+ ASYNC_VALIDATORS: [ validator ],
+ VALIDATORS: [],
+ MESSAGES: {}
+ }
+
+ pluginDefaults[name] = pluginData?.[name] ?? setting.commonOptions.default
+ }
+
+ this.pluginDataFormGroup = new FormGroup<any>({})
+ this.formValidatorService.updateFormGroup(
+ this.pluginDataFormGroup,
+ pluginFormErrors,
+ pluginValidationMessages,
+ pluginObj,
+ pluginDefaults
+ )
+
+ this.form.addControl('pluginData', this.pluginDataFormGroup)
+ this.formErrors['pluginData'] = pluginFormErrors
+ this.validationMessages['pluginData'] = pluginValidationMessages
+
+ this.formReactiveService.markAllAsDirty(this.form.controls)
+
+ this.cd.detectChanges()
+
+ // Plugins may need other control values to calculate potential errors
+ this.form.valueChanges.subscribe(() => this.formValidatorService.updateTreeValidity(this.pluginDataFormGroup))
+ }
+
+ // ---------------------------------------------------------------------------
+
+ private trackPrivacyChange () {
+ // We will update the schedule input and the wait transcoding checkbox validators
+ this.form.controls['privacy']
+ .valueChanges
+ .subscribe(newPrivacyId => this.updateScheduleRelatedControls(newPrivacyId))
+ }
+
+ private updateScheduleRelatedControls (newPrivacyId: number, isInitialPatch = false) {
+ this.schedulePublicationSelected = newPrivacyId === VideoEdit.SPECIAL_SCHEDULED_PRIVACY
+
+ const scheduleControl = this.form.get('schedulePublicationAt')
+ const waitTranscodingControl = this.form.get('waitTranscoding')
+
+ if (this.schedulePublicationSelected) {
+ scheduleControl.setValidators([ Validators.required ])
+
+ waitTranscodingControl.disable()
+ if (!isInitialPatch) waitTranscodingControl.setValue(false)
+ } else {
+ scheduleControl.clearValidators()
+ waitTranscodingControl.enable()
+
+ // Do not update the control value on first patch (values come from the server)
+ if (!isInitialPatch) waitTranscodingControl.setValue(true)
+ }
+
+ scheduleControl.updateValueAndValidity()
+ waitTranscodingControl.updateValueAndValidity()
+
+ this.passwordProtectionSelected = newPrivacyId === VideoPrivacy.PASSWORD_PROTECTED
+ const videoPasswordControl = this.form.get('videoPassword')
+
+ if (this.passwordProtectionSelected) videoPasswordControl.setValidators([ Validators.required, ...VIDEO_PASSWORD_VALIDATOR.VALIDATORS ])
+ else videoPasswordControl.clearValidators()
+
+ videoPasswordControl.updateValueAndValidity()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ private trackChannelChange () {
+ // We will update the "support" field depending on the channel
+ this.form.controls.channelId
+ .valueChanges
+ .subscribe(newChannelId => this.updateSupportFromChannel(newChannelId))
+ }
+
+ private updateSupportFromChannel (newChannelId: number) {
+ const newChannel = this.userChannels.find(c => c.id === newChannelId)
+ if (!newChannel) return
+
+ const currentSupport = this.form.value.support
+
+ const oldChannelId = this.form.value.channelId
+ const oldChannel = this.userChannels.find(c => c.id === oldChannelId)
+ if (!newChannel || !oldChannel) {
+ logger.error('Cannot find new or old channel.')
+ return
+ }
+
+ // Same channel, no need to update
+ if (oldChannelId === newChannel.id) return
+
+ // If the current support text is not the same than the old channel, the user updated it.
+ // We don't want the user to lose his text, so stop here
+ if (currentSupport && currentSupport !== oldChannel.support) return
+
+ // Update the support text with our new channel
+ this.updateSupportField(newChannel.support)
+ }
+
+ private updateSupportField (support: string) {
+ return this.form.patchValue({ support: support || '' })
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/moderation/video-moderation.component.html b/client/src/app/+videos-publish-manage/shared-manage/moderation/video-moderation.component.html
new file mode 100644
index 0000000000..4b22afb643
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/moderation/video-moderation.component.html
@@ -0,0 +1,36 @@
+<h2>
+ <my-global-icon iconName="moderation"></my-global-icon>
+
+ <ng-container i18n>Moderation</ng-container>
+</h2>
+
+<div [formGroup]="form">
+
+ <div class="form-columns">
+ <div>
+ <div class="form-group">
+ <label i18n for="commentsPolicy">Comments policy</label>
+
+ <div class="form-group-description" i18n>
+ You can require comments to be approved depending on <a routerLink="/my-account/auto-tag-policies" target="_blank">your auto-tags policies</a>
+ </div>
+
+ <my-select-options inputId="commentsPolicy" [items]="commentPolicies" formControlName="commentsPolicy"></my-select-options>
+
+ <div *ngIf="formErrors.commentsPolicy" class="form-error" role="alert">
+ {{ formErrors.commentsPolicy }}
+ </div>
+ </div>
+
+ <my-peertube-checkbox inputName="nsfw" formControlName="nsfw" helpPlacement="bottom-right">
+ <ng-template ptTemplate="label">
+ <ng-container i18n>Contains sensitive content</ng-container>
+ </ng-template>
+
+ <ng-template ptTemplate="help">
+ <ng-container i18n>Some instances hide videos containing mature or explicit content by default.</ng-container>
+ </ng-template>
+ </my-peertube-checkbox>
+ </div>
+ </div>
+</div>
diff --git a/client/src/app/+videos-publish-manage/shared-manage/moderation/video-moderation.component.ts b/client/src/app/+videos-publish-manage/shared-manage/moderation/video-moderation.component.ts
new file mode 100644
index 0000000000..6a5d5c447e
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/moderation/video-moderation.component.ts
@@ -0,0 +1,101 @@
+import { NgIf } from '@angular/common'
+import { Component, OnDestroy, OnInit, inject } from '@angular/core'
+import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { RouterLink } from '@angular/router'
+import { ServerService } from '@app/core'
+import { BuildFormArgument } from '@app/shared/form-validators/form-validator.model'
+import { FormReactiveErrors, FormReactiveService, FormReactiveValidationMessages } from '@app/shared/shared-forms/form-reactive.service'
+import { HTMLServerConfig, VideoCommentPolicyType, VideoConstant } from '@peertube/peertube-models'
+import debug from 'debug'
+import { CalendarModule } from 'primeng/calendar'
+import { Subscription } from 'rxjs'
+import { PeertubeCheckboxComponent } from '../../../shared/shared-forms/peertube-checkbox.component'
+import { SelectOptionsComponent } from '../../../shared/shared-forms/select/select-options.component'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { PeerTubeTemplateDirective } from '../../../shared/shared-main/common/peertube-template.directive'
+import { VideoManageController } from '../video-manage-controller.service'
+
+const debugLogger = debug('peertube:video-manage')
+
+type Form = {
+ nsfw: FormControl<boolean>
+ commentPolicies: FormControl<VideoCommentPolicyType>
+}
+
+@Component({
+ selector: 'my-video-moderation',
+ styleUrls: [
+ '../common/video-manage-page-common.scss'
+ ],
+ templateUrl: './video-moderation.component.html',
+ imports: [
+ RouterLink,
+ FormsModule,
+ ReactiveFormsModule,
+ NgIf,
+ PeerTubeTemplateDirective,
+ SelectOptionsComponent,
+ CalendarModule,
+ PeertubeCheckboxComponent,
+ GlobalIconComponent
+ ]
+})
+export class VideoModerationComponent implements OnInit, OnDestroy {
+ private formReactiveService = inject(FormReactiveService)
+ private serverService = inject(ServerService)
+ private manageController = inject(VideoManageController)
+
+ form: FormGroup<Form>
+ formErrors: FormReactiveErrors = {}
+ validationMessages: FormReactiveValidationMessages = {}
+
+ commentPolicies: VideoConstant<VideoCommentPolicyType>[] = []
+ serverConfig: HTMLServerConfig
+
+ private updatedSub: Subscription
+
+ ngOnInit () {
+ this.serverConfig = this.serverService.getHTMLConfig()
+
+ this.buildForm()
+
+ this.serverService.getCommentPolicies()
+ .subscribe(res => this.commentPolicies = res)
+ }
+
+ ngOnDestroy () {
+ this.updatedSub?.unsubscribe()
+ }
+
+ private buildForm () {
+ const videoEdit = this.manageController.getStore().videoEdit
+
+ const defaultValues = videoEdit.toCommonFormPatch()
+ const obj: BuildFormArgument = { nsfw: null, commentsPolicy: null }
+
+ const {
+ form,
+ formErrors,
+ validationMessages
+ } = this.formReactiveService.buildForm<Form>(obj, defaultValues)
+
+ this.form = form
+ this.formErrors = formErrors
+ this.validationMessages = validationMessages
+
+ this.form.valueChanges.subscribe(() => {
+ this.manageController.setFormError($localize`Moderation`, 'moderation', this.formErrors)
+
+ const formValues = this.form.value
+ debugLogger('Updating form values', formValues)
+
+ videoEdit.loadFromCommonForm(formValues)
+ })
+
+ this.formReactiveService.markAllAsDirty(this.form.controls)
+
+ this.updatedSub = this.manageController.getUpdatedObs().subscribe(() => {
+ this.form.patchValue(videoEdit.toCommonFormPatch())
+ })
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.html b/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.html
new file mode 100644
index 0000000000..24a7193eb2
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.html
@@ -0,0 +1,51 @@
+<h2>
+ <my-global-icon iconName="upload"></my-global-icon>
+
+ <ng-container i18n>Replace file</ng-container>
+</h2>
+
+@if (!replaceFileEnabled) {
+ <my-alert type="primary" i18n>File replacement is not enabled on {{ instanceName }}.</my-alert>
+} @else if (!canFileBeReplaced()) {
+ @if (isLive()) {
+ <my-alert type="primary" i18n>File replacement is not available on a live.</my-alert>
+ } @else if (isTranscoding()) {
+ <my-alert type="primary" i18n>File replacement is not available while the video is being transcoding.</my-alert>
+ } @else if (isEditing()) {
+ <my-alert type="primary" i18n>File replacement is not available while the video is being edited.</my-alert>
+ } @else if (isImporting()) {
+ <my-alert type="primary" i18n>File replacement is not available while the video is being imported.</my-alert>
+ } @else {
+ <my-alert type="primary" i18n>File replacement is not available.</my-alert>
+ }
+} @else {
+ <div [formGroup]="form">
+ <div class="form-columns reverse">
+ <div>
+ <div *ngIf="videoEdit.getVideoSource()" class="form-group">
+ <label i18n for="filename">Current uploaded file</label>
+
+ <input type="text" [disabled]="true" id="filename" class="form-control" [value]="videoEdit.getVideoSource().filename" />
+ </div>
+ </div>
+
+ <div>
+ <div class="form-group">
+ <label i18n for="videofile">Replace video file</label>
+
+ <div i18n class="form-group-description">⚠️ Uploading a new version of your video will completely erase the current version</div>
+
+ <div>
+ <my-reactive-file
+ formControlName="replaceFile"
+ i18n-inputLabel inputLabel="Select the file to upload"
+ inputName="videofile" [extensions]="getVideoExtensions()" [displayFilename]="true" [displayReset]="true"
+ [buttonTooltip]="'(extensions: ' + getVideoExtensions() + ')'"
+ theme="primary"
+ ></my-reactive-file>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.ts b/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.ts
new file mode 100644
index 0000000000..3bf8491baf
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/replace-file/video-replace-file.component.ts
@@ -0,0 +1,119 @@
+import { CommonModule } from '@angular/common'
+import { Component, inject, OnDestroy, OnInit } from '@angular/core'
+import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { ServerService } from '@app/core'
+import { BuildFormArgument } from '@app/shared/form-validators/form-validator.model'
+import { FormReactiveErrors, FormReactiveService, FormReactiveValidationMessages } from '@app/shared/shared-forms/form-reactive.service'
+import { canVideoFileBeEdited } from '@peertube/peertube-core-utils'
+import { VideoState } from '@peertube/peertube-models'
+import debug from 'debug'
+import { Subscription } from 'rxjs'
+import { ReactiveFileComponent } from '../../../shared/shared-forms/reactive-file.component'
+import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
+import { AlertComponent } from '../../../shared/shared-main/common/alert.component'
+import { VideoEdit } from '../common/video-edit.model'
+import { VideoUploadService } from '../common/video-upload.service'
+import { VideoManageController } from '../video-manage-controller.service'
+
+const debugLogger = debug('peertube:video-manage')
+
+type Form = {
+ replaceFile: FormControl<File>
+}
+
+@Component({
+ selector: 'my-video-replace-file',
+ styleUrls: [
+ '../common/video-manage-page-common.scss'
+ ],
+ templateUrl: './video-replace-file.component.html',
+ imports: [
+ CommonModule,
+ FormsModule,
+ ReactiveFormsModule,
+ ReactiveFileComponent,
+ AlertComponent,
+ GlobalIconComponent
+ ]
+})
+export class VideoReplaceFileComponent implements OnInit, OnDestroy {
+ private formReactiveService = inject(FormReactiveService)
+ private videoUploadService = inject(VideoUploadService)
+ private manageController = inject(VideoManageController)
+ private server = inject(ServerService)
+
+ form: FormGroup<Form>
+ formErrors: FormReactiveErrors = {}
+ validationMessages: FormReactiveValidationMessages = {}
+
+ videoEdit: VideoEdit
+
+ replaceFileEnabled: boolean
+ instanceName: string
+
+ private updatedSub: Subscription
+
+ ngOnInit () {
+ this.videoEdit = this.manageController.getStore().videoEdit
+
+ const config = this.server.getHTMLConfig()
+ this.replaceFileEnabled = config.videoFile.update.enabled === true
+ this.instanceName = config.instance.name
+
+ const defaultValues = this.videoEdit.toReplaceFileFormPatch()
+ const obj: BuildFormArgument = { replaceFile: null }
+
+ const {
+ form,
+ formErrors,
+ validationMessages
+ } = this.formReactiveService.buildForm<Form>(obj, defaultValues)
+
+ this.form = form
+ this.formErrors = formErrors
+ this.validationMessages = validationMessages
+
+ this.form.valueChanges.subscribe(() => {
+ this.manageController.setFormError($localize`Replace file`, 'replace-file', this.formErrors)
+
+ const formValues = this.form.value
+ debugLogger('Updating form values', formValues)
+
+ this.videoEdit.loadFromReplaceFileForm(formValues)
+ })
+
+ this.formReactiveService.markAllAsDirty(this.form.controls)
+
+ this.updatedSub = this.manageController.getUpdatedObs().subscribe(() => {
+ this.form.patchValue(this.videoEdit.toReplaceFileFormPatch())
+ })
+ }
+
+ ngOnDestroy (): void {
+ this.updatedSub?.unsubscribe()
+ }
+
+ getVideoExtensions () {
+ return this.videoUploadService.getVideoExtensions()
+ }
+
+ canFileBeReplaced () {
+ return canVideoFileBeEdited(this.videoEdit.getVideoAttributes().state)
+ }
+
+ isLive () {
+ return this.videoEdit.getVideoAttributes().isLive
+ }
+
+ isTranscoding () {
+ return this.videoEdit.getVideoAttributes().state === VideoState.TO_TRANSCODE
+ }
+
+ isEditing () {
+ return this.videoEdit.getVideoAttributes().state === VideoState.TO_EDIT
+ }
+
+ isImporting () {
+ return this.videoEdit.getVideoAttributes().state === VideoState.TO_IMPORT
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/routes.ts b/client/src/app/+videos-publish-manage/shared-manage/routes.ts
new file mode 100644
index 0000000000..08ad3a7880
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/routes.ts
@@ -0,0 +1,53 @@
+import { Routes } from '@angular/router'
+import { VideoCaptionsComponent } from './captions/video-captions.component'
+import { VideoChaptersComponent } from './chapters/video-chapters.component'
+import { VideoCustomizationComponent } from './customization/video-customization.component'
+import { VideoLiveSettingsComponent } from './live-settings/video-live-settings.component'
+import { VideoMainInfoComponent } from './main-info/video-main-info.component'
+import { VideoModerationComponent } from './moderation/video-moderation.component'
+import { VideoReplaceFileComponent } from './replace-file/video-replace-file.component'
+import { VideoStatsComponent } from './stats/video-stats.component'
+import { VideoStudioEditComponent } from './studio/video-studio.component'
+
+export const manageRoutes = [
+ {
+ path: '',
+ component: VideoMainInfoComponent
+ },
+ {
+ path: 'main-info',
+ component: VideoMainInfoComponent
+ },
+ {
+ path: 'captions',
+ component: VideoCaptionsComponent
+ },
+ {
+ path: 'chapters',
+ component: VideoChaptersComponent
+ },
+ {
+ path: 'customization',
+ component: VideoCustomizationComponent
+ },
+ {
+ path: 'live-settings',
+ component: VideoLiveSettingsComponent
+ },
+ {
+ path: 'moderation',
+ component: VideoModerationComponent
+ },
+ {
+ path: 'replace-file',
+ component: VideoReplaceFileComponent
+ },
+ {
+ path: 'stats',
+ component: VideoStatsComponent
+ },
+ {
+ path: 'studio',
+ component: VideoStudioEditComponent
+ }
+] satisfies Routes
diff --git a/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.html b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.html
new file mode 100644
index 0000000000..95e6d52d23
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.html
@@ -0,0 +1,73 @@
+<h2>
+ <my-global-icon iconName="stats"></my-global-icon>
+
+ <ng-container i18n>Statistics</ng-container>
+</h2>
+
+<div class="stats-embed">
+ <div class="global-stats">
+ <div *ngFor="let card of globalStatsCards" class="card stats-card">
+ <div class="label">
+ {{ card.label }}
+
+ <my-help *ngIf="card.help">
+ <ng-template ptTemplate="customHtml">{{ card.help }}</ng-template>
+ </my-help>
+ </div>
+ <div class="value">{{ card.value }}</div>
+ <div *ngIf="card.moreInfo" class="more-info">{{ card.moreInfo }}</div>
+ </div>
+ </div>
+
+ <my-embed [video]="videoEdit.getVideoAttributes()"></my-embed>
+</div>
+
+<div class="stats-with-date">
+
+ <div class="overall-stats">
+ <h2>{{ getViewersStatsTitle() }}</h2>
+
+ <div class="date-filter-wrapper">
+ <label class="visually-hidden" for="date-filter">Filter viewers stats by date</label>
+ <my-select-options inputId="date-filter" [(ngModel)]="currentDateFilter" (ngModelChange)="onDateFilterChange()" [items]="dateFilters"></my-select-options>
+ </div>
+
+ <div class="cards">
+ <div *ngFor="let card of overallStatCards" class="card stats-card">
+ <div class="label">{{ card.label }}</div>
+ <div class="value">{{ card.value }}</div>
+ <div *ngIf="card.moreInfo" class="more-info">{{ card.moreInfo }}</div>
+ </div>
+ </div>
+ </div>
+
+ <div class="timeserie">
+ <div ngbNav #nav="ngbNav" [activeId]="activeGraphId" (activeIdChange)="onChartChange($event)" class="nav-tabs">
+
+ <ng-container *ngFor="let availableChart of availableCharts" [ngbNavItem]="availableChart.id">
+ <a ngbNavLink>
+ <span>{{ availableChart.label }}</span>
+ </a>
+
+ <ng-template ngbNavContent>
+ <div class="chart-container">
+ <p-chart
+ *ngIf="chartOptions[availableChart.id]"
+ [height]="chartHeight" [width]="chartWidth"
+ [type]="chartOptions[availableChart.id].type" [options]="chartOptions[availableChart.id].options" [data]="chartOptions[availableChart.id].data"
+ [plugins]="chartPlugins"
+ ></p-chart>
+ </div>
+
+ <div class="zoom-container">
+ <span *ngIf="!hasZoom() && availableChart.zoomEnabled" i18n class="description">You can select a part of the graph to zoom in</span>
+
+ <my-button i18n *ngIf="hasZoom()" (click)="resetZoom()">Reset zoom</my-button>
+ </div>
+ </ng-template>
+ </ng-container>
+ </div>
+
+ <div [ngbNavOutlet]="nav"></div>
+ </div>
+</div>
diff --git a/client/src/app/+stats/video/video-stats.component.scss b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.scss
similarity index 100%
rename from client/src/app/+stats/video/video-stats.component.scss
rename to client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.scss
diff --git a/client/src/app/+stats/video/video-stats.component.ts b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.ts
similarity index 89%
rename from client/src/app/+stats/video/video-stats.component.ts
rename to client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.ts
index f1bf58506f..d50215bc80 100644
--- a/client/src/app/+stats/video/video-stats.component.ts
+++ b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.component.ts
@@ -1,10 +1,12 @@
-import { ChartConfiguration, ChartData, ChartOptions, PluginOptionsByType, Scale, TooltipItem, defaults as ChartJSDefaults } from 'chart.js'
-import zoomPlugin from 'chartjs-plugin-zoom'
-import { Observable, of } from 'rxjs'
-import { SelectOptionsItem } from 'src/types'
+import { NgFor, NgIf } from '@angular/common'
import { Component, LOCALE_ID, OnInit, inject } from '@angular/core'
+import { FormsModule } from '@angular/forms'
import { ActivatedRoute } from '@angular/router'
import { Notifier, PeerTubeRouterService } from '@app/core'
+import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'
+import { NumberFormatterPipe } from '@app/shared/shared-main/common/number-formatter.pipe'
+import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
+import { NgbNav, NgbNavContent, NgbNavItem, NgbNavLink, NgbNavLinkBase, NgbNavOutlet } from '@ng-bootstrap/ng-bootstrap'
import { secondsToTime } from '@peertube/peertube-core-utils'
import {
HttpStatusCode,
@@ -14,20 +16,19 @@ import {
VideoStatsTimeserie,
VideoStatsTimeserieMetric
} from '@peertube/peertube-models'
-import { VideoStatsService } from './video-stats.service'
-import { ButtonComponent } from '../../shared/shared-main/buttons/button.component'
+import { ChartConfiguration, ChartData, defaults as ChartJSDefaults, ChartOptions, PluginOptionsByType, Scale, TooltipItem } from 'chart.js'
+import zoomPlugin from 'chartjs-plugin-zoom'
import { ChartModule } from 'primeng/chart'
-import { NgbNav, NgbNavItem, NgbNavLink, NgbNavLinkBase, NgbNavContent, NgbNavOutlet } from '@ng-bootstrap/ng-bootstrap'
-import { FormsModule } from '@angular/forms'
-import { SelectOptionsComponent } from '../../shared/shared-forms/select/select-options.component'
-import { EmbedComponent } from '../../shared/shared-main/video/embed.component'
-import { PeerTubeTemplateDirective } from '../../shared/shared-main/common/peertube-template.directive'
-import { HelpComponent } from '../../shared/shared-main/buttons/help.component'
-import { NgFor, NgIf } from '@angular/common'
-import { NumberFormatterPipe } from '@app/shared/shared-main/common/number-formatter.pipe'
-import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
-import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
-import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'
+import { Observable, of } from 'rxjs'
+import { SelectOptionsItem } from 'src/types'
+import { SelectOptionsComponent } from '../../../shared/shared-forms/select/select-options.component'
+import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'
+import { HelpComponent } from '../../../shared/shared-main/buttons/help.component'
+import { PeerTubeTemplateDirective } from '../../../shared/shared-main/common/peertube-template.directive'
+import { EmbedComponent } from '../../../shared/shared-main/video/embed.component'
+import { VideoEdit } from '../common/video-edit.model'
+import { VideoManageController } from '../video-manage-controller.service'
+import { VideoStatsService } from './video-stats.service'
type ActiveGraphId = VideoStatsTimeserieMetric | 'retention' | 'countries' | 'regions'
@@ -52,7 +53,10 @@ ChartJSDefaults.color = getComputedStyle(document.body).getPropertyValue('--fg')
@Component({
templateUrl: './video-stats.component.html',
- styleUrls: [ './video-stats.component.scss' ],
+ styleUrls: [
+ '../common/video-manage-page-common.scss',
+ './video-stats.component.scss'
+ ],
providers: [ NumberFormatterPipe ],
imports: [
NgFor,
@@ -81,6 +85,7 @@ export class VideoStatsComponent implements OnInit {
private peertubeRouter = inject(PeerTubeRouterService)
private numberFormatter = inject(NumberFormatterPipe)
private liveService = inject(LiveVideoService)
+ private manageController = inject(VideoManageController)
// Cannot handle date filters
globalStatsCards: Card[] = []
@@ -94,7 +99,7 @@ export class VideoStatsComponent implements OnInit {
availableCharts: { id: ActiveGraphId, label: string, zoomEnabled: boolean }[] = []
activeGraphId: ActiveGraphId = 'viewers'
- video: VideoDetails
+ videoEdit: VideoEdit
countries: GeoData = []
regions: GeoData = []
@@ -115,7 +120,7 @@ export class VideoStatsComponent implements OnInit {
private chartIngestData: { [id in ActiveGraphId]?: ChartIngestData } = {}
ngOnInit () {
- this.video = this.route.snapshot.data.video
+ this.videoEdit = this.manageController.getStore().videoEdit
this.availableCharts = [
{
@@ -140,7 +145,7 @@ export class VideoStatsComponent implements OnInit {
}
]
- if (!this.video.isLive) {
+ if (!this.videoEdit.getVideoAttributes().isLive) {
this.availableCharts.push({
id: 'retention',
label: $localize`Retention`,
@@ -224,7 +229,9 @@ export class VideoStatsComponent implements OnInit {
}
private loadOverallStats () {
- this.statsService.getOverallStats({ videoId: this.video.uuid, startDate: this.statsStartDate, endDate: this.statsEndDate })
+ const uuid = this.videoEdit.getVideoAttributes().uuid
+
+ this.statsService.getOverallStats({ videoId: uuid, startDate: this.statsStartDate, endDate: this.statsEndDate })
.subscribe({
next: res => {
this.countries = res.countries.map(c => ({
@@ -242,13 +249,13 @@ export class VideoStatsComponent implements OnInit {
}
private loadDateFilters () {
- if (this.video.isLive) return this.loadLiveDateFilters()
+ if (this.videoEdit.getVideoAttributes().isLive) return this.loadLiveDateFilters()
return this.loadVODDateFilters()
}
private loadLiveDateFilters () {
- this.liveService.listSessions(this.video.id)
+ this.liveService.listSessions(this.videoEdit.getVideoAttributes().id)
.subscribe({
next: ({ data }) => {
const newFilters = data.map(session => this.buildLiveFilter(session))
@@ -261,7 +268,7 @@ export class VideoStatsComponent implements OnInit {
}
private loadVODDateFilters () {
- this.liveService.findLiveSessionFromVOD(this.video.id)
+ this.liveService.findLiveSessionFromVOD(this.videoEdit.getVideoAttributes().id)
.subscribe({
next: session => {
this.dateFilters = this.dateFilters.concat([ this.buildLiveFilter(session) ])
@@ -307,12 +314,12 @@ export class VideoStatsComponent implements OnInit {
this.globalStatsCards = [
{
label: $localize`Views`,
- value: this.numberFormatter.transform(this.video.views),
+ value: this.numberFormatter.transform(this.videoEdit.getVideoAttributes().views),
help: $localize`A view means that someone watched the video for several seconds (10 seconds by default)`
},
{
label: $localize`Likes`,
- value: this.numberFormatter.transform(this.video.likes)
+ value: this.numberFormatter.transform(this.videoEdit.getVideoAttributes().likes)
}
]
@@ -355,16 +362,16 @@ export class VideoStatsComponent implements OnInit {
private loadChart () {
const obsBuilders: { [id in ActiveGraphId]: Observable<ChartIngestData> } = {
- retention: this.statsService.getRetentionStats(this.video.uuid),
+ retention: this.statsService.getRetentionStats(this.videoEdit.getVideoAttributes().uuid),
aggregateWatchTime: this.statsService.getTimeserieStats({
- videoId: this.video.uuid,
+ videoId: this.videoEdit.getVideoAttributes().uuid,
startDate: this.statsStartDate,
endDate: this.statsEndDate,
metric: 'aggregateWatchTime'
}),
viewers: this.statsService.getTimeserieStats({
- videoId: this.video.uuid,
+ videoId: this.videoEdit.getVideoAttributes().uuid,
startDate: this.statsStartDate,
endDate: this.statsEndDate,
metric: 'viewers'
diff --git a/client/src/app/+stats/video/video-stats.service.ts b/client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.service.ts
similarity index 100%
rename from client/src/app/+stats/video/video-stats.service.ts
rename to client/src/app/+videos-publish-manage/shared-manage/stats/video-stats.service.ts
diff --git a/client/src/app/+video-studio/edit/video-studio-edit.component.html b/client/src/app/+videos-publish-manage/shared-manage/studio/video-studio.component.html
similarity index 62%
rename from client/src/app/+video-studio/edit/video-studio-edit.component.html
rename to client/src/app/+videos-publish-manage/shared-manage/studio/video-studio.component.html
index f6abf679fb..b2f33ff381 100644
--- a/client/src/app/+video-studio/edit/video-studio-edit.component.html
+++ b/client/src/app/+videos-publish-manage/shared-manage/studio/video-studio.component.html
@@ -1,31 +1,45 @@
-<div class="margin-content">
- <h1 class="title-page">
- <my-global-icon iconName="film"></my-global-icon>
-
- <ng-container i18n>Studio for {{ video.name }}</ng-container>
- </h1>
-
+<h2>
+ <my-global-icon iconName="studio"></my-global-icon>
+
+ <ng-container i18n>Studio</ng-container>
+</h2>
+
+@if (!studioEnabled) {
+ <my-alert type="primary" i18n>Studio is not enabled on {{ instanceName }}.</my-alert>
+} @else if (!canFileBeReplaced()) {
+ @if (isLive()) {
+ <my-alert type="primary" i18n>Studio is not available on a live.</my-alert>
+ } @else if (isTranscoding()) {
+ <my-alert type="primary" i18n>Studio is not available while the video is being transcoding.</my-alert>
+ } @else if (isEditing()) {
+ <my-alert type="primary" i18n>Studio is not available while the video is being edited.</my-alert>
+ } @else if (isImporting()) {
+ <my-alert type="primary" i18n>Studio is not available while the video is being imported.</my-alert>
+ } @else {
+ <my-alert type="primary" i18n>Studio is not available.</my-alert>
+ }
+} @else {
<div class="grid-container">
<form [formGroup]="form">
<div class="section cut" formGroupName="cut">
- <h2 class="section-label" i18n>CUT VIDEO</h2>
+ <h3 class="section-label" i18n>CUT VIDEO</h3>
<div i18n class="description">Set a new start/end.</div>
<div class="form-group">
<label i18n for="cutStart">New start</label>
- <my-timestamp-input inputName="cutStart" enableBorder="true" [maxTimestamp]="video.duration" formControlName="start"></my-timestamp-input>
+ <my-timestamp-input inputName="cutStart" enableBorder="true" [maxTimestamp]="videoEdit.getVideoAttributes().duration" formControlName="start"></my-timestamp-input>
</div>
<div class="form-group">
<label i18n for="cutEnd">New end</label>
- <my-timestamp-input inputName="cutEnd" enableBorder="true" [maxTimestamp]="video.duration" formControlName="end"></my-timestamp-input>
+ <my-timestamp-input inputName="cutEnd" enableBorder="true" [maxTimestamp]="videoEdit.getVideoAttributes().duration" formControlName="end"></my-timestamp-input>
</div>
</div>
<div class="section" formGroupName="add-intro">
- <h2 class="section-label" i18n>ADD INTRO</h2>
+ <h3 class="section-label" i18n>ADD INTRO</h3>
<div i18n class="description">Concatenate a file at the beginning of the video.</div>
@@ -39,7 +53,7 @@
</div>
<div class="section" formGroupName="add-outro">
- <h2 class="section-label" i18n>ADD OUTRO</h2>
+ <h3 class="section-label" i18n>ADD OUTRO</h3>
<div i18n class="description">Concatenate a file at the end of the video.</div>
@@ -53,7 +67,7 @@
</div>
<div class="section" formGroupName="add-watermark">
- <h2 class="section-label" i18n>ADD WATERMARK</h2>
+ <h3 class="section-label" i18n>ADD WATERMARK</h3>
<div i18n class="description">Add a watermark image to the video.</div>
@@ -65,25 +79,19 @@
></my-reactive-file>
</div>
</div>
-
- <my-button
- theme="primary" i18n-label label="Apply edits" icon="circle-tick"
- (click)="runEdit()" (keydown.enter)="runEdit()"
- [disabled]="!form.valid || isRunningEdit || noEdit()"
- ></my-button>
</form>
<div class="embed-container">
<div class="mb-1 fw-bold" i18n>Original video</div>
- <my-embed [video]="video"></my-embed>
+ <my-embed [video]="videoEdit.getVideoAttributes()"></my-embed>
</div>
<div class="tasks-container" *ngIf="!noEdit()">
<div class="mb-1 fw-bold" i18n>Edits to apply:</div>
<ol>
- <li *ngFor="let task of getTasksSummary()">{{ task }}</li>
+ <li *ngFor="let task of videoEdit.getStudioTasksSummary()">{{ task }}</li>
</ol>
</div>
</div>
-</div>
+}
diff --git a/client/src/app/+video-studio/edit/video-studio-edit.component.scss b/client/src/app/+videos-publish-manage/shared-manage/studio/video-studio.component.scss
similarity index 99%
rename from client/src/app/+video-studio/edit/video-studio-edit.component.scss
rename to client/src/app/+videos-publish-manage/shared-manage/studio/video-studio.component.scss
index 70da409d7a..20a0f1afb7 100644
--- a/client/src/app/+video-studio/edit/video-studio-edit.component.scss
+++ b/client/src/app/+videos-publish-manage/shared-manage/studio/video-studio.component.scss
@@ -52,7 +52,7 @@ my-timestamp-input {
}
}
-h2 {
+h3 {
font-weight: $font-bold;
font-size: 16px;
padding: 0 5px;
diff --git a/client/src/app/+videos-publish-manage/shared-manage/studio/video-studio.component.ts b/client/src/app/+videos-publish-manage/shared-manage/studio/video-studio.component.ts
new file mode 100644
index 0000000000..85dbb0f106
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/studio/video-studio.component.ts
@@ -0,0 +1,150 @@
+import { NgFor, NgIf } from '@angular/common'
+import { Component, OnDestroy, OnInit, inject } from '@angular/core'
+import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { ServerService } from '@app/core'
+import { FormReactiveErrors, FormReactiveService, FormReactiveValidationMessages } from '@app/shared/shared-forms/form-reactive.service'
+import { ReactiveFileComponent } from '@app/shared/shared-forms/reactive-file.component'
+import { TimestampInputComponent } from '@app/shared/shared-forms/timestamp-input.component'
+import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'
+import { EmbedComponent } from '@app/shared/shared-main/video/embed.component'
+import { canVideoFileBeEdited } from '@peertube/peertube-core-utils'
+import { VideoState } from '@peertube/peertube-models'
+import debug from 'debug'
+import { Subscription } from 'rxjs'
+import { VideoEdit } from '../common/video-edit.model'
+import { VideoManageController } from '../video-manage-controller.service'
+import { AlertComponent } from '../../../shared/shared-main/common/alert.component'
+
+const debugLogger = debug('peertube:video-manage')
+
+type Form = {
+ 'cut': FormGroup<{ start: FormControl<number>, end: FormControl<number> }>
+ 'add-intro': FormGroup<{ file: FormControl<File> }>
+ 'add-outro': FormGroup<{ file: FormControl<File> }>
+ 'add-watermark': FormGroup<{ file: FormControl<File> }>
+}
+
+@Component({
+ selector: 'my-video-studio',
+ templateUrl: './video-studio.component.html',
+ styleUrls: [
+ '../common/video-manage-page-common.scss',
+ './video-studio.component.scss'
+ ],
+ imports: [
+ FormsModule,
+ ReactiveFormsModule,
+ TimestampInputComponent,
+ ReactiveFileComponent,
+ EmbedComponent,
+ NgIf,
+ NgFor,
+ GlobalIconComponent,
+ AlertComponent
+ ]
+})
+export class VideoStudioEditComponent implements OnInit, OnDestroy {
+ private formReactiveService = inject(FormReactiveService)
+ private serverService = inject(ServerService)
+ private manageController = inject(VideoManageController)
+
+ form: FormGroup<Form>
+ formErrors: FormReactiveErrors = {}
+ validationMessages: FormReactiveValidationMessages = {}
+
+ isRunningEdit = false
+
+ videoEdit: VideoEdit
+
+ studioEnabled: boolean
+ instanceName: string
+
+ private updatedSub: Subscription
+
+ ngOnInit () {
+ this.videoEdit = this.manageController.getStore().videoEdit
+
+ const config = this.serverService.getHTMLConfig()
+ this.studioEnabled = config.videoStudio.enabled === true
+ this.instanceName = config.instance.name
+
+ const { form, formErrors, validationMessages } = this.formReactiveService.buildForm<Form>({
+ 'cut': {
+ start: null,
+ end: null
+ },
+ 'add-intro': {
+ file: null
+ },
+ 'add-outro': {
+ file: null
+ },
+ 'add-watermark': {
+ file: null
+ }
+ }, this.videoEdit.toStudioFormPatch())
+
+ this.form = form
+ this.formErrors = formErrors
+ this.validationMessages = validationMessages
+
+ this.form.valueChanges.subscribe(() => {
+ this.manageController.setFormError($localize`Studio`, 'studio', this.formErrors)
+
+ const formValues = this.form.value
+ debugLogger('Updating form values', formValues)
+
+ this.videoEdit.loadFromStudioForm(formValues)
+ })
+
+ this.formReactiveService.markAllAsDirty(this.form.controls)
+
+ this.updatedSub = this.manageController.getUpdatedObs().subscribe(() => {
+ this.form.patchValue(this.videoEdit.toStudioFormPatch())
+ })
+ }
+
+ ngOnDestroy (): void {
+ this.updatedSub?.unsubscribe()
+ }
+
+ get videoExtensions () {
+ return this.serverService.getHTMLConfig().video.file.extensions
+ }
+
+ get imageExtensions () {
+ return this.serverService.getHTMLConfig().video.image.extensions
+ }
+
+ getIntroOutroTooltip () {
+ return $localize`(extensions: ${this.videoExtensions.join(', ')})`
+ }
+
+ getWatermarkTooltip () {
+ return $localize`(extensions: ${this.imageExtensions.join(', ')})`
+ }
+
+ noEdit () {
+ return this.videoEdit.getStudioTasks().length === 0
+ }
+
+ canFileBeReplaced () {
+ return canVideoFileBeEdited(this.videoEdit.getVideoAttributes().state)
+ }
+
+ isLive () {
+ return this.videoEdit.getVideoAttributes().isLive
+ }
+
+ isTranscoding () {
+ return this.videoEdit.getVideoAttributes().state === VideoState.TO_TRANSCODE
+ }
+
+ isEditing () {
+ return this.videoEdit.getVideoAttributes().state === VideoState.TO_EDIT
+ }
+
+ isImporting () {
+ return this.videoEdit.getVideoAttributes().state === VideoState.TO_IMPORT
+ }
+}
diff --git a/client/src/app/+video-studio/shared/video-studio.service.ts b/client/src/app/+videos-publish-manage/shared-manage/studio/video-studio.service.ts
similarity index 100%
rename from client/src/app/+video-studio/shared/video-studio.service.ts
rename to client/src/app/+videos-publish-manage/shared-manage/studio/video-studio.service.ts
diff --git a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.html b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.html
new file mode 100644
index 0000000000..75920d9529
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.html
@@ -0,0 +1,161 @@
+<div class="root">
+ <div>
+ <div class="menu">
+ <h1 i18n>MANAGE MY VIDEO</h1>
+
+ <ul class="ul-unstyle">
+ <li>
+ <a routerLink="." queryParamsHandling="merge" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }">
+ <div class="global-icon-wrapper">
+ <my-global-icon iconName="film"></my-global-icon>
+ </div>
+
+ <span i18n>Main information</span>
+ </a>
+ </li>
+
+ <li *ngIf="getVideo().isLive">
+ <a routerLink="live-settings" queryParamsHandling="merge" routerLinkActive="active">
+ <div class="global-icon-wrapper">
+ <my-global-icon iconName="live"></my-global-icon>
+ </div>
+
+ <span i18n>Live settings</span>
+ </a>
+ </li>
+
+ <div class="separator">
+ <div></div>
+ </div>
+
+ <li>
+ <a routerLink="customization" queryParamsHandling="merge" routerLinkActive="active">
+ <div class="global-icon-wrapper">
+ <my-global-icon iconName="cog"></my-global-icon>
+ </div>
+
+ <span i18n>Customization</span>
+ </a>
+ </li>
+
+ <li>
+ <a routerLink="moderation" queryParamsHandling="merge" routerLinkActive="active">
+ <div class="global-icon-wrapper">
+ <my-global-icon iconName="moderation"></my-global-icon>
+ </div>
+
+ <span i18n>Moderation</span>
+ </a>
+ </li>
+
+ @if (!getVideo().isLive) {
+ <li>
+ <a routerLink="captions" queryParamsHandling="merge" routerLinkActive="active">
+ <div class="global-icon-wrapper">
+ <my-global-icon iconName="captions"></my-global-icon>
+ </div>
+
+ <span i18n>Captions</span>
+ </a>
+ </li>
+
+ <li>
+ <a routerLink="chapters" queryParamsHandling="merge" routerLinkActive="active">
+ <div class="global-icon-wrapper">
+ <my-global-icon iconName="chapters"></my-global-icon>
+ </div>
+
+ <span i18n>Chapters</span>
+ </a>
+ </li>
+
+ <div class="separator">
+ <div></div>
+ </div>
+
+ <li>
+ <a routerLink="studio" queryParamsHandling="merge" routerLinkActive="active">
+ <div class="global-icon-wrapper">
+ <my-global-icon iconName="studio"></my-global-icon>
+ </div>
+
+ <span i18n>Studio</span>
+ </a>
+ </li>
+
+ <li>
+ <a routerLink="replace-file" queryParamsHandling="merge" routerLinkActive="active">
+ <div class="global-icon-wrapper">
+ <my-global-icon iconName="upload"></my-global-icon>
+ </div>
+
+ <span i18n>Replace file</span>
+ </a>
+ </li>
+ }
+
+ @if (canWatch()) {
+ <div class="separator">
+ <div></div>
+ </div>
+
+ <li>
+ <a routerLink="stats" queryParamsHandling="merge" routerLinkActive="active">
+ <div class="global-icon-wrapper">
+ <my-global-icon iconName="stats"></my-global-icon>
+ </div>
+
+ <span i18n>Statistics</span>
+ </a>
+ </li>
+ }
+ </ul>
+ </div>
+
+ <div class="menu-placeholder"></div>
+ </div>
+
+ <div class="w-100">
+
+ <div class="video-header">
+ <div class="video-actions">
+ <my-button class="cancel-button" icon="arrow-left" theme="secondary" i18n [ptRouterLink]="cancelLink()">Cancel</my-button>
+
+ <h2>{{ getVideo().name }}</h2>
+
+ <div class="watch-save">
+ <my-button *ngIf="canWatch()" class="watch-button" icon="external-link" theme="secondary" class="me-3" [href]="getWatchUrl()">
+ <span i18n class="watch-button-label">Watch the video</span>
+ </my-button>
+
+ <my-button
+ theme="primary" class="save-button"
+ icon="circle-tick"
+ [disabled]="!canUpdate() || !hasPendingChanges()" (click)="onWantToUpdate()"
+ >
+ @if (hasStudioTasks()) {
+ <ng-container i18n>Save and run studio tasks</ng-container>
+ } @else if (hasReplaceFile()) {
+ <ng-container i18n>Save and replace file</ng-container>
+ } @else {
+ <ng-container i18n>Save</ng-container>
+ }
+ </my-button>
+ </div>
+ </div>
+
+ <my-manage-errors *ngIf="displayFormErrorsMsg && hasFormErrors()"></my-manage-errors>
+
+ <my-upload-progress
+ [isUploading]="isUploadingFile()"
+ [uploadPercents]="getUploadPercents()" [error]="getUploadError()" [uploaded]="hasUploadedFile()"
+ [enableRetryAfterError]="canRetryUpload" (retry)="retryUpload()"
+ >
+ </my-upload-progress>
+
+ <ng-content></ng-content>
+ </div>
+
+ <router-outlet></router-outlet>
+ </div>
+</div>
diff --git a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.scss b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.scss
new file mode 100644
index 0000000000..26cdd28d0a
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.scss
@@ -0,0 +1,225 @@
+@use '_variables' as *;
+@use '_mixins' as *;
+@use '_form-mixins' as *;
+@import 'bootstrap/scss/mixins';
+
+h1 {
+ color: pvar(--fg-200);
+ font-weight: $font-bold;
+ margin-bottom: 1rem;
+ text-align: center;
+
+ @include font-size(14px);
+}
+
+.root {
+ display: flex;
+}
+
+.menu,
+.menu-placeholder {
+ position: sticky;
+ top: pvar(--header-height);
+ width: calc(#{$menu-width} - 2rem);
+ max-height: calc(100vh - #{pvar(--header-height)});
+ z-index: z(menu);
+
+ @include margin-right(pvar(--x-margin-content));
+}
+
+.menu {
+ padding-top: 1.5rem;
+ padding-bottom: 1.5rem;
+ background-color: pvar(--bg-secondary-400);
+ border-radius: 14px;
+ overflow: auto;
+
+ .global-icon-wrapper {
+ display: inline-block;
+ border-radius: 100%;
+ padding: 5px;
+ background-color: pvar(--bg);
+ line-height: 1;
+ width: fit-content;
+
+ @include margin-right(0.75rem);
+
+ my-global-icon {
+ color: pvar(--primary);
+
+ @include global-icon-size(22px);
+ }
+ }
+
+ li {
+ list-style: none;
+ }
+
+ a,
+ .separator {
+ @include padding-left(1.5rem);
+ }
+
+ a {
+ display: block;
+ padding-top: 0.5rem;
+ padding-bottom: 0.5rem;
+ color: pvar(--fg-350);
+
+ @include disable-default-a-behaviour;
+
+ &:hover {
+ opacity: 1;
+ color: pvar(--fg-400);
+ }
+
+ &.active {
+ color: pvar(--fg-400);
+ font-weight: $font-bold;
+ background-color: pvar(--bg-secondary-350);
+
+ .global-icon-wrapper {
+ background-color: pvar(--primary);
+
+ my-global-icon {
+ color: pvar(--bg);
+ }
+ }
+ }
+ }
+
+ .separator {
+ padding-top: 1rem;
+ padding-bottom: 1rem;
+
+ @include padding-right(1.5rem);
+
+ > div {
+ height: 2px;
+ width: 100%;
+ background-color: pvar(--bg-secondary-500);
+ border-radius: 14px;
+ }
+ }
+}
+
+@media screen and (max-width: 1000px) {
+ .root {
+ margin-bottom: 150px;
+ }
+
+ h1 {
+ @include visually-hidden;
+ }
+
+ ul {
+ display: flex;
+ margin: 0 auto;
+ width: fit-content;
+ }
+
+ .menu-placeholder {
+ display: none;
+ }
+
+ .menu {
+ position: fixed;
+ bottom: 0;
+ top: unset;
+ width: calc(100vw - #{pvar(--menu-width)} - (#{pvar(--x-margin-content)} * 2));
+ padding: 0.75rem 0.5rem;
+ border: 1px solid pvar(--bg-secondary-450);
+ border-bottom: 0;
+ border-end-end-radius: 0;
+ border-end-start-radius: 0;
+
+ a {
+ display: flex;
+ flex-direction: column;
+ text-align: center;
+ align-items: center;
+
+ &.active {
+ background-color: inherit;
+ }
+ }
+
+ a,
+ .separator {
+ font-size: 12px;
+ line-height: 1.2;
+ padding: 0 0.5rem;
+ }
+
+ .separator > div {
+ width: 2px;
+ height: 100%;
+ }
+
+ .global-icon-wrapper {
+ margin: 0 0 0.25rem;
+ }
+ }
+}
+
+@media screen and (max-width: $mobile-view) {
+ .menu {
+ border-radius: 0;
+ border-width: 1px 0 0;
+ width: 100vw;
+ left: 0;
+ }
+}
+
+.video-header {
+ margin-bottom: 1rem;
+ display: flex;
+ flex-direction: column;
+ row-gap: 1rem;;
+
+ .video-actions {
+ padding: 1.5rem;
+ border-radius: 14px;
+ background-color: pvar(--bg-secondary-350);
+ display: flex;
+ justify-content: space-between;
+ gap: 1rem;
+ flex-wrap: wrap;
+
+ h2 {
+ font-size: 1.5rem;
+ flex-shrink: 1;
+ color: pvar(--fg-350);
+ font-weight: $font-bold;
+ margin-bottom: 0;
+ line-height: normal;
+
+ @include ellipsis;
+ }
+
+ .watch-save {
+ display: flex;
+ gap: 1rem;
+ flex-wrap: wrap;
+ }
+
+ @media screen and (max-width: 1200px) {
+ flex-direction: column;
+ text-align: center;
+
+ .cancel-button {
+ display: none;
+ }
+
+ .watch-save {
+ justify-content: center;
+ }
+ }
+ }
+
+ @include on-small-main-col {
+ .watch-button-label {
+ display: none;
+ }
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.ts b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.ts
new file mode 100644
index 0000000000..db3de27009
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.ts
@@ -0,0 +1,159 @@
+import { CommonModule } from '@angular/common'
+import { HttpErrorResponse } from '@angular/common/http'
+import { booleanAttribute, Component, inject, input, OnDestroy, OnInit, output } from '@angular/core'
+import { FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { RouterModule } from '@angular/router'
+import { MenuService, Notifier, ScreenService } from '@app/core'
+import { Video } from '@app/shared/shared-main/video/video.model'
+import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'
+import { GlobalIconComponent } from '../../shared/shared-icons/global-icon.component'
+import { ButtonComponent } from '../../shared/shared-main/buttons/button.component'
+import { UploadProgressComponent } from '../../shared/standalone-upload/upload-progress.component'
+import { ManageErrorsComponent } from './common/manage-errors.component'
+import { VideoEdit } from './common/video-edit.model'
+import { VideoManageController } from './video-manage-controller.service'
+import { HeaderService } from '@app/header/header.service'
+
+@Component({
+ selector: 'my-video-manage-container',
+ styleUrls: [ './video-manage-container.component.scss' ],
+ templateUrl: './video-manage-container.component.html',
+ imports: [
+ CommonModule,
+ RouterModule,
+ FormsModule,
+ ReactiveFormsModule,
+ ButtonComponent,
+ ManageErrorsComponent,
+ NgbTooltipModule,
+ UploadProgressComponent,
+ GlobalIconComponent
+ ]
+})
+export class VideoManageContainerComponent implements OnInit, OnDestroy {
+ private manageController = inject(VideoManageController)
+ private notifier = inject(Notifier)
+ private menuService = inject(MenuService)
+ private headerService = inject(HeaderService)
+ private screenService = inject(ScreenService)
+
+ readonly canWatch = input.required<boolean, string | boolean>({ transform: booleanAttribute })
+ readonly canUpdate = input.required<boolean, string | boolean>({ transform: booleanAttribute })
+
+ readonly cancelLink = input<string>()
+
+ readonly videoUpdated = output()
+
+ displayFormErrorsMsg = false
+
+ canRetryUpload = true
+
+ private isUpdating = false
+ private videoEdit: VideoEdit
+ private menuWasCollapsed: boolean
+
+ ngOnInit (): void {
+ this.menuWasCollapsed = this.menuService.isCollapsed()
+ this.menuService.setMenuCollapsed(true)
+
+ if (this.screenService.isInMobileView()) {
+ this.headerService.setSearchHidden(true)
+ }
+
+ const { videoEdit } = this.manageController.getStore()
+ this.videoEdit = videoEdit
+ }
+
+ ngOnDestroy (): void {
+ this.menuService.setMenuCollapsed(this.menuWasCollapsed)
+ this.headerService.setSearchHidden(false)
+ }
+
+ hasFormErrors () {
+ return this.manageController.hasFormErrors()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ hasPendingChanges () {
+ return this.manageController.hasPendingChanges()
+ }
+
+ hasReplaceFile () {
+ return this.manageController.hasReplaceFile()
+ }
+
+ hasStudioTasks () {
+ return this.manageController.hasStudioTasks()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ async onWantToUpdate () {
+ this.displayFormErrorsMsg = false
+
+ await this.manageController.runSaveHook()
+
+ if (this.hasFormErrors()) {
+ this.displayFormErrorsMsg = true
+ return
+ }
+
+ if (this.isUpdating) return
+ this.isUpdating = true
+
+ if (
+ !await this.manageController.checkAndConfirmVideoFileReplacement() ||
+ !await this.manageController.checkAndConfirmStudioTasks()
+ ) {
+ this.isUpdating = false
+ return
+ }
+
+ this.manageController.updateVideo()
+ .subscribe({
+ next: () => {
+ this.isUpdating = false
+
+ return this.videoUpdated.emit()
+ },
+
+ error: (err: HttpErrorResponse) => {
+ this.isUpdating = false
+
+ this.notifier.error(err.message)
+ }
+ })
+ }
+
+ getUploadPercents () {
+ return this.manageController.getUploadPercents()
+ }
+
+ getUploadError () {
+ return this.manageController.getUploadError()
+ }
+
+ isUploadingFile () {
+ return this.manageController.isUploadingFile()
+ }
+
+ hasUploadedFile () {
+ return this.manageController.hasUploadedFile()
+ }
+
+ getWatchUrl () {
+ return Video.buildWatchUrl(this.videoEdit.getVideoAttributes())
+ }
+
+ getVideo () {
+ return this.videoEdit.getVideoAttributes()
+ }
+
+ retryUpload () {
+ this.canRetryUpload = false
+
+ this.manageController.cancelUploadIfNeeded()
+ this.manageController.retryUpload()
+ }
+}
diff --git a/client/src/app/+videos-publish-manage/shared-manage/video-manage-controller.service.ts b/client/src/app/+videos-publish-manage/shared-manage/video-manage-controller.service.ts
new file mode 100644
index 0000000000..240bd0b151
--- /dev/null
+++ b/client/src/app/+videos-publish-manage/shared-manage/video-manage-controller.service.ts
@@ -0,0 +1,535 @@
+import { HttpErrorResponse } from '@angular/common/http'
+import { inject, Injectable, OnDestroy } from '@angular/core'
+import { ActivatedRoute } from '@angular/router'
+import { AuthService, ConfirmService, Notifier, PeerTubeRouterService } from '@app/core'
+import { buildHTTPErrorResponse, genericUploadErrorHandler } from '@app/helpers'
+import { FormReactiveErrors, FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
+import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
+import { VideoChapterService } from '@app/shared/shared-main/video/video-chapter.service'
+import { VideoPasswordService } from '@app/shared/shared-main/video/video-password.service'
+import { VideoService } from '@app/shared/shared-main/video/video.service'
+import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
+import { LoadingBarService } from '@ngx-loading-bar/core'
+import {
+ HTMLServerConfig,
+ HttpStatusCode,
+ UserVideoQuota,
+ VideoConstant,
+ VideoPassword,
+ VideoPrivacy,
+ VideoPrivacyType,
+ VideoState
+} from '@peertube/peertube-models'
+import debug from 'debug'
+import { UploadState, UploadxService } from 'ngx-uploadx'
+import { finalize, first, forkJoin, Observable, of, Subject, Subscription, switchMap, tap } from 'rxjs'
+import { SelectChannelItem } from '../../../types'
+import { VideoEdit } from './common/video-edit.model'
+import { VideoManageType } from './common/video-manage.type'
+import { VideoUploadService } from './common/video-upload.service'
+import { VideoStudioService } from './studio/video-studio.service'
+
+const debugLogger = debug('peertube:video-manage')
+
+@Injectable()
+export class VideoManageController implements OnDestroy {
+ private loadingBar = inject(LoadingBarService)
+ private videoService = inject(VideoService)
+ private videoCaptionService = inject(VideoCaptionService)
+ private videoChapterService = inject(VideoChapterService)
+ private liveVideoService = inject(LiveVideoService)
+ private videoPasswordService = inject(VideoPasswordService)
+ private notifier = inject(Notifier)
+ private videoUploadService = inject(VideoUploadService)
+ private auth = inject(AuthService)
+ private confirmService = inject(ConfirmService)
+ private resumableUploadService = inject(UploadxService)
+ private formReactiveService = inject(FormReactiveService)
+ private videoStudio = inject(VideoStudioService)
+ private peertubeRouter = inject(PeerTubeRouterService)
+
+ private videoEdit: VideoEdit
+ private userChannels: SelectChannelItem[]
+ private userQuota: UserVideoQuota
+ private privacies: VideoConstant<VideoPrivacyType>[]
+
+ private manageType: VideoManageType
+ private serverConfig: HTMLServerConfig
+
+ private uploadingVideo = false
+ private videoUploaded = false
+ private videoUploadPercents: number
+ private uploadError: string
+ private retryUploadFn: () => any
+
+ private isUpdatingVideo = false
+ private videoUploadedSubject = new Subject<void>()
+ private alreadyRefreshedToken = false
+
+ private embedVersion = 1
+
+ private uploadServiceSubscription: Subscription
+ private pendingUpdateObs: Observable<any>
+ private updatedSubject = new Subject<void>()
+
+ private formErrors: { page: string, path: string, errors: string[] }[] = []
+ private saveHook: () => Promise<any>
+
+ constructor () {
+ debugLogger('Building video manage controller service')
+
+ this.resetUploadState()
+
+ this.uploadServiceSubscription = this.resumableUploadService.events
+ .subscribe(state => this.onUploadVideoOngoing(state))
+ }
+
+ ngOnDestroy () {
+ debugLogger('Destroying video manage controller service')
+
+ this.resumableUploadService.disconnect()
+ this.uploadServiceSubscription?.unsubscribe()
+ }
+
+ reset () {
+ this.manageType = undefined
+ this.serverConfig = undefined
+ this.videoEdit = undefined
+ this.userChannels = undefined
+ this.userQuota = undefined
+ this.privacies = undefined
+ }
+
+ // ---------------------------------------------------------------------------
+
+ setConfig (config: {
+ manageType: VideoManageType
+ serverConfig: HTMLServerConfig
+ }) {
+ this.manageType = config.manageType
+ this.serverConfig = config.serverConfig
+ }
+
+ getConfig () {
+ const videoAttrs = this.videoEdit.getVideoAttributes()
+ const isPublish = new Set<VideoManageType>([ 'import-torrent', 'import-url', 'upload' ]).has(this.manageType)
+
+ return {
+ manageType: this.manageType,
+ displayTranscriptionInfo: isPublish,
+
+ hideWaitTranscoding: !isPublish && (videoAttrs.isLive || videoAttrs.state !== VideoState.TO_TRANSCODE),
+
+ forbidScheduledPublication: this.getForbidScheduledPublication()
+ }
+ }
+
+ private getForbidScheduledPublication () {
+ if (this.manageType === 'upload') return false
+
+ return this.manageType === 'update' && this.videoEdit.getVideoAttributes().privacy !== VideoPrivacy.PRIVATE
+ }
+
+ // ---------------------------------------------------------------------------
+
+ setStore (store: {
+ videoEdit: VideoEdit
+ userChannels: SelectChannelItem[]
+ userQuota: UserVideoQuota
+ privacies: VideoConstant<VideoPrivacyType>[]
+ }) {
+ this.videoEdit = store.videoEdit
+ this.userChannels = store.userChannels
+ this.userQuota = store.userQuota
+ this.privacies = store.privacies
+ }
+
+ setVideoEdit (videoEdit: VideoEdit) {
+ this.videoEdit = videoEdit
+ }
+
+ getStore () {
+ return {
+ videoEdit: this.videoEdit,
+ userChannels: this.userChannels,
+ privacies: this.privacies
+ }
+ }
+
+ setFormError (page: string, path: string, formErrors: FormReactiveErrors) {
+ const errors = this.formReactiveService.grabAllErrors(formErrors)
+ this.formErrors = this.formErrors.filter(e => e.page !== page)
+
+ if (errors.length === 0) return
+
+ this.formErrors.push({ page, path, errors })
+ }
+
+ getFormErrors () {
+ return this.formErrors
+ }
+
+ hasFormErrors () {
+ return this.formErrors.some(({ errors }) => errors.length !== 0)
+ }
+
+ getEmbedVersion () {
+ return this.embedVersion
+ }
+
+ // ---------------------------------------------------------------------------
+
+ registerSaveHook (fn: () => Promise<any>) {
+ this.saveHook = fn
+ }
+
+ unregisterSaveHook () {
+ this.saveHook = undefined
+ }
+
+ runSaveHook () {
+ if (!this.saveHook) return Promise.resolve()
+
+ return this.saveHook()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ hasPendingChanges () {
+ return this.videoEdit.hasPendingChanges()
+ }
+
+ hasStudioTasks () {
+ return this.videoEdit.hasStudioTasks()
+ }
+
+ hasReplaceFile () {
+ return this.videoEdit.hasReplaceFile()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ isUpdating () {
+ return this.isUpdatingVideo
+ }
+
+ getUpdatedObs () {
+ return this.updatedSubject.asObservable()
+ }
+
+ updateVideo () {
+ if (this.isUpdatingVideo === true) return
+
+ this.cancelUploadIfNeeded()
+
+ this.loadingBar.useRef().start()
+ this.isUpdatingVideo = true
+
+ const videoAttributes = this.videoEdit.getVideoAttributes()
+
+ const isLive = !!this.videoEdit.getLive()
+
+ this.pendingUpdateObs = this.videoUploadedSubject.pipe(
+ tap(() => this.videoEdit.resetReplaceFile()),
+ switchMap(() => {
+ if (isLive || !this.videoEdit.hasCaptionChanges()) return of(true)
+
+ debugLogger('Update captions')
+
+ return this.videoCaptionService.updateCaptions(videoAttributes.uuid, this.videoEdit.getCaptionsEdit())
+ }),
+ switchMap(() => {
+ if (isLive || !this.videoEdit.hasChaptersChanges()) return of(true)
+
+ debugLogger('Update chapters')
+
+ return this.videoChapterService.updateChapters(videoAttributes.uuid, this.videoEdit.getChaptersEdit())
+ }),
+ switchMap(() => {
+ if (!isLive || !this.videoEdit.hasLiveChanges()) return of(true)
+
+ debugLogger('Update live')
+
+ return this.liveVideoService.updateLive(videoAttributes.uuid, this.videoEdit.toLiveUpdate())
+ }),
+ switchMap(() => {
+ debugLogger('Update video')
+
+ return this.videoService.updateVideo(videoAttributes.uuid, this.videoEdit.toVideoUpdate())
+ }),
+ switchMap(() => {
+ if (!this.videoEdit.hasStudioTasks()) return of(true)
+
+ debugLogger('Run studio tasks')
+
+ return this.videoStudio.editVideo(videoAttributes.uuid, this.videoEdit.getStudioTasks())
+ .pipe(tap(() => this.videoEdit.resetStudio()))
+ }),
+ switchMap(() => {
+ return forkJoin([
+ this.videoService.getVideo({ videoId: videoAttributes.uuid }),
+
+ this.videoEdit.getVideoAttributes().privacy === VideoPrivacy.PASSWORD_PROTECTED
+ ? this.videoPasswordService.getVideoPasswords({ videoUUID: videoAttributes.uuid })
+ : of([] as VideoPassword[]),
+
+ isLive
+ ? this.liveVideoService.getVideoLive(videoAttributes.uuid)
+ : of(undefined),
+
+ !isLive
+ ? this.videoChapterService.getChapters({ videoId: videoAttributes.uuid })
+ : of(undefined),
+
+ !isLive
+ ? this.videoCaptionService.listCaptions(videoAttributes.uuid)
+ : of(undefined)
+ ])
+ }),
+ switchMap(([ video, videoPasswords, live, chaptersRes, captionsRes ]) => {
+ return this.videoEdit.loadFromAPI({
+ video,
+ videoPasswords: videoPasswords.map(p => p.password),
+ live,
+ chapters: chaptersRes?.chapters,
+ captions: captionsRes?.data
+ })
+ }),
+ first(), // To complete
+ finalize(() => {
+ debugLogger('Update complete')
+
+ this.loadingBar.useRef().complete()
+ this.isUpdatingVideo = false
+ this.updatedSubject.next()
+ this.embedVersion++
+ })
+ )
+
+ setTimeout(() => this.replaceFileIfNeeded())
+
+ return this.pendingUpdateObs
+ }
+
+ private replaceFileIfNeeded () {
+ if (!this.videoEdit.hasReplaceFile()) {
+ debugLogger('No file to replace')
+ this.videoUploadedSubject.next()
+ return
+ }
+
+ debugLogger('Upload file replacement')
+ this.uploadFileReplacement(this.videoEdit.getReplaceFile())
+ }
+
+ private uploadFileReplacement (file: File) {
+ this.uploadingVideo = true
+ this.retryUploadFn = () => this.uploadFileReplacement(file)
+
+ const metadata = { filename: file.name }
+
+ this.resumableUploadService.handleFiles(file, {
+ ...this.videoUploadService.getReplaceUploadxOptions(this.videoEdit.getVideoAttributes().uuid),
+
+ metadata
+ })
+ }
+
+ cancelUploadIfNeeded () {
+ if (this.uploadingVideo) {
+ this.resumableUploadService.control({ action: 'cancel' })
+ }
+
+ this.videoUploadedSubject = new Subject<void>()
+
+ this.pendingUpdateObs = undefined
+ this.loadingBar.useRef().complete()
+
+ this.resetUploadState()
+ }
+
+ retryUpload () {
+ this.retryUploadFn()
+ }
+
+ // ---------------------------------------------------------------------------
+
+ async checkAndConfirmVideoFileReplacement () {
+ if (!this.videoEdit.hasReplaceFile()) return true
+
+ if (this.videoEdit.hasStudioTasks()) {
+ this.notifier.error($localize`You cannot replace the video file and also have studio tasks.`)
+ return false
+ }
+
+ const replaceFile = this.videoEdit.getReplaceFile()
+
+ if (!this.checkUserQuota(replaceFile)) return false
+
+ const videoAttributes = this.videoEdit.getVideoAttributes()
+ const willBeBlocked = this.serverConfig.autoBlacklist.videos.ofUsers.enabled === true && !videoAttributes.blacklisted
+
+ let blockedWarning = ''
+ if (willBeBlocked) {
+ // eslint-disable-next-line max-len
+ blockedWarning = ' ' +
+ $localize`Your video will also be automatically blocked since video publication requires manual validation by moderators.`
+ }
+
+ const message = $localize`Uploading a new version of your video will completely erase the current version.` +
+ blockedWarning +
+ ' ' +
+ $localize`<br /><br />Do you still want to replace your video file?`
+
+ const res = await this.confirmService.confirm(message, $localize`Replace file warning`)
+ if (res === false) return false
+
+ return true
+ }
+
+ async checkAndConfirmStudioTasks () {
+ if (!this.videoEdit.hasStudioTasks()) return true
+
+ const title = $localize`Are you sure you want to create studio tasks for "${this.videoEdit.getVideoAttributes().name}"?`
+ const listHTML = this.videoEdit.getStudioTasksSummary().map(t => `<li>${t}</li>`).join('')
+
+ const confirmHTML =
+ // eslint-disable-next-line max-len
+ $localize`The current video will be overwritten by this edited video and <strong>you won't be able to recover it</strong>.<br /><br />` +
+ $localize`As a reminder, the following tasks will be executed: <ol>${listHTML}</ol>`
+
+ if (await this.confirmService.confirm(confirmHTML, title) !== true) return false
+
+ return true
+ }
+
+ checkUserQuota (file: File) {
+ const user = this.auth.getUser()
+
+ if (!this.videoUploadService.checkQuotaAndNotify(file, user.videoQuota, this.userQuota.videoQuotaUsed)) return false
+ if (!this.videoUploadService.checkQuotaAndNotify(file, user.videoQuotaDaily, this.userQuota.videoQuotaUsedDaily)) return false
+
+ return true
+ }
+
+ // ---------------------------------------------------------------------------
+
+ silentRedirectOnManage (shortUUID: string, route: ActivatedRoute) {
+ this.peertubeRouter.silentNavigate([ '.' ], { publishedId: shortUUID, uploading: null }, route)
+ }
+
+ silentRedirectOnUploading (route: ActivatedRoute) {
+ this.peertubeRouter.silentNavigate([ '.' ], { publishedId: null, uploading: 'true' }, route)
+ }
+
+ silentRedirectOnAbortUpload (route: ActivatedRoute) {
+ this.peertubeRouter.silentNavigate([ '.' ], { publishedId: null, uploading: null }, route)
+ }
+
+ // ---------------------------------------------------------------------------
+
+ uploadNewVideo (options: {
+ file: File
+ privacy: VideoPrivacyType
+ previewfile?: File
+ }) {
+ this.resetUploadState()
+
+ this.uploadingVideo = true
+ this.retryUploadFn = () => this.uploadNewVideo(options)
+
+ const metadata = {
+ ...this.videoEdit.toVideoCreate(options.privacy),
+
+ filename: options.file.name,
+ previewfile: options.previewfile
+ }
+
+ this.resumableUploadService.handleFiles(options.file, {
+ ...this.videoUploadService.getNewVideoUploadxOptions(),
+
+ metadata
+ })
+ }
+
+ private resetUploadState () {
+ this.videoUploaded = false
+ this.uploadingVideo = false
+ this.videoUploadPercents = 0
+ this.uploadError = ''
+ }
+
+ getUploadEventsObs () {
+ return this.resumableUploadService.events
+ }
+
+ getUploadPercents () {
+ return this.videoUploadPercents
+ }
+
+ getUploadError () {
+ return this.uploadError
+ }
+
+ isUploadingFile () {
+ return this.uploadingVideo
+ }
+
+ hasUploadedFile () {
+ return this.videoUploaded
+ }
+
+ // ---------------------------------------------------------------------------
+
+ private onUploadVideoOngoing (state: UploadState) {
+ debugLogger('Upload state update', state)
+
+ switch (state.status) {
+ case 'error': {
+ if (!this.alreadyRefreshedToken && state.responseStatus === HttpStatusCode.UNAUTHORIZED_401) {
+ this.alreadyRefreshedToken = true
+
+ return this.refreshTokenAndRetryUpload()
+ }
+
+ this.handleUploadError(buildHTTPErrorResponse(state))
+ break
+ }
+
+ case 'cancelled':
+ this.uploadingVideo = false
+ this.videoUploadPercents = 0
+ this.uploadError = ''
+ break
+
+ case 'uploading':
+ this.videoUploadPercents = state.progress || 0
+ break
+
+ case 'paused':
+ this.notifier.info($localize`Upload on hold`)
+ break
+
+ case 'complete':
+ this.uploadingVideo = false
+ this.videoUploadPercents = 100
+ this.videoUploaded = true
+ this.videoUploadedSubject.next()
+ break
+ }
+ }
+
+ private handleUploadError (err: HttpErrorResponse) {
+ this.videoUploadPercents = 0
+ this.uploadingVideo = false
+
+ this.uploadError = genericUploadErrorHandler({ err, name: $localize`video` })
+
+ this.videoUploadedSubject.error(err)
+ }
+
+ private refreshTokenAndRetryUpload () {
+ this.auth.refreshAccessToken()
+ .subscribe(() => this.retryUploadFn())
+ }
+}
diff --git a/client/src/app/+videos/+video-edit/add-routes.ts b/client/src/app/+videos/+video-edit/add-routes.ts
deleted file mode 100644
index fde09c7280..0000000000
--- a/client/src/app/+videos/+video-edit/add-routes.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { Routes } from '@angular/router'
-import { CanDeactivateGuard, LoginGuard } from '@app/core'
-import { VideoAddComponent } from './video-add.component'
-import { I18nPrimengCalendarService } from './shared/i18n-primeng-calendar.service'
-import { VideoUploadService } from './shared/video-upload.service'
-import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
-
-export default [
- {
- path: '',
- component: VideoAddComponent,
- canActivate: [ LoginGuard ],
- canDeactivate: [ CanDeactivateGuard ],
- providers: [
- LiveVideoService,
- I18nPrimengCalendarService,
- VideoUploadService
- ]
- }
-] satisfies Routes
diff --git a/client/src/app/+videos/+video-edit/shared/thumbnail-manager/thumbnail-manager.component.html b/client/src/app/+videos/+video-edit/shared/thumbnail-manager/thumbnail-manager.component.html
deleted file mode 100644
index baee978342..0000000000
--- a/client/src/app/+videos/+video-edit/shared/thumbnail-manager/thumbnail-manager.component.html
+++ /dev/null
@@ -1,37 +0,0 @@
-<div class="root">
-
- @if (video() && selectingFromVideo) {
- <my-embed #embed [video]="video()" enableAPI="true" mute="true" autoplay="true"></my-embed>
- } @else {
- <div class="preview-container">
- @if (imageSrc) {
- <img [src]="imageSrc" class="preview" alt="Preview" i18n-alt />
- } @else {
- <div class="preview no-image"></div>
- }
- </div>
- }
-
- <div class="mt-2">
-
- @if (selectingFromVideo) {
- <button i18n type="button" class="peertube-button primary-button me-2" (click)="selectFrame()">Use this frame</button>
-
- <button i18n type="button" i18n class="peertube-button secondary-button" (click)="resetSelectFromVideo()">Cancel</button>
- }
- @else {
- <my-reactive-file
- class="d-inline-block"
- inputName="uploadNewThumbnail" i18n-inputLabel inputLabel="Select from your device" [extensions]="videoImageExtensions"
- [maxFileSize]="maxVideoImageSize" placement="right" (fileChanged)="onFileChanged($event)"
- [buttonTooltip]="getReactiveFileButtonTooltip()" theme="primary">
- </my-reactive-file>
-
- @if (canSelectFromVideo()) {
- <button i18n type="button" class="peertube-button secondary-button ms-2" (click)="selectFromVideo()">Select from video</button>
- }
- }
-
- </div>
-
-</div>
diff --git a/client/src/app/+videos/+video-edit/shared/thumbnail-manager/thumbnail-manager.component.scss b/client/src/app/+videos/+video-edit/shared/thumbnail-manager/thumbnail-manager.component.scss
deleted file mode 100644
index 782fa8cb33..0000000000
--- a/client/src/app/+videos/+video-edit/shared/thumbnail-manager/thumbnail-manager.component.scss
+++ /dev/null
@@ -1,31 +0,0 @@
-@use 'sass:math';
-@use '_variables' as *;
-
-.root {
- height: auto;
- display: flex;
- flex-direction: column;
-}
-
-.preview-container {
- position: relative;
-
- .preview {
- object-fit: cover;
- border-radius: 4px;
-
- &.no-image {
- border: 2px solid #808080;
- background-color: pvar(--bg);
- }
- }
-}
-
-.preview,
-my-embed {
- max-width: 500px;
- width: 500px;
-
- max-height: 280px;
- height: 280px;
-}
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit-utils.ts b/client/src/app/+videos/+video-edit/shared/video-edit-utils.ts
deleted file mode 100644
index 6abe1b65c7..0000000000
--- a/client/src/app/+videos/+video-edit/shared/video-edit-utils.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { FormGroup } from '@angular/forms'
-import { VideoEdit } from '@app/shared/shared-main/video/video-edit.model'
-
-function hydrateFormFromVideo (formGroup: FormGroup, video: VideoEdit, thumbnailFiles: boolean) {
- formGroup.patchValue(video.toFormPatch())
-
- if (thumbnailFiles === false) return
-
- const objects = [
- {
- url: 'thumbnailUrl' as 'thumbnailUrl',
- name: 'thumbnailfile'
- },
- {
- url: 'previewUrl' as 'previewUrl',
- name: 'previewfile'
- }
- ]
-
- for (const obj of objects) {
- if (!video[obj.url]) continue
-
- fetch(video[obj.url])
- .then(response => response.blob())
- .then(data => {
- formGroup.patchValue({
- [obj.name]: data
- })
- })
- }
-}
-
-export {
- hydrateFormFromVideo
-}
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.html b/client/src/app/+videos/+video-edit/shared/video-edit.component.html
deleted file mode 100644
index 8365a44403..0000000000
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.html
+++ /dev/null
@@ -1,495 +0,0 @@
-<div class="video-edit" [formGroup]="form()">
- <div ngbNav #nav="ngbNav" class="nav-tabs">
-
- <ng-template #pluginSettingTemplate let-pluginSetting>
- <div class="form-group" [hidden]="isPluginFieldHidden(pluginSetting)">
- <my-dynamic-form-field [form]="pluginDataFormGroup" [formErrors]="formErrors()['pluginData']" [setting]="pluginSetting.commonOptions"></my-dynamic-form-field>
- </div>
- </ng-template>
-
- <ng-container ngbNavItem>
- <a ngbNavLink i18n>Basic info</a>
-
- <ng-template ngbNavContent>
- <div class="form-columns">
- <div class="col-video-edit">
- <div class="form-group">
- <label i18n for="name">Title</label>
- <input type="text" id="name" class="form-control" formControlName="name" />
- <div *ngIf="formErrors().name" class="form-error" role="alert">
- {{ formErrors().name }}
- </div>
- </div>
-
- <div class="form-group">
- <label for="label-tags" i18n class="label-tags">Tags</label>
-
- <my-help>
- <ng-template ptTemplate="customHtml">
- <ng-container i18n>
- Tags could be used to suggest relevant recommendations. <br />
- There is a maximum of 5 tags. <br />
- Press <kbd>Enter</kbd> to add a new tag.
- </ng-container>
- </ng-template>
- </my-help>
-
- <my-select-tags inputId="label-tags" formControlName="tags" class="d-block w-100"></my-select-tags>
- <div *ngIf="formErrors().tags" class="form-error" role="alert">
- {{ formErrors().tags }}
- </div>
- </div>
-
- <div class="form-group">
- <label i18n for="description">Description</label>
-
- <my-help helpType="markdownText">
- <ng-template ptTemplate="preHtml">
- <ng-container i18n>Video descriptions are truncated by default and require manual action to expand them.</ng-container>
-
- <br />
-
- <ng-container i18n>A timestamp (<i>00:05</i> for example) is automatically converted into a link to a part of the video.</ng-container>
- </ng-template>
- </my-help>
-
- <my-markdown-textarea
- inputId="description"
- formControlName="description" [markdownVideo]="publishedVideo()"
- [formError]="formErrors().description" truncateTo3Lines="true" withEmoji="true"
- ></my-markdown-textarea>
- </div>
- </div>
-
- <div class="col-video-edit">
- <div class="form-group">
- <label i18n for="channel">Channel</label>
- <my-select-channel class="d-block" inputId="channel" [items]="userVideoChannels()" formControlName="channelId"></my-select-channel>
- </div>
-
- <div class="form-group">
- <label i18n for="category">Category</label>
- <my-select-options inputId="category" [items]="videoCategories" formControlName="category" clearable="true"></my-select-options>
-
- <div *ngIf="formErrors().category" class="form-error" role="alert">
- {{ formErrors().category }}
- </div>
- </div>
-
- <div class="form-group">
- <label i18n for="licence">Licence</label>
-
- <my-help>
- <ng-template ptTemplate="customHtml">
- <ng-container i18n>
- <a href="https://chooser-beta.creativecommons.org/" target="_blank" rel="noopener noreferrer">Choose</a> the appropriate licence for your work.
- </ng-container>
- </ng-template>
- </my-help>
-
- <my-select-options inputId="licence" [items]="videoLicences" formControlName="licence" clearable="true"></my-select-options>
-
- <div *ngIf="formErrors().licence" class="form-error" role="alert">
- {{ formErrors().licence }}
- </div>
- </div>
-
- <div class="form-group">
- <label i18n for="language">Language</label>
- <my-select-options
- inputId="language" [items]="videoLanguages" formControlName="language"
- clearable="true" filter="true" virtualScroll="true"
- ></my-select-options>
-
- <div *ngIf="formErrors().language" class="form-error" role="alert">
- {{ formErrors().language }}
- </div>
- </div>
-
- <div class="form-group">
- <label i18n for="privacy">Privacy</label>
- <my-select-options inputId="privacy" [items]="videoPrivacies" formControlName="privacy"></my-select-options>
-
- <div *ngIf="formErrors().privacy" class="form-error" role="alert">
- {{ formErrors().privacy }}
- </div>
- </div>
-
- <div *ngIf="passwordProtectionSelected" class="form-group">
- <label i18n for="videoPassword">Password</label>
- <my-input-text formControlName="videoPassword" inputId="videoPassword" [withCopy]="true" [formError]="formErrors()['videoPassword']"></my-input-text>
- </div>
-
- <div *ngIf="schedulePublicationSelected" class="form-group">
- <label i18n for="schedulePublicationAt">Schedule publication ({{ calendarTimezone }})</label>
- <p-calendar
- id="schedulePublicationAt" formControlName="schedulePublicationAt" [dateFormat]="calendarDateFormat"
- [firstDayOfWeek]="0" [minDate]="minScheduledDate" [showTime]="true" [hideOnDateTimeSelect]="true"
- baseZIndex="20000"
- >
- </p-calendar>
-
- <div *ngIf="formErrors().schedulePublicationAt" class="form-error" role="alert">
- {{ formErrors().schedulePublicationAt }}
- </div>
- </div>
-
- <my-peertube-checkbox inputName="nsfw" formControlName="nsfw" helpPlacement="bottom-right">
- <ng-template ptTemplate="label">
- <ng-container i18n>Contains sensitive content</ng-container>
- </ng-template>
-
- <ng-template ptTemplate="help">
- <ng-container i18n>Some instances hide videos containing mature or explicit content by default.</ng-container>
- </ng-template>
- </my-peertube-checkbox>
-
- <my-peertube-checkbox *ngIf="!hideWaitTranscoding()" inputName="waitTranscoding" formControlName="waitTranscoding" helpPlacement="bottom-right">
- <ng-template ptTemplate="label">
- <ng-container i18n>Publish after transcoding</ng-container>
- </ng-template>
-
- <ng-template ptTemplate="help">
- <ng-container i18n>The video may be unplayable during the transcoding process. It's the reason why we prefer to publish publicly the video after transcoding.</ng-container>
- </ng-template>
- </my-peertube-checkbox>
-
- <ng-container
- *ngFor="let pluginSetting of getPluginsFields('main')"
- [ngTemplateOutlet]="pluginSettingTemplate" [ngTemplateOutletContext]="{ $implicit: pluginSetting }"
- >
- </ng-container>
- </div>
- </div>
- </ng-template>
- </ng-container>
-
- <ng-container ngbNavItem *ngIf="!liveVideo()">
- <a ngbNavLink i18n>Captions</a>
-
- <ng-template ngbNavContent>
- <div class="captions">
- <my-alert type="primary" *ngIf="displayTranscriptionInfo() && isTranscriptionEnabled() && !hasCaptions()" i18n>
- Subtitles will be automatically generated from your video.
- </my-alert>
-
- <div class="form-group" *ngFor="let videoCaption of videoCaptions()">
-
- <div class="caption-entry">
-
- @if (videoCaption.action) {
- <span class="caption-entry-label">{{ getCaptionLabel(videoCaption) }}</span>
-
- @switch (videoCaption.action) {
- @case ('CREATE') {
- <div i18n class="caption-entry-state green">Will be created on update</div>
- } @case ('UPDATE') {
- <div i18n class="caption-entry-state green">Will be edited on update</div>
- } @case ('REMOVE') {
- <div i18n class="caption-entry-state red">Will be deleted on update</div>
- }
- }
-
- @if (videoCaption.action === 'CREATE' || videoCaption.action === 'UPDATE') {
- <my-edit-button class="me-2" i18n-label label="Edit" (click)="openEditCaptionModal(videoCaption)"></my-edit-button>
- }
-
- <my-button i18n (click)="deleteCaption(videoCaption)" icon="undo">
- @switch (videoCaption.action) {
- @case ('CREATE') {
- Cancel creation
- } @case ('UPDATE') {
- Cancel editing
- } @case ('REMOVE') {
- Cancel deletion
- }
- }
- </my-button>
- } @else {
- <a
- i18n-title title="See the subtitle file" class="caption-entry-label" target="_blank" rel="noopener noreferrer"
- [href]="videoCaption.fileUrl"
- >{{ getCaptionLabel(videoCaption) }}</a>
-
- <div i18n class="caption-entry-state">Already uploaded on {{ videoCaption.updatedAt | ptDate }} &#10004;</div>
-
- <my-edit-button i18n-label label="Edit" class="me-2" (click)="openEditCaptionModal(videoCaption)"></my-edit-button>
- <my-delete-button label (click)="deleteCaption(videoCaption)"></my-delete-button>
- }
- </div>
- </div>
-
- <div i18n class="no-caption" *ngIf="videoCaptions()?.length === 0">
- No captions for now.
- </div>
-
- <div class="mt-3 mb-3">
- <button (click)="openAddCaptionModal()" class="peertube-create-button">
- <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>
- <ng-container i18n>Add a caption</ng-container>
- </button>
- </div>
-
- </div>
- </ng-template>
- </ng-container>
-
- <ng-container ngbNavItem *ngIf="!liveVideo()">
- <a ngbNavLink i18n>Chapters</a>
-
- <ng-template ngbNavContent>
- <div class="row mb-5">
- <div class="chapters col-md-12 col-xl-6" formArrayName="chapters">
- <my-alert type="primary" i18n>
- Chapters can also be set in the video description.
-
- Check the format <a href="https://docs.joinpeertube.org/use/create-upload-video#chapters" target="_blank" class="alert-link">in the PeerTube documentation</a>
- </my-alert>
-
- <ng-container *ngFor="let chapterControl of getChaptersFormArray().controls; let i = index">
- <div class="chapter" [formGroupName]="i">
- <!-- Row 1 -->
- <div></div>
-
- <label i18n [ngClass]="{ 'hide-chapter-label': i !== 0 }" [for]="'timecode[' + i + ']'">Timecode</label>
-
- <label i18n [ngClass]="{ 'hide-chapter-label': i !== 0 }" [for]="'title[' + i + ']'">Chapter name</label>
-
- <div></div>
-
- <!-- Row 2 -->
- <div class="position">{{ i + 1 }}</div>
-
- <my-timestamp-input
- class="d-block" enableBorder="true" [inputName]="'timecode[' + i + ']'"
- [maxTimestamp]="publishedVideo()?.duration" formControlName="timecode"
- ></my-timestamp-input>
-
- <div>
- <input
- [ngClass]="{ 'input-error': formErrors().chapters[i].title }"
- type="text" [id]="'title[' + i + ']'" [name]="'title[' + i + ']'" formControlName="title"
- />
-
- <div [ngClass]="{ 'opacity-0': !formErrors().chapters[i].title }" class="form-error" role="alert">
- <span class="opacity-0">t</span> <!-- Ensure we have reserve a correct height -->
- {{ formErrors().chapters[i].title }}
- </div>
- </div>
-
- <my-delete-button *ngIf="!isLastChapterControl(i)" (click)="deleteChapterControl(i)"></my-delete-button>
- </div>
- </ng-container>
-
- <div *ngIf="getChapterArrayErrors()" class="form-error" role="alert">
- {{ getChapterArrayErrors() }}
- </div>
- </div>
-
- <my-embed *ngIf="publishedVideo()" class="col-md-12 col-xl-6" [video]="publishedVideo()"></my-embed>
- </div>
- </ng-template>
- </ng-container>
-
- <ng-container ngbNavItem *ngIf="liveVideo()">
- <a ngbNavLink i18n>Live settings</a>
-
- <ng-template ngbNavContent>
- <div class="row live-settings">
- <div class="col-md-12">
- <my-alert type="primary">
- <my-live-documentation-link></my-live-documentation-link>
- </my-alert>
-
- <div *ngIf="liveVideo().rtmpUrl" class="form-group">
- <label for="liveVideoRTMPUrl" i18n>Live RTMP Url</label>
- <my-input-text inputId="liveVideoRTMPUrl" [value]="liveVideo().rtmpUrl" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-text>
- </div>
-
- <div *ngIf="liveVideo().rtmpsUrl" class="form-group">
- <label for="liveVideoRTMPSUrl" i18n>Live RTMPS Url</label>
- <my-input-text inputId="liveVideoRTMPSUrl" [value]="liveVideo().rtmpsUrl" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-text>
- </div>
-
- <div class="form-group">
- <label for="liveVideoStreamKey" i18n>Live stream key</label>
- <my-input-text inputId="liveVideoStreamKey" [value]="liveVideo().streamKey" [withCopy]="true" [readonly]="true"></my-input-text>
-
- <div class="form-group-description" i18n>⚠️ Never share your stream key with anyone.</div>
- </div>
-
- <div class="form-group">
- <div class="peertube-radio-container">
- <input type="radio" formControlName="permanentLive" id="permanentLiveFalse" [value]="false">
- <label i18n for="permanentLiveFalse" class="radio">This is a normal live</label>
-
- <span class="form-group-description" i18n>
- You can stream only once in a normal live. If you enable replay, it will be saved under the same URL as your live
- </span>
- </div>
-
- <div class="peertube-radio-container">
- <input type="radio" formControlName="permanentLive" id="permanentLiveTrue" [value]="true">
- <label i18n for="permanentLiveTrue" class="radio">This is a permanent/recurring live</label>
-
- <span class="form-group-description" i18n>
- You can stream multiple times in a permanent/recurring live. If you enable replays, they will be saved as separate videos
- </span>
- </div>
- </div>
-
- <div class="form-group" *ngIf="isSaveReplayAllowed()">
- <my-peertube-checkbox inputName="liveVideoSaveReplay" formControlName="saveReplay">
- <ng-template ptTemplate="label">
- <ng-container i18n>Automatically publish a replay when your live ends</ng-container>
- </ng-template>
-
- <ng-container ngProjectAs="description">
- <span i18n>⚠️ If you enable this option, your live will be terminated if you exceed your video quota</span>
- </ng-container>
- </my-peertube-checkbox>
- </div>
-
- <div class="form-group mx-4" *ngIf="isSaveReplayEnabled()">
- <label i18n for="replayPrivacy">Privacy of the new replay</label>
- <my-select-options inputId="replayPrivacy" [items]="replayPrivacies" formControlName="replayPrivacy"></my-select-options>
- </div>
-
- <div class="form-group" *ngIf="isLatencyModeEnabled()">
- <label i18n for="latencyMode">Latency mode</label>
- <my-select-options inputId="latencyMode" [items]="latencyModes" formControlName="latencyMode" clearable="true"></my-select-options>
-
- <div *ngIf="formErrors().latencyMode" class="form-error" role="alert">
- {{ formErrors().latencyMode }}
- </div>
- </div>
- </div>
- </div>
- </ng-template>
-
- </ng-container>
-
- <ng-container ngbNavItem>
- <a ngbNavLink i18n>Advanced settings</a>
-
- <ng-template ngbNavContent>
- <div class="row advanced-settings">
- <div class="col-md-12 col-xl-8">
-
- <ng-content></ng-content>
-
- <div class="form-group">
- <label i18n for="previewfile">Video thumbnail</label>
-
- <my-thumbnail-manager id="previewfile" formControlName="previewfile" [video]="publishedVideo()"></my-thumbnail-manager>
- </div>
-
- <div class="form-group">
- <label i18n for="support">Support</label>
-
- <my-help helpType="markdownEnhanced">
- <ng-template ptTemplate="preHtml">
- <ng-container i18n>
- Short text to tell people how they can support you (membership platform...).
- </ng-container>
- </ng-template>
- </my-help>
-
- <my-markdown-textarea
- inputId="support" formControlName="support" markdownType="enhanced"
- [formError]="formErrors()['support']"
- ></my-markdown-textarea>
- </div>
- </div>
-
- <div class="col-md-12 col-xl-4">
-
- <div *ngIf="videoSource()" class="form-group">
- <label i18n for="filename">Filename</label>
-
- <my-help>
- <ng-template ptTemplate="preHtml">
- <ng-container i18n>
- Name of the uploaded file
- </ng-container>
- </ng-template>
- </my-help>
-
- <input type="text" [disabled]="true" id="filename" class="form-control" [value]="videoSource().filename" />
- </div>
-
- <div class="form-group originally-published-at">
- <div class="label-container">
- <label i18n class="mb-0" for="originallyPublishedAt">Original publication date</label>
-
- <button i18n class="reset-button reset-button-small" (click)="resetField('originallyPublishedAt')" *ngIf="hasPublicationDate()">
- Reset
- </button>
- </div>
-
- <div class="form-group-description" i18n>
- This is the date when the content was originally published (e.g. the release date for a film)
- </div>
-
- <p-calendar
- inputId="originallyPublishedAt" formControlName="originallyPublishedAt" [dateFormat]="calendarDateFormat" [firstDayOfWeek]="0"
- [showTime]="true" [hideOnDateTimeSelect]="true" [monthNavigator]="true" [yearNavigator]="true" [yearRange]="myYearRange"
- baseZIndex="20000"
- >
- </p-calendar>
-
- <div *ngIf="formErrors().originallyPublishedAt" class="form-error" role="alert">
- {{ formErrors().originallyPublishedAt }}
- </div>
- </div>
-
- <div class="form-group mb-4">
- <label i18n class="mb-0" for="commentsPolicy">Comments policy</label>
-
- <div class="form-group-description" i18n>
- You can require comments to be approved depending on <a routerLink="/my-account/auto-tag-policies" target="_blank">your auto-tags policies</a>
- </div>
-
- <my-select-options inputId="commentsPolicy" [items]="commentPolicies" formControlName="commentsPolicy"></my-select-options>
-
- <div *ngIf="formErrors().commentsPolicy" class="form-error" role="alert">
- {{ formErrors().commentsPolicy }}
- </div>
- </div>
-
- <my-peertube-checkbox
- inputName="downloadEnabled" formControlName="downloadEnabled"
- i18n-labelText labelText="Enable download"
- ></my-peertube-checkbox>
- </div>
- </div>
- </ng-template>
- </ng-container>
-
- <ng-container ngbNavItem *ngIf="getPluginsFields('plugin-settings').length !== 0">
- <a ngbNavLink i18n>Plugin settings</a>
-
- <ng-template ngbNavContent>
- <div class="row plugin-settings">
-
- <div class="col-md-12 col-xl-8">
- <ng-container
- *ngFor="let pluginSetting of getPluginsFields('plugin-settings')"
- [ngTemplateOutlet]="pluginSettingTemplate" [ngTemplateOutletContext]="{ $implicit: pluginSetting }"
- >
- </ng-container>
- </div>
-
- </div>
- </ng-template>
- </ng-container>
- </div>
-
- <div [ngbNavOutlet]="nav"></div>
-</div>
-
-<my-video-caption-add-modal
- #videoCaptionAddModal [existingCaptions]="getExistingCaptions()" [serverConfig]="serverConfig" (captionAdded)="onCaptionEdited($event)"
-></my-video-caption-add-modal>
-
-<my-video-caption-edit-modal #videoCaptionEditModal></my-video-caption-edit-modal>
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.scss b/client/src/app/+videos/+video-edit/shared/video-edit.component.scss
deleted file mode 100644
index a2aebfa8af..0000000000
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.scss
+++ /dev/null
@@ -1,131 +0,0 @@
-@use '_variables' as *;
-@use '_mixins' as *;
-@use '_form-mixins' as *;
-
-.peertube-select-container {
- @include peertube-select-container(auto);
-}
-
-my-peertube-checkbox {
- display: block;
- margin-bottom: 1rem;
-}
-
-my-timestamp-input {
- width: 100px;
-}
-
-.nav-tabs {
- margin-bottom: 15px;
-}
-
-.video-edit {
- height: 100%;
- min-height: 300px;
-
- input {
- display: block;
-
- @include peertube-input-text(100%);
- }
-}
-
-.caption-entry {
- display: flex;
- min-height: 40px;
- align-items: center;
- flex-wrap: wrap;
-
- a.caption-entry-label {
- color: pvar(--fg);
-
- @include disable-default-a-behaviour;
-
- &:hover {
- opacity: 0.8;
- }
- }
-
- .caption-entry-label {
- font-weight: bold;
- min-width: 100px;
-
- @include margin-right(20px);
- }
-
- .caption-entry-state {
- min-width: 250px;
-
- @include margin-right(15px);
- }
-}
-
-.no-caption {
- text-align: center;
-}
-
-.submit-container {
- text-align: end;
-
- .message-submit {
- display: inline-block;
- color: pvar(--fg-300);
-
- @include margin-right(25px);
- }
-}
-
-p-calendar {
- display: block;
-
- ::ng-deep {
- .p-calendar {
- width: 100%;
- }
- }
-}
-
-.form-columns {
- display: grid;
-
- grid-template-columns: 66% 1fr;
- grid-gap: 30px;
-}
-
-.col-video-edit {
- max-width: 100%;
- min-width: 1px;
-}
-
-.hide-chapter-label {
- height: 0;
- opacity: 0;
-}
-
-.chapter {
- display: grid;
- grid-template-columns: auto auto minmax(150px, 350px) 1fr;
- grid-template-rows: auto auto;
- column-gap: 1rem;
-
- .position {
- height: 38px;
- min-width: 16px;
- display: flex;
- align-items: center;
- }
-
- my-delete-button {
- width: fit-content;
- }
-
- .form-error {
- margin-top: 0;
- }
-}
-
-@include on-small-main-col {
- .form-columns {
- grid-template-columns: 1fr;
- }
-}
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
deleted file mode 100644
index fd4e31e03c..0000000000
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
+++ /dev/null
@@ -1,688 +0,0 @@
-import { NgClass, NgFor, NgIf, NgTemplateOutlet } from '@angular/common'
-import { ChangeDetectorRef, Component, NgZone, OnDestroy, OnInit, booleanAttribute, inject, input, output, viewChild } from '@angular/core'
-import { AbstractControl, FormArray, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'
-import { RouterLink } from '@angular/router'
-import { HooksService, PluginService, ServerService } from '@app/core'
-import { removeElementFromArray } from '@app/helpers'
-import { BuildFormArgument, BuildFormValidator } from '@app/shared/form-validators/form-validator.model'
-import { VIDEO_CHAPTERS_ARRAY_VALIDATOR, VIDEO_CHAPTER_TITLE_VALIDATOR } from '@app/shared/form-validators/video-chapter-validators'
-import {
- VIDEO_CATEGORY_VALIDATOR,
- VIDEO_CHANNEL_VALIDATOR,
- VIDEO_DESCRIPTION_VALIDATOR,
- VIDEO_LANGUAGE_VALIDATOR,
- VIDEO_LICENCE_VALIDATOR,
- VIDEO_NAME_VALIDATOR,
- VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR,
- VIDEO_PASSWORD_VALIDATOR,
- VIDEO_PRIVACY_VALIDATOR,
- VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR,
- VIDEO_SUPPORT_VALIDATOR,
- VIDEO_TAGS_ARRAY_VALIDATOR
-} from '@app/shared/form-validators/video-validators'
-import { FormReactiveErrors, FormReactiveValidationMessages } from '@app/shared/shared-forms/form-reactive.service'
-import { FormValidatorService } from '@app/shared/shared-forms/form-validator.service'
-import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
-import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'
-import { InstanceService } from '@app/shared/shared-main/instance/instance.service'
-import { VideoCaptionEdit, VideoCaptionWithPathEdit } from '@app/shared/shared-main/video-caption/video-caption-edit.model'
-import { VideoChaptersEdit } from '@app/shared/shared-main/video/video-chapters-edit.model'
-import { VideoEdit } from '@app/shared/shared-main/video/video-edit.model'
-import { VideoService } from '@app/shared/shared-main/video/video.service'
-import { NgbNav, NgbNavContent, NgbNavItem, NgbNavLink, NgbNavLinkBase, NgbNavOutlet } from '@ng-bootstrap/ng-bootstrap'
-import {
- HTMLServerConfig,
- LiveVideo,
- LiveVideoLatencyMode,
- RegisterClientFormFieldOptions,
- RegisterClientVideoFieldOptions,
- VideoChapter,
- VideoCommentPolicyType,
- VideoConstant,
- VideoDetails,
- VideoPrivacy,
- VideoPrivacyType,
- VideoSource
-} from '@peertube/peertube-models'
-import { logger } from '@root-helpers/logger'
-import { PluginInfo } from '@root-helpers/plugins-manager'
-import { CalendarModule } from 'primeng/calendar'
-import { forkJoin } from 'rxjs'
-import { map } from 'rxjs/operators'
-import { SelectChannelItem, SelectOptionsItem } from 'src/types/select-options-item.model'
-import { DynamicFormFieldComponent } from '../../../shared/shared-forms/dynamic-form-field.component'
-import { InputTextComponent } from '../../../shared/shared-forms/input-text.component'
-import { MarkdownTextareaComponent } from '../../../shared/shared-forms/markdown-textarea.component'
-import { PeertubeCheckboxComponent } from '../../../shared/shared-forms/peertube-checkbox.component'
-import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'
-import { SelectOptionsComponent } from '../../../shared/shared-forms/select/select-options.component'
-import { SelectTagsComponent } from '../../../shared/shared-forms/select/select-tags.component'
-import { TimestampInputComponent } from '../../../shared/shared-forms/timestamp-input.component'
-import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
-import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'
-import { DeleteButtonComponent } from '../../../shared/shared-main/buttons/delete-button.component'
-import { EditButtonComponent } from '../../../shared/shared-main/buttons/edit-button.component'
-import { HelpComponent } from '../../../shared/shared-main/buttons/help.component'
-import { PeerTubeTemplateDirective } from '../../../shared/shared-main/common/peertube-template.directive'
-import { EmbedComponent } from '../../../shared/shared-main/video/embed.component'
-import { LiveDocumentationLinkComponent } from '../../../shared/shared-video-live/live-documentation-link.component'
-import { VideoCaptionAddModalComponent } from './caption/video-caption-add-modal.component'
-import { VideoCaptionEditModalComponent } from './caption/video-caption-edit-modal.component'
-import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service'
-import { ThumbnailManagerComponent } from './thumbnail-manager/thumbnail-manager.component'
-import { VideoEditType } from './video-edit.type'
-
-type PluginField = {
- pluginInfo: PluginInfo
- commonOptions: RegisterClientFormFieldOptions
- videoFormOptions: RegisterClientVideoFieldOptions
-}
-
-@Component({
- selector: 'my-video-edit',
- styleUrls: [ './video-edit.component.scss' ],
- templateUrl: './video-edit.component.html',
- imports: [
- RouterLink,
- FormsModule,
- ReactiveFormsModule,
- NgbNav,
- DynamicFormFieldComponent,
- NgbNavItem,
- NgbNavLink,
- NgbNavLinkBase,
- NgbNavContent,
- NgIf,
- HelpComponent,
- PeerTubeTemplateDirective,
- SelectTagsComponent,
- MarkdownTextareaComponent,
- SelectChannelComponent,
- SelectOptionsComponent,
- InputTextComponent,
- CalendarModule,
- PeertubeCheckboxComponent,
- NgFor,
- NgTemplateOutlet,
- GlobalIconComponent,
- NgClass,
- TimestampInputComponent,
- DeleteButtonComponent,
- EmbedComponent,
- LiveDocumentationLinkComponent,
- NgbNavOutlet,
- VideoCaptionAddModalComponent,
- PTDatePipe,
- ThumbnailManagerComponent,
- EditButtonComponent,
- ButtonComponent,
- AlertComponent,
- VideoCaptionEditModalComponent
- ]
-})
-export class VideoEditComponent implements OnInit, OnDestroy {
- private formValidatorService = inject(FormValidatorService)
- private videoService = inject(VideoService)
- private serverService = inject(ServerService)
- private pluginService = inject(PluginService)
- private instanceService = inject(InstanceService)
- private i18nPrimengCalendarService = inject(I18nPrimengCalendarService)
- private ngZone = inject(NgZone)
- private hooks = inject(HooksService)
- private cd = inject(ChangeDetectorRef)
-
- readonly form = input<FormGroup>(undefined)
- readonly formErrors = input<
- FormReactiveErrors & {
- chapters?: {
- title: string
- }[]
- }
- >({})
- readonly validationMessages = input<FormReactiveValidationMessages>({})
-
- readonly publishedVideo = input<VideoDetails>(undefined)
-
- readonly userVideoChannels = input<SelectChannelItem[]>([])
-
- readonly forbidScheduledPublication = input(true, { transform: booleanAttribute })
- readonly displayTranscriptionInfo = input(true, { transform: booleanAttribute })
-
- readonly videoCaptions = input<VideoCaptionWithPathEdit[]>([])
- readonly videoSource = input<VideoSource>(undefined)
-
- readonly videoChapters = input<VideoChapter[]>([])
-
- readonly hideWaitTranscoding = input(false, { transform: booleanAttribute })
- readonly updateVideoFileEnabled = input(false, { transform: booleanAttribute })
-
- readonly type = input<VideoEditType>(undefined)
- readonly liveVideo = input<LiveVideo>(undefined)
-
- readonly videoCaptionAddModal = viewChild<VideoCaptionAddModalComponent>('videoCaptionAddModal')
- readonly videoCaptionEditModal = viewChild<VideoCaptionEditModalComponent>('videoCaptionEditModal')
-
- readonly formBuilt = output()
- readonly pluginFieldsAdded = output()
-
- // So that it can be accessed in the template
- readonly SPECIAL_SCHEDULED_PRIVACY = VideoEdit.SPECIAL_SCHEDULED_PRIVACY
-
- videoPrivacies: VideoConstant<VideoPrivacyType | typeof VideoEdit.SPECIAL_SCHEDULED_PRIVACY>[] = []
- replayPrivacies: VideoConstant<VideoPrivacyType>[] = []
- videoCategories: VideoConstant<number>[] = []
- videoLicences: VideoConstant<number>[] = []
- commentPolicies: VideoConstant<VideoCommentPolicyType>[] = []
- videoLanguages: VideoConstant<string>[] = []
- latencyModes: SelectOptionsItem[] = [
- {
- id: LiveVideoLatencyMode.SMALL_LATENCY,
- label: $localize`Small latency`,
- description: $localize`Reduce latency to ~15s disabling P2P`
- },
- {
- id: LiveVideoLatencyMode.DEFAULT,
- label: $localize`Default`,
- description: $localize`Average latency of 30s`
- },
- {
- id: LiveVideoLatencyMode.HIGH_LATENCY,
- label: $localize`High latency`,
- description: $localize`Average latency of 60s increasing P2P ratio`
- }
- ]
-
- pluginDataFormGroup: FormGroup
-
- schedulePublicationSelected = false
- passwordProtectionSelected = false
-
- calendarLocale: any = {}
- minScheduledDate = new Date()
- myYearRange = '1880:' + (new Date()).getFullYear()
-
- calendarTimezone: string
- calendarDateFormat: string
-
- serverConfig: HTMLServerConfig
-
- pluginFields: PluginField[] = []
-
- private schedulerInterval: any
- private firstPatchDone = false
- private initialVideoCaptions: string[] = []
-
- constructor () {
- this.calendarTimezone = this.i18nPrimengCalendarService.getTimezone()
- this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat()
- }
-
- updateForm () {
- const defaultValues: any = {
- nsfw: 'false',
- commentsPolicy: this.serverConfig.defaults.publish.commentsPolicy,
- downloadEnabled: this.serverConfig.defaults.publish.downloadEnabled,
- waitTranscoding: true,
- licence: this.serverConfig.defaults.publish.licence,
- tags: []
- }
- const obj: BuildFormArgument = {
- name: VIDEO_NAME_VALIDATOR,
- privacy: VIDEO_PRIVACY_VALIDATOR,
- videoPassword: VIDEO_PASSWORD_VALIDATOR,
- channelId: VIDEO_CHANNEL_VALIDATOR,
- nsfw: null,
- commentsPolicy: null,
- downloadEnabled: null,
- waitTranscoding: null,
- category: VIDEO_CATEGORY_VALIDATOR,
- licence: VIDEO_LICENCE_VALIDATOR,
- language: VIDEO_LANGUAGE_VALIDATOR,
- description: VIDEO_DESCRIPTION_VALIDATOR,
- tags: VIDEO_TAGS_ARRAY_VALIDATOR,
- previewfile: null,
- support: VIDEO_SUPPORT_VALIDATOR,
- schedulePublicationAt: VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR,
- originallyPublishedAt: VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR,
- liveStreamKey: null,
- permanentLive: null,
- latencyMode: null,
- saveReplay: null,
- replayPrivacy: null
- }
-
- const form = this.form()
- this.formValidatorService.updateFormGroup(
- form,
- this.formErrors(),
- this.validationMessages(),
- obj,
- defaultValues
- )
-
- form.addControl('chapters', new FormArray([], VIDEO_CHAPTERS_ARRAY_VALIDATOR.VALIDATORS))
- this.addNewChapterControl()
-
- form.get('chapters').valueChanges.subscribe((chapters: { title: string, timecode: string }[]) => {
- const lastChapter = chapters[chapters.length - 1]
-
- if (lastChapter.title || lastChapter.timecode) {
- this.addNewChapterControl()
- }
- })
-
- this.trackChannelChange()
- this.trackPrivacyChange()
-
- this.formBuilt.emit()
- }
-
- ngOnInit () {
- this.serverConfig = this.serverService.getHTMLConfig()
-
- this.updateForm()
-
- this.pluginService.ensurePluginsAreLoaded('video-edit')
- .then(() => this.updatePluginFields())
-
- this.serverService.getVideoCategories()
- .subscribe(res => this.videoCategories = res)
-
- this.serverService.getVideoLicences()
- .subscribe(res => this.videoLicences = res)
-
- this.serverService.getCommentPolicies()
- .subscribe(res => this.commentPolicies = res)
-
- forkJoin([
- this.instanceService.getAbout(),
- this.serverService.getVideoLanguages()
- ]).pipe(map(([ about, languages ]) => ({ about, languages })))
- .subscribe(({ about, languages }) => {
- this.videoLanguages = [
- ...languages.filter(l => about.instance.languages.includes(l.id)),
-
- languages.find(l => l.id === 'zxx'),
-
- ...languages.filter(l => !about.instance.languages.includes(l.id) && l.id !== 'zxx')
- ]
- })
-
- this.serverService.getVideoPrivacies()
- .subscribe(privacies => {
- const videoPrivacies = this.videoService.explainedPrivacyLabels(privacies).videoPrivacies
- this.videoPrivacies = videoPrivacies
- this.replayPrivacies = videoPrivacies.filter(privacy => privacy.id !== VideoPrivacy.PASSWORD_PROTECTED)
-
- // Can't schedule publication if private privacy is not available (could be deleted by a plugin)
- const hasPrivatePrivacy = this.videoPrivacies.some(p => p.id === VideoPrivacy.PRIVATE)
- if (this.forbidScheduledPublication() || !hasPrivatePrivacy) return
-
- this.videoPrivacies.push({
- id: this.SPECIAL_SCHEDULED_PRIVACY,
- label: $localize`Scheduled`,
- description: $localize`Hide the video until a specific date`
- })
- })
-
- this.initialVideoCaptions = this.videoCaptions().map(c => c.language.id)
-
- this.ngZone.runOutsideAngular(() => {
- this.schedulerInterval = setInterval(() => this.minScheduledDate = new Date(), 1000 * 60) // Update every minute
- })
-
- const updateFormForPlugins = (values: any) => {
- this.form().patchValue(values)
- this.cd.detectChanges()
- }
- this.hooks.runAction('action:video-edit.init', 'video-edit', { type: this.type(), updateForm: updateFormForPlugins })
-
- this.form().valueChanges.subscribe(() => {
- this.hooks.runAction('action:video-edit.form.updated', 'video-edit', { type: this.type(), formValues: this.form().value })
- })
- }
-
- ngOnDestroy () {
- if (this.schedulerInterval) clearInterval(this.schedulerInterval)
- }
-
- // ---------------------------------------------------------------------------
-
- getCaptionLabel (caption: VideoCaptionWithPathEdit) {
- if (caption.automaticallyGenerated) {
- return $localize`${caption.language.label} (auto-generated)`
- }
-
- return caption.language.label
- }
-
- getExistingCaptions () {
- return this.videoCaptions()
- .filter(c => c.action !== 'REMOVE')
- .map(c => c.language.id)
- }
-
- onCaptionEdited (caption: VideoCaptionEdit) {
- const existingCaption = this.videoCaptions().find(c => c.language.id === caption.language.id)
-
- // Replace existing caption?
- if (existingCaption) {
- Object.assign(existingCaption, caption)
- } else {
- this.videoCaptions().push(
- Object.assign(caption, { action: 'CREATE' as 'CREATE' })
- )
- }
-
- this.sortVideoCaptions()
- }
-
- deleteCaption (caption: VideoCaptionEdit) {
- // Caption recovers his former state
- if (caption.action && this.initialVideoCaptions.includes(caption.language.id)) {
- caption.action = undefined
- return
- }
-
- // This caption is not on the server, just remove it from our array
- if (caption.action === 'CREATE' || caption.action === 'UPDATE') {
- removeElementFromArray(this.videoCaptions(), caption)
- return
- }
-
- caption.action = 'REMOVE' as 'REMOVE'
- }
-
- openAddCaptionModal () {
- this.videoCaptionAddModal().show()
- }
-
- openEditCaptionModal (videoCaption: VideoCaptionWithPathEdit) {
- this.videoCaptionEditModal().show({
- videoCaption,
- serverConfig: this.serverConfig,
- publishedVideo: this.publishedVideo(),
- captionEdited: caption => this.onCaptionEdited(caption)
- })
- }
-
- // ---------------------------------------------------------------------------
-
- isSaveReplayAllowed () {
- return this.serverConfig.live.allowReplay
- }
-
- isSaveReplayEnabled () {
- return this.form().value['saveReplay'] === true
- }
-
- isPermanentLiveEnabled () {
- return this.form().value['permanentLive'] === true
- }
-
- isLatencyModeEnabled () {
- return this.serverConfig.live.latencySetting.enabled
- }
-
- hasPublicationDate () {
- return !!this.form().value['originallyPublishedAt']
- }
-
- isTranscriptionEnabled () {
- return this.serverConfig.videoTranscription.enabled
- }
-
- hasCaptions () {
- return this.getExistingCaptions().length !== 0
- }
-
- // ---------------------------------------------------------------------------
-
- resetField (name: string) {
- this.form().patchValue({ [name]: null })
- }
-
- // ---------------------------------------------------------------------------
-
- isPluginFieldHidden (pluginField: PluginField) {
- if (typeof pluginField.commonOptions.hidden !== 'function') return false
-
- return pluginField.commonOptions.hidden({
- formValues: this.form().value,
- videoToUpdate: this.publishedVideo(),
- liveVideo: this.liveVideo()
- })
- }
-
- getPluginsFields (tab: 'main' | 'plugin-settings') {
- return this.pluginFields.filter(p => {
- const wanted = p.videoFormOptions.tab ?? 'plugin-settings'
-
- return wanted === tab
- })
- }
-
- private sortVideoCaptions () {
- this.videoCaptions().sort((v1, v2) => {
- if (v1.language.label < v2.language.label) return -1
- if (v1.language.label === v2.language.label) return 0
-
- return 1
- })
- }
-
- private async updatePluginFields () {
- this.pluginFields = this.pluginService.getRegisteredVideoFormFields(this.type())
-
- if (this.pluginFields.length === 0) return
-
- const pluginObj: { [id: string]: BuildFormValidator } = {}
- const pluginValidationMessages: FormReactiveValidationMessages = {}
- const pluginFormErrors: any = {}
- const pluginDefaults: any = {}
-
- for (const setting of this.pluginFields) {
- await this.pluginService.translateSetting(setting.pluginInfo.plugin.npmName, setting.commonOptions)
-
- // Not a form input, just a HTML tag
- if (setting.commonOptions.type === 'html') continue
-
- const validator = async (control: AbstractControl) => {
- if (!setting.commonOptions.error) return null
-
- const error = await setting.commonOptions.error({ formValues: this.form().value, value: control.value })
-
- return error?.error ? { [setting.commonOptions.name]: error.text } : null
- }
-
- const name = setting.commonOptions.name
-
- pluginObj[name] = {
- ASYNC_VALIDATORS: [ validator ],
- VALIDATORS: [],
- MESSAGES: {}
- }
-
- pluginDefaults[name] = setting.commonOptions.default
- }
-
- this.pluginDataFormGroup = new FormGroup({})
- this.formValidatorService.updateFormGroup(
- this.pluginDataFormGroup,
- pluginFormErrors,
- pluginValidationMessages,
- pluginObj,
- pluginDefaults
- )
-
- this.form().addControl('pluginData', this.pluginDataFormGroup)
- // FIXME: use update function to signal
- this.formErrors()['pluginData'] = pluginFormErrors
- this.validationMessages()['pluginData'] = pluginValidationMessages
-
- this.cd.detectChanges()
- this.pluginFieldsAdded.emit()
-
- // Plugins may need other control values to calculate potential errors
- this.form().valueChanges.subscribe(() => this.formValidatorService.updateTreeValidity(this.pluginDataFormGroup))
- }
-
- // ---------------------------------------------------------------------------
-
- addNewChapterControl () {
- const chaptersFormArray = this.getChaptersFormArray()
- const controls = chaptersFormArray.controls
-
- if (controls.length !== 0) {
- const lastControl = chaptersFormArray.controls[controls.length - 1]
- lastControl.get('title').addValidators(Validators.required)
- }
-
- this.formValidatorService.addControlInFormArray({
- controlName: 'chapters',
- formArray: chaptersFormArray,
- formErrors: this.formErrors(),
- validationMessages: this.validationMessages(),
- formToBuild: {
- timecode: null,
- title: VIDEO_CHAPTER_TITLE_VALIDATOR
- },
- defaultValues: {
- timecode: 0
- }
- })
- }
-
- getChaptersFormArray () {
- return this.form().controls['chapters'] as FormArray
- }
-
- deleteChapterControl (index: number) {
- this.formValidatorService.removeControlFromFormArray({
- controlName: 'chapters',
- formArray: this.getChaptersFormArray(),
- formErrors: this.formErrors(),
- validationMessages: this.validationMessages(),
- index
- })
- }
-
- isLastChapterControl (index: number) {
- return this.getChaptersFormArray().length - 1 === index
- }
-
- patchChapters (chaptersEdit: VideoChaptersEdit) {
- const totalChapters = chaptersEdit.getChaptersForUpdate().length
- const totalControls = this.getChaptersFormArray().length
-
- // Add missing controls. We use <= because we need the "empty control" to add another chapter
- for (let i = 0; i <= totalChapters - totalControls; i++) {
- this.addNewChapterControl()
- }
-
- this.form().patchValue(chaptersEdit.toFormPatch())
- }
-
- getChapterArrayErrors () {
- if (!this.getChaptersFormArray().errors) return ''
-
- return Object.values(this.getChaptersFormArray().errors).join('. ')
- }
-
- // ---------------------------------------------------------------------------
-
- private trackPrivacyChange () {
- // We will update the schedule input and the wait transcoding checkbox validators
- this.form().controls['privacy']
- .valueChanges
- .pipe(map(res => parseInt(res.toString(), 10)))
- .subscribe(
- newPrivacyId => {
- this.schedulePublicationSelected = newPrivacyId === this.SPECIAL_SCHEDULED_PRIVACY
-
- // Value changed
- const scheduleControl = this.form().get('schedulePublicationAt')
- const waitTranscodingControl = this.form().get('waitTranscoding')
-
- if (this.schedulePublicationSelected) {
- scheduleControl.setValidators([ Validators.required ])
-
- waitTranscodingControl.disable()
- waitTranscodingControl.setValue(false)
- } else {
- scheduleControl.clearValidators()
-
- waitTranscodingControl.enable()
-
- // Do not update the control value on first patch (values come from the server)
- if (this.firstPatchDone === true) {
- waitTranscodingControl.setValue(true)
- }
- }
-
- scheduleControl.updateValueAndValidity()
- waitTranscodingControl.updateValueAndValidity()
-
- this.firstPatchDone = true
-
- this.passwordProtectionSelected = newPrivacyId === VideoPrivacy.PASSWORD_PROTECTED
- const videoPasswordControl = this.form().get('videoPassword')
-
- if (this.passwordProtectionSelected) {
- videoPasswordControl.setValidators([ Validators.required ])
- } else {
- videoPasswordControl.clearValidators()
- }
-
- videoPasswordControl.updateValueAndValidity()
- }
- )
- }
-
- private trackChannelChange () {
- // We will update the "support" field depending on the channel
- this.form().controls['channelId']
- .valueChanges
- .pipe(map(res => parseInt(res.toString(), 10)))
- .subscribe(
- newChannelId => {
- const oldChannelId = parseInt(this.form().value['channelId'], 10)
-
- // Not initialized yet
- if (isNaN(newChannelId)) return
- const newChannel = this.userVideoChannels().find(c => c.id === newChannelId)
- if (!newChannel) return
-
- // Wait support field update
- setTimeout(() => {
- const currentSupport = this.form().value['support']
-
- // First time we set the channel?
- if (isNaN(oldChannelId)) {
- // Fill support if it's empty
- if (!currentSupport) this.updateSupportField(newChannel.support)
-
- return
- }
-
- const oldChannel = this.userVideoChannels().find(c => c.id === oldChannelId)
- if (!newChannel || !oldChannel) {
- logger.error('Cannot find new or old channel.')
- return
- }
-
- // If the current support text is not the same than the old channel, the user updated it.
- // We don't want the user to lose his text, so stop here
- if (currentSupport && currentSupport !== oldChannel.support) return
-
- // Update the support text with our new channel
- this.updateSupportField(newChannel.support)
- })
- }
- )
- }
-
- private updateSupportField (support: string) {
- return this.form().patchValue({ support: support || '' })
- }
-}
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.type.ts b/client/src/app/+videos/+video-edit/shared/video-edit.type.ts
deleted file mode 100644
index fdbe9505cf..0000000000
--- a/client/src/app/+videos/+video-edit/shared/video-edit.type.ts
+++ /dev/null
@@ -1 +0,0 @@
-export type VideoEditType = 'update' | 'upload' | 'import-url' | 'import-torrent' | 'go-live'
diff --git a/client/src/app/+videos/+video-edit/update-routes.ts b/client/src/app/+videos/+video-edit/update-routes.ts
deleted file mode 100644
index d57a2ace16..0000000000
--- a/client/src/app/+videos/+video-edit/update-routes.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { Routes } from '@angular/router'
-import { CanDeactivateGuard, LoginGuard } from '@app/core'
-import { VideoUpdateComponent } from './video-update.component'
-import { VideoUpdateResolver } from './video-update.resolver'
-import { I18nPrimengCalendarService } from './shared/i18n-primeng-calendar.service'
-import { VideoUploadService } from './shared/video-upload.service'
-import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
-
-export default [
- {
- path: '',
- component: VideoUpdateComponent,
- canActivate: [ LoginGuard ],
- canDeactivate: [ CanDeactivateGuard ],
- providers: [
- VideoUpdateResolver,
- LiveVideoService,
- I18nPrimengCalendarService,
- VideoUploadService
- ],
- resolve: {
- videoData: VideoUpdateResolver
- }
- }
-] satisfies Routes
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.html b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.html
deleted file mode 100644
index 95be942e2f..0000000000
--- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.html
+++ /dev/null
@@ -1,65 +0,0 @@
-<div *ngIf="!isInUpdateForm" class="upload-video-container">
- <div class="first-step-block">
- <my-global-icon class="upload-icon" iconName="upload" aria-hidden="true"></my-global-icon>
-
- <div class="form-group">
- <label i18n for="first-step-channel">Channel</label>
- <my-select-channel inputId="first-step-channel" [items]="userVideoChannels" [(ngModel)]="firstStepChannelId"></my-select-channel>
- </div>
-
- <div class="form-group">
- <label i18n for="first-step-privacy">Privacy</label>
- <my-select-options inputId="first-step-privacy" [items]="videoPrivacies" [(ngModel)]="firstStepPrivacyId"></my-select-options>
- </div>
-
- <div class="form-group live-type">
- <div class="peertube-radio-container">
- <input type="radio" id="permanentLiveFalse" [(ngModel)]="firstStepPermanentLive" [value]="false">
- <label i18n for="permanentLiveFalse" class="radio">Normal live</label>
-
- <span class="form-group-description">{{ getNormalLiveDescription() }}</span>
- </div>
-
- <div class="peertube-radio-container">
- <input type="radio" id="permanentLiveTrue" [(ngModel)]="firstStepPermanentLive" [value]="true">
- <label i18n for="permanentLiveTrue" class="radio">Permanent/recurring live</label>
-
- <span class="form-group-description" i18n>{{ getPermanentLiveDescription() }}</span>
- </div>
- </div>
-
- <input
- class="peertube-button primary-button"
- [disabled]="firstStepPermanentLive !== true && firstStepPermanentLive !== false"
- type="button" i18n-value value="Go Live" (click)="goLive()"
- />
- </div>
-</div>
-
-<my-alert *ngIf="error" type="danger">
- <div i18n>Sorry, but something went wrong</div>
-
- {{ error }}
-</my-alert>
-
-<my-alert type="primary" i18n *ngIf="isInUpdateForm && getMaxLiveDuration() >= 0">
- Max live duration is {{ getMaxLiveDuration() | myTimeDurationFormatter }}.
- If your live reaches this limit, it will be automatically terminated.
-</my-alert>
-
-<!-- Hidden because we want to load the component -->
-<form [hidden]="!isInUpdateForm" novalidate [formGroup]="form">
- <my-video-edit
- [form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions"
- [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels" [liveVideo]="liveVideo"
- forbidScheduledPublication="true" hideWaitTranscoding="true" displayTranscriptionInfo="false"
- type="go-live"
- ></my-video-edit>
-
- <div class="submit-container">
- <my-button
- theme="primary" i18n-label label="Update" icon="circle-tick"
- (click)="updateSecondStep()" [disabled]="!form.valid || isUpdatingVideo === true"
- ></my-button>
- </div>
-</form>
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts
deleted file mode 100644
index 8cae1b9889..0000000000
--- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts
+++ /dev/null
@@ -1,240 +0,0 @@
-import { NgIf } from '@angular/common'
-import { AfterViewInit, Component, OnInit, inject, output } from '@angular/core'
-import { FormsModule, ReactiveFormsModule } from '@angular/forms'
-import { Router } from '@angular/router'
-import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
-import { scrollToTop } from '@app/helpers'
-import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
-import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
-import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
-import { VideoChapterService } from '@app/shared/shared-main/video/video-chapter.service'
-import { VideoEdit } from '@app/shared/shared-main/video/video-edit.model'
-import { Video } from '@app/shared/shared-main/video/video.model'
-import { VideoService } from '@app/shared/shared-main/video/video.service'
-import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
-import { LoadingBarService } from '@ngx-loading-bar/core'
-import {
- LiveVideo,
- LiveVideoCreate,
- LiveVideoLatencyMode,
- LiveVideoUpdate,
- PeerTubeProblemDocument,
- ServerErrorCode,
- VideoPrivacy
-} from '@peertube/peertube-models'
-import { logger } from '@root-helpers/logger'
-import { forkJoin } from 'rxjs'
-import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'
-import { SelectOptionsComponent } from '../../../shared/shared-forms/select/select-options.component'
-import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
-import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'
-import { TimeDurationFormatterPipe } from '../../../shared/shared-main/date/time-duration-formatter.pipe'
-import { VideoEditComponent } from '../shared/video-edit.component'
-import { VideoSend } from './video-send'
-
-@Component({
- selector: 'my-video-go-live',
- templateUrl: './video-go-live.component.html',
- styleUrls: [
- '../shared/video-edit.component.scss',
- './video-go-live.component.scss',
- './video-send.scss'
- ],
- imports: [
- NgIf,
- GlobalIconComponent,
- SelectChannelComponent,
- FormsModule,
- SelectOptionsComponent,
- ReactiveFormsModule,
- VideoEditComponent,
- ButtonComponent,
- TimeDurationFormatterPipe,
- AlertComponent
- ]
-})
-export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterViewInit, CanComponentDeactivate {
- protected formReactiveService = inject(FormReactiveService)
- protected loadingBar = inject(LoadingBarService)
- protected notifier = inject(Notifier)
- protected authService = inject(AuthService)
- protected serverService = inject(ServerService)
- protected videoService = inject(VideoService)
- protected videoCaptionService = inject(VideoCaptionService)
- protected videoChapterService = inject(VideoChapterService)
- private liveVideoService = inject(LiveVideoService)
- private router = inject(Router)
- private hooks = inject(HooksService)
-
- readonly firstStepDone = output<string>()
- readonly firstStepError = output()
-
- firstStepPermanentLive: boolean
-
- isInUpdateForm = false
- isUpdatingVideo = false
- isOrHasGoingLive = false
-
- liveVideo: LiveVideo
-
- videoId: number
- videoUUID: string
- videoShortUUID: string
-
- error: string
-
- ngOnInit () {
- super.ngOnInit()
- }
-
- ngAfterViewInit () {
- this.hooks.runAction('action:go-live.init', 'video-edit')
- }
-
- canDeactivate () {
- return { canDeactivate: true }
- }
-
- goLive () {
- if (this.isOrHasGoingLive) return
- this.isOrHasGoingLive = true
-
- const name = 'Live'
-
- const video: LiveVideoCreate = {
- name,
-
- // Password privacy needs a password that will be set in the next step
- privacy: this.firstStepPrivacyId === VideoPrivacy.PASSWORD_PROTECTED
- ? VideoPrivacy.PRIVATE
- : this.highestPrivacy,
-
- nsfw: this.serverConfig.instance.isNSFW,
- waitTranscoding: true,
- permanentLive: this.firstStepPermanentLive,
- latencyMode: LiveVideoLatencyMode.DEFAULT,
- saveReplay: this.isReplayAllowed(),
- replaySettings: { privacy: VideoPrivacy.PRIVATE },
- channelId: this.firstStepChannelId
- }
-
- // Go live in private mode, but correctly fill the update form with the first user choice
- const toPatch = { ...video, privacy: this.firstStepPrivacyId, replayPrivacy: video.replaySettings.privacy }
- this.form.patchValue(toPatch)
-
- this.liveVideoService.goLive(video)
- .subscribe({
- next: res => {
- this.videoId = res.video.id
- this.videoUUID = res.video.uuid
- this.videoShortUUID = res.video.shortUUID
- this.isInUpdateForm = true
-
- this.firstStepDone.emit(name)
-
- this.fetchVideoLive()
- },
-
- error: err => {
- this.firstStepError.emit()
-
- let message = err.message
-
- const error = err.body as PeerTubeProblemDocument
-
- if (error?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) {
- message = $localize`Cannot create live because this platform have too many created lives`
- } else if (error?.code === ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED) {
- message = $localize`Cannot create live because you created too many lives`
- }
-
- this.notifier.error(message)
- }
- })
- }
-
- async updateSecondStep () {
- if (!await this.isFormValid()) return
-
- this.isUpdatingVideo = true
-
- const video = new VideoEdit()
- video.patch(this.form.value)
- video.id = this.videoId
- video.uuid = this.videoUUID
- video.shortUUID = this.videoShortUUID
-
- this.chaptersEdit.patch(this.form.value)
-
- const saveReplay = this.form.value.saveReplay
- const replaySettings = saveReplay
- ? { privacy: this.form.value.replayPrivacy }
- : undefined
-
- const liveVideoUpdate: LiveVideoUpdate = {
- saveReplay,
- replaySettings,
- latencyMode: this.form.value.latencyMode,
- permanentLive: this.form.value.permanentLive
- }
-
- // Update the video
- forkJoin([
- this.updateVideoAndCaptionsAndChapters({ video, captions: this.videoCaptions }),
-
- this.liveVideoService.updateLive(this.videoId, liveVideoUpdate)
- ]).subscribe({
- next: () => {
- this.isUpdatingVideo = false
-
- this.notifier.success($localize`Live published.`)
-
- this.router.navigateByUrl(Video.buildWatchUrl(video))
- },
-
- error: err => {
- this.error = err.message
- scrollToTop()
- logger.error(err)
- }
- })
- }
-
- getMaxLiveDuration () {
- return this.serverConfig.live.maxDuration / 1000
- }
-
- getNormalLiveDescription () {
- if (this.isReplayAllowed()) {
- return $localize`Stream only once, replay will replace your live`
- }
-
- return $localize`Stream only once`
- }
-
- getPermanentLiveDescription () {
- if (this.isReplayAllowed()) {
- return $localize`Stream multiple times, replays will be separate videos`
- }
-
- return $localize`Stream multiple times using the same URL`
- }
-
- private isReplayAllowed () {
- return this.serverConfig.live.allowReplay
- }
-
- private fetchVideoLive () {
- this.liveVideoService.getVideoLive(this.videoId)
- .subscribe({
- next: liveVideo => {
- this.liveVideo = liveVideo
- },
-
- error: err => {
- this.firstStepError.emit()
- this.notifier.error(err.message)
- }
- })
- }
-}
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.html b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.html
deleted file mode 100644
index 284494fce6..0000000000
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.html
+++ /dev/null
@@ -1,71 +0,0 @@
-<div *ngIf="!hasImportedVideo" class="upload-video-container" myDragDrop (fileDropped)="setTorrentFile($event)">
- <div class="first-step-block">
- <my-global-icon class="upload-icon" iconName="upload" aria-hidden="true"></my-global-icon>
-
- <div class="button-file primary-button form-control" [ngbTooltip]="'(extensions: .torrent)'">
- <span i18n>Select the torrent to import</span>
- <input
- aria-label="Select the torrent to import" i18n-aria-label
- #torrentfileInput type="file" name="torrentfile" id="torrentfile" accept=".torrent" (change)="fileChange()"
- />
- </div>
-
- <div class="torrent-or-magnet" i18n-data-content data-content="OR"></div>
-
- <div class="form-group form-group-magnet-uri">
- <label i18n for="magnetUri">Paste magnet URI</label>
- <my-help>
- <ng-template ptTemplate="customHtml">
- <ng-container i18n>
- You can import any torrent file that points to a media file.
- You should make sure you have diffusion rights over the content it points to, otherwise it could cause legal trouble to yourself and your instance.
- </ng-container>
- </ng-template>
- </my-help>
-
- <input type="text" id="magnetUri" [(ngModel)]="magnetUri" class="form-control" />
- </div>
-
- <div class="form-group">
- <label i18n for="first-step-channel">Channel</label>
- <my-select-channel inputId="first-step-channel" [items]="userVideoChannels" [(ngModel)]="firstStepChannelId"></my-select-channel>
- </div>
-
- <div class="form-group">
- <label i18n for="first-step-privacy">Privacy</label>
- <my-select-options inputId="first-step-privacy" [items]="videoPrivacies" [(ngModel)]="firstStepPrivacyId"></my-select-options>
- </div>
-
- <input
- type="button" i18n-value value="Import" class="peertube-button primary-button"
- [disabled]="!isMagnetUrlValid() || isImportingVideo" (click)="importVideo()"
- />
- </div>
-</div>
-
-<my-alert *ngIf="error" type="danger">
- <div i18n>Sorry, but something went wrong</div>
-
- {{ error }}
-</my-alert>
-
-<my-alert type="primary" *ngIf="hasImportedVideo && !error" i18n>
- Congratulations, the video will be imported with BitTorrent! You can already add information about this video.
-</my-alert>
-
-<!-- Hidden because we want to load the component -->
-<form [hidden]="!hasImportedVideo" novalidate [formGroup]="form">
- <my-video-edit
- [form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions"
- [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
- forbidScheduledPublication="true"
- type="import-torrent"
- ></my-video-edit>
-
- <div class="submit-container">
- <my-button
- theme="primary" i18n-label label="Update" icon="circle-tick" (click)="updateSecondStep()"
- [disabled]="!form.valid || isUpdatingVideo === true"
- ></my-button>
- </div>
-</form>
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
deleted file mode 100644
index f68f8247d1..0000000000
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
+++ /dev/null
@@ -1,176 +0,0 @@
-import { NgIf } from '@angular/common'
-import { AfterViewInit, Component, ElementRef, OnInit, inject, output, viewChild } from '@angular/core'
-import { FormsModule, ReactiveFormsModule } from '@angular/forms'
-import { Router } from '@angular/router'
-import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
-import { scrollToTop } from '@app/helpers'
-import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
-import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
-import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
-import { VideoChapterService } from '@app/shared/shared-main/video/video-chapter.service'
-import { VideoEdit } from '@app/shared/shared-main/video/video-edit.model'
-import { VideoImportService } from '@app/shared/shared-main/video/video-import.service'
-import { VideoService } from '@app/shared/shared-main/video/video.service'
-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
-import { LoadingBarService } from '@ngx-loading-bar/core'
-import { PeerTubeProblemDocument, ServerErrorCode, VideoUpdate } from '@peertube/peertube-models'
-import { logger } from '@root-helpers/logger'
-import { switchMap } from 'rxjs'
-import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'
-import { SelectOptionsComponent } from '../../../shared/shared-forms/select/select-options.component'
-import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
-import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'
-import { HelpComponent } from '../../../shared/shared-main/buttons/help.component'
-import { PeerTubeTemplateDirective } from '../../../shared/shared-main/common/peertube-template.directive'
-import { hydrateFormFromVideo } from '../shared/video-edit-utils'
-import { VideoEditComponent } from '../shared/video-edit.component'
-import { DragDropDirective } from './drag-drop.directive'
-import { VideoSend } from './video-send'
-
-@Component({
- selector: 'my-video-import-torrent',
- templateUrl: './video-import-torrent.component.html',
- styleUrls: [
- '../shared/video-edit.component.scss',
- './video-import-torrent.component.scss',
- './video-send.scss'
- ],
- imports: [
- NgIf,
- DragDropDirective,
- GlobalIconComponent,
- NgbTooltip,
- HelpComponent,
- PeerTubeTemplateDirective,
- FormsModule,
- SelectChannelComponent,
- SelectOptionsComponent,
- ReactiveFormsModule,
- VideoEditComponent,
- ButtonComponent,
- AlertComponent
- ]
-})
-export class VideoImportTorrentComponent extends VideoSend implements OnInit, AfterViewInit, CanComponentDeactivate {
- protected formReactiveService = inject(FormReactiveService)
- protected loadingBar = inject(LoadingBarService)
- protected notifier = inject(Notifier)
- protected authService = inject(AuthService)
- protected serverService = inject(ServerService)
- protected videoService = inject(VideoService)
- protected videoCaptionService = inject(VideoCaptionService)
- protected videoChapterService = inject(VideoChapterService)
- private router = inject(Router)
- private videoImportService = inject(VideoImportService)
- private hooks = inject(HooksService)
-
- readonly firstStepDone = output<string>()
- readonly firstStepError = output()
- readonly torrentfileInput = viewChild<ElementRef<HTMLInputElement>>('torrentfileInput')
-
- magnetUri = ''
-
- isImportingVideo = false
- hasImportedVideo = false
- isUpdatingVideo = false
-
- video: VideoEdit
- error: string
-
- ngOnInit () {
- super.ngOnInit()
- }
-
- ngAfterViewInit () {
- this.hooks.runAction('action:video-torrent-import.init', 'video-edit')
- }
-
- canDeactivate () {
- return { canDeactivate: true }
- }
-
- isMagnetUrlValid () {
- return !!this.magnetUri
- }
-
- fileChange () {
- const torrentfile = this.torrentfileInput().nativeElement.files[0]
- if (!torrentfile) return
-
- this.importVideo(torrentfile)
- }
-
- setTorrentFile (files: FileList) {
- this.torrentfileInput().nativeElement.files = files
- this.fileChange()
- }
-
- importVideo (torrentfile?: Blob) {
- this.isImportingVideo = true
-
- const videoUpdate: VideoUpdate = {
- privacy: this.highestPrivacy,
- waitTranscoding: false,
- channelId: this.firstStepChannelId
- }
-
- this.loadingBar.useRef().start()
-
- this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate)
- .pipe(switchMap(({ video }) => this.videoService.getVideo({ videoId: video.uuid })))
- .subscribe({
- next: video => {
- this.loadingBar.useRef().complete()
- this.firstStepDone.emit(video.name)
- this.isImportingVideo = false
- this.hasImportedVideo = true
-
- this.video = new VideoEdit(video)
- this.video.patch({ privacy: this.firstStepPrivacyId })
-
- hydrateFormFromVideo(this.form, this.video, false)
- },
-
- error: err => {
- this.loadingBar.useRef().complete()
- this.isImportingVideo = false
- this.firstStepError.emit()
-
- let message = err.message
-
- const error = err.body as PeerTubeProblemDocument
- if (error?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) {
- message = $localize`Torrents with only 1 file are supported.`
- }
-
- this.notifier.error(message)
- }
- })
- }
-
- async updateSecondStep () {
- if (!await this.isFormValid()) return
-
- this.video.patch(this.form.value)
- this.chaptersEdit.patch(this.form.value)
-
- this.isUpdatingVideo = true
-
- // Update the video
- this.updateVideoAndCaptionsAndChapters({ video: this.video, captions: this.videoCaptions, chapters: this.chaptersEdit })
- .subscribe({
- next: () => {
- this.isUpdatingVideo = false
- this.notifier.success($localize`Video to import updated.`)
-
- this.router.navigate([ '/my-library', 'video-imports' ])
- },
-
- error: err => {
- this.error = err.message
- scrollToTop()
- logger.error(err)
- }
- })
- }
-}
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.html b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.html
deleted file mode 100644
index 4a61d79fc5..0000000000
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.html
+++ /dev/null
@@ -1,69 +0,0 @@
-<div *ngIf="!hasImportedVideo" class="upload-video-container">
- <div class="first-step-block">
- <my-global-icon class="upload-icon" iconName="upload" aria-hidden="true"></my-global-icon>
-
- <div class="form-group">
- <label i18n for="targetUrl">URL</label>
-
- <my-help>
- <ng-template ptTemplate="customHtml">
- <ng-container i18n>
- You can import any URL <a href='https://rg3.github.io/youtube-dl/supportedsites.html' target='_blank' rel='noopener noreferrer'>supported by youtube-dl</a>
- or URL that points to a media file.
- You should make sure you have diffusion rights over the content it points to, otherwise it could cause legal trouble to yourself and your instance.
- </ng-container>
- </ng-template>
- </my-help>
-
- <input type="text" id="targetUrl" [(ngModel)]="targetUrl" class="form-control" />
-
- <div *ngIf="isChannelSyncEnabled()" class="form-group-description" i18n>
- You can also synchronize a remote channel in <a class="text-decoration-underline" routerLink="/my-library/video-channel-syncs">your library</a>
- </div>
- </div>
-
- <div class="form-group">
- <label i18n for="first-step-channel">Channel</label>
- <my-select-channel inputId="first-step-channel" [items]="userVideoChannels" [(ngModel)]="firstStepChannelId"></my-select-channel>
- </div>
-
- <div class="form-group">
- <label i18n for="first-step-privacy">Privacy</label>
- <my-select-options inputId="first-step-privacy" [items]="videoPrivacies" [(ngModel)]="firstStepPrivacyId"></my-select-options>
- </div>
-
- <input
- type="button" i18n-value value="Import" class="peertube-button primary-button"
- [disabled]="!isTargetUrlValid() || isImportingVideo" (click)="importVideo()"
- />
- </div>
-</div>
-
-
-<my-alert *ngIf="error" type="danger">
- <div i18n>Sorry, but something went wrong</div>
-
- {{ error }}
-</my-alert>
-
-<my-alert type="primary" *ngIf="!error && hasImportedVideo" i18n>
- Congratulations, the video behind {{ targetUrl }} will be imported! You can already add information about this video.
-</my-alert>
-
-<!-- Hidden because we want to load the component -->
-<form [hidden]="!hasImportedVideo" novalidate [formGroup]="form">
- <my-video-edit
- #videoEdit
- [form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions"
- [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
- forbidScheduledPublication="true"
- type="import-url"
- ></my-video-edit>
-
- <div class="submit-container">
- <my-button
- theme="primary" i18n-label label="Update" icon="circle-tick" (click)="updateSecondStep()"
- [disabled]="!form.valid || isUpdatingVideo === true"
- ></my-button>
- </div>
-</form>
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
deleted file mode 100644
index ab4961316a..0000000000
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
+++ /dev/null
@@ -1,172 +0,0 @@
-import { NgIf } from '@angular/common'
-import { AfterViewInit, Component, OnInit, inject, output, viewChild } from '@angular/core'
-import { FormsModule, ReactiveFormsModule } from '@angular/forms'
-import { Router, RouterLink } from '@angular/router'
-import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
-import { scrollToTop } from '@app/helpers'
-import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
-import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
-import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
-import { VideoChapterService } from '@app/shared/shared-main/video/video-chapter.service'
-import { VideoEdit } from '@app/shared/shared-main/video/video-edit.model'
-import { VideoImportService } from '@app/shared/shared-main/video/video-import.service'
-import { VideoService } from '@app/shared/shared-main/video/video.service'
-import { LoadingBarService } from '@ngx-loading-bar/core'
-import { VideoUpdate } from '@peertube/peertube-models'
-import { logger } from '@root-helpers/logger'
-import { forkJoin } from 'rxjs'
-import { map, switchMap } from 'rxjs/operators'
-import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'
-import { SelectOptionsComponent } from '../../../shared/shared-forms/select/select-options.component'
-import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
-import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'
-import { HelpComponent } from '../../../shared/shared-main/buttons/help.component'
-import { PeerTubeTemplateDirective } from '../../../shared/shared-main/common/peertube-template.directive'
-import { hydrateFormFromVideo } from '../shared/video-edit-utils'
-import { VideoEditComponent } from '../shared/video-edit.component'
-import { VideoSend } from './video-send'
-
-@Component({
- selector: 'my-video-import-url',
- templateUrl: './video-import-url.component.html',
- styleUrls: [
- '../shared/video-edit.component.scss',
- './video-send.scss'
- ],
- imports: [
- NgIf,
- GlobalIconComponent,
- HelpComponent,
- PeerTubeTemplateDirective,
- FormsModule,
- RouterLink,
- SelectChannelComponent,
- SelectOptionsComponent,
- ReactiveFormsModule,
- VideoEditComponent,
- ButtonComponent,
- AlertComponent
- ]
-})
-export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterViewInit, CanComponentDeactivate {
- protected formReactiveService = inject(FormReactiveService)
- protected loadingBar = inject(LoadingBarService)
- protected notifier = inject(Notifier)
- protected authService = inject(AuthService)
- protected serverService = inject(ServerService)
- protected videoService = inject(VideoService)
- protected videoCaptionService = inject(VideoCaptionService)
- protected videoChapterService = inject(VideoChapterService)
- private router = inject(Router)
- private videoImportService = inject(VideoImportService)
- private hooks = inject(HooksService)
-
- readonly videoEditComponent = viewChild<VideoEditComponent>('videoEdit')
-
- readonly firstStepDone = output<string>()
- readonly firstStepError = output()
-
- targetUrl = ''
-
- isImportingVideo = false
- hasImportedVideo = false
- isUpdatingVideo = false
-
- video: VideoEdit
- error: string
-
- ngOnInit () {
- super.ngOnInit()
- }
-
- ngAfterViewInit () {
- this.hooks.runAction('action:video-url-import.init', 'video-edit')
- }
-
- canDeactivate () {
- return { canDeactivate: true }
- }
-
- isTargetUrlValid () {
- return this.targetUrl?.match(/https?:\/\//)
- }
-
- isChannelSyncEnabled () {
- return this.serverConfig.import.videoChannelSynchronization.enabled
- }
-
- importVideo () {
- this.isImportingVideo = true
-
- const videoUpdate: VideoUpdate = {
- privacy: this.highestPrivacy,
- waitTranscoding: false,
- channelId: this.firstStepChannelId
- }
-
- this.loadingBar.useRef().start()
-
- this.videoImportService
- .importVideoUrl(this.targetUrl, videoUpdate)
- .pipe(
- switchMap(previous => {
- return forkJoin([
- this.videoCaptionService.listCaptions(previous.video.uuid),
- this.videoChapterService.getChapters({ videoId: previous.video.uuid }),
- this.videoService.getVideo({ videoId: previous.video.uuid })
- ]).pipe(map(([ videoCaptionsResult, { chapters }, video ]) => ({ videoCaptions: videoCaptionsResult.data, chapters, video })))
- })
- )
- .subscribe({
- next: ({ video, videoCaptions, chapters }) => {
- this.loadingBar.useRef().complete()
- this.firstStepDone.emit(video.name)
- this.isImportingVideo = false
- this.hasImportedVideo = true
-
- this.video = new VideoEdit(video)
- this.video.patch({ privacy: this.firstStepPrivacyId })
-
- this.chaptersEdit.loadFromAPI(chapters)
-
- this.videoCaptions = videoCaptions
-
- hydrateFormFromVideo(this.form, this.video, true)
- setTimeout(() => this.videoEditComponent().patchChapters(this.chaptersEdit))
- },
-
- error: err => {
- this.loadingBar.useRef().complete()
- this.isImportingVideo = false
- this.firstStepError.emit()
- this.notifier.error(err.message)
- }
- })
- }
-
- async updateSecondStep () {
- if (!await this.isFormValid()) return
-
- this.video.patch(this.form.value)
- this.chaptersEdit.patch(this.form.value)
-
- this.isUpdatingVideo = true
-
- // Update the video
- this.updateVideoAndCaptionsAndChapters({ video: this.video, captions: this.videoCaptions, chapters: this.chaptersEdit })
- .subscribe({
- next: () => {
- this.isUpdatingVideo = false
- this.notifier.success($localize`Video to import updated.`)
-
- this.router.navigate([ '/my-library', 'video-imports' ])
- },
-
- error: err => {
- this.error = err.message
- scrollToTop()
- logger.error(err)
- }
- })
- }
-}
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts
deleted file mode 100644
index 6ffb94dabe..0000000000
--- a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts
+++ /dev/null
@@ -1,103 +0,0 @@
-import { Directive, OnInit, OutputEmitterRef } from '@angular/core'
-import { AuthService, CanComponentDeactivateResult, Notifier, ServerService } from '@app/core'
-import { listUserChannelsForSelect } from '@app/helpers'
-import { FormReactive } from '@app/shared/shared-forms/form-reactive'
-import { VideoCaptionEdit } from '@app/shared/shared-main/video-caption/video-caption-edit.model'
-import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
-import { VideoChapterService } from '@app/shared/shared-main/video/video-chapter.service'
-import { VideoChaptersEdit } from '@app/shared/shared-main/video/video-chapters-edit.model'
-import { VideoEdit } from '@app/shared/shared-main/video/video-edit.model'
-import { VideoService } from '@app/shared/shared-main/video/video.service'
-import { LoadingBarService } from '@ngx-loading-bar/core'
-import { HTMLServerConfig, VideoConstant, VideoPrivacyType } from '@peertube/peertube-models'
-import { of } from 'rxjs'
-import { catchError, switchMap, tap } from 'rxjs/operators'
-import { SelectChannelItem } from 'src/types/select-options-item.model'
-
-@Directive()
-// eslint-disable-next-line @angular-eslint/directive-class-suffix
-export abstract class VideoSend extends FormReactive implements OnInit {
- userVideoChannels: SelectChannelItem[] = []
- videoPrivacies: VideoConstant<VideoPrivacyType>[] = []
- videoCaptions: VideoCaptionEdit[] = []
- chaptersEdit = new VideoChaptersEdit()
-
- firstStepPrivacyId: VideoPrivacyType
- firstStepChannelId: number
-
- abstract firstStepDone: OutputEmitterRef<string>
- abstract firstStepError: OutputEmitterRef<void>
-
- protected loadingBar: LoadingBarService
- protected notifier: Notifier
- protected authService: AuthService
-
- protected serverService: ServerService
- protected videoService: VideoService
- protected videoCaptionService: VideoCaptionService
- protected videoChapterService: VideoChapterService
-
- protected serverConfig: HTMLServerConfig
-
- protected highestPrivacy: VideoPrivacyType
-
- abstract canDeactivate (): CanComponentDeactivateResult
-
- ngOnInit () {
- this.buildForm({})
-
- listUserChannelsForSelect(this.authService)
- .subscribe(channels => {
- this.userVideoChannels = channels
- this.firstStepChannelId = this.userVideoChannels[0].id
- })
-
- this.serverConfig = this.serverService.getHTMLConfig()
-
- this.serverService.getVideoPrivacies()
- .subscribe(
- privacies => {
- const defaultPrivacy = this.serverConfig.defaults.publish.privacy
-
- const { videoPrivacies, defaultPrivacyId } = this.videoService.explainedPrivacyLabels(privacies, defaultPrivacy)
-
- this.videoPrivacies = videoPrivacies
- this.firstStepPrivacyId = defaultPrivacyId
-
- this.highestPrivacy = this.videoService.getHighestAvailablePrivacy(privacies)
- }
- )
- }
-
- protected updateVideoAndCaptionsAndChapters (options: {
- video: VideoEdit
- captions: VideoCaptionEdit[]
- chapters?: VideoChaptersEdit
- }) {
- const { video, captions, chapters } = options
-
- this.loadingBar.useRef().start()
-
- return this.videoService.updateVideo(video)
- .pipe(
- switchMap(() => this.videoCaptionService.updateCaptions(video.uuid, captions)),
- switchMap(() => {
- return chapters
- ? this.videoChapterService.updateChapters(video.uuid, chapters)
- : of(true)
- }),
- tap(() => this.loadingBar.useRef().complete()),
- catchError(err => {
- this.loadingBar.useRef().complete()
- throw err
- })
- )
- }
-
- protected async isFormValid () {
- await this.waitPendingCheck()
- this.forceCheck()
-
- return this.form.valid
- }
-}
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html
deleted file mode 100644
index 3d90c81877..0000000000
--- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html
+++ /dev/null
@@ -1,78 +0,0 @@
-<div *ngIf="!isUploadingVideo" class="upload-video-container" myDragDrop (fileDropped)="onFileDropped($event)">
- <div class="first-step-block">
- <my-global-icon class="upload-icon" iconName="upload" aria-hidden="true"></my-global-icon>
-
- <div class="button-file primary-button form-control" [ngbTooltip]="'(extensions: ' + getVideoExtensions() + ')'">
- <span i18n>Select the file to upload</span>
- <input
- aria-label="Select the file to upload"
- i18n-aria-label
- #videofileInput
- [accept]="getVideoExtensions()"
- (change)="onFileChange($event)"
- id="videofile"
- type="file"
- />
- </div>
-
- <div class="form-group form-group-channel">
- <label i18n for="first-step-channel">Channel</label>
- <my-select-channel inputId="first-step-channel" [items]="userVideoChannels" [(ngModel)]="firstStepChannelId"></my-select-channel>
- </div>
-
- <div class="form-group">
- <label i18n for="first-step-privacy">Privacy</label>
- <my-select-options inputId="first-step-privacy" [items]="videoPrivacies" [(ngModel)]="firstStepPrivacyId"></my-select-options>
- </div>
-
- <ng-container *ngIf="isUploadingAudioFile">
- <div class="form-group audio-preview">
- <label i18n for="previewfileUpload">Video background image</label>
-
- <div i18n class="audio-image-info">
- Image that will be merged with your audio file.
- <br />
- The chosen image will be definitive and cannot be modified.
- </div>
-
- <my-preview-upload
- i18n-inputLabel inputLabel="Edit" inputName="previewfileUpload" [(ngModel)]="previewfileUpload"
- previewWidth="360px" previewHeight="200px"
- ></my-preview-upload>
- </div>
-
- <div class="form-group upload-audio-button">
- <my-button theme="primary" [label]="getAudioUploadLabel()" icon="upload" (click)="uploadAudio()"></my-button>
- </div>
- </ng-container>
- </div>
-</div>
-
-<my-upload-progress
- [isUploading]="isUploadingVideo" [uploadPercents]="videoUploadPercents" [error]="error" [uploaded]="videoUploaded"
- [enableRetryAfterError]="enableRetryAfterError" (cancelUpload)="cancelUpload()" (retry)="retryUpload()"
->
-</my-upload-progress>
-
-<my-alert *ngIf="videoUploaded && !error" type="primary" i18n>
- Congratulations! Your video is now available in your private library.
-</my-alert>
-
-<!-- Hidden because we want to load the component -->
-<form [hidden]="!isUploadingVideo" novalidate [formGroup]="form" class="mb-3">
- <my-video-edit
- [form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions"
- [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
- forbidScheduledPublication="false"
- type="upload"
- ></my-video-edit>
-
- <div class="submit-container">
- <div i18n *ngIf="videoUploaded === false" class="message-submit">Publish will be available when upload is finished</div>
-
- <my-button
- theme="primary" i18n-label label="Publish" icon="circle-tick"
- (click)="updateSecondStep()" (keydown.enter)="updateSecondStep()" [disabled]="isPublishingButtonDisabled()"
- ></my-button>
- </div>
-</form>
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
deleted file mode 100644
index 6b2ec8ed98..0000000000
--- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
+++ /dev/null
@@ -1,369 +0,0 @@
-import { NgIf } from '@angular/common'
-import { HttpErrorResponse } from '@angular/common/http'
-import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, inject, output, viewChild } from '@angular/core'
-import { FormsModule, ReactiveFormsModule } from '@angular/forms'
-import { ActivatedRoute, Router } from '@angular/router'
-import { AuthService, CanComponentDeactivate, HooksService, MetaService, Notifier, ServerService, UserService } from '@app/core'
-import { buildHTTPErrorResponse, genericUploadErrorHandler, scrollToTop } from '@app/helpers'
-import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
-import { AlertComponent } from '@app/shared/shared-main/common/alert.component'
-import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
-import { VideoChapterService } from '@app/shared/shared-main/video/video-chapter.service'
-import { VideoEdit } from '@app/shared/shared-main/video/video-edit.model'
-import { Video } from '@app/shared/shared-main/video/video.model'
-import { VideoService } from '@app/shared/shared-main/video/video.service'
-import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
-import { LoadingBarService } from '@ngx-loading-bar/core'
-import { HttpStatusCode, VideoCreateResult } from '@peertube/peertube-models'
-import { logger } from '@root-helpers/logger'
-import { truncate } from 'lodash-es'
-import { UploadState, UploadxService } from 'ngx-uploadx'
-import { Subscription } from 'rxjs'
-import { PreviewUploadComponent } from '../../../shared/shared-forms/preview-upload.component'
-import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'
-import { SelectOptionsComponent } from '../../../shared/shared-forms/select/select-options.component'
-import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'
-import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'
-import { UploadProgressComponent } from '../../../shared/standalone-upload/upload-progress.component'
-import { VideoEditComponent } from '../shared/video-edit.component'
-import { VideoUploadService } from '../shared/video-upload.service'
-import { DragDropDirective } from './drag-drop.directive'
-import { VideoSend } from './video-send'
-
-@Component({
- selector: 'my-video-upload',
- templateUrl: './video-upload.component.html',
- styleUrls: [
- '../shared/video-edit.component.scss',
- './video-upload.component.scss',
- './video-send.scss'
- ],
- imports: [
- NgIf,
- DragDropDirective,
- GlobalIconComponent,
- NgbTooltip,
- SelectChannelComponent,
- FormsModule,
- SelectOptionsComponent,
- PreviewUploadComponent,
- ButtonComponent,
- UploadProgressComponent,
- ReactiveFormsModule,
- VideoEditComponent,
- AlertComponent
- ]
-})
-export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy, AfterViewInit, CanComponentDeactivate {
- protected formReactiveService = inject(FormReactiveService)
- protected loadingBar = inject(LoadingBarService)
- protected notifier = inject(Notifier)
- protected authService = inject(AuthService)
- protected serverService = inject(ServerService)
- protected videoService = inject(VideoService)
- protected videoCaptionService = inject(VideoCaptionService)
- protected videoChapterService = inject(VideoChapterService)
- private userService = inject(UserService)
- private router = inject(Router)
- private hooks = inject(HooksService)
- private resumableUploadService = inject(UploadxService)
- private metaService = inject(MetaService)
- private route = inject(ActivatedRoute)
- private videoUploadService = inject(VideoUploadService)
-
- readonly firstStepDone = output<string>()
- readonly firstStepError = output()
- readonly videofileInput = viewChild<ElementRef<HTMLInputElement>>('videofileInput')
-
- userVideoQuotaUsed = 0
- userVideoQuotaUsedDaily = 0
-
- isUploadingAudioFile = false
- isUploadingVideo = false
-
- videoUploaded = false
- videoUploadPercents = 0
- videoUploadedIds: VideoCreateResult = {
- id: 0,
- uuid: '',
- shortUUID: ''
- }
- formData: FormData
-
- previewfileUpload: File
-
- error: string
- enableRetryAfterError: boolean
-
- private isUpdatingVideo = false
- private fileToUpload: File
-
- private alreadyRefreshedToken = false
-
- private uploadServiceSubscription: Subscription
-
- ngOnInit () {
- super.ngOnInit()
-
- this.userService.getMyVideoQuotaUsed()
- .subscribe(data => {
- this.userVideoQuotaUsed = data.videoQuotaUsed
- this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
- })
-
- this.uploadServiceSubscription = this.resumableUploadService.events
- .subscribe(state => this.onUploadVideoOngoing(state))
- }
-
- ngAfterViewInit () {
- this.hooks.runAction('action:video-upload.init', 'video-edit')
- }
-
- ngOnDestroy () {
- this.resumableUploadService.disconnect()
-
- if (this.uploadServiceSubscription) this.uploadServiceSubscription.unsubscribe()
- }
-
- canDeactivate () {
- let text = ''
-
- if (this.videoUploaded === true) {
- // We can't concatenate strings using $localize
- text = $localize`Your video was uploaded to your account and is private.` + ' ' +
- $localize`But associated data (tags, description...) will be lost, are you sure you want to leave this page?`
- } else {
- text = $localize`Your video is not uploaded yet, are you sure you want to leave this page?`
- }
-
- return {
- canDeactivate: !this.isUploadingVideo,
- text
- }
- }
-
- updateTitle () {
- const videoName = this.form.get('name').value
-
- if (this.videoUploaded) {
- this.metaService.setTitle($localize`Publish ${videoName}`)
- } else if (this.isUploadingAudioFile || this.isUploadingVideo) {
- this.metaService.setTitle(`${this.videoUploadPercents}% - ${videoName}`)
- } else {
- this.metaService.update(this.route.snapshot.data['meta'])
- }
- }
-
- getVideoExtensions () {
- return this.videoUploadService.getVideoExtensions().join(', ')
- }
-
- onUploadVideoOngoing (state: UploadState) {
- switch (state.status) {
- case 'error': {
- if (!this.alreadyRefreshedToken && state.responseStatus === HttpStatusCode.UNAUTHORIZED_401) {
- this.alreadyRefreshedToken = true
-
- return this.refreshTokenAndRetryUpload()
- }
-
- this.handleUploadError(buildHTTPErrorResponse(state))
- break
- }
-
- case 'cancelled':
- this.isUploadingVideo = false
- this.videoUploadPercents = 0
-
- this.firstStepError.emit()
- this.enableRetryAfterError = false
- this.error = ''
- this.isUploadingAudioFile = false
- break
-
- case 'queue':
- this.closeFirstStep(state.name)
- break
-
- case 'uploading':
- this.videoUploadPercents = state.progress
- break
-
- case 'paused':
- this.notifier.info($localize`Upload on hold`)
- break
-
- case 'complete':
- this.videoUploaded = true
- this.videoUploadPercents = 100
-
- this.videoUploadedIds = state?.response.video
- break
- }
-
- this.updateTitle()
- }
-
- onFileDropped (files: FileList) {
- const videofileInput = this.videofileInput()
- videofileInput.nativeElement.files = files
-
- this.onFileChange({ target: videofileInput.nativeElement })
- }
-
- onFileChange (event: Event | { target: HTMLInputElement }) {
- const file = (event.target as HTMLInputElement).files[0]
-
- if (!file) return
-
- const user = this.authService.getUser()
-
- if (!this.videoUploadService.checkQuotaAndNotify(file, user.videoQuota, this.userVideoQuotaUsed)) return
- if (!this.videoUploadService.checkQuotaAndNotify(file, user.videoQuotaDaily, this.userVideoQuotaUsedDaily)) return
-
- if (this.videoUploadService.isAudioFile(file.name)) {
- this.isUploadingAudioFile = true
- return
- }
-
- this.isUploadingVideo = true
- this.fileToUpload = file
-
- this.uploadFile(file)
- }
-
- uploadAudio () {
- this.uploadFile(this.getInputVideoFile(), this.previewfileUpload)
- }
-
- retryUpload () {
- this.enableRetryAfterError = false
- this.error = ''
- this.uploadFile(this.fileToUpload)
- }
-
- cancelUpload () {
- this.resumableUploadService.control({ action: 'cancel' })
- }
-
- isPublishingButtonDisabled () {
- return !this.form.valid ||
- this.isUpdatingVideo === true ||
- this.videoUploaded !== true ||
- !this.videoUploadedIds.id
- }
-
- getAudioUploadLabel () {
- const videofile = this.getInputVideoFile()
- if (!videofile) return $localize`Upload`
-
- return $localize`Upload ${videofile.name}`
- }
-
- async updateSecondStep () {
- if (!await this.isFormValid()) return
- if (this.isPublishingButtonDisabled()) return
-
- const video = new VideoEdit()
- video.patch(this.form.value)
- video.id = this.videoUploadedIds.id
- video.uuid = this.videoUploadedIds.uuid
- video.shortUUID = this.videoUploadedIds.shortUUID
-
- this.chaptersEdit.patch(this.form.value)
-
- this.isUpdatingVideo = true
-
- this.updateVideoAndCaptionsAndChapters({ video, captions: this.videoCaptions, chapters: this.chaptersEdit })
- .subscribe({
- next: () => {
- this.isUpdatingVideo = false
- this.isUploadingVideo = false
-
- this.notifier.success($localize`Video published.`)
- this.router.navigateByUrl(Video.buildWatchUrl(video))
- },
-
- error: err => {
- this.error = err.message
- scrollToTop()
- logger.error(err)
- }
- })
- }
-
- private getInputVideoFile () {
- return this.videofileInput().nativeElement.files[0]
- }
-
- private uploadFile (file: File, previewfile?: File) {
- const metadata = {
- waitTranscoding: true,
- channelId: this.firstStepChannelId,
- nsfw: this.serverConfig.instance.isNSFW,
- privacy: this.highestPrivacy.toString(),
- name: this.buildVideoFilename(file.name),
- filename: file.name,
- previewfile: previewfile as any
- }
-
- this.resumableUploadService.handleFiles(file, {
- ...this.videoUploadService.getNewUploadxOptions(),
-
- metadata
- })
-
- this.isUploadingVideo = true
- }
-
- private handleUploadError (err: HttpErrorResponse) {
- // Reset progress (but keep isUploadingVideo true)
- this.videoUploadPercents = 0
- this.enableRetryAfterError = true
-
- this.error = genericUploadErrorHandler({
- err,
- name: $localize`video`,
- notifier: this.notifier,
- sticky: false
- })
-
- if (err.status === HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415) {
- this.cancelUpload()
- }
- }
-
- private closeFirstStep (filename: string) {
- const name = this.buildVideoFilename(filename)
-
- this.form.patchValue({
- name,
- privacy: this.firstStepPrivacyId,
- nsfw: this.serverConfig.instance.isNSFW,
- channelId: this.firstStepChannelId,
- previewfile: this.previewfileUpload
- })
-
- this.firstStepDone.emit(name)
- this.updateTitle()
- }
-
- private buildVideoFilename (filename: string) {
- const nameWithoutExtension = filename.replace(/\.[^/.]+$/, '')
- let name = nameWithoutExtension.length < 3
- ? filename
- : nameWithoutExtension
-
- const videoNameMaxSize = 110
- if (name.length > videoNameMaxSize) {
- name = truncate(name, { length: videoNameMaxSize, omission: '' })
- }
-
- return name
- }
-
- private refreshTokenAndRetryUpload () {
- this.authService.refreshAccessToken()
- .subscribe(() => this.retryUpload())
- }
-}
diff --git a/client/src/app/+videos/+video-edit/video-add.component.html b/client/src/app/+videos/+video-edit/video-add.component.html
deleted file mode 100644
index c0b5f22731..0000000000
--- a/client/src/app/+videos/+video-edit/video-add.component.html
+++ /dev/null
@@ -1,101 +0,0 @@
-<ng-template #AlertButtons>
- @if (isContactFormEnabled) {
- <a i18n routerLink="/about/contact" class="peertube-button-link primary-button mt-2">Contact us</a>
- } @else {
- <a i18n routerLink="/about/instance" class="peertube-button-link primary-button mt-2">Read instance rules for help</a>
- }
-</ng-template>
-
-@if (user.hasUploadDisabled()) {
- <div class="margin-content">
- <my-alert class="upload-message upload-disabled" type="warning">
- <div>{{ uploadMessages?.noQuota }}</div>
- <ng-template [ngTemplateOutlet]="AlertButtons"></ng-template>
- </my-alert>
-
- <div class="upload-image">
- <img src="/client/assets/images/mascot/defeated.svg" alt="defeated mascot">
- </div>
- </div>
-} @else {
- <div class="margin-content">
- <my-alert *ngIf="user.isAutoBlocked(serverConfig)" class="upload-message auto-blocked" type="warning">
- <div>{{ uploadMessages?.autoBlock }}</div>
- <ng-template [ngTemplateOutlet]="AlertButtons" *ngIf="!hasNoQuotaLeft && !hasNoQuotaLeftDaily"></ng-template>
- </my-alert>
-
- <my-alert *ngIf="hasNoQuotaLeftDaily" class="upload-message quota-daily-left" type="warning">
- <div>{{ uploadMessages?.quotaLeftDaily }}</div>
- <ng-template [ngTemplateOutlet]="AlertButtons" *ngIf="!hasNoQuotaLeft"></ng-template>
- </my-alert>
-
- <my-alert *ngIf="hasNoQuotaLeft" class="upload-message quota-left" type="warning">
- <div>{{ uploadMessages?.quotaLeft }}</div>
- <ng-template [ngTemplateOutlet]="AlertButtons"></ng-template>
- </my-alert>
-
- <my-alert *ngIf="isRootUser()" class="upload-message root-user root-user root-user" type="warning">
- <ng-container i18n>We recommend you to not use the <strong>root</strong> user to publish your videos, since it's the super-admin account of your instance.</ng-container>
-
- <br />
-
- <ng-container i18n>Instead, <a class="text-decoration-underline alert-link" routerLink="/admin/overview/users">create a dedicated account</a> to upload your videos.</ng-container>
- </my-alert>
-
- <my-channels-setup-message></my-channels-setup-message>
-
- <my-user-quota *ngIf="!isInSecondStep() || secondStepType === 'go-live'"></my-user-quota>
-
- <div class="title-page" *ngIf="isInSecondStep()">
- @if (secondStepType === 'import-url' || secondStepType === 'import-torrent') {
- <ng-container i18n>Import {{ videoName }}</ng-container>
- } @else if (secondStepType === 'upload') {
- <ng-container i18n>Upload {{ videoName }}</ng-container>
- }
- </div>
-
- <div ngbNav #nav="ngbNav" class="nav-tabs video-add-nav" [activeId]="activeNav" (activeIdChange)="onNavChange($event)" [ngClass]="{ 'hide-nav': !!secondStepType }">
- <ng-container ngbNavItem="upload">
- <a ngbNavLink>
- <span i18n>Upload a file</span>
- </a>
-
- <ng-template ngbNavContent>
- <my-video-upload #videoUpload (firstStepDone)="onFirstStepDone('upload', $event)" (firstStepError)="onError()"></my-video-upload>
- </ng-template>
- </ng-container>
-
- <ng-container ngbNavItem="import-url" *ngIf="isVideoImportHttpEnabled()">
- <a ngbNavLink>
- <span i18n>Import with URL</span>
- </a>
-
- <ng-template ngbNavContent>
- <my-video-import-url #videoImportUrl (firstStepDone)="onFirstStepDone('import-url', $event)" (firstStepError)="onError()"></my-video-import-url>
- </ng-template>
- </ng-container>
-
- <ng-container ngbNavItem="import-torrent" *ngIf="isVideoImportTorrentEnabled()">
- <a ngbNavLink>
- <span i18n>Import with torrent</span>
- </a>
-
- <ng-template ngbNavContent>
- <my-video-import-torrent #videoImportTorrent (firstStepDone)="onFirstStepDone('import-torrent', $event)" (firstStepError)="onError()"></my-video-import-torrent>
- </ng-template>
- </ng-container>
-
- <ng-container ngbNavItem="go-live" *ngIf="isVideoLiveEnabled()">
- <a ngbNavLink>
- <span i18n>Go live</span>
- </a>
-
- <ng-template ngbNavContent>
- <my-video-go-live #videoGoLive (firstStepDone)="onFirstStepDone('go-live', $event)" (firstStepError)="onError()"></my-video-go-live>
- </ng-template>
- </ng-container>
- </div>
-
- <div class="nav-content" [ngbNavOutlet]="nav"></div>
- </div>
-}
diff --git a/client/src/app/+videos/+video-edit/video-update.component.html b/client/src/app/+videos/+video-edit/video-update.component.html
deleted file mode 100644
index 80103b727f..0000000000
--- a/client/src/app/+videos/+video-edit/video-update.component.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<div class="margin-content">
- <h1 class="title-page" i18n>Update {{ videoDetails?.name }}</h1>
-
- <my-upload-progress
- [isUploading]="isReplacingVideoFile" [uploadPercents]="videoUploadPercents" [error]="uploadError" [uploaded]="updateDone"
- [enableRetryAfterError]="false" (cancelUpload)="cancelUpload()"
- >
- </my-upload-progress>
-
- <form novalidate [formGroup]="form">
-
- <my-video-edit
- #videoEdit
- [form]="form" [formErrors]="formErrors" [forbidScheduledPublication]="forbidScheduledPublication"
- [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
- [videoCaptions]="videoCaptions" [hideWaitTranscoding]="isWaitTranscodingHidden()"
- type="update" (pluginFieldsAdded)="hydratePluginFieldsFromVideo()"
- [liveVideo]="liveVideo" [publishedVideo]="videoDetails"
- [videoSource]="videoSource" [updateVideoFileEnabled]="isUpdateVideoFileEnabled()"
- displayTranscriptionInfo="false"
-
- (formBuilt)="onFormBuilt()"
- >
-
- <div *ngIf="isUpdateVideoFileEnabled()" class="form-group">
- <label class="mb-0" i18n for="videofile">Replace video file</label>
-
- <div i18n class="form-group-description">⚠️ Uploading a new version of your video will completely erase the current version</div>
-
- <div>
- <my-reactive-file
- formControlName="replaceFile"
- i18n-inputLabel inputLabel="Select the file to upload"
- inputName="videofile" [extensions]="getVideoExtensions()" [displayFilename]="true" [displayReset]="true"
- [buttonTooltip]="'(extensions: ' + getVideoExtensions() + ')'"
- theme="primary"
- ></my-reactive-file>
- </div>
- </div>
- </my-video-edit>
-
- <div class="submit-container">
- <my-button
- theme="primary" i18n-label label="Update" icon="circle-tick" (click)="update()" (keydown.enter)="update()"
- [disabled]="!form.valid || isUpdatingVideo === true"
- ></my-button>
- </div>
- </form>
-</div>
diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts
deleted file mode 100644
index 3ef3275dde..0000000000
--- a/client/src/app/+videos/+video-edit/video-update.component.ts
+++ /dev/null
@@ -1,393 +0,0 @@
-import { NgIf } from '@angular/common'
-import { HttpErrorResponse } from '@angular/common/http'
-import { Component, HostListener, OnDestroy, OnInit, inject, viewChild } from '@angular/core'
-import { FormsModule, ReactiveFormsModule } from '@angular/forms'
-import { ActivatedRoute, Router } from '@angular/router'
-import { AuthService, CanComponentDeactivate, ConfirmService, Notifier, ServerService, UserService } from '@app/core'
-import { buildHTTPErrorResponse, genericUploadErrorHandler } from '@app/helpers'
-import { FormReactive } from '@app/shared/shared-forms/form-reactive'
-import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
-import { VideoCaptionEdit } from '@app/shared/shared-main/video-caption/video-caption-edit.model'
-import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
-import { VideoChapterService } from '@app/shared/shared-main/video/video-chapter.service'
-import { VideoChaptersEdit } from '@app/shared/shared-main/video/video-chapters-edit.model'
-import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
-import { VideoEdit } from '@app/shared/shared-main/video/video-edit.model'
-import { Video } from '@app/shared/shared-main/video/video.model'
-import { VideoService } from '@app/shared/shared-main/video/video.service'
-import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'
-import { LoadingBarService } from '@ngx-loading-bar/core'
-import { simpleObjectsDeepEqual } from '@peertube/peertube-core-utils'
-import { HttpStatusCode, LiveVideo, LiveVideoUpdate, VideoPrivacy, VideoSource, VideoState } from '@peertube/peertube-models'
-import debug from 'debug'
-import { UploadState, UploadxService } from 'ngx-uploadx'
-import { of, Subject, Subscription } from 'rxjs'
-import { catchError, map, switchMap } from 'rxjs/operators'
-import { SelectChannelItem } from 'src/types/select-options-item.model'
-import { ReactiveFileComponent } from '../../shared/shared-forms/reactive-file.component'
-import { ButtonComponent } from '../../shared/shared-main/buttons/button.component'
-import { UploadProgressComponent } from '../../shared/standalone-upload/upload-progress.component'
-import { hydrateFormFromVideo } from './shared/video-edit-utils'
-import { VideoEditComponent } from './shared/video-edit.component'
-import { VideoUploadService } from './shared/video-upload.service'
-
-const debugLogger = debug('peertube:video-update')
-
-@Component({
- selector: 'my-videos-update',
- styleUrls: [ './shared/video-edit.component.scss' ],
- templateUrl: './video-update.component.html',
- imports: [
- UploadProgressComponent,
- FormsModule,
- ReactiveFormsModule,
- VideoEditComponent,
- NgIf,
- ReactiveFileComponent,
- ButtonComponent
- ]
-})
-export class VideoUpdateComponent extends FormReactive implements OnInit, OnDestroy, CanComponentDeactivate {
- protected formReactiveService = inject(FormReactiveService)
- private route = inject(ActivatedRoute)
- private router = inject(Router)
- private notifier = inject(Notifier)
- private videoService = inject(VideoService)
- private loadingBar = inject(LoadingBarService)
- private videoCaptionService = inject(VideoCaptionService)
- private videoChapterService = inject(VideoChapterService)
- private server = inject(ServerService)
- private liveVideoService = inject(LiveVideoService)
- private videoUploadService = inject(VideoUploadService)
- private confirmService = inject(ConfirmService)
- private auth = inject(AuthService)
- private userService = inject(UserService)
- private resumableUploadService = inject(UploadxService)
-
- readonly videoEditComponent = viewChild<VideoEditComponent>('videoEdit')
-
- videoEdit: VideoEdit
- videoDetails: VideoDetails
- videoSource: VideoSource
- userVideoChannels: SelectChannelItem[] = []
- videoCaptions: VideoCaptionEdit[] = []
- liveVideo: LiveVideo
-
- userVideoQuotaUsed = 0
- userVideoQuotaUsedDaily = 0
-
- isUpdatingVideo = false
- forbidScheduledPublication = false
-
- isReplacingVideoFile = false
- videoUploadPercents: number
- uploadError: string
-
- updateDone = false
-
- private videoReplacementUploadedSubject = new Subject<void>()
- private alreadyRefreshedToken = false
-
- private uploadServiceSubscription: Subscription
- private updateSubcription: Subscription
-
- private chaptersEdit = new VideoChaptersEdit()
-
- ngOnInit () {
- this.buildForm({
- replaceFile: null
- })
-
- this.userService.getMyVideoQuotaUsed()
- .subscribe(data => {
- this.userVideoQuotaUsed = data.videoQuotaUsed
- this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
- })
-
- this.uploadServiceSubscription = this.resumableUploadService.events
- .subscribe(state => this.onUploadVideoOngoing(state))
-
- const { videoData } = this.route.snapshot.data
- const { video, videoChannels, videoCaptions, videoChapters, videoSource, liveVideo, videoPassword } = videoData
-
- this.videoDetails = video
- this.videoEdit = new VideoEdit(this.videoDetails, videoPassword)
- this.chaptersEdit.loadFromAPI(videoChapters)
-
- this.userVideoChannels = videoChannels
- this.videoCaptions = videoCaptions
- this.videoSource = videoSource
- this.liveVideo = liveVideo
-
- this.forbidScheduledPublication = this.videoEdit.privacy !== VideoPrivacy.PRIVATE
- }
-
- ngOnDestroy () {
- this.resumableUploadService.disconnect()
-
- if (this.uploadServiceSubscription) this.uploadServiceSubscription.unsubscribe()
- }
-
- onFormBuilt () {
- hydrateFormFromVideo(this.form, this.videoEdit, true)
-
- setTimeout(() => this.videoEditComponent().patchChapters(this.chaptersEdit))
-
- if (this.liveVideo) {
- this.form.patchValue({
- saveReplay: this.liveVideo.saveReplay,
- replayPrivacy: this.liveVideo.replaySettings ? this.liveVideo.replaySettings.privacy : VideoPrivacy.PRIVATE,
- latencyMode: this.liveVideo.latencyMode,
- permanentLive: this.liveVideo.permanentLive
- })
- }
- }
-
- @HostListener('window:beforeunload', [ '$event' ])
- onUnload (event: any) {
- const { text, canDeactivate } = this.canDeactivate()
-
- if (canDeactivate) return
-
- event.returnValue = text
- return text
- }
-
- canDeactivate (): { canDeactivate: boolean, text?: string } {
- if (this.updateDone === true) return { canDeactivate: true }
-
- if (this.isUpdatingVideo) {
- return {
- canDeactivate: false,
- text: $localize`Your video is currently being updated. If you leave, your changes will be lost.`
- }
- }
-
- const text = $localize`You have unsaved changes! If you leave, your changes will be lost.`
-
- for (const caption of this.videoCaptions) {
- if (caption.action) return { canDeactivate: false, text }
- }
-
- return { canDeactivate: this.formChanged === false, text }
- }
-
- getVideoExtensions () {
- return this.videoUploadService.getVideoExtensions()
- }
-
- isWaitTranscodingHidden () {
- return this.videoDetails.state.id !== VideoState.TO_TRANSCODE
- }
-
- isUpdateVideoFileEnabled () {
- if (!this.server.getHTMLConfig().videoFile.update.enabled) return false
-
- if (this.videoDetails.isLive) return false
- if (this.videoDetails.state.id !== VideoState.PUBLISHED) return false
-
- return true
- }
-
- async update () {
- await this.waitPendingCheck()
- this.forceCheck()
-
- if (!this.form.valid || this.isUpdatingVideo === true) return
-
- // Check and warn users about a file replacement
- if (!await this.checkAndConfirmVideoFileReplacement()) return
-
- this.videoEdit.patch(this.form.value)
- this.chaptersEdit.patch(this.form.value)
-
- this.abortUpdateIfNeeded()
-
- this.loadingBar.useRef().start()
- this.isUpdatingVideo = true
-
- this.updateSubcription = this.videoReplacementUploadedSubject.pipe(
- switchMap(() => this.videoService.updateVideo(this.videoEdit)),
- switchMap(() => this.videoCaptionService.updateCaptions(this.videoEdit.uuid, this.videoCaptions)),
- switchMap(() => {
- if (this.liveVideo) return of(true)
-
- return this.videoChapterService.updateChapters(this.videoEdit.uuid, this.chaptersEdit)
- }),
- switchMap(() => {
- if (!this.liveVideo) return of(undefined)
-
- const saveReplay = !!this.form.value.saveReplay
- const replaySettings = saveReplay
- ? { privacy: this.form.value.replayPrivacy }
- : undefined
-
- const liveVideoUpdate: LiveVideoUpdate = {
- saveReplay,
- replaySettings,
- permanentLive: !!this.form.value.permanentLive,
- latencyMode: this.form.value.latencyMode
- }
-
- // Don't update live attributes if they did not change
- const baseVideo = {
- saveReplay: this.liveVideo.saveReplay,
- replaySettings: this.liveVideo.replaySettings,
- permanentLive: this.liveVideo.permanentLive,
- latencyMode: this.liveVideo.latencyMode
- }
- const liveChanged = !simpleObjectsDeepEqual(baseVideo, liveVideoUpdate)
- if (!liveChanged) return of(undefined)
-
- return this.liveVideoService.updateLive(this.videoEdit.id, liveVideoUpdate)
- }),
- map(() => true),
- catchError(err => {
- this.notifier.error(err.message)
-
- return of(false)
- })
- )
- .subscribe({
- next: success => {
- this.isUpdatingVideo = false
- this.loadingBar.useRef().complete()
-
- if (!success) return
-
- this.updateDone = true
- this.notifier.success($localize`Video updated.`)
- this.router.navigateByUrl(Video.buildWatchUrl(this.videoEdit))
- }
- })
-
- this.replaceFileIfNeeded()
- }
-
- hydratePluginFieldsFromVideo () {
- if (!this.videoEdit.pluginData) return
-
- this.form.patchValue({
- pluginData: this.videoEdit.pluginData
- })
- }
-
- getVideoUrl () {
- return Video.buildWatchUrl(this.videoDetails)
- }
-
- private async checkAndConfirmVideoFileReplacement () {
- const replaceFile: File = this.form.value['replaceFile']
- if (!replaceFile) return true
-
- const user = this.auth.getUser()
- if (!this.videoUploadService.checkQuotaAndNotify(replaceFile, user.videoQuota, this.userVideoQuotaUsed)) return
- if (!this.videoUploadService.checkQuotaAndNotify(replaceFile, user.videoQuotaDaily, this.userVideoQuotaUsedDaily)) return
-
- const willBeBlocked = this.server.getHTMLConfig().autoBlacklist.videos.ofUsers.enabled === true && !this.videoDetails.blacklisted
- let blockedWarning = ''
- if (willBeBlocked) {
- // eslint-disable-next-line max-len
- blockedWarning = ' ' +
- $localize`Your video will also be automatically blocked since video publication requires manual validation by moderators.`
- }
-
- const message = $localize`Uploading a new version of your video will completely erase the current version.` +
- blockedWarning +
- ' ' +
- $localize`<br /><br />Do you still want to replace your video file?`
-
- const res = await this.confirmService.confirm(message, $localize`Replace file warning`)
- if (res === false) return false
-
- return true
- }
-
- private replaceFileIfNeeded () {
- if (!this.form.value['replaceFile']) {
- this.videoReplacementUploadedSubject.next()
- return
- }
-
- this.uploadFileReplacement(this.form.value['replaceFile'])
- }
-
- private uploadFileReplacement (file: File) {
- const metadata = {
- filename: file.name
- }
-
- this.resumableUploadService.handleFiles(file, {
- ...this.videoUploadService.getReplaceUploadxOptions(this.videoDetails.uuid),
-
- metadata
- })
-
- this.isReplacingVideoFile = true
- }
-
- onUploadVideoOngoing (state: UploadState) {
- debugLogger('Upload state update', state)
-
- switch (state.status) {
- case 'error': {
- if (!this.alreadyRefreshedToken && state.responseStatus === HttpStatusCode.UNAUTHORIZED_401) {
- this.alreadyRefreshedToken = true
-
- return this.refreshTokenAndRetryUpload()
- }
-
- this.handleUploadError(buildHTTPErrorResponse(state))
- break
- }
-
- case 'cancelled':
- this.isReplacingVideoFile = false
- this.videoUploadPercents = 0
- this.uploadError = ''
- break
-
- case 'uploading':
- this.videoUploadPercents = state.progress || 0
- break
-
- case 'complete':
- this.isReplacingVideoFile = false
- this.videoReplacementUploadedSubject.next()
- this.videoUploadPercents = 100
- break
- }
- }
-
- cancelUpload () {
- debugLogger('Cancelling upload')
-
- this.resumableUploadService.control({ action: 'cancel' })
-
- this.abortUpdateIfNeeded()
- }
-
- private handleUploadError (err: HttpErrorResponse) {
- this.videoUploadPercents = 0
- this.isReplacingVideoFile = false
-
- this.uploadError = genericUploadErrorHandler({ err, name: $localize`video` })
-
- this.videoReplacementUploadedSubject.error(err)
- }
-
- private refreshTokenAndRetryUpload () {
- this.auth.refreshAccessToken()
- .subscribe(() => this.uploadFileReplacement(this.form.value['replaceFile']))
- }
-
- private abortUpdateIfNeeded () {
- if (this.updateSubcription) {
- this.updateSubcription.unsubscribe()
- this.updateSubcription = undefined
- }
-
- this.videoReplacementUploadedSubject = new Subject<void>()
- this.loadingBar.useRef().complete()
- }
-}
diff --git a/client/src/app/+videos/+video-watch/player-styles.component.scss b/client/src/app/+videos/+video-watch/player-styles.component.scss
deleted file mode 100644
index d2b386a5b4..0000000000
--- a/client/src/app/+videos/+video-watch/player-styles.component.scss
+++ /dev/null
@@ -1 +0,0 @@
-@use '../../../standalone/player/build/peertube-player.css';
diff --git a/client/src/app/app.routes.ts b/client/src/app/app.routes.ts
index cd49a658c0..08c11bdb93 100644
--- a/client/src/app/app.routes.ts
+++ b/client/src/app/app.routes.ts
@@ -13,6 +13,9 @@ const routes: Routes = [
loadChildren: () => import('./+admin/routes'),
canActivateChild: [ MetaGuard ]
},
+
+ // ---------------------------------------------------------------------------
+
{
path: 'my-account',
loadChildren: () => import('./+my-account/routes'),
@@ -39,6 +42,8 @@ const routes: Routes = [
canActivateChild: [ MetaGuard ]
},
+ // ---------------------------------------------------------------------------
+
{
path: 'video-channels',
redirectTo: 'c'
@@ -61,6 +66,8 @@ const routes: Routes = [
redirectTo: '/my-library/video-channels/update/:channel'
},
+ // ---------------------------------------------------------------------------
+
{
path: 'p',
loadChildren: () => import('./shared/shared-plugin-pages/routes'),
@@ -96,27 +103,60 @@ const routes: Routes = [
canActivateChild: [ MetaGuard ]
},
+ // ---------------------------------------------------------------------------
+
+ {
+ path: 'studio/edit/:videoId',
+ redirectTo: '/videos/manage/:videoId/studio',
+ pathMatch: 'full'
+ },
+
+ {
+ path: 'stats/videos/:videoId',
+ redirectTo: '/videos/manage/:videoId/stats',
+ pathMatch: 'full'
+ },
+
{
path: 'videos/upload',
- loadChildren: () => import('@app/+videos/+video-edit/add-routes'),
+ redirectTo: '/videos/publish',
+ pathMatch: 'full'
+ },
+ {
+ path: 'videos/update/:uuid',
+ pathMatch: 'full',
+ redirectTo: '/videos/manage/:uuid'
+ },
+
+ {
+ path: 'videos/manage/:uuid',
+ loadChildren: () => import('./+videos-publish-manage/+video-manage/routes'),
canActivateChild: [ MetaGuard ],
data: {
meta: {
- title: $localize`Upload a video`
+ title: $localize`Manage your video`
}
}
},
+
{
- path: 'videos/update/:uuid',
- loadChildren: () => import('@app/+videos/+video-edit/update-routes'),
+ path: 'videos/publish',
+ loadChildren: () => import('./+videos-publish-manage/+video-publish/routes'),
canActivateChild: [ MetaGuard ],
data: {
meta: {
- title: $localize`Edit a video`
+ title: $localize`Publish your video`
}
}
},
+ // ---------------------------------------------------------------------------
+
+ {
+ path: 'video-playlists/watch',
+ redirectTo: 'w/p'
+ },
+
{
path: 'videos/watch/playlist',
redirectTo: 'w/p'
@@ -127,13 +167,15 @@ const routes: Routes = [
},
{
path: 'w',
- loadChildren: () => import('@app/+videos/+video-watch/routes'),
+ loadChildren: () => import('./+video-watch/routes'),
data: {
preload: 5000
}
},
+ // ---------------------------------------------------------------------------
// /home and other /videos routes
+ // ---------------------------------------------------------------------------
{
matcher: (url): UrlMatchResult => {
if (url.length < 1) return null
@@ -153,16 +195,13 @@ const routes: Routes = [
},
{
path: 'videos',
- loadChildren: () => import('./+videos/routes'),
+ loadChildren: () => import('./+video-list/routes'),
canActivateChild: [ MetaGuard ]
}
]
},
- {
- path: 'video-playlists/watch',
- redirectTo: 'videos/watch/playlist'
- },
+ // ---------------------------------------------------------------------------
{
path: 'remote-interaction',
@@ -170,19 +209,9 @@ const routes: Routes = [
canActivateChild: [ MetaGuard ]
},
- {
- path: 'studio',
- loadChildren: () => import('./+video-studio/routes'),
- canActivateChild: [ MetaGuard ]
- },
-
- {
- path: 'stats',
- loadChildren: () => import('./+stats/routes'),
- canActivateChild: [ MetaGuard ]
- },
-
- // Matches /@:actorName
+ // ---------------------------------------------------------------------------
+ // /@:actorName
+ // ---------------------------------------------------------------------------
{
matcher: (url): UrlMatchResult => {
const regex = new RegExp(`^@(${USER_USERNAME_REGEX_CHARACTERS}+)$`)
@@ -203,6 +232,8 @@ const routes: Routes = [
component: EmptyComponent
},
+ // ---------------------------------------------------------------------------
+
{
path: '',
component: HomepageRedirectComponent
diff --git a/client/src/app/core/core-providers.ts b/client/src/app/core/core-providers.ts
index 6fe7d0e770..44b2328fba 100644
--- a/client/src/app/core/core-providers.ts
+++ b/client/src/app/core/core-providers.ts
@@ -25,6 +25,7 @@ import { ThemeService } from './theme'
import { UserLocalStorageService, UserService } from './users'
import { LocalStorageService, ScreenService, SessionStorageService } from './wrappers'
import { HotkeysService } from './hotkeys'
+import { HeaderService } from '@app/header/header.service'
export function getCoreProviders () {
return [
@@ -34,6 +35,7 @@ export function getCoreProviders () {
ServerService,
ThemeService,
MenuService,
+ HeaderService,
LoginGuard,
UserRightGuard,
UnloggedGuard,
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts
index cb70e5b293..2afb41d1de 100644
--- a/client/src/app/core/plugins/plugin.service.ts
+++ b/client/src/app/core/plugins/plugin.service.ts
@@ -1,8 +1,6 @@
-import { firstValueFrom, Observable, of } from 'rxjs'
-import { catchError, map, shareReplay } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
-import { Injectable, LOCALE_ID, NgZone, inject } from '@angular/core'
-import { VideoEditType } from '@app/+videos/+video-edit/shared/video-edit.type'
+import { inject, Injectable, LOCALE_ID, NgZone } from '@angular/core'
+import { VideoManageType } from '@app/+videos-publish-manage/shared-manage/common/video-manage.type'
import { AuthService } from '@app/core/auth'
import { Notifier } from '@app/core/notification'
import { MarkdownService } from '@app/core/renderer'
@@ -27,10 +25,12 @@ import {
RegisterClientVideoFieldOptions,
ServerConfigPlugin
} from '@peertube/peertube-models'
+import { logger } from '@root-helpers/logger'
import { PluginInfo, PluginsManager } from '@root-helpers/plugins-manager'
+import { firstValueFrom, Observable, of } from 'rxjs'
+import { catchError, map, shareReplay } from 'rxjs/operators'
import { environment } from '../../../environments/environment'
import { RegisterClientHelpers } from '../../../types/register-client-option.model'
-import { logger } from '@root-helpers/logger'
type FormFields = {
video: {
@@ -136,7 +136,7 @@ export class PluginService implements ClientHook {
return prefix + name
}
- getRegisteredVideoFormFields (type: VideoEditType) {
+ getRegisteredVideoFormFields (type: VideoManageType) {
return this.formFields.video.filter(f => f.videoFormOptions.type === type)
}
diff --git a/client/src/app/core/renderer/linkifier.service.ts b/client/src/app/core/renderer/linkifier.service.ts
index 0a8bfa75e5..6f7deb969d 100644
--- a/client/src/app/core/renderer/linkifier.service.ts
+++ b/client/src/app/core/renderer/linkifier.service.ts
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core'
-import { getAbsoluteAPIUrl } from '@app/helpers/utils'
-import type * as LinkifyJS from 'linkifyjs'
+import { getAPIUrl } from '@app/helpers/utils'
import type LinkifyHTML from 'linkify-html'
+import type * as LinkifyJS from 'linkifyjs'
@Injectable()
export class LinkifierService {
@@ -19,7 +19,7 @@ export class LinkifierService {
},
formatHref: {
mention: (href: string) => {
- return getAbsoluteAPIUrl() + '/services/redirect/accounts/' + href.substring(1)
+ return getAPIUrl() + '/services/redirect/accounts/' + href.substring(1)
}
}
}
diff --git a/client/src/app/core/rest/rest-table.ts b/client/src/app/core/rest/rest-table.ts
index 9cc300210e..2a7e41eca4 100644
--- a/client/src/app/core/rest/rest-table.ts
+++ b/client/src/app/core/rest/rest-table.ts
@@ -8,8 +8,7 @@ import { RestPagination } from './rest-pagination'
const debugLogger = debug('peertube:tables:RestTable')
-export abstract class RestTable <T = unknown> {
-
+export abstract class RestTable<T = unknown> {
abstract totalRecords: number
abstract sort: SortMeta
abstract pagination: RestPagination
@@ -32,6 +31,8 @@ export abstract class RestTable <T = unknown> {
private valueToBadge = new Map<string, Map<string, string>>()
private badgesUsed = new Set<string>()
+ private lastLazyLoadEvent: TableLazyLoadEvent
+
abstract getIdentifier (): string
initialize () {
@@ -57,6 +58,19 @@ export abstract class RestTable <T = unknown> {
loadLazy (event: TableLazyLoadEvent) {
debugLogger('Load lazy %o.', event)
+ if (this.lastLazyLoadEvent) {
+ // Prevent lazy loading twice
+ // TODO: remove when https://github.com/primefaces/primeng/issues/5480 is fixed
+ if (
+ this.lastLazyLoadEvent.first === event.first &&
+ this.lastLazyLoadEvent.rows === event.rows &&
+ this.lastLazyLoadEvent.sortField === event.sortField &&
+ this.lastLazyLoadEvent.sortOrder === event.sortOrder
+ ) return
+ }
+
+ this.lastLazyLoadEvent = event
+
this.sort = {
order: event.sortOrder,
field: event.sortField as string
@@ -76,12 +90,17 @@ export abstract class RestTable <T = unknown> {
}
onSearch (search: string) {
+ this.search = search
+
+ this.resetAndReload()
+ }
+
+ protected resetAndReload () {
this.pagination = {
start: 0,
count: this.rowsPerPage
}
- this.search = search
this.reloadData()
}
@@ -90,7 +109,7 @@ export abstract class RestTable <T = unknown> {
}
getPaginationTemplate () {
- return $localize`{first} - {last} of {totalRecords}`
+ return $localize`Showing {first} to {last} of {totalRecords} elements`
}
protected abstract reloadDataInternal (): void
diff --git a/client/src/app/core/routing/peertube-router.service.ts b/client/src/app/core/routing/peertube-router.service.ts
index d307628a62..5e158a13ce 100644
--- a/client/src/app/core/routing/peertube-router.service.ts
+++ b/client/src/app/core/routing/peertube-router.service.ts
@@ -1,6 +1,6 @@
-import { filter } from 'rxjs/operators'
import { Injectable, inject } from '@angular/core'
-import { ActivatedRoute, ActivatedRouteSnapshot, Event, NavigationEnd, Router, Scroll } from '@angular/router'
+import { ActivatedRoute, ActivatedRouteSnapshot, Event, NavigationEnd, Params, Router, Scroll } from '@angular/router'
+import { filter } from 'rxjs/operators'
import { ServerService } from '../server'
export const enum RouterSetting {
@@ -60,16 +60,16 @@ export class PeerTubeRouterService {
)
}
- silentNavigate (baseRoute: string[], queryParams: { [id: string]: string }) {
+ silentNavigate (baseRoute: string[], existingParams: Params, relativeTo?: ActivatedRoute) {
let routeSetting = this.getRouteSetting() ?? RouterSetting.NONE
routeSetting |= RouterSetting.DISABLE_SCROLL_RESTORE
- queryParams = {
- ...queryParams,
+ const queryParams = {
+ ...existingParams,
[PeerTubeRouterService.ROUTE_SETTING_NAME]: routeSetting
}
- return this.router.navigate(baseRoute, { queryParams })
+ return this.router.navigate(baseRoute, { queryParams, relativeTo })
}
}
diff --git a/client/src/app/header/header.component.html b/client/src/app/header/header.component.html
index f20148e662..c0fdc9e947 100644
--- a/client/src/app/header/header.component.html
+++ b/client/src/app/header/header.component.html
@@ -8,14 +8,14 @@
</button>
</div>
-<div class="root">
+<div class="root" [ngClass]="{ 'search-hidden': searchHidden }">
<a class="peertube-title" [routerLink]="getDefaultRoute()" [queryParams]="getDefaultRouteQuery()">
<span class="icon-logo"></span>
<span class="instance-name">{{ instanceName }}</span>
</a>
- <my-search-typeahead [hidden]="!isLoaded()"></my-search-typeahead>
+ <my-search-typeahead *ngIf="!searchHidden" [hidden]="!isLoaded()"></my-search-typeahead>
<div class="d-flex align-items-center buttons-container" [hidden]="!isLoaded()">
@if (!loggedIn) {
diff --git a/client/src/app/header/header.component.ts b/client/src/app/header/header.component.ts
index 7f6faac3b7..0a2e02f591 100644
--- a/client/src/app/header/header.component.ts
+++ b/client/src/app/header/header.component.ts
@@ -1,16 +1,7 @@
import { CommonModule } from '@angular/common'
import { Component, OnDestroy, OnInit, inject, viewChild } from '@angular/core'
import { NavigationEnd, Router, RouterLink } from '@angular/router'
-import {
- AuthService,
- AuthStatus,
- AuthUser,
- HotkeysService,
- MenuService,
- RedirectService,
- ScreenService,
- ServerService
-} from '@app/core'
+import { AuthService, AuthStatus, AuthUser, HotkeysService, MenuService, RedirectService, ScreenService, ServerService } from '@app/core'
import { NotificationDropdownComponent } from '@app/header/notification-dropdown.component'
import { LanguageChooserComponent } from '@app/menu/language-chooser.component'
import { QuickSettingsModalComponent } from '@app/menu/quick-settings-modal.component'
@@ -27,6 +18,7 @@ import { Subscription } from 'rxjs'
import { GlobalIconComponent } from '../shared/shared-icons/global-icon.component'
import { ButtonComponent } from '../shared/shared-main/buttons/button.component'
import { SearchTypeaheadComponent } from './search-typeahead.component'
+import { HeaderService } from './header.service'
@Component({
selector: 'my-header',
@@ -59,6 +51,7 @@ export class HeaderComponent implements OnInit, OnDestroy {
private modalService = inject(PeertubeModalService)
private router = inject(Router)
private menu = inject(MenuService)
+ private headerService = inject(HeaderService)
private static LS_HIDE_MOBILE_MSG = 'hide-mobile-msg'
@@ -77,10 +70,13 @@ export class HeaderComponent implements OnInit, OnDestroy {
androidAppUrl = ''
iosAppUrl = ''
+ searchHidden = false
+
private config: ServerConfig
private htmlConfig: HTMLServerConfig
private quickSettingsModalSub: Subscription
+ private getSearchHiddenSub: Subscription
private hotkeysSub: Subscription
private authSub: Subscription
@@ -134,6 +130,14 @@ export class HeaderComponent implements OnInit, OnDestroy {
this.quickSettingsModalSub = this.modalService.openQuickSettingsSubject
.subscribe(() => this.openQuickSettings())
+ this.getSearchHiddenSub = this.headerService.getSearchHiddenObs()
+ .subscribe(hidden => {
+ if (hidden) document.body.classList.add('global-search-hidden')
+ else document.body.classList.remove('global-search-hidden')
+
+ this.searchHidden = hidden
+ })
+
this.setupMobileMsg()
}
@@ -141,6 +145,7 @@ export class HeaderComponent implements OnInit, OnDestroy {
if (this.quickSettingsModalSub) this.quickSettingsModalSub.unsubscribe()
if (this.hotkeysSub) this.hotkeysSub.unsubscribe()
if (this.authSub) this.authSub.unsubscribe()
+ if (this.getSearchHiddenSub) this.getSearchHiddenSub.unsubscribe()
}
// ---------------------------------------------------------------------------
diff --git a/client/src/app/header/header.service.ts b/client/src/app/header/header.service.ts
new file mode 100644
index 0000000000..5362fbc7d4
--- /dev/null
+++ b/client/src/app/header/header.service.ts
@@ -0,0 +1,22 @@
+import { Injectable } from '@angular/core'
+import { Subject } from 'rxjs'
+
+@Injectable()
+export class HeaderService {
+ private searchHidden = false
+
+ private searchHiddenSubject = new Subject<boolean>()
+
+ isSearchHidden () {
+ return this.searchHidden
+ }
+
+ setSearchHidden (hidden: boolean) {
+ this.searchHidden = hidden
+ this.searchHiddenSubject.next(hidden)
+ }
+
+ getSearchHiddenObs () {
+ return this.searchHiddenSubject.asObservable()
+ }
+}
diff --git a/client/src/app/helpers/utils/channel.ts b/client/src/app/helpers/utils/channel.ts
index 5ee0d9b034..3b6e894155 100644
--- a/client/src/app/helpers/utils/channel.ts
+++ b/client/src/app/helpers/utils/channel.ts
@@ -21,12 +21,15 @@ function listUserChannelsForSelect (authService: AuthService) {
if (a.updatedAt > b.updatedAt) return -1
return 0
})
- .map(c => ({
- id: c.id,
- label: c.displayName,
- support: c.support,
- avatarPath: getAvatarPath(c)
- }) as SelectChannelItem)
+ .map(c =>
+ ({
+ id: c.id,
+ name: c.name,
+ label: c.displayName,
+ support: c.support,
+ avatarPath: getAvatarPath(c)
+ }) as SelectChannelItem
+ )
})
)
}
diff --git a/client/src/app/helpers/utils/upload.ts b/client/src/app/helpers/utils/upload.ts
index ef4eb5533a..d1c364a1e3 100644
--- a/client/src/app/helpers/utils/upload.ts
+++ b/client/src/app/helpers/utils/upload.ts
@@ -7,7 +7,7 @@ export function genericUploadErrorHandler (options: {
err: Pick<HttpErrorResponse, 'message' | 'status' | 'headers'>
name: string
notifier?: Notifier
- sticky?: boolean
+ sticky?: boolean // default false
}) {
const { err, name, notifier, sticky = false } = options
const title = $localize`Upload failed`
@@ -51,19 +51,23 @@ function buildMessage (name: string, err: Pick<HttpErrorResponse, 'message' | 's
return $localize`The connection was interrupted`
}
+ if (err.status === HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415) {
+ return $localize`Your ${name} file format is not supported by your platform.`
+ }
+
if (err.status === HttpStatusCode.INTERNAL_SERVER_ERROR_500) {
- return $localize`The server encountered an error`
+ return $localize`The server encountered an error.`
}
if (err.status === HttpStatusCode.REQUEST_TIMEOUT_408) {
- return $localize`Your ${name} file couldn't be transferred before the server proxy timeout`
+ return $localize`Your ${name} file couldn't be transferred before the server proxy timeout.`
}
if (err.status === HttpStatusCode.PAYLOAD_TOO_LARGE_413) {
const maxFileSize = err.headers?.get('X-File-Maximum-Size')
- let message = $localize`Your ${name} file was too large `
+ let message = $localize`Your ${name} file was too large.`
- if (maxFileSize) message += $localize` (max. size: ${maxFileSize})`
+ if (maxFileSize) message += $localize` Max size is ${maxFileSize}.`
return message
}
diff --git a/client/src/app/helpers/utils/url.ts b/client/src/app/helpers/utils/url.ts
index 85b3d7fea3..c460942558 100644
--- a/client/src/app/helpers/utils/url.ts
+++ b/client/src/app/helpers/utils/url.ts
@@ -1,34 +1,19 @@
import { environment } from '../../../environments/environment'
-export function getAbsoluteAPIUrl () {
- let absoluteAPIUrl = environment.hmr === true
- ? 'http://localhost:9000'
- : environment.apiUrl
-
- if (!absoluteAPIUrl) {
- // The API is on the same domain
- absoluteAPIUrl = window.location.origin
- }
-
- return absoluteAPIUrl
+export function getAPIUrl () {
+ return environment.apiUrl || window.location.origin
}
export function getOriginUrl () {
return environment.originServerUrl || window.location.origin
}
-export function getAPIHost () {
- return new URL(getAbsoluteAPIUrl()).host
+export function getBackendUrl () {
+ return environment.apiUrl || environment.originServerUrl || window.location.origin
}
-export function getAbsoluteEmbedUrl () {
- let absoluteEmbedUrl = environment.originServerUrl
- if (!absoluteEmbedUrl) {
- // The Embed is on the same domain
- absoluteEmbedUrl = window.location.origin
- }
-
- return absoluteEmbedUrl
+export function getBackendHost () {
+ return new URL(getBackendUrl()).host
}
// Thanks: https://gist.github.com/ghinda/8442a57f22099bdb2e34
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index 0b8748f75e..b0c20b8fd5 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -1,16 +1,7 @@
import { CommonModule } from '@angular/common'
import { Component, OnDestroy, OnInit, inject } from '@angular/core'
import { Params, RouterLink, RouterLinkActive } from '@angular/router'
-import {
- AuthService,
- AuthStatus,
- AuthUser,
- HooksService,
- MenuService,
- RedirectService,
- ServerService,
- UserService
-} from '@app/core'
+import { AuthService, AuthStatus, AuthUser, HooksService, MenuService, RedirectService, ServerService, UserService } from '@app/core'
import { GlobalIconComponent, GlobalIconName } from '@app/shared/shared-icons/global-icon.component'
import { ButtonComponent } from '@app/shared/shared-main/buttons/button.component'
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'
@@ -193,7 +184,7 @@ export class MenuComponent implements OnInit, OnDestroy {
},
{
- path: '/videos/upload',
+ path: '/videos/publish',
icon: 'upload' as GlobalIconName,
label: $localize`Publish`,
isPrimaryButton: true,
diff --git a/client/src/app/shared/form-validators/form-validator.model.ts b/client/src/app/shared/form-validators/form-validator.model.ts
index 1e4bba86b5..87d3651d18 100644
--- a/client/src/app/shared/form-validators/form-validator.model.ts
+++ b/client/src/app/shared/form-validators/form-validator.model.ts
@@ -4,13 +4,13 @@ export type BuildFormValidator = {
VALIDATORS: ValidatorFn[]
ASYNC_VALIDATORS?: AsyncValidatorFn[]
- MESSAGES: { [ name: string ]: string }
+ MESSAGES: { [name: string]: string }
}
export type BuildFormArgument = {
- [ id: string ]: BuildFormValidator | BuildFormArgument
+ [id: string]: BuildFormValidator | BuildFormArgument
}
export type BuildFormDefaultValues = {
- [ name: string ]: boolean | number | string | string[] | BuildFormDefaultValues
+ [name: string]: Blob | Date | boolean | number | string | string[] | BuildFormDefaultValues
}
diff --git a/client/src/app/shared/form-validators/video-validators.ts b/client/src/app/shared/form-validators/video-validators.ts
index a434c777f5..bf18ba6308 100644
--- a/client/src/app/shared/form-validators/video-validators.ts
+++ b/client/src/app/shared/form-validators/video-validators.ts
@@ -29,29 +29,29 @@ export const VIDEO_PRIVACY_VALIDATOR: BuildFormValidator = {
export const VIDEO_PASSWORD_VALIDATOR: BuildFormValidator = {
VALIDATORS: [ Validators.minLength(2), Validators.maxLength(100) ], // Required is set dynamically
MESSAGES: {
- minLength: $localize`A password should be at least 2 characters long.`,
- maxLength: $localize`A password should be shorter than 100 characters long.`,
+ minlength: $localize`A password should be at least 2 characters long.`,
+ maxlength: $localize`A password should be shorter than 100 characters long.`,
required: $localize`A password is required for password protected video.`
}
}
export const VIDEO_CATEGORY_VALIDATOR: BuildFormValidator = {
- VALIDATORS: [ ],
+ VALIDATORS: [],
MESSAGES: {}
}
export const VIDEO_LICENCE_VALIDATOR: BuildFormValidator = {
- VALIDATORS: [ ],
+ VALIDATORS: [],
MESSAGES: {}
}
export const VIDEO_LANGUAGE_VALIDATOR: BuildFormValidator = {
- VALIDATORS: [ ],
+ VALIDATORS: [],
MESSAGES: {}
}
export const VIDEO_IMAGE_VALIDATOR: BuildFormValidator = {
- VALIDATORS: [ ],
+ VALIDATORS: [],
MESSAGES: {}
}
@@ -87,14 +87,14 @@ export const VIDEO_SUPPORT_VALIDATOR: BuildFormValidator = {
}
export const VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR: BuildFormValidator = {
- VALIDATORS: [ ], // Required is set dynamically
+ VALIDATORS: [], // Required is set dynamically
MESSAGES: {
required: $localize`A date is required to schedule video update.`
}
}
export const VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR: BuildFormValidator = {
- VALIDATORS: [ ],
+ VALIDATORS: [],
MESSAGES: {}
}
diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html
index 19fb26a314..fc5ea25961 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html
+++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html
@@ -61,19 +61,14 @@
<ng-container *ngIf="abuse.video">
<td *ngIf="!abuse.video.deleted">
- <my-video-cell [video]="abuse.video">
- <span image>
- <span
- class="table-video-image-label" *ngIf="abuse.count > 1"
- i18n-title title="This video has been reported multiple times."
- >
- {{ abuse.nth }}/{{ abuse.count }}
+ <my-video-cell [video]="abuse.video" size="small">
+ <div>
+ <span *ngIf="abuse.count > 1" class="pt-badge badge-secondary me-1" i18n-title title="This video has been reported multiple times" i18n>
+ {abuse.count, plural, =1 {1 abuse} other {{{ abuse.count }} abuses}}
</span>
- </span>
- <span name>
- <my-global-icon *ngIf="abuse.video.blacklisted" iconName="no" i18n-title title="The video was blocked"></my-global-icon>
- </span>
+ <span *ngIf="abuse.video.blacklisted" class="pt-badge badge-red" i18n-title title="The video is blocked" i18n>Blocked</span>
+ </div>
</my-video-cell>
</td>
@@ -83,7 +78,7 @@
<div>
{{ abuse.video.name }}
- <span i18n class="fst-italic">(Deleted video)</span>
+ <span i18n class="pt-badge badge-secondary ms-1">Deleted video</span>
</div>
<div class="video-owner" i18n>by {{ abuse.video.channel?.displayName }} on {{ abuse.video.channel?.host }} </div>
diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
index b582b73677..ebd1744f4e 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
+++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
@@ -128,11 +128,11 @@ export class AbuseListTableComponent extends RestTable implements OnInit, OnDest
this.buildAccountActions()
]
+ this.initialize()
+
this.abuseActions = viewType === 'admin'
? await this.hooks.wrapObject(abuseActions, 'admin-comments', 'filter:admin-abuse-list.actions.create.result')
: abuseActions
-
- this.initialize()
}
ngOnDestroy () {
diff --git a/client/src/app/shared/shared-actor-image/actor-avatar.component.scss b/client/src/app/shared/shared-actor-image/actor-avatar.component.scss
index 6245b4dc5b..922bab361e 100644
--- a/client/src/app/shared/shared-actor-image/actor-avatar.component.scss
+++ b/client/src/app/shared/shared-actor-image/actor-avatar.component.scss
@@ -10,11 +10,11 @@
&.account {
object-fit: cover;
- border-radius: 50%;
+ border-radius: $account-avatar-radius;
}
&.channel {
- border-radius: 5px;
+ border-radius: $channel-avatar-radius;
}
&.instance {
diff --git a/client/src/app/shared/shared-forms/advanced-input-filter.component.html b/client/src/app/shared/shared-forms/advanced-input-filter.component.html
index 7c845890c1..d3babc6a31 100644
--- a/client/src/app/shared/shared-forms/advanced-input-filter.component.html
+++ b/client/src/app/shared/shared-forms/advanced-input-filter.component.html
@@ -1,4 +1,4 @@
-<div class="input-group has-clear flex-nowrap" ngbDropdown placement="bottom-left auto" container="body">
+<div class="input-group has-clear flex-nowrap" [ngClass]="{ 'has-icon': icon() }" ngbDropdown placement="bottom-left auto" container="body">
<ng-container *ngIf="hasFilters()">
<button class="input-group-text c-hand" title="Open quick filters" i18n-title ngbDropdownToggle>
@@ -17,9 +17,14 @@
</div>
</ng-container>
+ <button *ngIf="icon()" class="button-unstyle search-button" title="Search" i18n-title (click)="onSearchClick()">
+ <my-global-icon iconName="search"></my-global-icon>
+ </button>
+
<input
- type="text" name="table-filter" id="table-filter" i18n-placeholder placeholder="Filter..."
+ type="text" [name]="inputId()" [id]="inputId()" [placeholder]="placeholder()"
class="last-in-group"
+ [ngClass]="{ 'first-in-group': !hasFilters() }"
[(ngModel)]="searchValue"
(keyup)="onInputSearch($event)"
#input
diff --git a/client/src/app/shared/shared-forms/advanced-input-filter.component.scss b/client/src/app/shared/shared-forms/advanced-input-filter.component.scss
index f7ce51b997..a4541aa6e5 100644
--- a/client/src/app/shared/shared-forms/advanced-input-filter.component.scss
+++ b/client/src/app/shared/shared-forms/advanced-input-filter.component.scss
@@ -14,6 +14,22 @@ input {
@include peertube-input-text(250px);
}
+.has-icon input {
+ padding-inline-start: 46px;
+}
+
+.search-button {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ left: 20px;
+ color: pvar(--fg-200);
+
+ my-global-icon {
+ @include global-icon-size(19px);
+ }
+}
+
.input-group-text {
background-color: transparent;
transition: 0.3s ease-out;
@@ -24,21 +40,16 @@ input {
}
.form-control-clear my-global-icon {
- display: block;
-
- ::ng-deep svg {
- vertical-align: inherit;
- }
+ @include global-icon-size(19px);
}
-my-global-icon {
+div[role=menu] my-global-icon {
$size: 19px;
$margin: 2px;
opacity: 1;
- width: $size;
- height: $size;
+ @include global-icon-size($size);
@include margin-right($margin);
&.no-visible {
@@ -49,6 +60,8 @@ my-global-icon {
}
}
+
+
div[role=menu] {
max-height: 50vh;
overflow: auto;
diff --git a/client/src/app/shared/shared-forms/advanced-input-filter.component.ts b/client/src/app/shared/shared-forms/advanced-input-filter.component.ts
index 385a212228..fac7111768 100644
--- a/client/src/app/shared/shared-forms/advanced-input-filter.component.ts
+++ b/client/src/app/shared/shared-forms/advanced-input-filter.component.ts
@@ -1,13 +1,13 @@
+import { NgClass, NgFor, NgIf } from '@angular/common'
+import { AfterViewInit, Component, OnInit, booleanAttribute, inject, input, output } from '@angular/core'
+import { FormsModule } from '@angular/forms'
+import { ActivatedRoute, Router } from '@angular/router'
+import { RestService } from '@app/core'
+import { NgbDropdown, NgbDropdownMenu, NgbDropdownToggle } from '@ng-bootstrap/ng-bootstrap'
import debug from 'debug'
import { Subject } from 'rxjs'
import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
-import { AfterViewInit, Component, OnInit, inject, input, output } from '@angular/core'
-import { ActivatedRoute, Params, Router } from '@angular/router'
-import { RestService } from '@app/core'
-import { FormsModule } from '@angular/forms'
import { GlobalIconComponent } from '../shared-icons/global-icon.component'
-import { NgIf, NgFor, NgClass } from '@angular/common'
-import { NgbDropdown, NgbDropdownToggle, NgbDropdownMenu } from '@ng-bootstrap/ng-bootstrap'
export type AdvancedInputFilter = {
title: string
@@ -34,7 +34,10 @@ export class AdvancedInputFilterComponent implements OnInit, AfterViewInit {
private router = inject(Router)
readonly filters = input<AdvancedInputFilter[]>([])
- readonly emitOnInit = input(true)
+ readonly emitOnInit = input(true, { transform: booleanAttribute })
+ readonly icon = input(false, { transform: booleanAttribute })
+ readonly placeholder = input($localize`Filter...`)
+ readonly inputId = input('table-filter')
readonly search = output<string>()
@@ -63,6 +66,10 @@ export class AdvancedInputFilterComponent implements OnInit, AfterViewInit {
this.scheduleSearchUpdate((event.target as HTMLInputElement).value)
}
+ onSearchClick () {
+ this.scheduleSearchUpdate(this.searchValue)
+ }
+
onResetTableFilter () {
this.immediateSearchUpdate('')
}
@@ -81,7 +88,7 @@ export class AdvancedInputFilterComponent implements OnInit, AfterViewInit {
? this.removeFilterToSearch(this.searchValue, filter)
: this.addFilterToSearch(this.searchValue, filter)
- this.router.navigate([ '.' ], { relativeTo: this.route, queryParams: { search: newSearch.trim() } })
+ this.setQueryParams(newSearch)
}
private scheduleSearchUpdate (value: string) {
@@ -142,10 +149,11 @@ export class AdvancedInputFilterComponent implements OnInit, AfterViewInit {
}
private setQueryParams (search: string) {
- const queryParams: Params = {}
+ const searchParams = search
+ ? { search: search.trim() }
+ : {}
- if (search) Object.assign(queryParams, { search })
- this.router.navigate([], { queryParams })
+ this.router.navigate([ '.' ], { relativeTo: this.route, queryParams: { ...this.route.snapshot.queryParams, ...searchParams } })
}
private removeFilterToSearch (search: string, removedFilter: AdvancedInputFilterChild) {
diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.html b/client/src/app/shared/shared-forms/dynamic-form-field.component.html
index 37e4bb509c..e393ab5464 100644
--- a/client/src/app/shared/shared-forms/dynamic-form-field.component.html
+++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.html
@@ -1,4 +1,4 @@
-<div *ngIf="form()" [formGroup]="form()">
+<div *ngIf="form()" [formGroup]="form()" class="form-group">
<label *ngIf="setting().label && setting().type !== 'input-checkbox'" [attr.for]="setting().name" [innerHTML]="setting().label"></label>
<my-peertube-checkbox
@@ -8,7 +8,7 @@
[labelInnerHTML]="setting().label"
></my-peertube-checkbox>
- <div *ngIf="setting().descriptionHTML" class="label-small-info" [innerHTML]="setting().descriptionHTML"></div>
+ <div *ngIf="setting().descriptionHTML" class="form-group-description" [innerHTML]="setting().descriptionHTML"></div>
@switch (setting().type) {
@case ('input') {
diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.scss b/client/src/app/shared/shared-forms/dynamic-form-field.component.scss
index 1022e5b576..9b6c8f6fd7 100644
--- a/client/src/app/shared/shared-forms/dynamic-form-field.component.scss
+++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.scss
@@ -21,12 +21,6 @@ textarea {
@include peertube-select-container(340px);
}
-.label-small-info {
- font-style: italic;
- margin-bottom: 10px;
- font-size: 13px;
-}
-
my-peertube-checkbox + .label-small-info {
margin-top: 5px;
}
diff --git a/client/src/app/shared/shared-forms/form-reactive.service.ts b/client/src/app/shared/shared-forms/form-reactive.service.ts
index 32e334d7e8..9b608db858 100644
--- a/client/src/app/shared/shared-forms/form-reactive.service.ts
+++ b/client/src/app/shared/shared-forms/form-reactive.service.ts
@@ -1,6 +1,6 @@
import { Injectable, inject } from '@angular/core'
-import { AbstractControl, FormGroup } from '@angular/forms'
-import { wait } from '@root-helpers/utils'
+import { AbstractControl, FormGroup, StatusChangeEvent } from '@angular/forms'
+import { filter, firstValueFrom } from 'rxjs'
import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
import { FormValidatorService } from './form-validator.service'
@@ -13,29 +13,20 @@ export type FormReactiveValidationMessages = {
export class FormReactiveService {
private formValidatorService = inject(FormValidatorService)
- buildForm (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) {
- const { formErrors, validationMessages, form } = this.formValidatorService.buildForm(obj, defaultValues)
+ buildForm<T = any> (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) {
+ const { formErrors, validationMessages, form } = this.formValidatorService.internalBuildForm<T>(obj, defaultValues)
- form.statusChanges.subscribe(async () => {
- // FIXME: remove when https://github.com/angular/angular/issues/41519 is fixed
- await this.waitPendingCheck(form)
-
- this.onStatusChanged({ form, formErrors, validationMessages })
- })
+ form.events
+ .pipe(filter(e => e instanceof StatusChangeEvent))
+ .subscribe(() => this.onStatusChanged({ form, formErrors, validationMessages }))
return { form, formErrors, validationMessages }
}
- async waitPendingCheck (form: FormGroup) {
+ waitPendingCheck (form: FormGroup) {
if (form.status !== 'PENDING') return
- // FIXME: the following line does not work: https://github.com/angular/angular/issues/41519
- // return firstValueFrom(form.statusChanges.pipe(filter(status => status !== 'PENDING')))
- // So we have to fallback to active wait :/
-
- do {
- await wait(10)
- } while (form.status === 'PENDING')
+ return firstValueFrom(form.events.pipe(filter(e => e instanceof StatusChangeEvent && e.status !== 'PENDING')))
}
markAllAsDirty (controlsArg: { [key: string]: AbstractControl }) {
@@ -57,6 +48,31 @@ export class FormReactiveService {
this.onStatusChanged({ form, formErrors, validationMessages, onlyDirty: false })
}
+ grabAllErrors (errorObjectArg: FormReactiveErrors | FormReactiveErrors[]) {
+ let acc: string[] = []
+
+ if (Array.isArray(errorObjectArg)) {
+ for (const errorObject of errorObjectArg) {
+ acc = acc.concat(this.grabAllErrors(errorObject))
+ }
+
+ return acc
+ }
+
+ for (const key of Object.keys(errorObjectArg)) {
+ const value = errorObjectArg[key]
+ if (!value) continue
+
+ if (typeof value === 'string') {
+ acc.push(value)
+ } else {
+ acc = acc.concat(this.grabAllErrors(value))
+ }
+ }
+
+ return acc
+ }
+
private onStatusChanged (options: {
form: FormGroup
formErrors: FormReactiveErrors
diff --git a/client/src/app/shared/shared-forms/form-reactive.ts b/client/src/app/shared/shared-forms/form-reactive.ts
index d1e7be8026..0257dcd5d7 100644
--- a/client/src/app/shared/shared-forms/form-reactive.ts
+++ b/client/src/app/shared/shared-forms/form-reactive.ts
@@ -18,10 +18,6 @@ export abstract class FormReactive {
this.validationMessages = validationMessages
}
- protected async waitPendingCheck () {
- return this.formReactiveService.waitPendingCheck(this.form)
- }
-
protected markAllAsDirty () {
return this.formReactiveService.markAllAsDirty(this.form.controls)
}
diff --git a/client/src/app/shared/shared-forms/form-validator.service.ts b/client/src/app/shared/shared-forms/form-validator.service.ts
index 645c7aa896..cbfb51c20a 100644
--- a/client/src/app/shared/shared-forms/form-validator.service.ts
+++ b/client/src/app/shared/shared-forms/form-validator.service.ts
@@ -8,7 +8,7 @@ import { FormReactiveErrors, FormReactiveValidationMessages } from './form-react
export class FormValidatorService {
private formBuilder = inject(FormBuilder)
- buildForm (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) {
+ internalBuildForm<T = any> (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) {
const formErrors: FormReactiveErrors = {}
const validationMessages: FormReactiveValidationMessages = {}
const group: { [key: string]: any } = {}
@@ -18,7 +18,7 @@ export class FormValidatorService {
const field = obj[name]
if (this.isRecursiveField(field)) {
- const result = this.buildForm(field as BuildFormArgument, defaultValues[name] as BuildFormDefaultValues)
+ const result = this.internalBuildForm(field as BuildFormArgument, defaultValues[name] as BuildFormDefaultValues)
group[name] = result.form
formErrors[name] = result.formErrors
validationMessages[name] = result.validationMessages
@@ -34,7 +34,7 @@ export class FormValidatorService {
else group[name] = [ defaultValue ]
}
- const form = this.formBuilder.group(group)
+ const form = this.formBuilder.group<T>(group as any)
return { form, formErrors, validationMessages }
}
diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.html b/client/src/app/shared/shared-forms/markdown-textarea.component.html
index ef92aae682..43392edb83 100644
--- a/client/src/app/shared/shared-forms/markdown-textarea.component.html
+++ b/client/src/app/shared/shared-forms/markdown-textarea.component.html
@@ -1,4 +1,9 @@
-<div class="root" [ngClass]="{ 'maximized': isMaximized }">
+<ng-template #previewContent>
+ <div #previewElement></div>
+ <div [innerHTML]="previewHTML"></div>
+</ng-template>
+
+<div class="root" [ngClass]="{ 'maximized': isMaximized, monospace: monospace() }">
<textarea #textarea
[(ngModel)]="content" (ngModelChange)="onModelChange()"
@@ -7,36 +12,40 @@
[id]="inputId()" [name]="inputId()" [dir]="dir()">
</textarea>
- <div ngbNav #nav="ngbNav" class="nav-pills nav-preview">
- <ng-container ngbNavItem *ngIf="truncateTo3Lines()">
- <a ngbNavLink i18n>Truncated preview</a>
-
- <ng-template ngbNavContent>
- <div class="ellipsis-multiline-3" [innerHTML]="previewHTML"></div>
- </ng-template>
- </ng-container>
+ <div *ngIf="isMaximized" class="preview-maximized muted-2">
+ <ng-container *ngTemplateOutlet="previewContent"></ng-container>
+ </div>
- <ng-container ngbNavItem>
- <a ngbNavLink i18n>Complete preview</a>
+ <div *ngIf="withPreview()" class="buttons mt-3">
+ <button
+ *ngIf="!isMaximized"
+ type="button" class="peertube-button secondary-button" (click)="previewCollapsed = !previewCollapsed"
+ [attr.aria-expanded]="!previewCollapsed" [attr.aria-controls]="inputId() + '-collapse'"
+ >
+ <my-global-icon iconName="arrow-down" [ngClass]="{ 'scale-y--1': !previewCollapsed }"></my-global-icon>
- <ng-template ngbNavContent>
- <div #previewElement></div>
- <div [innerHTML]="previewHTML"></div>
- </ng-template>
- </ng-container>
+ @if (previewCollapsed) {
+ <ng-container i18n>Show preview</ng-container>
+ } @else {
+ <ng-container i18n>Hide preview</ng-container>
+ }
+ </button>
- <button type="button" (click)="onMaximizeClick()" class="maximize-button border-0 m-3" [disabled]="disabled">
+ <button type="button" (click)="onMaximizeClick()" class="maximize-button button-as-link" [disabled]="disabled">
@if (isMaximized) {
- <my-global-icon [ngbTooltip]="maximizeOutText" iconName="exit-fullscreen"></my-global-icon>
- <span class="visually-hidden">{{ maximizeOutText }}</span>
+ <ng-container i18n>Exit full-screen editor</ng-container>
} @else {
- <my-global-icon [ngbTooltip]="maximizeInText" iconName="fullscreen"></my-global-icon>
- <span class="visually-hidden">{{ maximizeInText }}</span>
+ <ng-container i18n>Full-screen editor</ng-container>
}
</button>
</div>
- <div [ngbNavOutlet]="nav"></div>
-
- <div *ngIf="!isMaximized && formError()" class="form-error" role="alert">{{ formError() }}</div>
+ <div
+ *ngIf="!isMaximized" class="preview-collapse mt-3 muted-2"
+ #collapse="ngbCollapse" [(ngbCollapse)]="previewCollapsed" [id]="inputId() + '-collapse'"
+ >
+ <ng-container *ngTemplateOutlet="previewContent"></ng-container>
+ </div>
</div>
+
+<div *ngIf="!isMaximized && formError()" class="form-error" role="alert">{{ formError() }}</div>
diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.scss b/client/src/app/shared/shared-forms/markdown-textarea.component.scss
index 94862d8494..95c3b3b908 100644
--- a/client/src/app/shared/shared-forms/markdown-textarea.component.scss
+++ b/client/src/app/shared/shared-forms/markdown-textarea.component.scss
@@ -3,79 +3,27 @@
@use '_mixins' as *;
@use '_form-mixins' as *;
-$nav-preview-tab-height: 30px;
-$base-padding: 15px;
-$input-border-radius: 3px;
-
.root {
display: flex;
flex-direction: column;
textarea {
- @include peertube-textarea(100%, 150px);
-
- & {
- color: pvar(--textarea-fg);
- background-color: pvar(--textarea-bg);
-
- font-family: monospace;
- font-size: 14px;
- border-bottom: 0;
- border-bottom-left-radius: 0;
- border-bottom-right-radius: 0;
- }
- }
-
- .nav-preview {
- padding: 10px 0;
-
- border: 1px solid pvar(--input-border-color);
- border-top: 1px dashed pvar(--input-border-color);
-
- border-bottom-right-radius: $input-border-radius;
- border-bottom-left-radius: $input-border-radius;
-
- display: flex;
- flex-grow: 1;
- border-bottom-left-radius: unset;
- border-bottom-right-radius: unset;
- border-bottom: 2px solid pvar(--primary);
-
- .maximize-button {
- opacity: 0.6;
-
- &:not([disabled]) {
- &:hover,
- &:active {
- opacity: 1;
- }
- }
- }
- }
-
- .nav-pills {
- display: flex;
- align-items: center;
- justify-content: flex-end;
-
- > * {
- font-size: 0.9em !important;
- }
+ @include peertube-textarea(100%, 170px);
}
- .tab-content {
+ .preview {
min-height: 75px;
max-height: 210px;
- padding: $base-padding;
overflow-y: auto;
word-wrap: break-word;
+ }
- border: 1px solid pvar(--input-border-color);
- border-top: 0;
-
- border-bottom-left-radius: $input-border-radius;
- border-bottom-right-radius: $input-border-radius;
+ .buttons {
+ gap: 1rem;
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: flex-end;
}
&.maximized {
@@ -83,9 +31,7 @@ $input-border-radius: 3px;
position: fixed;
top: pvar(--header-height);
- max-height: none !important;
- max-width: none !important;
- width: calc(100% - #{$menu-width});
+ width: calc(100% - #{pvar(--menu-width)} - (#{pvar(--x-margin-content)} * 2));
height: calc(100vh - #{pvar(--header-height)});
display: grid;
@@ -94,35 +40,42 @@ $input-border-radius: 3px;
background-color: pvar(--bg);
- @include left($menu-width);
+ @include left(calc(#{pvar(--menu-width)} + #{pvar(--x-margin-content)}));
- .nav-preview {
+ .buttons {
grid-row: 1;
grid-column: 1 / 3;
- border: 0;
border-bottom: 2px solid pvar(--primary);
padding: 20px 0;
width: 100% !important;
}
+ textarea,
+ .preview-maximized {
+ height: 100% !important;
+ max-height: none !important;
+ border-radius: 0;
+
+ padding: 1rem;
+ }
+
textarea {
grid-column: 1;
+ grid-row: 2;
border: 0;
border-right: 1px dashed pvar(--input-border-color);
-
resize: none;
// Prevent "outline" overflow with left menu
box-shadow: none !important;
}
- ::ng-deep .tab-content {
+ .preview-maximized {
grid-column: 2;
-
- border: 0;
+ grid-row: 2;
display: block;
overflow-y: auto;
@@ -130,45 +83,16 @@ $input-border-radius: 3px;
scrollbar-color: pvar(--fg-300) pvar(--bg);
}
-
- textarea,
- ::ng-deep .tab-content {
- grid-row: 2;
-
- height: 100% !important;
- max-height: none !important;
- border-radius: 0;
-
- padding: 15px;
- }
-
- @media screen and (max-width: $mobile-view) {
- grid-template-rows: auto 45% 1fr;
- grid-template-columns: 1fr;
-
- .nav-preview {
- grid-column: 1;
- }
-
- textarea {
- grid-row: 2;
- grid-column: 1;
- border: 0;
- border-bottom: 1px dashed pvar(--input-border-color);;
- }
-
- ::ng-deep .tab-content {
- grid-column: 1;
- grid-row: 3;
- }
- }
}
}
-:host-context(.main-col.expanded) {
- .root.maximized {
- width: calc(100% - #{$menu-collapsed-width});
-
- @include left($menu-collapsed-width);
+@include on-small-main-col () {
+ .maximize-button {
+ display: none;
}
}
+
+.monospace textarea {
+ font-family: monospace;
+ font-size: 14px;
+}
diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.ts b/client/src/app/shared/shared-forms/markdown-textarea.component.ts
index dfa4fac7bc..7637586ed8 100644
--- a/client/src/app/shared/shared-forms/markdown-textarea.component.ts
+++ b/client/src/app/shared/shared-forms/markdown-textarea.component.ts
@@ -1,9 +1,9 @@
-import { NgClass, NgIf, ViewportScroller } from '@angular/common'
+import { CommonModule, ViewportScroller } from '@angular/common'
import { booleanAttribute, Component, ElementRef, forwardRef, inject, input, model, OnDestroy, OnInit, viewChild } from '@angular/core'
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'
import { SafeHtml } from '@angular/platform-browser'
import { MarkdownService, ScreenService } from '@app/core'
-import { NgbNav, NgbNavContent, NgbNavItem, NgbNavLink, NgbNavLinkBase, NgbNavOutlet, NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
+import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap'
import { Video } from '@peertube/peertube-models'
import { Subject } from 'rxjs'
import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
@@ -22,17 +22,10 @@ import { FormReactiveErrors } from './form-reactive.service'
}
],
imports: [
- NgClass,
+ CommonModule,
FormsModule,
- NgbNav,
- NgIf,
- NgbNavItem,
- NgbNavLink,
- NgbNavLinkBase,
- NgbNavContent,
- GlobalIconComponent,
- NgbTooltip,
- NgbNavOutlet
+ NgbCollapseModule,
+ GlobalIconComponent
]
})
export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit, OnDestroy {
@@ -44,22 +37,23 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit,
readonly formError = input<string | FormReactiveErrors | FormReactiveErrors[]>(undefined)
- readonly truncateTo3Lines = input<boolean, unknown>(undefined, { transform: booleanAttribute })
-
readonly markdownType = input<'text' | 'enhanced' | 'to-unsafe-html'>('text')
readonly customMarkdownRenderer = input<(text: string) => Promise<string | HTMLElement>>(undefined)
readonly debounceTime = input(150)
- readonly markdownVideo = input<Video>(undefined)
+ readonly markdownVideo = input<Pick<Video, 'shortUUID'>>(undefined)
readonly inputId = input.required<string>()
readonly dir = input<string>(undefined)
+ readonly withPreview = input(true, { transform: booleanAttribute })
readonly withHtml = input(false, { transform: booleanAttribute })
readonly withEmoji = input(false, { transform: booleanAttribute })
+ readonly monospace = input(false, { transform: booleanAttribute })
+
readonly textareaElement = viewChild<ElementRef>('textarea')
readonly previewElement = viewChild<ElementRef>('previewElement')
@@ -67,9 +61,7 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit,
isMaximized = false
disabled = false
-
- maximizeInText = $localize`Maximize editor`
- maximizeOutText = $localize`Exit maximized editor`
+ previewCollapsed = true
private contentChanged = new Subject<string>()
private scrollPosition: [number, number]
@@ -167,7 +159,9 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit,
if (result instanceof HTMLElement) {
setTimeout(() => {
- const wrapperElement = this.previewElement().nativeElement as HTMLElement
+ const wrapperElement = this.previewElement()?.nativeElement as HTMLElement
+ if (!wrapperElement) return
+
wrapperElement.innerHTML = ''
wrapperElement.appendChild(result)
})
diff --git a/client/src/app/shared/shared-forms/preview-upload.component.html b/client/src/app/shared/shared-forms/preview-upload.component.html
index 302051940f..05c12eee88 100644
--- a/client/src/app/shared/shared-forms/preview-upload.component.html
+++ b/client/src/app/shared/shared-forms/preview-upload.component.html
@@ -2,7 +2,7 @@
<div class="preview-container">
<my-reactive-file
[inputName]="inputName()" [inputLabel]="inputLabel()" [extensions]="videoImageExtensions" [maxFileSize]="maxVideoImageSize" placement="right"
- icon="edit" (fileChanged)="onFileChanged($event)" [buttonTooltip]="getReactiveFileButtonTooltip()" theme="primary"
+ icon="upload" (fileChanged)="onFileChanged($event)" [buttonTooltip]="getReactiveFileButtonTooltip()" theme="primary"
></my-reactive-file>
<img *ngIf="imageSrc" [ngStyle]="{ width: previewWidth(), height: previewHeight() }" [src]="imageSrc" class="preview" alt="Preview" i18n-alt />
diff --git a/client/src/app/shared/shared-forms/reactive-file.component.scss b/client/src/app/shared/shared-forms/reactive-file.component.scss
index 863039f905..4dcf1cf4ba 100644
--- a/client/src/app/shared/shared-forms/reactive-file.component.scss
+++ b/client/src/app/shared/shared-forms/reactive-file.component.scss
@@ -9,7 +9,7 @@
.button-file {
&.with-icon {
- @include button-with-icon;
+ @include button-with-icon(24px);
}
}
diff --git a/client/src/app/shared/shared-forms/select/select-checkbox.component.html b/client/src/app/shared/shared-forms/select/select-checkbox.component.html
index 115c3870aa..c4666da2f5 100644
--- a/client/src/app/shared/shared-forms/select/select-checkbox.component.html
+++ b/client/src/app/shared/shared-forms/select/select-checkbox.component.html
@@ -8,6 +8,8 @@
[placeholder]="placeholder()"
[showClear]="showClear()"
+ [showHeader]="showHeader()"
+ [showToggleAll]="showToggleAll()"
optionValue="id"
diff --git a/client/src/app/shared/shared-forms/select/select-checkbox.component.ts b/client/src/app/shared/shared-forms/select/select-checkbox.component.ts
index c3409b77df..68b3e63441 100644
--- a/client/src/app/shared/shared-forms/select/select-checkbox.component.ts
+++ b/client/src/app/shared/shared-forms/select/select-checkbox.component.ts
@@ -34,6 +34,8 @@ export class SelectCheckboxComponent implements ControlValueAccessor {
readonly virtualScrollItemSize = input(33, { transform: numberAttribute })
readonly showClear = input<boolean, unknown>(undefined, { transform: booleanAttribute })
+ readonly showHeader = input<boolean, unknown>(undefined, { transform: booleanAttribute })
+ readonly showToggleAll = input<boolean, unknown>(undefined, { transform: booleanAttribute })
readonly panelHide = output()
diff --git a/client/src/app/shared/shared-icons/global-icon.component.ts b/client/src/app/shared/shared-icons/global-icon.component.ts
index 6779ca25e7..5b2aa330a5 100644
--- a/client/src/app/shared/shared-icons/global-icon.component.ts
+++ b/client/src/app/shared/shared-icons/global-icon.component.ts
@@ -27,15 +27,22 @@ const icons = {
'videos': require('../../../assets/images/feather/videos.svg'),
'add': require('../../../assets/images/feather/plus.svg'),
'alert': require('../../../assets/images/feather/alert.svg'),
+ 'chapters': require('../../../assets/images/feather/chapters.svg'),
+ 'studio': require('../../../assets/images/feather/studio.svg'),
'overview': require('../../../assets/images/feather/overview.svg'),
'moderation': require('../../../assets/images/feather/moderation.svg'),
+ 'captions': require('../../../assets/images/feather/captions.svg'),
'config': require('../../../assets/images/feather/config.svg'),
'award': require('../../../assets/images/feather/award.svg'),
'bell': require('../../../assets/images/feather/bell.svg'),
'opened-bell': require('../../../assets/images/feather/opened-bell.svg'),
'channel': require('../../../assets/images/feather/channel.svg'),
'chevrons-up': require('../../../assets/images/feather/chevrons-up.svg'),
+ 'chevron-up': require('../../../assets/images/feather/chevron-up.svg'),
+ 'chevron-down': require('../../../assets/images/feather/chevron-down.svg'),
'chevron-left': require('../../../assets/images/feather/chevron-left.svg'),
+ 'arrow-left': require('../../../assets/images/feather/arrow-left.svg'),
+ 'arrow-down': require('../../../assets/images/feather/arrow-down.svg'),
'circle-tick': require('../../../assets/images/feather/check-circle.svg'),
'clock-arrow-down': require('../../../assets/images/feather/clock-arrow-down.svg'),
'clock': require('../../../assets/images/feather/clock.svg'),
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 5a7ff4087d..e300dabcc3 100644
--- a/client/src/app/shared/shared-main/account/actor.model.ts
+++ b/client/src/app/shared/shared-main/account/actor.model.ts
@@ -1,5 +1,5 @@
-import { getAbsoluteAPIUrl, getAPIHost } from '@app/helpers'
-import { Actor as ServerActor, ActorImage } from '@peertube/peertube-models'
+import { getBackendHost, getAPIUrl } from '@app/helpers'
+import { ActorImage, Actor as ServerActor } from '@peertube/peertube-models'
export abstract class Actor implements ServerActor {
id: number
@@ -28,13 +28,11 @@ export abstract class Actor implements ServerActor {
if (avatar.fileUrl) return avatar.fileUrl
if (avatar.url) return avatar.url
- const absoluteAPIUrl = getAbsoluteAPIUrl()
-
- return absoluteAPIUrl + avatar.path
+ return getAPIUrl() + avatar.path
}
static CREATE_BY_STRING (accountName: string, host: string, forceHostname = false) {
- const thisHost = getAPIHost()
+ const thisHost = getBackendHost()
if (host.trim() === thisHost && !forceHostname) return accountName
@@ -42,7 +40,7 @@ export abstract class Actor implements ServerActor {
}
static IS_LOCAL (host: string) {
- const thisHost = getAPIHost()
+ const thisHost = getBackendHost()
return host.trim() === thisHost
}
diff --git a/client/src/app/shared/shared-main/buttons/button.component.ts b/client/src/app/shared/shared-main/buttons/button.component.ts
index 6bd9c50320..399019e89a 100644
--- a/client/src/app/shared/shared-main/buttons/button.component.ts
+++ b/client/src/app/shared/shared-main/buttons/button.component.ts
@@ -6,6 +6,8 @@ import {
ChangeDetectorRef,
Component,
ElementRef,
+ HostBinding,
+ HostListener,
OnChanges,
booleanAttribute,
inject,
@@ -60,6 +62,7 @@ export class ButtonComponent implements OnChanges, AfterViewInit {
readonly responsiveLabel = input(false, { transform: booleanAttribute })
readonly autoFontSize = input(false, { transform: booleanAttribute })
readonly rounded = input(false, { transform: booleanAttribute })
+ readonly small = input(false, { transform: booleanAttribute })
readonly labelContent = viewChild<ElementRef>('labelContent')
@@ -73,6 +76,19 @@ export class ButtonComponent implements OnChanges, AfterViewInit {
this.buildClasses()
}
+ @HostListener('touchend', [ '$event' ])
+ onTouchEnd (event: TouchEvent): void {
+ if (this.disabled()) {
+ event.preventDefault()
+ event.stopPropagation()
+ }
+ }
+
+ @HostBinding('style.pointer-events')
+ get pointerEvents (): string {
+ return this.disabled() ? 'none' : 'auto'
+ }
+
private buildClasses () {
const isButtonLink = !!this.ptRouterLink() || !!this.href()
const label = this.getLabel() || ''
@@ -88,7 +104,8 @@ export class ButtonComponent implements OnChanges, AfterViewInit {
'rounded-icon-button': !!this.rounded(),
'icon-only': !label,
'label-xl': this.autoFontSize() && label.length > 10,
- 'responsive-label': this.responsiveLabel()
+ 'responsive-label': this.responsiveLabel(),
+ 'small-button': this.small()
}
debugLogger('Built button classes', { classes: this.classes, label, labelContent: this.labelContent() })
diff --git a/client/src/app/shared/shared-main/channel/video-channel.model.ts b/client/src/app/shared/shared-main/channel/video-channel.model.ts
index 88cf87f6a8..348ada8eb0 100644
--- a/client/src/app/shared/shared-main/channel/video-channel.model.ts
+++ b/client/src/app/shared/shared-main/channel/video-channel.model.ts
@@ -1,4 +1,4 @@
-import { getAbsoluteAPIUrl } from '@app/helpers'
+import { getAPIUrl } from '@app/helpers'
import { maxBy } from '@peertube/peertube-core-utils'
import { ActorImage, Account as ServerAccount, VideoChannel as ServerVideoChannel, ViewsPerDate } from '@peertube/peertube-models'
import { Actor } from '../account/actor.model'
@@ -43,7 +43,8 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
if (!banner) return ''
if (banner.url) return banner.url
- return getAbsoluteAPIUrl() + banner.path
+
+ return getAPIUrl() + banner.path
}
static GET_DEFAULT_AVATAR_URL (size: number) {
@@ -54,6 +55,10 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
return `${window.location.origin}/client/assets/images/default-avatar-video-channel.png`
}
+ static buildPublicUrl (channel: Pick<ServerVideoChannel, 'name' | 'host'>) {
+ return `/c/${Actor.CREATE_BY_STRING(channel.name, channel.host)}`
+ }
+
constructor (hash: Partial<ServerVideoChannel>) {
super(hash)
diff --git a/client/src/app/shared/shared-main/menu/horizontal-menu.component.scss b/client/src/app/shared/shared-main/menu/horizontal-menu.component.scss
index 55443a6988..fcd2670bdf 100644
--- a/client/src/app/shared/shared-main/menu/horizontal-menu.component.scss
+++ b/client/src/app/shared/shared-main/menu/horizontal-menu.component.scss
@@ -12,6 +12,7 @@
h1 {
margin-bottom: 1.5rem;
color: pvar(--fg-400);
+ font-weight: $font-bold;
@include font-size(2rem);
diff --git a/client/src/app/shared/shared-main/text/markdown-hint.component.html b/client/src/app/shared/shared-main/text/markdown-hint.component.html
new file mode 100644
index 0000000000..6f2bbc05bc
--- /dev/null
+++ b/client/src/app/shared/shared-main/text/markdown-hint.component.html
@@ -0,0 +1,19 @@
+<ng-template #tooltipTemplate>
+ Supported markdown formats:
+
+ <ul>
+ @for (rule of markdownRules; track rule) {
+ <li>{{ rule }}</li>
+ }
+
+ <li>
+ <a href="https://docs.joinmastodon.org/user/profile/#verification" target="_blank" rel="noopener noreferrer">Mastodon verification link</a>
+ </li>
+ </ul>
+
+ <a class="pt" href="https://wikipedia.org/wiki/Markdown#Example" target="_blank" rel="noopener noreferrer">Learn more about Markdown</a>
+</ng-template>
+
+<span class="root fake-link" [ngbPopover]="tooltipTemplate">
+ <ng-content></ng-content>
+</span>
diff --git a/client/src/app/shared/shared-main/text/markdown-hint.component.scss b/client/src/app/shared/shared-main/text/markdown-hint.component.scss
new file mode 100644
index 0000000000..fce5da77eb
--- /dev/null
+++ b/client/src/app/shared/shared-main/text/markdown-hint.component.scss
@@ -0,0 +1,6 @@
+@use '_variables' as *;
+@use '_mixins' as *;
+
+.root {
+ cursor: help;
+}
diff --git a/client/src/app/shared/shared-main/text/markdown-hint.component.ts b/client/src/app/shared/shared-main/text/markdown-hint.component.ts
new file mode 100644
index 0000000000..0f1da5b270
--- /dev/null
+++ b/client/src/app/shared/shared-main/text/markdown-hint.component.ts
@@ -0,0 +1,50 @@
+import { CommonModule } from '@angular/common'
+import { booleanAttribute, Component, input, OnChanges, OnInit } from '@angular/core'
+import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
+import { ENHANCED_RULES, TEXT_RULES } from '@peertube/peertube-core-utils'
+
+@Component({
+ selector: 'my-markdown-hint',
+ styleUrls: [ './markdown-hint.component.scss' ],
+ templateUrl: './markdown-hint.component.html',
+ imports: [ CommonModule, NgbPopover ]
+})
+export class MarkdownHintComponent implements OnInit, OnChanges {
+ readonly helpType = input.required<'markdownText' | 'markdownEnhanced'>()
+ readonly supportRelMe = input(false, { transform: booleanAttribute })
+
+ markdownRules: string[] = []
+
+ ngOnInit () {
+ this.init()
+ }
+
+ ngOnChanges () {
+ this.init()
+ }
+
+ private init () {
+ const helpType = this.helpType()
+ if (helpType === 'markdownText') {
+ this.markdownRules = this.createMarkdownList(TEXT_RULES)
+ return
+ }
+
+ if (helpType === 'markdownEnhanced') {
+ this.markdownRules = this.createMarkdownList(ENHANCED_RULES)
+ return
+ }
+ }
+
+ createMarkdownList (rules: string[]) {
+ const rulesToText: { [id: string]: string } = {
+ emphasis: $localize`Emphasis: *text*`,
+ link: $localize`Links: [title](https://example.com)`,
+ newline: $localize`New lines`,
+ list: $localize`Lists`,
+ image: $localize`Images: ![description](https://example.com/image.png)`
+ }
+
+ return rules.map(r => rulesToText[r]).filter(text => !!text)
+ }
+}
diff --git a/client/src/app/shared/shared-main/video-caption/video-caption.service.ts b/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
index dbe49329b9..ddd61b9d62 100644
--- a/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
+++ b/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
@@ -8,7 +8,7 @@ import { Observable, from, of, throwError } from 'rxjs'
import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
import { VideoPasswordService } from '../video/video-password.service'
import { VideoService } from '../video/video.service'
-import { VideoCaptionEdit } from './video-caption-edit.model'
+import { VideoCaptionEdit } from '../../../+videos-publish-manage/shared-manage/common/video-caption-edit.model'
@Injectable()
export class VideoCaptionService {
diff --git a/client/src/app/shared/shared-main/video/embed.component.ts b/client/src/app/shared/shared-main/video/embed.component.ts
index d52cf3e44b..b4905daaaa 100644
--- a/client/src/app/shared/shared-main/video/embed.component.ts
+++ b/client/src/app/shared/shared-main/video/embed.component.ts
@@ -1,9 +1,9 @@
-import { environment } from 'src/environments/environment'
-import { Component, ElementRef, OnInit, booleanAttribute, inject, input } from '@angular/core'
+import { Component, ElementRef, OnChanges, booleanAttribute, inject, input, numberAttribute } from '@angular/core'
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
-import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'
import { buildVideoEmbedLink, decorateVideoLink } from '@peertube/peertube-core-utils'
import { Video } from '@peertube/peertube-models'
+import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'
+import { environment } from 'src/environments/environment'
export type EmbedVideoInput = Pick<Video, 'name' | 'uuid'> & Partial<Pick<Video, 'aspectRatio'>>
@@ -13,7 +13,7 @@ export type EmbedVideoInput = Pick<Video, 'name' | 'uuid'> & Partial<Pick<Video,
templateUrl: './embed.component.html',
standalone: true
})
-export class EmbedComponent implements OnInit {
+export class EmbedComponent implements OnChanges {
private sanitizer = inject(DomSanitizer)
private el = inject(ElementRef)
@@ -21,10 +21,11 @@ export class EmbedComponent implements OnInit {
readonly enableAPI = input<boolean, unknown>(undefined, { transform: booleanAttribute })
readonly mute = input<boolean, unknown>(undefined, { transform: booleanAttribute })
readonly autoplay = input<boolean, unknown>(undefined, { transform: booleanAttribute })
+ readonly version = input<number, unknown>(undefined, { transform: numberAttribute })
embedHTML: SafeHtml
- ngOnInit () {
+ ngOnChanges () {
const html = buildVideoOrPlaylistEmbed({
embedUrl: decorateVideoLink({
url: buildVideoEmbedLink(this.video(), environment.originServerUrl),
@@ -33,7 +34,8 @@ export class EmbedComponent implements OnInit {
warningTitle: false,
api: this.enableAPI(),
muted: this.mute(),
- autoplay: this.autoplay()
+ autoplay: this.autoplay(),
+ version: this.version()
}),
embedTitle: this.video().name,
aspectRatio: this.video().aspectRatio
diff --git a/client/src/app/shared/shared-main/video/video-chapter.service.ts b/client/src/app/shared/shared-main/video/video-chapter.service.ts
index 2f5b220011..38c5408c20 100644
--- a/client/src/app/shared/shared-main/video/video-chapter.service.ts
+++ b/client/src/app/shared/shared-main/video/video-chapter.service.ts
@@ -1,12 +1,11 @@
-import { catchError } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
import { Injectable, inject } from '@angular/core'
import { RestExtractor } from '@app/core'
import { VideoChapter, VideoChapterUpdate } from '@peertube/peertube-models'
+import { catchError } from 'rxjs/operators'
+import { VideoChaptersEdit } from '../../../+videos-publish-manage/shared-manage/common/video-chapters-edit.model'
import { VideoPasswordService } from './video-password.service'
import { VideoService } from './video.service'
-import { VideoChaptersEdit } from './video-chapters-edit.model'
-import { of } from 'rxjs'
@Injectable()
export class VideoChapterService {
@@ -21,8 +20,6 @@ export class VideoChapterService {
}
updateChapters (videoId: string, chaptersEdit: VideoChaptersEdit) {
- if (chaptersEdit.shouldUpdateAPI() !== true) return of(true)
-
const body = { chapters: chaptersEdit.getChaptersForUpdate() } as VideoChapterUpdate
return this.authHttp.put(`${VideoService.BASE_VIDEO_URL}/${videoId}/chapters`, body)
diff --git a/client/src/app/shared/shared-main/video/video-edit.model.ts b/client/src/app/shared/shared-main/video/video-edit.model.ts
deleted file mode 100644
index e8e1f90ca0..0000000000
--- a/client/src/app/shared/shared-main/video/video-edit.model.ts
+++ /dev/null
@@ -1,138 +0,0 @@
-import { getAbsoluteAPIUrl } from '@app/helpers'
-import { objectKeysTyped } from '@peertube/peertube-core-utils'
-import {
- VideoCommentPolicyType,
- VideoPassword,
- VideoPrivacy,
- VideoPrivacyType,
- VideoScheduleUpdate,
- VideoUpdate
-} from '@peertube/peertube-models'
-import { VideoDetails } from './video-details.model'
-
-export class VideoEdit implements VideoUpdate {
- static readonly SPECIAL_SCHEDULED_PRIVACY = -1
-
- category: number
- licence: number
- language: string
- description: string
- name: string
- tags: string[]
- nsfw: boolean
- commentsPolicy: VideoCommentPolicyType
- downloadEnabled: boolean
- waitTranscoding: boolean
- channelId: number
- privacy: VideoPrivacyType
- videoPassword?: string
- support: string
- thumbnailfile?: any
- previewfile?: any
- thumbnailUrl: string
- previewUrl: string
- scheduleUpdate?: VideoScheduleUpdate
- originallyPublishedAt?: Date | string
-
- id?: number
- uuid?: string
- shortUUID?: string
-
- pluginData?: any
-
- constructor (video?: VideoDetails, videoPassword?: VideoPassword) {
- if (!video) return
-
- this.id = video.id
- this.uuid = video.uuid
- this.shortUUID = video.shortUUID
- this.category = video.category.id
- this.licence = video.licence.id
- this.language = video.language.id
- this.description = video.description
- this.name = video.name
- this.tags = video.tags
- this.nsfw = video.nsfw
- this.waitTranscoding = video.waitTranscoding
- this.channelId = video.channel.id
- this.privacy = video.privacy.id
-
- this.support = video.support
-
- this.commentsPolicy = video.commentsPolicy.id
- this.downloadEnabled = video.downloadEnabled
-
- if (video.thumbnailPath) this.thumbnailUrl = getAbsoluteAPIUrl() + video.thumbnailPath
- if (video.previewPath) this.previewUrl = getAbsoluteAPIUrl() + video.previewPath
-
- this.scheduleUpdate = video.scheduledUpdate
- this.originallyPublishedAt = video.originallyPublishedAt
- ? new Date(video.originallyPublishedAt)
- : null
-
- this.pluginData = video.pluginData
-
- if (videoPassword) this.videoPassword = videoPassword.password
- }
-
- patch (values: { [ id: string ]: any }) {
- objectKeysTyped(values).forEach(key => {
- (this as any)[key] = values[key]
- })
-
- // If schedule publication, the video is private and will be changed to public privacy
- if (parseInt(values['privacy'], 10) === VideoEdit.SPECIAL_SCHEDULED_PRIVACY) {
- const updateAt = new Date(values['schedulePublicationAt'])
- updateAt.setSeconds(0)
-
- this.privacy = VideoPrivacy.PRIVATE
- this.scheduleUpdate = {
- updateAt: updateAt.toISOString(),
- privacy: VideoPrivacy.PUBLIC
- }
- } else {
- this.scheduleUpdate = null
- }
-
- // Convert originallyPublishedAt to string so that function objectToFormData() works correctly
- if (this.originallyPublishedAt) {
- const originallyPublishedAt = new Date(this.originallyPublishedAt)
- this.originallyPublishedAt = originallyPublishedAt.toISOString()
- }
-
- // Use the same file than the preview for the thumbnail
- if (this.previewfile) {
- this.thumbnailfile = this.previewfile
- }
- }
-
- toFormPatch () {
- const json = {
- category: this.category,
- licence: this.licence,
- language: this.language,
- description: this.description,
- support: this.support,
- name: this.name,
- tags: this.tags,
- nsfw: this.nsfw,
- commentsPolicy: this.commentsPolicy,
- downloadEnabled: this.downloadEnabled,
- waitTranscoding: this.waitTranscoding,
- channelId: this.channelId,
- privacy: this.privacy,
- videoPassword: this.videoPassword,
- originallyPublishedAt: this.originallyPublishedAt
- }
-
- // Special case if we scheduled an update
- if (this.scheduleUpdate) {
- Object.assign(json, {
- privacy: VideoEdit.SPECIAL_SCHEDULED_PRIVACY,
- schedulePublicationAt: new Date(this.scheduleUpdate.updateAt.toString())
- })
- }
-
- return json
- }
-}
diff --git a/client/src/app/shared/shared-main/video/video-import.service.ts b/client/src/app/shared/shared-main/video/video-import.service.ts
index a876fb96d7..fb184658a5 100644
--- a/client/src/app/shared/shared-main/video/video-import.service.ts
+++ b/client/src/app/shared/shared-main/video/video-import.service.ts
@@ -1,12 +1,12 @@
-import { SortMeta } from 'primeng/api'
-import { Observable } from 'rxjs'
-import { catchError, map, switchMap } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable, inject } from '@angular/core'
import { RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core'
import { objectToFormData } from '@app/helpers'
import { peertubeTranslate } from '@peertube/peertube-core-utils'
-import { ResultList, VideoImport, VideoImportCreate, VideoUpdate } from '@peertube/peertube-models'
+import { ResultList, VideoImport, VideoImportCreate } from '@peertube/peertube-models'
+import { SortMeta } from 'primeng/api'
+import { Observable } from 'rxjs'
+import { catchError, map, switchMap } from 'rxjs/operators'
import { environment } from '../../../../environments/environment'
@Injectable()
@@ -18,25 +18,10 @@ export class VideoImportService {
private static BASE_VIDEO_IMPORT_URL = environment.apiUrl + '/api/v1/videos/imports/'
- importVideoUrl (targetUrl: string, video: VideoUpdate): Observable<VideoImport> {
- const url = VideoImportService.BASE_VIDEO_IMPORT_URL
-
- const body = this.buildImportVideoObject(video)
- body.targetUrl = targetUrl
-
- const data = objectToFormData(body)
- return this.authHttp.post<VideoImport>(url, data)
- .pipe(catchError(res => this.restExtractor.handleError(res)))
- }
-
- importVideoTorrent (target: string | Blob, video: VideoUpdate): Observable<VideoImport> {
+ importVideo (options: VideoImportCreate): Observable<VideoImport> {
const url = VideoImportService.BASE_VIDEO_IMPORT_URL
- const body: VideoImportCreate = this.buildImportVideoObject(video)
-
- if (typeof target === 'string') body.magnetUri = target
- else body.torrentfile = target
- const data = objectToFormData(body)
+ const data = objectToFormData(options)
return this.authHttp.post<VideoImport>(url, data)
.pipe(catchError(res => this.restExtractor.handleError(res)))
}
@@ -76,36 +61,6 @@ export class VideoImportService {
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
- private buildImportVideoObject (video: VideoUpdate): VideoImportCreate {
- const language = video.language || null
- const licence = video.licence || null
- const category = video.category || null
- const description = video.description || null
- const support = video.support || null
- const scheduleUpdate = video.scheduleUpdate || null
- const originallyPublishedAt = video.originallyPublishedAt || null
-
- return {
- name: video.name,
- category,
- licence,
- language,
- support,
- description,
- channelId: video.channelId,
- privacy: video.privacy,
- tags: video.tags,
- nsfw: video.nsfw,
- waitTranscoding: video.waitTranscoding,
- commentsPolicy: video.commentsPolicy,
- downloadEnabled: video.downloadEnabled,
- thumbnailfile: video.thumbnailfile,
- previewfile: video.previewfile,
- scheduleUpdate,
- originallyPublishedAt
- }
- }
-
private extractVideoImports (result: ResultList<VideoImport>): Observable<ResultList<VideoImport>> {
return this.serverService.getServerLocale()
.pipe(
diff --git a/client/src/app/shared/shared-main/video/video-password.service.ts b/client/src/app/shared/shared-main/video/video-password.service.ts
index 7cbae247a4..f1dc70816f 100644
--- a/client/src/app/shared/shared-main/video/video-password.service.ts
+++ b/client/src/app/shared/shared-main/video/video-password.service.ts
@@ -1,8 +1,8 @@
-import { ResultList, VideoPassword } from '@peertube/peertube-models'
-import { Injectable, inject } from '@angular/core'
-import { catchError, switchMap } from 'rxjs'
import { HttpClient, HttpHeaders } from '@angular/common/http'
+import { Injectable, inject } from '@angular/core'
import { RestExtractor } from '@app/core'
+import { ResultList, VideoPassword } from '@peertube/peertube-models'
+import { catchError, map } from 'rxjs'
import { VideoService } from './video.service'
@Injectable()
@@ -19,7 +19,7 @@ export class VideoPasswordService {
getVideoPasswords (options: { videoUUID: string }) {
return this.authHttp.get<ResultList<VideoPassword>>(`${VideoService.BASE_VIDEO_URL}/${options.videoUUID}/passwords`)
.pipe(
- switchMap(res => res.data),
+ map(res => res.data),
catchError(err => this.restExtractor.handleError(err))
)
}
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts
index 1c092e9cec..d9579165c0 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -1,6 +1,6 @@
import { AuthUser } from '@app/core'
import { User } from '@app/core/users/user.model'
-import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
+import { durationToString, getAPIUrl, getOriginUrl } from '@app/helpers'
import { Actor } from '@app/shared/shared-main/account/actor.model'
import { buildVideoWatchPath, getAllFiles, peertubeTranslate } from '@peertube/peertube-core-utils'
import {
@@ -121,12 +121,14 @@ export class Video implements VideoServerModel {
}
static buildUpdateUrl (video: Partial<Pick<Video, 'uuid' | 'shortUUID'>>) {
- return '/videos/update/' + (video.shortUUID || video.uuid)
+ return '/videos/manage/' + (video.shortUUID || video.uuid)
}
- constructor (hash: VideoServerModel, translations: { [ id: string ]: string } = {}) {
- const absoluteAPIUrl = getAbsoluteAPIUrl()
+ static buildDurationLabel (video: Partial<Pick<Video, 'duration'>>) {
+ return durationToString(video.duration)
+ }
+ constructor (hash: VideoServerModel, translations: { [id: string]: string } = {}) {
this.createdAt = new Date(hash.createdAt.toString())
this.publishedAt = new Date(hash.publishedAt.toString())
this.category = hash.category
@@ -142,7 +144,7 @@ export class Video implements VideoServerModel {
this.isLive = hash.isLive
this.duration = hash.duration
- this.durationLabel = durationToString(hash.duration)
+ this.durationLabel = Video.buildDurationLabel(this)
this.id = hash.id
this.uuid = hash.uuid
@@ -153,16 +155,16 @@ export class Video implements VideoServerModel {
this.thumbnailPath = hash.thumbnailPath
this.thumbnailUrl = this.thumbnailPath
- ? hash.thumbnailUrl || (absoluteAPIUrl + hash.thumbnailPath)
+ ? hash.thumbnailUrl || (getAPIUrl() + hash.thumbnailPath)
: null
this.previewPath = hash.previewPath
this.previewUrl = this.previewPath
- ? hash.previewUrl || (absoluteAPIUrl + hash.previewPath)
+ ? hash.previewUrl || (getAPIUrl() + hash.previewPath)
: null
this.embedPath = hash.embedPath
- this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath)
+ this.embedUrl = hash.embedUrl || (getOriginUrl() + hash.embedPath)
this.url = hash.url
@@ -277,10 +279,10 @@ export class Video implements VideoServerModel {
canRunTranscoding (user: AuthUser) {
return this.isLocal &&
- !this.isLive &&
- user?.hasRight(UserRight.RUN_VIDEO_TRANSCODING) &&
- this.state?.id &&
- !this.transcodingAndTranscriptionIncompatibleStates().has(this.state.id)
+ !this.isLive &&
+ user?.hasRight(UserRight.RUN_VIDEO_TRANSCODING) &&
+ this.state?.id &&
+ !this.transcodingAndTranscriptionIncompatibleStates().has(this.state.id)
}
canGenerateTranscription (user: AuthUser, transcriptionEnabled: boolean) {
diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts
index e73ce35f6e..97af562bfa 100644
--- a/client/src/app/shared/shared-main/video/video.service.ts
+++ b/client/src/app/shared/shared-main/video/video.service.ts
@@ -1,8 +1,17 @@
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
-import { Injectable, inject } from '@angular/core'
-import { AuthService, ComponentPaginationLight, ConfirmService, RestExtractor, RestService, ServerService, UserService } from '@app/core'
+import { inject, Injectable } from '@angular/core'
+import {
+ AuthService,
+ ComponentPaginationLight,
+ ConfirmService,
+ RestExtractor,
+ RestPagination,
+ RestService,
+ ServerService,
+ UserService
+} from '@app/core'
import { objectToFormData } from '@app/helpers'
-import { arrayify, buildDownloadFilesUrl } from '@peertube/peertube-core-utils'
+import { arrayify, buildDownloadFilesUrl, exists } from '@peertube/peertube-core-utils'
import {
BooleanBothQuery,
FeedFormat,
@@ -21,6 +30,7 @@ import {
VideoIncludeType,
VideoPrivacy,
VideoPrivacyType,
+ VideosCommonQuery,
Video as VideoServerModel,
VideoSortField,
VideoSource,
@@ -36,7 +46,6 @@ import { AccountService } from '../account/account.service'
import { VideoChannel } from '../channel/video-channel.model'
import { VideoChannelService } from '../channel/video-channel.service'
import { VideoDetails } from './video-details.model'
-import { VideoEdit } from './video-edit.model'
import { VideoPasswordService } from './video-password.service'
import { Video } from './video.model'
@@ -86,42 +95,10 @@ export class VideoService {
)
}
- updateVideo (video: VideoEdit) {
- const language = video.language || null
- const licence = video.licence || null
- const category = video.category || null
- const description = video.description || null
- const support = video.support || null
- const scheduleUpdate = video.scheduleUpdate || null
- const originallyPublishedAt = video.originallyPublishedAt || null
-
- const body: VideoUpdate = {
- name: video.name,
- category,
- licence,
- language,
- support,
- description,
- channelId: video.channelId,
- privacy: video.privacy,
- videoPasswords: video.privacy === VideoPrivacy.PASSWORD_PROTECTED
- ? [ video.videoPassword ]
- : undefined,
- tags: video.tags,
- nsfw: video.nsfw,
- waitTranscoding: video.waitTranscoding,
- commentsPolicy: video.commentsPolicy,
- downloadEnabled: video.downloadEnabled,
- thumbnailfile: video.thumbnailfile,
- previewfile: video.previewfile,
- pluginData: video.pluginData,
- scheduleUpdate,
- originallyPublishedAt
- }
-
- const data = objectToFormData(body)
+ updateVideo (id: number | string, video: VideoUpdate) {
+ const data = objectToFormData(video)
- return this.authHttp.put(`${VideoService.BASE_VIDEO_URL}/${video.id}`, data)
+ return this.authHttp.put(`${VideoService.BASE_VIDEO_URL}/${id}`, data)
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
@@ -133,38 +110,37 @@ export class VideoService {
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
- getMyVideos (options: {
- videoPagination: ComponentPaginationLight
- sort: VideoSortField
+ listMyVideos (options: {
+ videoPagination?: ComponentPaginationLight
+ restPagination?: RestPagination
+
+ sort: VideoSortField | SortMeta
userChannels?: VideoChannelServerModel[]
+
+ isLive?: boolean
+ privacyOneOf?: VideoPrivacyType[]
+ channelNameOneOf: string[]
search?: string
}): Observable<ResultList<Video>> {
- const { videoPagination, sort, userChannels = [], search } = options
+ const { videoPagination, restPagination, sort, channelNameOneOf, privacyOneOf, search } = options
- const pagination = this.restService.componentToRestPagination(videoPagination)
+ const pagination = videoPagination
+ ? this.restService.componentToRestPagination(videoPagination)
+ : restPagination
let params = new HttpParams()
- params = this.restService.addRestGetParams(params, pagination, sort)
-
- if (search) {
- const filters = this.restService.parseQueryStringFilter(search, {
- isLive: {
- prefix: 'isLive:',
- isBoolean: true
- },
- channelId: {
- prefix: 'channel:',
- handler: (name: string) => {
- const channel = userChannels.find(c => c.name === name)
-
- if (channel) return channel.id
-
- return undefined
- }
- }
- })
+ params = this.restService.addRestGetParams(params, pagination, this.buildListSort(sort))
+
+ const commonFilters: VideosCommonQuery = {}
+
+ if (exists(options.isLive)) commonFilters.isLive = options.isLive
+ if (options.search) commonFilters.search = search
+ if (options.privacyOneOf) commonFilters.privacyOneOf = privacyOneOf
+
+ params = this.restService.addObjectParams(params, commonFilters)
- params = this.restService.addObjectParams(params, filters)
+ if (channelNameOneOf !== undefined && channelNameOneOf.length !== 0) {
+ params = this.restService.addArrayParams(params, 'channelNameOneOf', channelNameOneOf)
}
return this.authHttp
diff --git a/client/src/app/shared/shared-share-modal/video-share.component.html b/client/src/app/shared/shared-share-modal/video-share.component.html
index 1a61c4049f..91e357018a 100644
--- a/client/src/app/shared/shared-share-modal/video-share.component.html
+++ b/client/src/app/shared/shared-share-modal/video-share.component.html
@@ -106,7 +106,7 @@
<my-alert *ngIf="isPrivateVideo()" class="alert-private" type="warning">
<div i18n>This video is private so you won't be able to share it with external users</div>
- <a i18n class="peertube-button-link primary-button mt-3" [routerLink]="[ '/videos/', 'update', video().shortUUID ]" target="_blank" rel="noopener noreferrer">
+ <a i18n class="peertube-button-link primary-button mt-3" [routerLink]="[ '/videos/', 'manage', video().shortUUID ]" target="_blank" rel="noopener noreferrer">
Update video privacy
</a>
</my-alert>
diff --git a/client/src/app/shared/shared-tables/video-cell.component.html b/client/src/app/shared/shared-tables/video-cell.component.html
index 709e2869f5..16fc28810b 100644
--- a/client/src/app/shared/shared-tables/video-cell.component.html
+++ b/client/src/app/shared/shared-tables/video-cell.component.html
@@ -1,19 +1,26 @@
-<a [href]="getVideoUrl()" class="table-video-link" [title]="video().name" target="_blank" rel="noopener noreferrer">
- <div class="table-video">
- <div class="table-video-image">
- <img [src]="video().thumbnailPath" alt="">
+<div class="root" [ngClass]="{ 'small': size() === 'small' }">
- <ng-content select="[image]"></ng-content>
- </div>
-
- <div class="table-video-text">
- <div>
- <ng-content select="[name]"></ng-content>
+ <my-video-thumbnail
+ *ngIf="thumbnail()"
+ [video]="video()" [videoRouterLink]="getVideoUrl()" [ariaLabel]="video().name" playOverlay="false"
+ ></my-video-thumbnail>
+ <div *ngIf="title()" class="min-width-0" [ngClass]="{ ellipsis: ellipsis }">
+ <div class="d-flex flex-wrap">
+ <a class="name" [ngClass]="{ ellipsis: ellipsis }" [routerLink]="getVideoUrl()" [title]="video().name">
{{ video().name }}
- </div>
+ </a>
- <div class="muted">by {{ video().channel?.displayName }} on {{ video().channel?.host }} </div>
+ <ng-content></ng-content>
</div>
+
+ <a *ngIf="video().channel" [routerLink]="getChannelUrl()" class="channel" [ngClass]="{ ellipsis: ellipsis }">
+ {{ video().channel?.displayName }}
+
+ <ng-container *ngIf="hostInfo()" i18n>
+ on {{ video().channel?.host }}
+ </ng-container>
+ </a>
</div>
-</a>
+
+</div>
diff --git a/client/src/app/shared/shared-tables/video-cell.component.scss b/client/src/app/shared/shared-tables/video-cell.component.scss
index 13b389c1fa..11afd8fa6f 100644
--- a/client/src/app/shared/shared-tables/video-cell.component.scss
+++ b/client/src/app/shared/shared-tables/video-cell.component.scss
@@ -3,63 +3,42 @@
@use '_mixins' as *;
@use '_miniature' as *;
-.table-video-link {
- position: relative;
- top: 3px;
+.root {
+ --co-image-height: 78px;
- @include disable-outline;
-}
-
-.table-video {
- display: inline-flex;
-
- .table-video-image {
- @include miniature-thumbnail;
- @include margin-right(0.5rem);
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
- & {
- $image-height: 45px;
-
- height: $image-height;
- width: #{math.div(16, 9) * $image-height};
- border-radius: 2px;
- border: 0;
- background: transparent;
- display: inline-flex;
- justify-content: center;
- position: relative;
- }
+ @media screen and (max-width: $mobile-view) {
+ --co-image-height: 64px;
+ }
- img {
- height: 100%;
- width: 100%;
- border-radius: 2px;
- }
+ &.small {
+ --co-image-height: 45px;
+ }
+}
- .table-video-image-label {
- position: absolute;
- border-radius: 3px;
- font-size: 10px;
- padding: 0 3px;
- line-height: 1.3;
- bottom: 2px;
- right: 2px;
+my-video-thumbnail {
+ display: block;
+ height: var(--co-image-height);
+ width: calc(#{math.div(16, 9)} * var(--co-image-height));
- @include static-thumbnail-overlay;
- }
+ & + .name {
+ @include margin-left(0.5rem);
}
+}
- .table-video-text {
- display: inline-flex;
- flex-direction: column;
- justify-content: center;
- font-size: 90%;
- color: pvar(--fg);
- line-height: 1rem;
+.name {
+ color: pvar(--fg);
+ line-height: 1rem;
+ font-weight: $font-bold;
+ text-decoration: none;
+}
- div + div {
- color: pvar(--fg-300);
- font-size: 11px;
- }
- }
+.channel {
+ color: pvar(--fg-200);
+ text-decoration: none;
+
+ @include font-size(14px);
}
diff --git a/client/src/app/shared/shared-tables/video-cell.component.ts b/client/src/app/shared/shared-tables/video-cell.component.ts
index fb2ef9e7f7..d519ec6aba 100644
--- a/client/src/app/shared/shared-tables/video-cell.component.ts
+++ b/client/src/app/shared/shared-tables/video-cell.component.ts
@@ -1,16 +1,42 @@
-import { Component, input } from '@angular/core'
+import { CommonModule } from '@angular/common'
+import { booleanAttribute, Component, inject, input, OnInit } from '@angular/core'
+import { RouterLink } from '@angular/router'
+import { ScreenService } from '@app/core'
+import { VideoChannel } from '../shared-main/channel/video-channel.model'
import { Video } from '../shared-main/video/video.model'
+import { VideoThumbnailComponent } from '../shared-thumbnail/video-thumbnail.component'
@Component({
selector: 'my-video-cell',
styleUrls: [ 'video-cell.component.scss' ],
templateUrl: 'video-cell.component.html',
- standalone: true
+ standalone: true,
+ imports: [
+ CommonModule,
+ RouterLink,
+ VideoThumbnailComponent
+ ]
})
-export class VideoCellComponent {
- readonly video = input<Video>(undefined)
+export class VideoCellComponent implements OnInit {
+ private readonly screenService = inject(ScreenService)
+
+ readonly video = input.required<Video>()
+ readonly size = input<'small' | 'normal'>('normal')
+ readonly thumbnail = input<boolean, boolean | string>(true, { transform: booleanAttribute })
+ readonly title = input<boolean, boolean | string>(true, { transform: booleanAttribute })
+ readonly hostInfo = input<boolean, boolean | string>(true, { transform: booleanAttribute })
+
+ ellipsis: boolean
+
+ ngOnInit () {
+ this.ellipsis = !this.screenService.isInMobileView()
+ }
getVideoUrl () {
return Video.buildWatchUrl(this.video())
}
+
+ getChannelUrl () {
+ return VideoChannel.buildPublicUrl(this.video().channel)
+ }
}
diff --git a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.html b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.html
index 4790186cca..aad0a62431 100644
--- a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.html
+++ b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.html
@@ -38,11 +38,11 @@
<ng-container i18n>WAIT LIVE</ng-container>
}
</div>
- } @else {
- <div class="duration-overlay" [ariaLabel]="getDurationOverlayLabel()">{{ video().durationLabel }}</div>
+ } @else if (getDurationLabel()) {
+ <div class="duration-overlay" [ariaLabel]="getDurationOverlayLabel()">{{ getDurationLabel() }}</div>
}
- <div class="play-overlay">
+ <div *ngIf="playOverlay()" class="play-overlay">
<div class="icon"></div>
</div>
diff --git a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
index a8dfc8b148..6f7ed994bf 100644
--- a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
+++ b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
@@ -1,24 +1,38 @@
import { NgClass, NgIf, NgStyle, NgTemplateOutlet } from '@angular/common'
-import { Component, inject, input, output, viewChild } from '@angular/core'
+import { booleanAttribute, Component, inject, input, OnChanges, output, viewChild } from '@angular/core'
import { RouterLink } from '@angular/router'
import { ScreenService } from '@app/core'
+import { getAPIUrl } from '@app/helpers'
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
-import { VideoState } from '@peertube/peertube-models'
+import { Video as VideoServerModel, VideoState } from '@peertube/peertube-models'
import { GlobalIconComponent } from '../shared-icons/global-icon.component'
import { Video } from '../shared-main/video/video.model'
+export type VideoThumbnailInput = Pick<
+ VideoServerModel,
+ | 'duration'
+ | 'id'
+ | 'uuid'
+ | 'shortUUID'
+ | 'isLive'
+ | 'state'
+ | 'previewPath'
+ | 'previewUrl'
+ | 'thumbnailPath'
+ | 'thumbnailUrl'
+ | 'userHistory'
+>
+
@Component({
selector: 'my-video-thumbnail',
styleUrls: [ './video-thumbnail.component.scss' ],
templateUrl: './video-thumbnail.component.html',
imports: [ NgIf, RouterLink, NgTemplateOutlet, NgClass, NgbTooltip, GlobalIconComponent, NgStyle ]
})
-export class VideoThumbnailComponent {
+export class VideoThumbnailComponent implements OnChanges {
private screenService = inject(ScreenService)
- readonly watchLaterTooltip = viewChild<NgbTooltip>('watchLaterTooltip')
-
- readonly video = input<Video>(undefined)
+ readonly video = input.required<VideoThumbnailInput>()
readonly nsfw = input(false)
readonly videoRouterLink = input<string | any[]>(undefined)
@@ -28,21 +42,31 @@ export class VideoThumbnailComponent {
readonly videoHref = input<string>(undefined)
readonly videoTarget = input<string>(undefined)
- readonly displayWatchLaterPlaylist = input<boolean>(undefined)
- readonly inWatchLaterPlaylist = input<boolean>(undefined)
+ readonly displayWatchLaterPlaylist = input<boolean, boolean | string>(false, { transform: booleanAttribute })
+ readonly inWatchLaterPlaylist = input<boolean, boolean | string>(false, { transform: booleanAttribute })
+ readonly playOverlay = input<boolean, boolean | string>(true, { transform: booleanAttribute })
readonly ariaLabel = input.required<string>()
+ readonly watchLaterTooltip = viewChild<NgbTooltip>('watchLaterTooltip')
readonly watchLaterClick = output<boolean>()
addToWatchLaterText: string
removeFromWatchLaterText: string
+ durationLabel: string
+
constructor () {
this.addToWatchLaterText = $localize`Add to watch later`
this.removeFromWatchLaterText = $localize`Remove from watch later`
}
+ ngOnChanges () {
+ this.durationLabel = this.video().duration
+ ? Video.buildDurationLabel(this.video())
+ : undefined
+ }
+
getWatchIconText () {
if (this.inWatchLaterPlaylist()) return this.removeFromWatchLaterText
@@ -67,10 +91,10 @@ export class VideoThumbnailComponent {
if (!video) return ''
if (this.screenService.isInMobileView()) {
- return video.previewUrl
+ return video.previewUrl || getAPIUrl() + video.previewPath
}
- return video.thumbnailUrl
+ return video.thumbnailUrl || getAPIUrl() + video.thumbnailPath
}
getProgressPercent () {
@@ -83,7 +107,7 @@ export class VideoThumbnailComponent {
}
getDurationOverlayLabel () {
- return $localize`Video duration is ${this.video().durationLabel}`
+ return $localize`Video duration is ${this.getDurationLabel()}`
}
getVideoRouterLink () {
@@ -101,4 +125,8 @@ export class VideoThumbnailComponent {
return false
}
+
+ getDurationLabel () {
+ return this.durationLabel
+ }
}
diff --git a/client/src/app/shared/shared-video-comment/video-comment.model.ts b/client/src/app/shared/shared-video-comment/video-comment.model.ts
index efa9228b3c..6a5d8e6aca 100644
--- a/client/src/app/shared/shared-video-comment/video-comment.model.ts
+++ b/client/src/app/shared/shared-video-comment/video-comment.model.ts
@@ -1,8 +1,8 @@
-import { getAbsoluteAPIUrl } from '@app/helpers'
+import { getBackendHost } from '@app/helpers'
import {
Account as AccountInterface,
- VideoComment as VideoCommentServerModel,
- VideoCommentForAdminOrUser as VideoCommentForAdminOrUserServerModel
+ VideoCommentForAdminOrUser as VideoCommentForAdminOrUserServerModel,
+ VideoComment as VideoCommentServerModel
} from '@peertube/peertube-models'
import { Actor } from '../shared-main/account/actor.model'
import { Video } from '../shared-main/video/video.model'
@@ -45,9 +45,7 @@ export class VideoComment implements VideoCommentServerModel {
if (this.account) {
this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
- const absoluteAPIUrl = getAbsoluteAPIUrl()
- const thisHost = new URL(absoluteAPIUrl).host
- this.isLocal = this.account.host.trim() === thisHost
+ this.isLocal = this.account.host.trim() === getBackendHost()
}
}
}
diff --git a/client/src/app/shared/shared-video-live/live-stream-information.component.html b/client/src/app/shared/shared-video-live/live-stream-information.component.html
deleted file mode 100644
index ea0592c6df..0000000000
--- a/client/src/app/shared/shared-video-live/live-stream-information.component.html
+++ /dev/null
@@ -1,60 +0,0 @@
-<ng-template #modal let-close="close" let-dismiss="dismiss">
- <div class="modal-header">
- <h4 i18n class="modal-title">Live information</h4>
-
- <button class="border-0 p-0" title="Close this modal" i18n-title (click)="dismiss()">
- <my-global-icon iconName="cross"></my-global-icon>
- </button>
- </div>
-
- <div class="modal-body" *ngIf="live">
- <div>
- <div class="pt-badge badge-blue" *ngIf="live.permanentLive" i18n>Permanent/Recurring live</div>
- <div class="pt-badge badge-blue" *ngIf="live.saveReplay" i18n>Replay will be saved</div>
- </div>
-
- <my-alert type="primary">
- <my-live-documentation-link></my-live-documentation-link>
- </my-alert>
-
- <div *ngIf="live.rtmpUrl" class="form-group">
- <label for="liveVideoRTMPUrl" i18n>Live RTMP Url</label>
- <my-input-text inputId="liveVideoRTMPUrl" [value]="live.rtmpUrl" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-text>
- </div>
-
- <div *ngIf="live.rtmpsUrl" class="form-group">
- <label for="liveVideoRTMPSUrl" i18n>Live RTMPS Url</label>
- <my-input-text inputId="liveVideoRTMPSUrl" [value]="live.rtmpsUrl" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-text>
- </div>
-
- <div class="form-group">
- <label for="liveVideoStreamKey" i18n>Live stream key</label>
- <my-input-text inputId="liveVideoStreamKey" [value]="live.streamKey" [withCopy]="true" [readonly]="true"></my-input-text>
-
- <div class="form-group-description" i18n>⚠️ Never share your stream key with anyone.</div>
- </div>
-
- <div class="journal" *ngIf="latestLiveSessions.length !== 0">
- <div class="mb-2 fw-bold" i18n>Latest live sessions</div>
-
- <div class="journal-session" *ngFor="let session of latestLiveSessions">
- <span i18n class="pt-badge badge-success" *ngIf="!getErrorLabel(session)">Success</span>
- <span class="pt-badge badge-danger" *ngIf="getErrorLabel(session)">{{ getErrorLabel(session) }}</span>
-
- <span i18n>Started on {{ session.startDate | ptDate:'medium' }}</span>
- <span i18n *ngIf="session.endDate">Ended on {{ session.endDate | ptDate:'medium' }}</span>
- <a i18n *ngIf="session.replayVideo" [routerLink]="getVideoUrl(session.replayVideo)" target="_blank">Go to replay</a>
- <span i18n *ngIf="isReplayBeingProcessed(session)">Replay is being processed...</span>
- </div>
- </div>
- </div>
-
- <div class="modal-footer inputs">
- <input type="button" role="button" i18n-value value="Close" class="peertube-button secondary-button" (click)="dismiss()" />
-
- <my-edit-button
- i18n-label label="Update live settings"
- [ptRouterLink]="[ '/videos', 'update', video.shortUUID ]" (click)="dismiss()"
- ></my-edit-button>
- </div>
-</ng-template>
diff --git a/client/src/app/shared/shared-video-live/live-stream-information.component.scss b/client/src/app/shared/shared-video-live/live-stream-information.component.scss
deleted file mode 100644
index ba352d0456..0000000000
--- a/client/src/app/shared/shared-video-live/live-stream-information.component.scss
+++ /dev/null
@@ -1,30 +0,0 @@
-@use '_variables' as *;
-@use '_mixins' as *;
-
-p-autocomplete {
- display: block;
-}
-
-.form-group {
- margin: 20px 0;
-}
-
-my-alert {
- display: block;
- margin: 1rem 0;
-}
-
-.pt-badge {
- font-size: 13px;
-
- @include margin-right(5px);
-}
-
-.journal-session {
- margin-bottom: 5px;
-
- span:not(.pt-badge, :last-child)::after {
- margin: 3px;
- content: '•';
- }
-}
diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html
index b70add2a31..a1c8a56c5c 100644
--- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html
+++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html
@@ -24,5 +24,4 @@
<my-video-download #videoDownloadModal></my-video-download>
<my-video-report #videoReportModal [video]="video()"></my-video-report>
<my-video-block #videoBlockModal (videoBlocked)="onVideoBlocked()"></my-video-block>
- <my-live-stream-information #liveStreamInformationModal *ngIf="displayOptions().liveInfo"></my-live-stream-information>
</ng-container>
diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
index f6fa12d1c5..7cdefa260d 100644
--- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
@@ -20,7 +20,6 @@ import { BlocklistService } from '../shared-moderation/blocklist.service'
import { VideoReportComponent } from '../shared-moderation/report-modals'
import { VideoBlockComponent } from '../shared-moderation/video-block.component'
import { VideoBlockService } from '../shared-moderation/video-block.service'
-import { LiveStreamInformationComponent } from '../shared-video-live/live-stream-information.component'
import { VideoAddToPlaylistComponent } from '../shared-video-playlist/video-add-to-playlist.component'
import { VideoDownloadComponent } from './download/video-download.component'
@@ -55,8 +54,7 @@ export type VideoActionsDisplayType = {
ActionDropdownComponent,
VideoDownloadComponent,
VideoReportComponent,
- VideoBlockComponent,
- LiveStreamInformationComponent
+ VideoBlockComponent
]
})
export class VideoActionsDropdownComponent implements OnChanges {
@@ -77,7 +75,6 @@ export class VideoActionsDropdownComponent implements OnChanges {
readonly videoDownloadModal = viewChild<VideoDownloadComponent>('videoDownloadModal')
readonly videoReportModal = viewChild<VideoReportComponent>('videoReportModal')
readonly videoBlockModal = viewChild<VideoBlockComponent>('videoBlockModal')
- readonly liveStreamInformationModal = viewChild<LiveStreamInformationComponent>('liveStreamInformationModal')
readonly video = input<Video | VideoDetails>(undefined)
readonly videoCaptions = input<VideoCaption[]>([])
@@ -174,12 +171,6 @@ export class VideoActionsDropdownComponent implements OnChanges {
this.videoBlockModal().show([ this.video() ])
}
- showLiveInfoModal (video: Video) {
- this.modalOpened.emit()
-
- this.liveStreamInformationModal().show(video)
- }
-
// ---------------------------------------------------------------------------
// Actions checker
// ---------------------------------------------------------------------------
@@ -479,28 +470,16 @@ export class VideoActionsDropdownComponent implements OnChanges {
],
[ // private actions regarding the video
{
- label: $localize`Display live information`,
- handler: ({ video }) => this.showLiveInfoModal(video),
+ label: $localize`Live information`,
+ linkBuilder: ({ video }) => [ '/videos/manage', video.shortUUID, 'live-settings' ],
isDisplayed: () => this.displayOptions().liveInfo && this.isVideoLiveInfoAvailable(),
iconName: 'live'
},
{
- label: $localize`Update`,
- linkBuilder: ({ video }) => [ '/videos/update', video.shortUUID ],
- iconName: 'edit',
- isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions().update && this.isVideoUpdatable()
- },
- {
- label: $localize`Studio`,
- linkBuilder: ({ video }) => [ '/studio/edit', video.shortUUID ],
+ label: $localize`Manage`,
+ linkBuilder: ({ video }) => [ '/videos/manage', video.shortUUID ],
iconName: 'film',
- isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions().studio && this.isVideoEditable()
- },
- {
- label: $localize`Stats`,
- linkBuilder: ({ video }) => [ '/stats/videos', video.shortUUID ],
- iconName: 'stats',
- isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions().stats && this.isVideoStatsAvailable()
+ isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions().update && this.isVideoUpdatable()
},
{
label: $localize`Block`,
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.scss b/client/src/app/shared/shared-video-miniature/video-miniature.component.scss
index 24f6cdb946..cdb3747637 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.scss
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.scss
@@ -50,6 +50,8 @@ $more-button-width: 40px;
my-actor-host {
flex-shrink: 1;
min-width: 1px;
+
+ @include margin-left(0.25rem);
}
.owner-label {
@@ -64,10 +66,6 @@ my-actor-host {
}
}
-my-actor-host {
- @include margin-left(0.25rem);
-}
-
.video-actions {
width: $more-button-width;
@@ -124,13 +122,11 @@ my-actor-host {
@include left(-2px);
&[actorType=account] {
- // TODO: use SASS var in sync with thumbnail component
- border-radius: 100%;
+ border-radius: $account-avatar-radius;
}
&[actorType=channel] {
- // TODO: use SASS var in sync with thumbnail component
- border-radius: 5px;
+ border-radius: $channel-avatar-radius;
}
& + .owner-container {
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
index e9ba4cf969..fd2ffe7e96 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
+++ b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
@@ -1,10 +1,10 @@
-import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
+import { getAPIUrl, getOriginUrl } from '@app/helpers'
import { buildPlaylistWatchPath, peertubeTranslate } from '@peertube/peertube-core-utils'
import {
AccountSummary,
+ VideoPlaylist as ServerVideoPlaylist,
VideoChannelSummary,
VideoConstant,
- VideoPlaylist as ServerVideoPlaylist,
VideoPlaylistPrivacyType,
VideoPlaylistType,
VideoPlaylistType_Type
@@ -48,9 +48,7 @@ export class VideoPlaylist implements ServerVideoPlaylist {
return buildPlaylistWatchPath({ shortUUID: playlist.shortUUID || playlist.uuid })
}
- constructor (hash: ServerVideoPlaylist, translations: { [ id: string ]: string }) {
- const absoluteAPIUrl = getAbsoluteAPIUrl()
-
+ constructor (hash: ServerVideoPlaylist, translations: { [id: string]: string }) {
this.id = hash.id
this.uuid = hash.uuid
this.shortUUID = hash.shortUUID
@@ -66,11 +64,11 @@ export class VideoPlaylist implements ServerVideoPlaylist {
this.thumbnailPath = hash.thumbnailPath
this.thumbnailUrl = this.thumbnailPath
- ? hash.thumbnailUrl || (absoluteAPIUrl + hash.thumbnailPath)
- : absoluteAPIUrl + '/client/assets/images/default-playlist.jpg'
+ ? hash.thumbnailUrl || (getAPIUrl() + hash.thumbnailPath)
+ : getAPIUrl() + '/client/assets/images/default-playlist.jpg'
this.embedPath = hash.embedPath
- this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath)
+ this.embedUrl = hash.embedUrl || (getOriginUrl() + hash.embedPath)
this.videosLength = hash.videosLength
diff --git a/client/src/app/shared/shared-video/video-privacy-badge.component.html b/client/src/app/shared/shared-video/video-privacy-badge.component.html
new file mode 100644
index 0000000000..349efeede0
--- /dev/null
+++ b/client/src/app/shared/shared-video/video-privacy-badge.component.html
@@ -0,0 +1,3 @@
+<span [ngClass]="badgeClass" class="pt-badge" [ngbTooltip]="tooltip">
+ {{ label }}
+</span>
diff --git a/client/src/app/shared/shared-video/video-privacy-badge.component.ts b/client/src/app/shared/shared-video/video-privacy-badge.component.ts
new file mode 100644
index 0000000000..b077ace35a
--- /dev/null
+++ b/client/src/app/shared/shared-video/video-privacy-badge.component.ts
@@ -0,0 +1,55 @@
+import { CommonModule } from '@angular/common'
+import { Component, inject, input, LOCALE_ID, OnChanges } from '@angular/core'
+import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'
+import { Video, VideoPrivacy, VideoPrivacyType } from '@peertube/peertube-models'
+
+@Component({
+ selector: 'my-video-privacy-badge',
+ templateUrl: './video-privacy-badge.component.html',
+ imports: [ CommonModule, NgbTooltipModule ]
+})
+export class VideoPrivacyBadgeComponent implements OnChanges {
+ private readonly localeId = inject(LOCALE_ID)
+ readonly video = input.required<Pick<Video, 'privacy' | 'scheduledUpdate'>>()
+
+ private badges: { [id in VideoPrivacyType]: string } = {
+ [VideoPrivacy.PUBLIC]: 'badge-green',
+ [VideoPrivacy.INTERNAL]: 'badge-yellow',
+ [VideoPrivacy.PRIVATE]: 'badge-grey',
+ [VideoPrivacy.PASSWORD_PROTECTED]: 'badge-purple',
+ [VideoPrivacy.UNLISTED]: 'badge-blue'
+ }
+
+ label: string
+ badgeClass: string
+ tooltip: string
+
+ ngOnChanges (): void {
+ this.label = this.buildLabel()
+ this.badgeClass = this.buildBadgeClass()
+ this.tooltip = this.buildTooltip()
+ }
+
+ buildBadgeClass () {
+ return this.badges[this.video().privacy.id]
+ }
+
+ private buildLabel () {
+ const video = this.video()
+
+ if (video.scheduledUpdate) return $localize`Scheduled`
+
+ return video.privacy.label
+ }
+
+ private buildTooltip () {
+ const video = this.video()
+
+ if (video.scheduledUpdate) {
+ const updateAt = new Date(video.scheduledUpdate.updateAt.toString()).toLocaleString(this.localeId)
+ return $localize`Scheduled on ${updateAt}`
+ }
+
+ return this.buildLabel()
+ }
+}
diff --git a/client/src/app/shared/shared-video/video-state-badge.component.html b/client/src/app/shared/shared-video/video-state-badge.component.html
new file mode 100644
index 0000000000..ceb96b4261
--- /dev/null
+++ b/client/src/app/shared/shared-video/video-state-badge.component.html
@@ -0,0 +1 @@
+<span *ngIf="label" [ngClass]="badgeClass" class="pt-badge">{{ label }}</span>
diff --git a/client/src/app/shared/shared-video/video-state-badge.component.ts b/client/src/app/shared/shared-video/video-state-badge.component.ts
new file mode 100644
index 0000000000..de569dbed8
--- /dev/null
+++ b/client/src/app/shared/shared-video/video-state-badge.component.ts
@@ -0,0 +1,108 @@
+import { CommonModule } from '@angular/common'
+import { Component, input, OnChanges } from '@angular/core'
+import { Video, VideoPrivacy, VideoState, VideoStateType } from '@peertube/peertube-models'
+
+@Component({
+ selector: 'my-video-state-badge',
+ templateUrl: './video-state-badge.component.html',
+ imports: [ CommonModule ]
+})
+export class VideoStateBadgeComponent implements OnChanges {
+ readonly video = input.required<Pick<Video, 'privacy' | 'state' | 'waitTranscoding'>>()
+
+ private states: { [id in VideoStateType]: string } = {
+ [VideoState.PUBLISHED]: 'badge-green',
+ [VideoState.TO_TRANSCODE]: 'badge-brown',
+ [VideoState.TO_IMPORT]: 'badge-brown',
+ [VideoState.WAITING_FOR_LIVE]: 'badge-blue',
+ [VideoState.LIVE_ENDED]: 'badge-green',
+ [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE]: 'badge-brown',
+ [VideoState.TRANSCODING_FAILED]: 'badge-red',
+ [VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED]: 'badge-red',
+ [VideoState.TO_EDIT]: 'badge-brown',
+ [VideoState.TO_MOVE_TO_FILE_SYSTEM]: 'badge-brown',
+ [VideoState.TO_MOVE_TO_FILE_SYSTEM_FAILED]: 'badge-brown'
+ }
+
+ label: string
+ badgeClass: string
+
+ ngOnChanges (): void {
+ this.buildBadgeAndLabel()
+ }
+
+ private buildBadgeAndLabel () {
+ const video = this.video()
+
+ if (!video.state) {
+ this.label = ''
+ return
+ }
+
+ const state = video.state.id
+ this.badgeClass = this.states[video.state.id]
+
+ switch (state) {
+ case VideoState.PUBLISHED:
+ if (video.privacy.id === VideoPrivacy.PRIVATE) {
+ this.label = $localize`In your library`
+ this.badgeClass = 'badge-grey'
+ return
+ }
+
+ if (video.privacy.id === VideoPrivacy.INTERNAL) {
+ this.label = $localize`Internal`
+ this.badgeClass = 'badge-blue'
+ return
+ }
+
+ this.label = $localize`Published`
+ return
+
+ case VideoState.WAITING_FOR_LIVE:
+ this.label = $localize`Waiting live`
+ return
+
+ case VideoState.LIVE_ENDED:
+ this.label = $localize`Live ended`
+ return
+
+ case VideoState.TRANSCODING_FAILED:
+ this.label = $localize`Transcoding failed`
+ return
+
+ case VideoState.TO_MOVE_TO_FILE_SYSTEM:
+ this.label = $localize`Moving to file system`
+ return
+
+ case VideoState.TO_MOVE_TO_FILE_SYSTEM_FAILED:
+ this.label = $localize`Moving to file system failed`
+ return
+
+ case VideoState.TO_MOVE_TO_EXTERNAL_STORAGE:
+ this.label = $localize`Moving to external storage`
+ return
+
+ case VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED:
+ this.label = $localize`Move to external storage failed`
+ return
+
+ case VideoState.TO_TRANSCODE:
+ this.label = this.video().waitTranscoding === true
+ ? $localize`Waiting transcoding`
+ : $localize`To transcode`
+ return
+
+ case VideoState.TO_IMPORT:
+ this.label = $localize`To import`
+ return
+
+ case VideoState.TO_EDIT:
+ this.label = $localize`To edit`
+ return
+
+ default:
+ return state satisfies never
+ }
+ }
+}
diff --git a/client/src/app/shared/standalone-channels/channel-toggle.component.html b/client/src/app/shared/standalone-channels/channel-toggle.component.html
new file mode 100644
index 0000000000..796c548ae0
--- /dev/null
+++ b/client/src/app/shared/standalone-channels/channel-toggle.component.html
@@ -0,0 +1,5 @@
+<button class="root button-unstyle" [ngClass]="{ active: checked() }" [title]="label()" (click)="toggle()">
+ <my-actor-avatar [actor]="channel()" actorType="channel" size="34"></my-actor-avatar>
+
+ <div class="name">{{ channel().displayName }}</div>
+</button>
diff --git a/client/src/app/shared/standalone-channels/channel-toggle.component.scss b/client/src/app/shared/standalone-channels/channel-toggle.component.scss
new file mode 100644
index 0000000000..4da52d131c
--- /dev/null
+++ b/client/src/app/shared/standalone-channels/channel-toggle.component.scss
@@ -0,0 +1,48 @@
+@use '_variables' as *;
+@use '_mixins' as *;
+
+.root {
+ position: relative;
+ display: flex;
+ align-items: center;
+
+ // Don't use mixin, we need the exact value
+ padding-inline-start: 17px;
+
+ &:hover {
+ opacity: 0.9;
+ }
+}
+
+.name {
+ border-radius: 4px;
+ color: pvar(--fg-400);
+ background-color: pvar(--bg-secondary-400);
+ max-width: 130px;
+ padding-top: 0.75rem;
+ padding-bottom: 0.75rem;
+
+ @include padding-right(0.5rem);
+ @include padding-left(24px);
+ @include font-size(14px);
+ @include ellipsis;
+}
+
+my-actor-avatar {
+ position: absolute;
+ left: 0;
+ border: 2px solid pvar(--bg-secondary-400);
+ border-radius: $channel-avatar-radius;
+}
+
+.root.active {
+ .name {
+ font-weight: $font-bold;
+ background-color: pvar(--bg-secondary-450);
+ }
+
+ my-actor-avatar {
+ border-color: pvar(--bg-secondary-450);
+ background-color: pvar(--bg-secondary-450);
+ }
+}
diff --git a/client/src/app/shared/standalone-channels/channel-toggle.component.ts b/client/src/app/shared/standalone-channels/channel-toggle.component.ts
new file mode 100644
index 0000000000..a715c0fc9a
--- /dev/null
+++ b/client/src/app/shared/standalone-channels/channel-toggle.component.ts
@@ -0,0 +1,50 @@
+import { CommonModule } from '@angular/common'
+import { Component, forwardRef, input, model } from '@angular/core'
+import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
+import { VideoChannel } from '@peertube/peertube-models'
+import { ActorAvatarComponent } from '../shared-actor-image/actor-avatar.component'
+
+@Component({
+ selector: 'my-channel-toggle',
+ styleUrls: [ './channel-toggle.component.scss' ],
+ templateUrl: './channel-toggle.component.html',
+ providers: [
+ {
+ provide: NG_VALUE_ACCESSOR,
+ useExisting: forwardRef(() => ChannelToggleComponent),
+ multi: true
+ }
+ ],
+ standalone: true,
+ imports: [
+ CommonModule,
+ ActorAvatarComponent
+ ]
+})
+export class ChannelToggleComponent implements ControlValueAccessor {
+ readonly checked = model(false)
+ readonly channel = input.required<VideoChannel>()
+ readonly inputName = input<string>(undefined)
+ readonly label = input($localize`Toggle this channel`)
+
+ propagateChange = (_: any) => {
+ // empty
+ }
+
+ writeValue (checked: boolean) {
+ this.checked.set(checked)
+ }
+
+ registerOnChange (fn: (_: any) => void) {
+ this.propagateChange = fn
+ }
+
+ registerOnTouched () {
+ // Unused
+ }
+
+ toggle () {
+ this.checked.set(!this.checked())
+ this.propagateChange(this.checked())
+ }
+}
diff --git a/client/src/app/shared/standalone-channels/video-channel-edit.component.html b/client/src/app/shared/standalone-channels/video-channel-edit.component.html
index 6ee68db422..b5e04e6554 100644
--- a/client/src/app/shared/standalone-channels/video-channel-edit.component.html
+++ b/client/src/app/shared/standalone-channels/video-channel-edit.component.html
@@ -58,7 +58,7 @@
<my-help helpType="markdownText" supportRelMe="true"></my-help>
<my-markdown-textarea
- inputId="description" formControlName="description" class="form-control"
+ inputId="description" formControlName="description"
markdownType="enhanced" [formError]="formErrors['description']" withEmoji="true" withHtml="true"
></my-markdown-textarea>
@@ -75,7 +75,7 @@
></my-help>
<my-markdown-textarea
- inputId="support" formControlName="support" class="form-control"
+ inputId="support" formControlName="support"
markdownType="enhanced" [formError]="formErrors['support']" withEmoji="true" withHtml="true"
></my-markdown-textarea>
</div>
diff --git a/client/src/app/shared/standalone-channels/video-channel-edit.component.scss b/client/src/app/shared/standalone-channels/video-channel-edit.component.scss
index c0308366c3..a1adf65de8 100644
--- a/client/src/app/shared/standalone-channels/video-channel-edit.component.scss
+++ b/client/src/app/shared/standalone-channels/video-channel-edit.component.scss
@@ -20,6 +20,7 @@ textarea {
my-markdown-textarea {
max-width: 500px;
+ display: block;
}
.peertube-select-container {
diff --git a/client/src/app/shared/standalone-upload/upload-progress.component.html b/client/src/app/shared/standalone-upload/upload-progress.component.html
index 007cbc9ad9..ddd0d9dec0 100644
--- a/client/src/app/shared/standalone-upload/upload-progress.component.html
+++ b/client/src/app/shared/standalone-upload/upload-progress.component.html
@@ -1,29 +1,27 @@
-<!-- Upload progress/cancel/error/success header -->
-<div *ngIf="isUploading() && !error()" class="upload-progress-cancel">
- <my-progress-bar
- i18n-label label="Total uploaded" theme="green"
- [value]="uploadPercents()" [valueFormatted]="getUploadingLabel()"
- >
- </my-progress-bar>
+@if (error()) {
+ @if (enableRetryAfterError()) {
+ <div class="d-flex">
+ <my-progress-bar
+ [label]="error()" value="100" [valueFormatted]="error()"
+ theme="red"
+ >
+ </my-progress-bar>
- <input
- *ngIf="uploaded() === false"
- type="button" class="peertube-button secondary-button ms-1" i18n-value="Cancel ongoing upload" value="Cancel" (click)="cancelUpload.emit()"
- />
-</div>
+ <input type="button" class="peertube-button secondary-button ms-1" i18n-value="Retry failed upload" value="Retry" (click)="retry.emit()" />
+ </div>
+ } @else {
+ <my-alert type="danger" class="mt-3">
+ <div i18n>Sorry, but something went wrong.</div>
-<div *ngIf="error() && enableRetryAfterError()" class="upload-progress-retry">
- <my-progress-bar
- [label]="error()" value="100" [valueFormatted]="error()"
- theme="red"
- >
- </my-progress-bar>
-
- <input type="button" class="peertube-button secondary-button ms-1" i18n-value="Retry failed upload" value="Retry" (click)="retry.emit()" />
- <input type="button" class="peertube-button secondary-button ms-1" i18n-value="Cancel ongoing upload" value="Cancel" (click)="cancelUpload.emit()" />
-</div>
-
-<my-alert *ngIf="error() && !enableRetryAfterError()" type="danger">
- <div i18n>Sorry, but something went wrong</div>
- {{ error() }}
-</my-alert>
+ {{ error() }}
+ </my-alert>
+ }
+} @else if (isUploading() || uploaded()){
+ <div>
+ <my-progress-bar
+ i18n-label label="Total uploaded" theme="green"
+ [value]="uploadPercents()" [valueFormatted]="getUploadingLabel()"
+ >
+ </my-progress-bar>
+ </div>
+}
diff --git a/client/src/app/shared/standalone-upload/upload-progress.component.scss b/client/src/app/shared/standalone-upload/upload-progress.component.scss
index 3a495e27b1..bb452d6267 100644
--- a/client/src/app/shared/standalone-upload/upload-progress.component.scss
+++ b/client/src/app/shared/standalone-upload/upload-progress.component.scss
@@ -1,12 +1,6 @@
@use '_variables' as *;
@use '_mixins' as *;
-.upload-progress-retry,
-.upload-progress-cancel {
- display: flex;
- margin-bottom: 40px;
-}
-
my-progress-bar {
width: 100%;
}
diff --git a/client/src/app/shared/standalone-upload/upload-progress.component.ts b/client/src/app/shared/standalone-upload/upload-progress.component.ts
index 40c4ddbf2b..5893739f45 100644
--- a/client/src/app/shared/standalone-upload/upload-progress.component.ts
+++ b/client/src/app/shared/standalone-upload/upload-progress.component.ts
@@ -16,14 +16,13 @@ export class UploadProgressComponent {
readonly uploaded = input<boolean>(undefined)
readonly enableRetryAfterError = input<boolean>(undefined)
- readonly cancelUpload = output()
readonly retry = output()
getUploadingLabel () {
+ if (this.uploaded()) return $localize`File uploaded!`
+
const uploadPercents = this.uploadPercents()
- if (uploadPercents === 100 && this.uploaded() === false) {
- return $localize`Processing…`
- }
+ if (uploadPercents === 100) return $localize`Processing…`
return $localize`${uploadPercents}%`
}
diff --git a/client/src/assets/images/feather/arrow-down.svg b/client/src/assets/images/feather/arrow-down.svg
new file mode 100644
index 0000000000..bb5b04ca71
--- /dev/null
+++ b/client/src/assets/images/feather/arrow-down.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down"><path d="M12 5v14"/><path d="m19 12-7 7-7-7"/></svg>
diff --git a/client/src/assets/images/feather/arrow-left.svg b/client/src/assets/images/feather/arrow-left.svg
new file mode 100644
index 0000000000..727d3573ba
--- /dev/null
+++ b/client/src/assets/images/feather/arrow-left.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-left"><path d="m12 19-7-7 7-7"/><path d="M19 12H5"/></svg>
diff --git a/client/src/assets/images/feather/captions.svg b/client/src/assets/images/feather/captions.svg
new file mode 100644
index 0000000000..7009bf7e72
--- /dev/null
+++ b/client/src/assets/images/feather/captions.svg
@@ -0,0 +1,5 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M7 12.1C7 10.1 8.5 9 10.1 9C10.8 9 11.4 9.3 11.8 9.6L11 10.7C10.7 10.5 10.5 10.4 10.2 10.4C9.4 10.4 8.8 11.1 8.8 12.1C8.8 13.1 9.4 13.8 10.1 13.8C10.5 13.8 10.9 13.6 11.2 13.4L11.9 14.6C11.3 15.1 10.6 15.3 9.9 15.3C8.3 15.2 7 14.1 7 12.1Z" fill="currentColor"/>
+<path d="M12.2998 12.1C12.2998 10.1 13.7998 9 15.3998 9C16.0998 9 16.6998 9.3 17.0998 9.6L16.2998 10.7C15.9998 10.5 15.7998 10.3 15.4998 10.3C14.6998 10.3 14.0998 11 14.0998 12C14.0998 13 14.6998 13.7 15.3998 13.7C15.7998 13.7 16.1998 13.5 16.4998 13.3L17.1998 14.5C16.5998 15 15.8998 15.2 15.1998 15.2C13.4998 15.2 12.2998 14.1 12.2998 12.1Z" fill="currentColor"/>
+<path d="M12 23C5.9 23 1 18.1 1 12C1 5.9 5.9 1 12 1C18.1 1 23 5.9 23 12C23 18.1 18.1 23 12 23ZM12 3C7 3 3 7 3 12C3 17 7 21 12 21C17 21 21 17 21 12C21 7 17 3 12 3Z" fill="currentColor"/>
+</svg>
diff --git a/client/src/assets/images/feather/chapters.svg b/client/src/assets/images/feather/chapters.svg
new file mode 100644
index 0000000000..ada2b1abb1
--- /dev/null
+++ b/client/src/assets/images/feather/chapters.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M12 7V21" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M3 18C2.73478 18 2.48043 17.8946 2.29289 17.7071C2.10536 17.5196 2 17.2652 2 17V4C2 3.73478 2.10536 3.48043 2.29289 3.29289C2.48043 3.10536 2.73478 3 3 3H8C9.06087 3 10.0783 3.42143 10.8284 4.17157C11.5786 4.92172 12 5.93913 12 7C12 5.93913 12.4214 4.92172 13.1716 4.17157C13.9217 3.42143 14.9391 3 16 3H21C21.2652 3 21.5196 3.10536 21.7071 3.29289C21.8946 3.48043 22 3.73478 22 4V17C22 17.2652 21.8946 17.5196 21.7071 17.7071C21.5196 17.8946 21.2652 18 21 18H15C14.2044 18 13.4413 18.3161 12.8787 18.8787C12.3161 19.4413 12 20.2044 12 21C12 20.2044 11.6839 19.4413 11.1213 18.8787C10.5587 18.3161 9.79565 18 9 18H3Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/client/src/assets/images/feather/chevron-down.svg b/client/src/assets/images/feather/chevron-down.svg
new file mode 100644
index 0000000000..0f684d68e7
--- /dev/null
+++ b/client/src/assets/images/feather/chevron-down.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 -2 10 10">
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
+</svg>
diff --git a/client/src/assets/images/feather/chevron-up.svg b/client/src/assets/images/feather/chevron-up.svg
new file mode 100644
index 0000000000..79a565b46d
--- /dev/null
+++ b/client/src/assets/images/feather/chevron-up.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 -2 10 10">
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5 5 1 1 5"/>
+</svg>
diff --git a/client/src/assets/images/feather/columns.svg b/client/src/assets/images/feather/columns.svg
index d264b557ba..51ca577613 100644
--- a/client/src/assets/images/feather/columns.svg
+++ b/client/src/assets/images/feather/columns.svg
@@ -1 +1,7 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-columns"><path d="M12 3h7a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-7m0-18H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7m0-18v18"></path></svg>
\ No newline at end of file
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M21 12.29V5C21 4.46957 20.7893 3.96086 20.4142 3.58579C20.0391 3.21071 19.5304 3 19 3H5C4.46957 3 3.96086 3.21071 3.58579 3.58579C3.21071 3.96086 3 4.46957 3 5V19C3 19.5304 3.21071 20.0391 3.58579 20.4142C3.96086 20.7893 4.46957 21 5 21H12.88" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M9 3V21" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M15 3V15.24" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M18.75 16L21.75 19L18.75 22" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M16.25 19H21.75" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
\ No newline at end of file
diff --git a/client/src/assets/images/feather/stats.svg b/client/src/assets/images/feather/stats.svg
index 864167a6cb..4591c6eec4 100644
--- a/client/src/assets/images/feather/stats.svg
+++ b/client/src/assets/images/feather/stats.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-bar-chart-2"><line x1="18" y1="20" x2="18" y2="10"></line><line x1="12" y1="20" x2="12" y2="4"></line><line x1="6" y1="20" x2="6" y2="14"></line></svg>
\ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chart-pie"><path d="M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z"/><path d="M21.21 15.89A10 10 0 1 1 8 2.83"/></svg>
diff --git a/client/src/assets/images/feather/studio.svg b/client/src/assets/images/feather/studio.svg
new file mode 100644
index 0000000000..9efd712442
--- /dev/null
+++ b/client/src/assets/images/feather/studio.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clapperboard"><path d="M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z"/><path d="m6.2 5.3 3.1 3.9"/><path d="m12.4 3.4 3.1 4"/><path d="M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"/></svg>
diff --git a/client/src/assets/images/feather/upload.svg b/client/src/assets/images/feather/upload.svg
index f6ba0fd066..be90fcb31c 100644
--- a/client/src/assets/images/feather/upload.svg
+++ b/client/src/assets/images/feather/upload.svg
@@ -1,59 +1 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- width="24"
- height="24"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- stroke-width="2"
- stroke-linecap="round"
- stroke-linejoin="round"
- class="feather feather-upload-cloud"
- version="1.1"
- id="svg2"
- sodipodi:docname="upload.svg"
- inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:svg="http://www.w3.org/2000/svg">
- <defs
- id="defs2" />
- <sodipodi:namedview
- id="namedview2"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:showpageshadow="2"
- inkscape:pageopacity="0.0"
- inkscape:pagecheckerboard="0"
- inkscape:deskcolor="#d1d1d1"
- inkscape:zoom="30.708333"
- inkscape:cx="12.016282"
- inkscape:cy="12.537313"
- inkscape:window-width="1916"
- inkscape:window-height="1036"
- inkscape:window-x="0"
- inkscape:window-y="0"
- inkscape:window-maximized="0"
- inkscape:current-layer="svg2" />
- <polyline
- points="16 16 12 12 8 16"
- id="polyline1"
- transform="matrix(0.9,0,0,0.9,1.2001804,1.2002762)" />
- <line
- x1="12.00018"
- y1="12.000277"
- x2="12.00018"
- y2="20.100277"
- id="line1"
- style="stroke-width:1.8" />
- <path
- d="m 19.55118,17.751276 a 4.5,4.5 0 0 0 -2.151,-8.4509998 h -1.134 A 7.2,7.2 0 1 0 3.9001804,15.870276"
- id="path1"
- style="stroke-width:1.8" />
- <polyline
- points="16 16 12 12 8 16"
- id="polyline2"
- transform="matrix(0.9,0,0,0.9,1.2001804,1.2002762)" />
-</svg>
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-cloud-upload"><path d="M12 13v8"/><path d="M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242"/><path d="m8 17 4-4 4 4"/></svg>
diff --git a/client/src/environments/environment.e2e.ts b/client/src/environments/environment.e2e.ts
deleted file mode 100644
index f92ccaf0db..0000000000
--- a/client/src/environments/environment.e2e.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export const environment = {
- production: false,
- hmr: false,
- apiUrl: 'http://127.0.0.1:9001',
- originServerUrl: 'http://127.0.0.1:9001'
-}
diff --git a/client/src/main.ts b/client/src/main.ts
index ef7e41fd4d..59cd329035 100644
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -63,78 +63,80 @@ if (environment.production) {
logger.registerServerSending(environment.apiUrl)
-const bootstrap = () => bootstrapApplication(AppComponent, {
- providers: [
- provideZoneChangeDetection({ eventCoalescing: true }),
-
- importProvidersFrom(
- BrowserModule,
- BrowserAnimationsModule,
- ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })
- ),
-
- provideHttpClient(),
-
- importProvidersFrom(
- LoadingBarHttpClientModule,
- LoadingBarModule,
- ToastModule,
- NgbModalModule
- ),
-
- getCoreProviders(),
- getMainProviders(),
- getFormProviders(),
-
- PreloadSelectedModulesList,
- { provide: RouteReuseStrategy, useClass: CustomReuseStrategy },
-
- provideRouter(routes,
- withPreloading(PreloadSelectedModulesList),
- withInMemoryScrolling({
- anchorScrolling: 'disabled',
- // Redefined in app component
- scrollPositionRestoration: 'disabled'
+const bootstrap = () =>
+ bootstrapApplication(AppComponent, {
+ providers: [
+ provideZoneChangeDetection({ eventCoalescing: true }),
+
+ importProvidersFrom(
+ BrowserModule,
+ BrowserAnimationsModule,
+ ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })
+ ),
+
+ provideHttpClient(),
+
+ importProvidersFrom(
+ LoadingBarHttpClientModule,
+ LoadingBarModule,
+ ToastModule,
+ NgbModalModule
+ ),
+
+ getCoreProviders(),
+ getMainProviders(),
+ getFormProviders(),
+
+ PreloadSelectedModulesList,
+ { provide: RouteReuseStrategy, useClass: CustomReuseStrategy },
+
+ provideRouter(
+ routes,
+ withPreloading(PreloadSelectedModulesList),
+ withInMemoryScrolling({
+ anchorScrolling: 'disabled',
+ // Redefined in app component
+ scrollPositionRestoration: 'disabled'
+ })
+ ),
+
+ {
+ provide: APP_BASE_HREF,
+ useValue: '/'
+ },
+ provideAppInitializer(() => {
+ const initializerFn = loadConfigFactory(inject(ServerService), inject(PluginService), inject(ThemeService), inject(RedirectService))
+
+ return initializerFn()
})
- ),
+ ]
+ })
+ .then(bootstrapModule => {
+ if (!environment.production) {
+ const applicationRef = bootstrapModule.injector.get(ApplicationRef)
+ const componentRef = applicationRef.components[0]
- {
- provide: APP_BASE_HREF,
- useValue: '/'
- },
- provideAppInitializer(() => {
- const initializerFn = loadConfigFactory(inject(ServerService), inject(PluginService), inject(ThemeService), inject(RedirectService))
+ // allows to run `ng.profiler.timeChangeDetection();`
+ enableDebugTools(componentRef)
+ }
- return initializerFn()
+ return bootstrapModule
})
- ]
-})
- .then(bootstrapModule => {
- if (!environment.production) {
- const applicationRef = bootstrapModule.injector.get(ApplicationRef)
- const componentRef = applicationRef.components[0]
-
- // allows to run `ng.profiler.timeChangeDetection();`
- enableDebugTools(componentRef)
- }
-
- return bootstrapModule
- })
- .catch(err => {
- try {
- logger.error(err)
- } catch (err2) {
- console.error('Cannot log error', { err, err2 })
- }
-
- // Ensure we display an "incompatible message" on Angular bootstrap error
- setTimeout(() => {
- if (document.querySelector('my-app').innerHTML === '') {
- throw err
+ .catch(err => {
+ try {
+ logger.error(err)
+ } catch (err2) {
+ console.error('Cannot log error', { err, err2 })
}
- }, 1000)
- return null as any
- })
+ // Ensure we display an "incompatible message" on Angular bootstrap error
+ setTimeout(() => {
+ if (document.querySelector('my-app').innerHTML === '') {
+ throw err
+ }
+ }, 1000)
+
+ return null as any
+ })
bootstrap()
diff --git a/client/src/root-helpers/plugins-manager.ts b/client/src/root-helpers/plugins-manager.ts
index c82836f9fc..c7b53d2e4a 100644
--- a/client/src/root-helpers/plugins-manager.ts
+++ b/client/src/root-helpers/plugins-manager.ts
@@ -1,8 +1,4 @@
/* eslint-disable @typescript-eslint/no-implied-eval */
-import debug from 'debug'
-import { firstValueFrom, ReplaySubject } from 'rxjs'
-import { first, shareReplay } from 'rxjs/operators'
-import { RegisterClientHelpers } from '../types/register-client-option.model'
import { getExternalAuthHref, getHookType, internalRunHook } from '@peertube/peertube-core-utils'
import {
ClientDoAction,
@@ -20,8 +16,11 @@ import {
RegisterClientVideoFieldOptions,
ServerConfigPlugin
} from '@peertube/peertube-models'
-import { environment } from '../environments/environment'
+import debug from 'debug'
+import { firstValueFrom, ReplaySubject } from 'rxjs'
+import { first, shareReplay } from 'rxjs/operators'
import { ClientScript } from '../types'
+import { RegisterClientHelpers } from '../types/register-client-option.model'
import { logger } from './logger'
interface HookStructValue extends RegisterClientHookOptions {
@@ -29,7 +28,7 @@ interface HookStructValue extends RegisterClientHookOptions {
clientScript: ClientScriptJSON
}
-type Hooks = { [ name: string ]: HookStructValue[] }
+type Hooks = { [name: string]: HookStructValue[] }
type PluginInfo = {
plugin: ServerConfigPlugin
@@ -55,13 +54,13 @@ const debugLogger = debug('peertube:plugins')
class PluginsManager {
private hooks: Hooks = {}
- private scopes: { [ scopeName: string ]: PluginInfo[] } = {}
+ private scopes: { [scopeName: string]: PluginInfo[] } = {}
- private loadedScripts: { [ script: string ]: boolean } = {}
+ private loadedScripts: { [script: string]: boolean } = {}
private loadedScopes: PluginClientScope[] = []
private loadingScopes: { [id in PluginClientScope]?: boolean } = {}
- private pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = {
+ private pluginsLoaded: { [scope in PluginClientScope]: ReplaySubject<boolean> } = {
'common': new ReplaySubject<boolean>(1),
'admin-plugin': new ReplaySubject<boolean>(1),
'search': new ReplaySubject<boolean>(1),
@@ -151,7 +150,7 @@ class PluginsManager {
this.loadPluginsByScope(scope)
const obs = this.pluginsLoaded[scope].asObservable()
- .pipe(first(), shareReplay())
+ .pipe(first(), shareReplay())
return firstValueFrom(obs)
}
@@ -284,7 +283,7 @@ class PluginsManager {
logger.info(`Loading script ${clientScript.script} of plugin ${plugin.name}`)
- const absURL = (this.backendUrl || environment.apiUrl || window.location.origin) + clientScript.script
+ const absURL = (this.backendUrl || window.location.origin) + clientScript.script
return dynamicImport(absURL)
.then((script: ClientScript) => {
return script.register({
@@ -311,11 +310,10 @@ class PluginsManager {
export {
PluginsManager,
-
- type PluginInfo,
- type PeertubeHelpersFactory,
type OnFormFields,
- type OnSettingsScripts
+ type OnSettingsScripts,
+ type PeertubeHelpersFactory,
+ type PluginInfo
}
// ---------------------------------------------------------------------------
diff --git a/client/src/sass/application.scss b/client/src/sass/application.scss
index a37c3ba14b..8cb4096bda 100644
--- a/client/src/sass/application.scss
+++ b/client/src/sass/application.scss
@@ -13,10 +13,7 @@
@use '_css-variables' as *;
@mixin main-col-expanded {
- --main-col-width: 100vw;
-
- width: calc(100% - #{$menu-collapsed-width});
- margin-inline-start: $menu-collapsed-width;
+ --menu-width: #{$menu-collapsed-width};
}
/* clears the ‘X’ from Chrome */
@@ -63,7 +60,7 @@ noscript,
}
strong {
- font-weight: $font-semibold;
+ font-weight: $font-bold;
}
input[readonly] {
@@ -85,14 +82,6 @@ button {
@include disable-outline;
}
-label,
-.label {
- font-weight: $font-bold;
- margin-bottom: 0.5rem;
- font-size: 18px;
- color: pvar(--fg-350);
-}
-
.pt-label-container {
margin-bottom: 0.5rem;
@@ -123,11 +112,15 @@ a:hover {
opacity: 0.8;
}
+a.pt {
+ text-decoration-color: pvar(--border-primary);
+ text-underline-offset: 0.25em;
+}
+
.main-col {
// Don't use rfs to get exact pixels
- margin-inline-start: $menu-width;
-
- width: calc(100% - #{$menu-width});
+ width: calc(100% - #{pvar(--menu-width)});
+ margin-inline-start: pvar(--menu-width);
outline: none;
.margin-content {
@@ -155,8 +148,7 @@ a:hover {
}
}
-.modal-open,
-.main-col.expanded {
+.modal-open {
overflow: hidden !important;
}
diff --git a/client/src/sass/bootstrap.scss b/client/src/sass/bootstrap.scss
index 8047ea7cfe..6765aab342 100644
--- a/client/src/sass/bootstrap.scss
+++ b/client/src/sass/bootstrap.scss
@@ -346,6 +346,11 @@ body {
border-top-right-radius: pvar(--input-border-radius) !important;
border-bottom-right-radius: pvar(--input-border-radius) !important;
}
+
+ .first-in-group {
+ border-top-left-radius: pvar(--input-border-radius) !important;
+ border-bottom-left-radius: pvar(--input-border-radius) !important;
+ }
}
.has-clear {
diff --git a/client/src/sass/class-helpers/_buttons.scss b/client/src/sass/class-helpers/_buttons.scss
index 602cbf02ba..5ab50580c1 100644
--- a/client/src/sass/class-helpers/_buttons.scss
+++ b/client/src/sass/class-helpers/_buttons.scss
@@ -38,6 +38,10 @@
@include tertiary-button;
}
+.button-as-link {
+ @include button-as-link;
+}
+
.danger-button {
@include danger-button;
}
diff --git a/client/src/sass/class-helpers/_forms.scss b/client/src/sass/class-helpers/_forms.scss
index 82f657be1d..ead7109a95 100644
--- a/client/src/sass/class-helpers/_forms.scss
+++ b/client/src/sass/class-helpers/_forms.scss
@@ -11,7 +11,7 @@
}
.form-group {
- margin-bottom: 1rem;
+ margin-bottom: 1.5rem;
}
.input-error:not(:focus) {
@@ -55,7 +55,7 @@
font-size: 14px;
margin-top: 10px;
- @include muted;
+ @include muted-2;
}
// Useful with a "reset" button
@@ -65,8 +65,26 @@
align-items: baseline;
}
+label,
+.label {
+ font-weight: $font-bold;
+ margin-bottom: 0.5rem;
+ font-size: 18px;
+ color: pvar(--fg-300);
+}
+
+.label-inline {
+ display: inline;
+ font-size: 1rem;
+ color: pvar(--fg-200);
+ font-weight: normal;
+ margin-bottom: 0;
+
+ @include margin-right(0.75rem);
+}
+
label + .form-group-description,
.label-container + .form-group-description {
margin-bottom: 10px;
- margin-top: 0;
+ margin-top: -0.5rem;
}
diff --git a/client/src/sass/class-helpers/_layout.scss b/client/src/sass/class-helpers/_layout.scss
index e8031d3ee0..3bba6b6d1b 100644
--- a/client/src/sass/class-helpers/_layout.scss
+++ b/client/src/sass/class-helpers/_layout.scss
@@ -59,3 +59,15 @@
display: none !important;
}
}
+
+.d-inline-block-mw {
+ @include on-mobile-main-col {
+ display: inline-block !important;
+ }
+}
+
+.d-inline-block-sw {
+ @include on-small-main-col {
+ display: none !important;
+ }
+}
diff --git a/client/src/sass/class-helpers/_text.scss b/client/src/sass/class-helpers/_text.scss
index 7a7b537dfc..9636f1db56 100644
--- a/client/src/sass/class-helpers/_text.scss
+++ b/client/src/sass/class-helpers/_text.scss
@@ -98,8 +98,13 @@
// ---------------------------------------------------------------------------
-.muted {
- @include muted;
+.muted,
+.muted-1 {
+ @include muted-1;
+}
+
+.muted-2 {
+ @include muted-2;
}
// ---------------------------------------------------------------------------
diff --git a/client/src/sass/class-helpers/_transform.scss b/client/src/sass/class-helpers/_transform.scss
new file mode 100644
index 0000000000..87fee89ae0
--- /dev/null
+++ b/client/src/sass/class-helpers/_transform.scss
@@ -0,0 +1,13 @@
+@use 'sass:color';
+@use '_badges' as *;
+@use '_icons' as *;
+@use '_variables' as *;
+@use '_mixins' as *;
+
+.scale-x--1 {
+ transform: scaleX(-1);
+}
+
+.scale-y--1 {
+ transform: scaleY(-1);
+}
diff --git a/client/src/sass/class-helpers/index.scss b/client/src/sass/class-helpers/index.scss
index c9c8dcba74..c52bed8c17 100644
--- a/client/src/sass/class-helpers/index.scss
+++ b/client/src/sass/class-helpers/index.scss
@@ -7,3 +7,4 @@
@use './_text';
@use './_layout';
@use './_position';
+@use './_transform';
diff --git a/client/src/sass/include/_badges.scss b/client/src/sass/include/_badges.scss
index 424e18fbcc..675b9ecc88 100644
--- a/client/src/sass/include/_badges.scss
+++ b/client/src/sass/include/_badges.scss
@@ -3,11 +3,11 @@
@mixin peertube-badge {
display: inline-block;
- border-radius: .25rem;
- padding: .25em .4em;
- font-size: 75%;
+ border-radius: 4px;
+ padding: 2px 6px;
+ font-size: 12px;
font-weight: $font-semibold;
- line-height: 1.1;
+ line-height: normal;
max-width: 100%;
white-space: normal;
word-break: normal;
@@ -39,29 +39,34 @@
&.badge-yellow,
&.badge-warning {
- background-color: #feedaf;
- color: #8a5340;
+ background-color: #FEEDAF;
+ color: #7E432E;
}
&.badge-brown {
- background-color: #ffd8b2;
- color: #805b36;
+ background-color: #FBC98D;
+ color: #7B2F1A;
}
&.badge-green,
&.badge-success {
- background-color: #c8e6c9;
- color: #256029;
+ background-color: #8FEBA4;
+ color: #213B2D;
}
&.badge-blue,
&.badge-info {
- background-color: #b3e5fc;
- color: #23547b;
+ background-color: #B3E4E6;
+ color: #273236;
}
&.badge-purple {
- background-color: #eccfff;
- color: #694382;
+ background-color: #DCBCFA;
+ color: #50386E;
+ }
+
+ &.badge-grey {
+ color: #2D3448;
+ background-color: #CBD7E0;
}
}
diff --git a/client/src/sass/include/_button-mixins.scss b/client/src/sass/include/_button-mixins.scss
index a65d61efff..3548fb9d11 100644
--- a/client/src/sass/include/_button-mixins.scss
+++ b/client/src/sass/include/_button-mixins.scss
@@ -99,7 +99,8 @@
cursor: default;
}
- &:active {
+ &:active,
+ &.active {
background-color: pvar(--bg-secondary-450);
}
@@ -117,9 +118,31 @@
}
}
+@mixin button-as-link {
+ border: 0;
+ padding: 0;
+ color: pvar(--fg);
+ text-decoration: underline;
+
+ &:hover {
+ color: pvar(--fg-300);
+ }
+}
+
@mixin rounded-icon-button {
padding: 0.5rem !important;
border-radius: 100% !important;
+
+ &.small-button {
+ padding: 6px !important;
+ line-height: 0 !important;
+
+ my-global-icon {
+ line-height: 0;
+
+ @include global-icon-size(12px);
+ }
+ }
}
@mixin danger-button {
@@ -154,7 +177,7 @@
font-size: $button-font-size;
line-height: 1.5;
- my-global-icon + *:not(:empty) {
+ &:not(.icon-only) my-global-icon + *:not(:empty) {
@include margin-left(8px);
}
diff --git a/client/src/sass/include/_css-variables.scss b/client/src/sass/include/_css-variables.scss
index 5e025caf3d..8e615e3269 100644
--- a/client/src/sass/include/_css-variables.scss
+++ b/client/src/sass/include/_css-variables.scss
@@ -8,6 +8,8 @@
--menu-bg: var(--menuBackgroundColor);
--menu-fg: var(--menuForegroundColor);
+ --menu-margin-left: #{$menu-margin-left};
+ --menu-width: #{$menu-width};
--fg: var(--mainForegroundColor, #000);
@@ -36,6 +38,8 @@
--input-border-radius: 4px;
+ --textarea-y-padding: 12px;
+ --textarea-x-padding: 15px;
--textarea-fg: var(--textareaForegroundColor, #{pvar(--input-fg)});
--textarea-bg: var(--textareaBackgroundColor, #{pvar(--input-bg)});
@@ -45,8 +49,6 @@
--x-margin-content: 2rem;
- --main-col-width: calc(100vw - #{$menu-width});
-
--secondary-icon-color: #{pvar(--fg-50)};
--active-icon-color: #{pvar(--on-primary)};
--active-icon-bg: #{pvar(--primary)};
@@ -58,36 +60,36 @@
--alert-primary-bg: #{pvar(--primary-200)};
--alert-primary-border-color: #{pvar(--primary-300)};
- --menu-margin-left: #{$menu-margin-left};
-
- --header-height: #{$header-height};
-
--embed-fg: #fff;
--embed-big-play-bg: rgba(0, 0, 0, 0.8);
- &.mobile-app-msg {
- --header-height: #{$header-height + $header-mobile-msg-height};
- }
-
--menu-fg: #{pvar(--fg-400)};
--menu-bg: #{pvar(--bg-secondary-400)};
- @media screen and (max-width: $small-view) {
- --header-height: #{$header-height-small-view};
+ // ---------------------------------------------------------------------------
- &.mobile-app-msg {
- --header-height: #{$header-height-small-view + $header-mobile-msg-height};
- }
+ --tmp-header-height: #{$header-height};
+
+ @media screen and (max-width: $small-view) {
+ --tmp-header-height: #{$header-height-small-view};
}
@media screen and (max-width: $mobile-view) {
- --header-height: #{$header-height-mobile-view};
+ --tmp-header-height: #{$header-height-mobile-view};
- &.mobile-app-msg {
- --header-height: #{$header-height-mobile-view + $header-mobile-msg-height};
+ &.global-search-hidden {
+ --tmp-header-height: #{$header-height-mobile-view-without-search};
}
}
+ --header-height: #{pvar(--tmp-header-height)};
+
+ &.mobile-app-msg {
+ --header-height: calc(#{pvar(--tmp-header-height)} + #{$header-mobile-msg-height});
+ }
+
+ // ---------------------------------------------------------------------------
+
// Light theme
&[data-pt-theme=peertube-core-light-beige],
&[data-pt-theme=default] {
diff --git a/client/src/sass/include/_form-mixins.scss b/client/src/sass/include/_form-mixins.scss
index c5a3a8497b..33e5cd0734 100644
--- a/client/src/sass/include/_form-mixins.scss
+++ b/client/src/sass/include/_form-mixins.scss
@@ -33,7 +33,8 @@
}
&[disabled] {
- opacity: 0.4;
+ color: pvar(--fg-300);
+ opacity: 0.8;
}
@media screen and (max-width: calc(#{$width} + 40px)) {
@@ -48,7 +49,7 @@
color: pvar(--textarea-fg) !important;
background-color: pvar(--textarea-bg) !important;
height: $height;
- padding: pvar(--input-y-padding) calc(#{pvar(--input-x-padding)} / 2);
+ padding: pvar(--textarea-y-padding) pvar(--textarea-x-padding);
}
}
@@ -102,7 +103,7 @@
}
&[disabled] {
- opacity: 0.4;
+ opacity: 0.5;
}
}
}
@@ -110,7 +111,7 @@
// Thanks: https://codepen.io/manabox/pen/raQmpL
@mixin peertube-radio-container {
&[disabled] {
- opacity: 0.4;
+ opacity: 0.5;
}
label {
@@ -255,7 +256,7 @@
&[disabled] + span,
&[disabled] + span + span {
- opacity: 0.4;
+ opacity: 0.5;
cursor: default;
}
}
diff --git a/client/src/sass/include/_mixins.scss b/client/src/sass/include/_mixins.scss
index 0f54c1d975..9c3301394a 100644
--- a/client/src/sass/include/_mixins.scss
+++ b/client/src/sass/include/_mixins.scss
@@ -48,10 +48,20 @@
text-overflow: ellipsis;
}
-@mixin muted {
+@mixin muted-1 {
color: pvar(--fg-300) !important;
}
+@mixin muted-2 {
+ color: pvar(--fg-200) !important;
+
+ a,
+ .fake-link {
+ color: pvar(--fg);
+ text-decoration: underline;
+ }
+}
+
@mixin fade-text ($fade-after, $background-color) {
position: relative;
overflow: hidden;
diff --git a/client/src/sass/include/_variables.scss b/client/src/sass/include/_variables.scss
index fbfb6b700f..0a0c481e3f 100644
--- a/client/src/sass/include/_variables.scss
+++ b/client/src/sass/include/_variables.scss
@@ -21,8 +21,9 @@ $white: #fff;
$button-font-size: 1rem;
$header-height: 94px;
-$header-height-small-view: 74px;
-$header-height-mobile-view: 124px;
+$header-height-small-view: 78px;
+$header-height-mobile-view: 128px;
+$header-height-mobile-view-without-search: 80px;
$header-mobile-msg-height: 48px;
$menu-width: 248px;
@@ -61,6 +62,8 @@ $video-thumbnail-small-width: 125px;
// ---------------------------------------------------------------------------
$instance-img-radius: 31%;
+$channel-avatar-radius: 5px;
+$account-avatar-radius: 50%;
// ---------------------------------------------------------------------------
@@ -84,7 +87,7 @@ $primeng-breakpoint: 960px;
$variables: (
--x-margin-content: var(--x-margin-content),
- --main-col-width: var(--main-col-width),
+ --tmp-header-height: var(--tmp-header-height),
--header-height: var(--header-height),
--fg: var(--fg),
@@ -109,6 +112,8 @@ $variables: (
--input-x-padding: var(--input-x-padding),
--input-y-padding: var(--input-y-padding),
+ --textarea-x-padding: var(--textarea-x-padding),
+ --textarea-y-padding: var(--textarea-y-padding),
--textarea-fg: var(--textarea-fg),
--textarea-bg: var(--textarea-bg),
@@ -166,6 +171,9 @@ $variables: (
--menu-bg-250: var(--menu-bg-250),
--menu-bg-200: var(--menu-bg-200),
+ --menu-margin-left: var(--menu-margin-left),
+ --menu-width: var(--menu-width),
+
--on-primary: var(--on-primary),
--on-primary-700: var(--on-primary-700),
--on-primary-650: var(--on-primary-650),
@@ -205,8 +213,6 @@ $variables: (
--alert-primary-bg: var(--alert-primary-bg),
--alert-primary-border-color: var(--alert-primary-border-color),
- --menu-margin-left: var(--menu-margin-left),
-
--embed-fg: var(--embed-fg),
--embed-big-play-bg: var(--embed-big-play-bg),
);
diff --git a/client/src/sass/primeng-custom.scss b/client/src/sass/primeng-custom.scss
index 664e3daf83..d508316c5c 100644
--- a/client/src/sass/primeng-custom.scss
+++ b/client/src/sass/primeng-custom.scss
@@ -13,7 +13,7 @@ input[type=button] {
}
p-table .p-datatable-header .caption {
- margin-bottom: 15px;
+ margin-bottom: 1rem;
}
// Taken from old nova light theme
@@ -544,12 +544,13 @@ p-chips.p-chips-clearable .p-chips-clear-icon {
}
.p-multiselect .p-multiselect-label {
padding: pvar(--input-y-padding) pvar(--input-x-padding);
- line-height: normal;
+ line-height: 1.5rem;
font-weight: normal;
transition: background-color 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.p-multiselect .p-multiselect-label.p-placeholder {
color: pvar(--input-placeholder);
+ font-size: 14px;
}
.p-multiselect.p-multiselect-chip .p-multiselect-token {
padding: 2px 7px;
@@ -770,7 +771,9 @@ p-table {
gap: 0.5rem;
.left-buttons {
- @include padding-left(1rem);
+ @include font-size(22px);
+
+ color: pvar(--fg-300);
}
}
}
@@ -790,16 +793,10 @@ p-table {
}
td {
- @include padding-left(15px !important);
+ @include padding-left(1rem !important);
&.expand-cell {
- padding: 10px 15px;
- }
-
- &:not(.action-cell):not(.expand-cell):not(.checkbox-cell) {
- overflow: hidden !important;
- text-overflow: ellipsis !important;
- white-space: nowrap !important;
+ padding: 10px 1rem;
}
}
@@ -896,6 +893,15 @@ p-table {
}
}
+ .checkbox-cell {
+ @include padding-left(0.25rem !important);
+ @include padding-right(0 !important);
+
+ @media screen and (max-width: $mobile-view) {
+ @include padding-left(0 !important);
+ }
+ }
+
.action-cell {
width: 250px !important;
@@ -1021,11 +1027,18 @@ p-table {
}
.pt-badge {
- font-size: 12px;
text-transform: uppercase;
}
}
+p-table:not(.cell-wrap) {
+ td:not(.action-cell):not(.expand-cell):not(.checkbox-cell) {
+ overflow: hidden !important;
+ text-overflow: ellipsis !important;
+ white-space: nowrap !important;
+ }
+}
+
// overflow data table
p-table {
.p-datatable-wrapper {
@@ -1060,6 +1073,32 @@ p-table {
}
}
+@media screen and (max-width: $primeng-breakpoint) {
+ p-table {
+ td {
+ &.expand-cell {
+ padding: 5px;
+ }
+ }
+ }
+}
+
+@media screen and (max-width: $mobile-view) {
+ p-table {
+ th,
+ td {
+ @include padding-left(0.5rem !important);
+ }
+
+ .p-datatable-header {
+ .caption > div {
+ width: 100%;
+ padding: 0 !important;
+ }
+ }
+ }
+}
+
p-tablecheckbox:hover div .p-checkbox-box {
box-shadow: 0 0 0 .1rem rgba(87, 85, 217, .2);
}
@@ -1153,38 +1192,6 @@ p-toast {
}
}
-@media screen and (max-width: $primeng-breakpoint) {
- p-table {
- td {
- padding: 3px 0;
-
- &.expand-cell {
- padding: 5px;
- }
- }
-
- .p-datatable-tbody {
-
- td:last-child {
- padding-bottom: 15px;
- margin-bottom: 15px;
- border-bottom: 1px solid $separator-border-color !important;
- }
- }
- }
-}
-
-@media screen and (max-width: $mobile-view) {
- p-table {
- .p-datatable-header {
- .caption > div {
- width: 100%;
- padding: 0 !important;
- }
- }
- }
-}
-
p-chips {
.p-input-wrapper {
display: flex;
@@ -1231,3 +1238,138 @@ p-chips {
min-height: 29px;
}
}
+
+// ---------------------------------------------------------------------------
+
+.new-p-table {
+ .column-toggle {
+ .tertiary-button:not(.active) {
+ color: pvar(--fg-300) !important;
+ }
+ }
+
+ &.loading table {
+ opacity: 0.5;
+ }
+
+ thead {
+ tr {
+ height: 1.5rem;
+ }
+ }
+
+ th {
+ font-size: 14px !important;
+ color: pvar(--fg-200) !important;
+ font-weight: normal !important;
+
+ &.p-highlight {
+ background-color: pvar(--bg) !important;
+ }
+
+ .column-toggle {
+ .dropdown > my-button::after {
+ display: none;
+ }
+ }
+ }
+
+ th,
+ .p-paginator {
+ border-color: pvar(--bg-secondary-450) !important;
+ }
+
+ .p-sortable-column-icon {
+ display: inline-block;
+ position: relative;
+ top: -1px;
+
+ .tertiary-button:not(.active) {
+ color: pvar(--secondary-icon-color) !important;
+ }
+ }
+
+ p-paginator {
+ .p-paginator {
+ padding-top: 1.5rem;
+ margin-top: 0.75rem;
+ height: auto !important;
+
+ .p-paginator-pages {
+ .p-paginator-page {
+ font-weight: normal !important;
+ height: 34px !important;
+ width: 34px !important;
+ border-radius: 100% !important;
+
+ &.p-highlight {
+ &, &:hover, &:active, &:focus {
+ background-color: pvar(--bg-secondary-450) !important;
+ color: pvar(--fg) !important;
+ font-weight: $font-bold !important;
+ }
+ }
+ }
+ }
+
+ .p-dropdown,
+ .p-dropdown-trigger {
+ color: pvar(--input-fg);
+ background-color: pvar(--input-bg);
+ }
+
+ .p-paginator-element .p-icon-wrapper {
+ color: pvar(--fg-300) !important;
+ }
+ }
+ }
+
+ .p-paginator-right-content {
+ margin-left: 0;
+ margin-right: 0;
+ color: pvar(--fg-300);
+
+ @include margin-left(1rem);
+ }
+
+ .action-cell {
+ width: 0 !important;
+
+ @include padding-right(0.25rem);
+ }
+}
+
+.sticky-p-table {
+ table {
+ table-layout: auto;
+ }
+
+ @media screen and (min-width: $small-view) {
+ .action-cell,
+ .action-head {
+ position: sticky;
+ right: 0;
+ background-color: inherit;
+ }
+
+ .action-cell {
+ z-index: 10;
+ }
+ }
+
+ thead th {
+ position: sticky;
+ top: 0;
+ z-index: 20;
+ background-color: pvar(--bg);
+ }
+
+ .p-datatable,
+ .p-datatable-wrapper {
+ max-height: inherit;
+ }
+
+ .p-datatable-wrapper {
+ overflow: auto;
+ }
+}
diff --git a/client/src/types/select-options-item.model.ts b/client/src/types/select-options-item.model.ts
index 17450c752d..aa0767c7ee 100644
--- a/client/src/types/select-options-item.model.ts
+++ b/client/src/types/select-options-item.model.ts
@@ -1,5 +1,5 @@
-export interface SelectOptionsItem {
- id: string | number
+export interface SelectOptionsItem<T = string | number> {
+ id: T
label: string
description?: string
@@ -9,6 +9,7 @@ export interface SelectOptionsItem {
export interface SelectChannelItem extends SelectOptionsItem {
id: number // Force number
- avatarPath?: string
- support?: string
+ name: string
+ avatarPath: string
+ support: string
}
diff --git a/client/src/types/type-helpers.ts b/client/src/types/type-helpers.ts
new file mode 100644
index 0000000000..025ecde7b2
--- /dev/null
+++ b/client/src/types/type-helpers.ts
@@ -0,0 +1,8 @@
+/* eslint-disable @typescript-eslint/array-type */
+import { FormArray, FormControl, FormGroup } from '@angular/forms'
+
+type Unbox<T> = T extends Array<infer V> ? V : T
+
+export type ModelFormGroup<T> = FormGroup<
+ { [K in keyof T]: T[K] extends Array<any> ? FormArray<FormControl<Unbox<T[K]>>> : FormControl<T[K]> }
+>
diff --git a/client/yarn.lock b/client/yarn.lock
index 9d736b04a8..bcd09565b7 100644
--- a/client/yarn.lock
+++ b/client/yarn.lock
@@ -9203,6 +9203,11 @@ type-fest@^4.2.0:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.33.0.tgz#2da0c135b9afa76cf8b18ecfd4f260ecd414a432"
integrity sha512-s6zVrxuyKbbAsSAD5ZPTB77q4YIdRctkTbJ2/Dqlinwz+8ooH2gd+YA7VA6Pa93KML9GockVvoxjZ2vHP+mu8g==
+type-fest@^4.37.0:
+ version "4.37.0"
+ resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.37.0.tgz#7cf008bf77b63a33f7ca014fa2a3f09fd69e8937"
+ integrity sha512-S/5/0kFftkq27FPNye0XM1e2NsnoD/3FS+pBmbjmmtLT6I+i344KoOf7pvXreaFsDamWeaJX55nczA1m5PsBDg==
+
typed-array-buffer@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz#a72395450a4869ec033fd549371b47af3a2ee536"
diff --git a/config/dev.yaml b/config/dev.yaml
index 6903103331..2ca02149e7 100644
--- a/config/dev.yaml
+++ b/config/dev.yaml
@@ -106,6 +106,11 @@ import:
instance:
default_nsfw_policy: 'display'
+# Set by API when the field is not provided and put as default value in client
+defaults:
+ publish:
+ licence: 2
+
plugins:
index:
check_latest_versions_interval: '10 minutes'
diff --git a/package.json b/package.json
index 3599cf4ce3..671be56d79 100644
--- a/package.json
+++ b/package.json
@@ -256,6 +256,7 @@
"swagger-cli": "^4.0.2",
"tsc-watch": "^6.0.0",
"tsx": "^4.7.1",
+ "type-fest": "^4.37.0",
"typescript": "~5.5.2"
}
}
diff --git a/packages/core-utils/src/common/object.ts b/packages/core-utils/src/common/object.ts
index 1276bfcc7c..0d6f1bc057 100644
--- a/packages/core-utils/src/common/object.ts
+++ b/packages/core-utils/src/common/object.ts
@@ -1,4 +1,6 @@
-function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> {
+import { Jsonify } from 'type-fest'
+
+export function pick<O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> {
const result: any = {}
for (const key of keys) {
@@ -10,7 +12,7 @@ function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick
return result
}
-function omit <O extends object, K extends keyof O> (object: O, keys: K[]): Exclude<O, K> {
+export function omit<O extends object, K extends keyof O> (object: O, keys: K[]): Exclude<O, K> {
const result: any = {}
const keysSet = new Set(keys) as Set<string>
@@ -23,19 +25,19 @@ function omit <O extends object, K extends keyof O> (object: O, keys: K[]): Excl
return result
}
-function objectKeysTyped <O extends object, K extends keyof O> (object: O): K[] {
+export function objectKeysTyped<O extends object, K extends keyof O> (object: O): K[] {
return (Object.keys(object) as K[])
}
-function getKeys <O extends object, K extends keyof O> (object: O, keys: K[]): K[] {
+export function getKeys<O extends object, K extends keyof O> (object: O, keys: K[]): K[] {
return (Object.keys(object) as K[]).filter(k => keys.includes(k))
}
-function hasKey <T extends object> (obj: T, k: keyof any): k is keyof T {
+export function hasKey<T extends object> (obj: T, k: keyof any): k is keyof T {
return k in obj
}
-function sortObjectComparator (key: string, order: 'asc' | 'desc') {
+export function sortObjectComparator (key: string, order: 'asc' | 'desc') {
return (a: any, b: any) => {
if (a[key] < b[key]) {
return order === 'asc' ? -1 : 1
@@ -49,12 +51,19 @@ function sortObjectComparator (key: string, order: 'asc' | 'desc') {
}
}
-function shallowCopy <T> (o: T): T {
+export function shallowCopy<T> (o: T): T {
return Object.assign(Object.create(Object.getPrototypeOf(o)), o)
}
-function simpleObjectsDeepEqual (a: any, b: any) {
- if (a === b) return true
+export function exists (value: any) {
+ return value !== undefined && value !== null
+}
+
+// ---------------------------------------------------------------------------
+
+export function simpleObjectsDeepEqual<T, U> (a: Jsonify<T>, b: Jsonify<U>) {
+ if (a as any === b as any) return true
+ if (a === undefined && b === undefined) return true
if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {
return false
@@ -73,14 +82,3 @@ function simpleObjectsDeepEqual (a: any, b: any) {
return true
}
-
-export {
- pick,
- omit,
- objectKeysTyped,
- getKeys,
- hasKey,
- shallowCopy,
- sortObjectComparator,
- simpleObjectsDeepEqual
-}
diff --git a/packages/core-utils/src/common/url.ts b/packages/core-utils/src/common/url.ts
index 5eb00e54b3..405c3877f8 100644
--- a/packages/core-utils/src/common/url.ts
+++ b/packages/core-utils/src/common/url.ts
@@ -103,6 +103,8 @@ function decorateVideoLink (options: {
p2p?: boolean
api?: boolean
+
+ version?: number
}) {
const { url } = options
@@ -134,6 +136,8 @@ function decorateVideoLink (options: {
if (options.api !== undefined) params.set('api', options.api ? '1' : '0')
+ if (options.version !== undefined) params.set('v', options.version + '')
+
return buildUrl(url, params)
}
diff --git a/packages/core-utils/src/videos/index.ts b/packages/core-utils/src/videos/index.ts
index 7d3dacdd41..e984b6c1f2 100644
--- a/packages/core-utils/src/videos/index.ts
+++ b/packages/core-utils/src/videos/index.ts
@@ -1,2 +1,3 @@
export * from './bitrate.js'
export * from './common.js'
+export * from './state.js'
diff --git a/packages/core-utils/src/videos/state.ts b/packages/core-utils/src/videos/state.ts
new file mode 100644
index 0000000000..7332e2d7c8
--- /dev/null
+++ b/packages/core-utils/src/videos/state.ts
@@ -0,0 +1,12 @@
+import { VideoState, VideoStateType } from '@peertube/peertube-models'
+
+export function canVideoFileBeEdited (state: VideoStateType) {
+ const validStates = new Set<VideoStateType>([
+ VideoState.PUBLISHED,
+ VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED,
+ VideoState.TO_MOVE_TO_FILE_SYSTEM_FAILED,
+ VideoState.TRANSCODING_FAILED
+ ])
+
+ return validStates.has(state)
+}
diff --git a/packages/models/src/moderation/abuse/abuse.model.ts b/packages/models/src/moderation/abuse/abuse.model.ts
index 253a3f44c3..8c24901d13 100644
--- a/packages/models/src/moderation/abuse/abuse.model.ts
+++ b/packages/models/src/moderation/abuse/abuse.model.ts
@@ -8,6 +8,7 @@ export interface AdminVideoAbuse {
id: number
name: string
uuid: string
+ shortUUID: string
nsfw: boolean
deleted: boolean
@@ -66,5 +67,7 @@ export type UserVideoAbuse = Omit<AdminVideoAbuse, 'countReports' | 'nthReport'>
export type UserVideoCommentAbuse = AdminVideoCommentAbuse
-export type UserAbuse = Omit<AdminAbuse, 'reporterAccount' | 'countReportsForReportee' | 'countReportsForReporter' | 'startAt' | 'endAt'
-| 'count' | 'nth' | 'moderationComment'>
+export type UserAbuse = Omit<
+ AdminAbuse,
+ 'reporterAccount' | 'countReportsForReportee' | 'countReportsForReporter' | 'startAt' | 'endAt' | 'count' | 'nth' | 'moderationComment'
+>
diff --git a/packages/models/src/videos/video-create.model.ts b/packages/models/src/videos/video-create.model.ts
index 6fa72fde01..8179a47054 100644
--- a/packages/models/src/videos/video-create.model.ts
+++ b/packages/models/src/videos/video-create.model.ts
@@ -25,8 +25,8 @@ export interface VideoCreate {
originallyPublishedAt?: Date | string
videoPasswords?: string[]
- thumbnailfile?: Blob | string
- previewfile?: Blob | string
+ thumbnailfile?: Blob
+ previewfile?: Blob
// Default is true if the feature is enabled by the instance admin
generateTranscription?: boolean
diff --git a/packages/server-commands/src/videos/live-command.ts b/packages/server-commands/src/videos/live-command.ts
index 407d9dc732..f6a7a0e7a4 100644
--- a/packages/server-commands/src/videos/live-command.ts
+++ b/packages/server-commands/src/videos/live-command.ts
@@ -23,10 +23,11 @@ import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'
import { sendRTMPStream, testFfmpegStreamError } from './live.js'
export class LiveCommand extends AbstractCommand {
-
- get (options: OverrideCommandOptions & {
- videoId: number | string
- }) {
+ get (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ }
+ ) {
const path = '/api/v1/videos/live'
return this.getRequestBody<LiveVideo>({
@@ -40,9 +41,11 @@ export class LiveCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- listSessions (options: OverrideCommandOptions & {
- videoId: number | string
- }) {
+ listSessions (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ }
+ ) {
const path = `/api/v1/videos/live/${options.videoId}/sessions`
return this.getRequestBody<ResultList<LiveVideoSession>>({
@@ -54,17 +57,21 @@ export class LiveCommand extends AbstractCommand {
})
}
- async findLatestSession (options: OverrideCommandOptions & {
- videoId: number | string
- }) {
+ async findLatestSession (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ }
+ ) {
const { data: sessions } = await this.listSessions(options)
return sessions[sessions.length - 1]
}
- getReplaySession (options: OverrideCommandOptions & {
- videoId: number | string
- }) {
+ getReplaySession (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ }
+ ) {
const path = `/api/v1/videos/${options.videoId}/live-session`
return this.getRequestBody<LiveVideoSession>({
@@ -78,10 +85,12 @@ export class LiveCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- update (options: OverrideCommandOptions & {
- videoId: number | string
- fields: LiveVideoUpdate
- }) {
+ update (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ fields: LiveVideoUpdate
+ }
+ ) {
const { videoId, fields } = options
const path = '/api/v1/videos/live'
@@ -95,9 +104,11 @@ export class LiveCommand extends AbstractCommand {
})
}
- async create (options: OverrideCommandOptions & {
- fields: LiveVideoCreate
- }) {
+ async create (
+ options: OverrideCommandOptions & {
+ fields: Omit<LiveVideoCreate, 'thumbnailfile' | 'previewfile'> & { thumbnailfile?: string | Blob, previewfile?: string | Blob }
+ }
+ ) {
const { fields } = options
const path = '/api/v1/videos/live'
@@ -118,13 +129,15 @@ export class LiveCommand extends AbstractCommand {
return body.video
}
- async quickCreate (options: OverrideCommandOptions & {
- saveReplay: boolean
- permanentLive: boolean
- name?: string
- privacy?: VideoPrivacyType
- videoPasswords?: string[]
- }) {
+ async quickCreate (
+ options: OverrideCommandOptions & {
+ saveReplay: boolean
+ permanentLive: boolean
+ name?: string
+ privacy?: VideoPrivacyType
+ videoPasswords?: string[]
+ }
+ ) {
const { name = 'live', saveReplay, permanentLive, privacy = VideoPrivacy.PUBLIC, videoPasswords } = options
const replaySettings = privacy === VideoPrivacy.PASSWORD_PROTECTED
@@ -153,22 +166,26 @@ export class LiveCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- async sendRTMPStreamInVideo (options: OverrideCommandOptions & {
- videoId: number | string
- fixtureName?: string
- copyCodecs?: boolean
- }) {
+ async sendRTMPStreamInVideo (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ fixtureName?: string
+ copyCodecs?: boolean
+ }
+ ) {
const { videoId, fixtureName, copyCodecs } = options
const videoLive = await this.get({ videoId })
return sendRTMPStream({ rtmpBaseUrl: videoLive.rtmpUrl, streamKey: videoLive.streamKey, fixtureName, copyCodecs })
}
- async runAndTestStreamError (options: OverrideCommandOptions & {
- videoId: number | string
- shouldHaveError: boolean
- fixtureName?: string
- }) {
+ async runAndTestStreamError (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ shouldHaveError: boolean
+ fixtureName?: string
+ }
+ ) {
const command = await this.sendRTMPStreamInVideo(options)
return testFfmpegStreamError(command, options.shouldHaveError)
@@ -176,35 +193,43 @@ export class LiveCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- waitUntilPublished (options: OverrideCommandOptions & {
- videoId: number | string
- }) {
+ waitUntilPublished (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ }
+ ) {
const { videoId } = options
return this.waitUntilState({ videoId, state: VideoState.PUBLISHED })
}
- waitUntilWaiting (options: OverrideCommandOptions & {
- videoId: number | string
- }) {
+ waitUntilWaiting (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ }
+ ) {
const { videoId } = options
return this.waitUntilState({ videoId, state: VideoState.WAITING_FOR_LIVE })
}
- waitUntilEnded (options: OverrideCommandOptions & {
- videoId: number | string
- }) {
+ waitUntilEnded (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ }
+ ) {
const { videoId } = options
return this.waitUntilState({ videoId, state: VideoState.LIVE_ENDED })
}
- async waitUntilSegmentGeneration (options: OverrideCommandOptions & {
- server: PeerTubeServer
- videoUUID: string
- playlistNumber: number
- segment: number
- objectStorage?: ObjectStorageCommand
- objectStorageBaseUrl?: string
- }) {
+ async waitUntilSegmentGeneration (
+ options: OverrideCommandOptions & {
+ server: PeerTubeServer
+ videoUUID: string
+ playlistNumber: number
+ segment: number
+ objectStorage?: ObjectStorageCommand
+ objectStorageBaseUrl?: string
+ }
+ ) {
const {
server,
objectStorage,
@@ -253,9 +278,11 @@ export class LiveCommand extends AbstractCommand {
}
}
- async waitUntilReplacedByReplay (options: OverrideCommandOptions & {
- videoId: number | string
- }) {
+ async waitUntilReplacedByReplay (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ }
+ ) {
let video: VideoDetails
do {
@@ -267,12 +294,14 @@ export class LiveCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- getSegmentFile (options: OverrideCommandOptions & {
- videoUUID: string
- playlistNumber: number
- segment: number
- objectStorage?: ObjectStorageCommand
- }) {
+ getSegmentFile (
+ options: OverrideCommandOptions & {
+ videoUUID: string
+ playlistNumber: number
+ segment: number
+ objectStorage?: ObjectStorageCommand
+ }
+ ) {
const { playlistNumber, segment, videoUUID, objectStorage } = options
const segmentName = `${playlistNumber}-00000${segment}.ts`
@@ -291,11 +320,13 @@ export class LiveCommand extends AbstractCommand {
})
}
- getPlaylistFile (options: OverrideCommandOptions & {
- videoUUID: string
- playlistName: string
- objectStorage?: ObjectStorageCommand
- }) {
+ getPlaylistFile (
+ options: OverrideCommandOptions & {
+ videoUUID: string
+ playlistName: string
+ objectStorage?: ObjectStorageCommand
+ }
+ ) {
const { playlistName, videoUUID, objectStorage } = options
const baseUrl = objectStorage
@@ -315,9 +346,11 @@ export class LiveCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- async countPlaylists (options: OverrideCommandOptions & {
- videoUUID: string
- }) {
+ async countPlaylists (
+ options: OverrideCommandOptions & {
+ videoUUID: string
+ }
+ ) {
const basePath = this.server.servers.buildDirectory('streaming-playlists')
const hlsPath = join(basePath, 'hls', options.videoUUID)
@@ -326,10 +359,12 @@ export class LiveCommand extends AbstractCommand {
return files.filter(f => f.endsWith('.m3u8')).length
}
- private async waitUntilState (options: OverrideCommandOptions & {
- videoId: number | string
- state: VideoStateType
- }) {
+ private async waitUntilState (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ state: VideoStateType
+ }
+ ) {
let video: VideoDetails
do {
diff --git a/packages/server-commands/src/videos/videos-command.ts b/packages/server-commands/src/videos/videos-command.ts
index c7a588d22d..e3b33a2ac3 100644
--- a/packages/server-commands/src/videos/videos-command.ts
+++ b/packages/server-commands/src/videos/videos-command.ts
@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
-import validator from 'validator'
import { getAllPrivacies, omit, pick, wait } from '@peertube/peertube-core-utils'
import {
HttpStatusCode,
- HttpStatusCodeType, ResultList,
+ HttpStatusCodeType,
+ ResultList,
UserVideoRateType,
Video,
VideoCommentPolicy,
@@ -20,6 +20,7 @@ import {
VideoTranscodingCreate
} from '@peertube/peertube-models'
import { buildAbsoluteFixturePath, buildUUID } from '@peertube/peertube-node-utils'
+import validator from 'validator'
import { unwrapBody } from '../requests/index.js'
import { waitJobs } from '../server/jobs.js'
import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'
@@ -31,7 +32,6 @@ export type VideoEdit = Partial<Omit<VideoCreate, 'thumbnailfile' | 'previewfile
}
export class VideosCommand extends AbstractCommand {
-
getCategories (options: OverrideCommandOptions = {}) {
const path = '/api/v1/videos/categories'
@@ -82,9 +82,11 @@ export class VideosCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- getFileMetadata (options: OverrideCommandOptions & {
- url: string
- }) {
+ getFileMetadata (
+ options: OverrideCommandOptions & {
+ url: string
+ }
+ ) {
return unwrapBody<VideoFileMetadata>(this.getRawRequest({
...options,
@@ -96,11 +98,13 @@ export class VideosCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- rate (options: OverrideCommandOptions & {
- id: number | string
- rating: UserVideoRateType
- videoPassword?: string
- }) {
+ rate (
+ options: OverrideCommandOptions & {
+ id: number | string
+ rating: UserVideoRateType
+ videoPassword?: string
+ }
+ ) {
const { id, rating, videoPassword } = options
const path = '/api/v1/videos/' + id + '/rate'
@@ -117,9 +121,11 @@ export class VideosCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- get (options: OverrideCommandOptions & {
- id: number | string
- }) {
+ get (
+ options: OverrideCommandOptions & {
+ id: number | string
+ }
+ ) {
const path = '/api/v1/videos/' + options.id
return this.getRequestBody<VideoDetails>({
@@ -131,9 +137,11 @@ export class VideosCommand extends AbstractCommand {
})
}
- getWithToken (options: OverrideCommandOptions & {
- id: number | string
- }) {
+ getWithToken (
+ options: OverrideCommandOptions & {
+ id: number | string
+ }
+ ) {
return this.get({
...options,
@@ -141,15 +149,17 @@ export class VideosCommand extends AbstractCommand {
})
}
- getWithPassword (options: OverrideCommandOptions & {
- id: number | string
- password?: string
- }) {
+ getWithPassword (
+ options: OverrideCommandOptions & {
+ id: number | string
+ password?: string
+ }
+ ) {
const path = '/api/v1/videos/' + options.id
return this.getRequestBody<VideoDetails>({
...options,
- headers:{
+ headers: {
'x-peertube-video-password': options.password
},
path,
@@ -158,9 +168,11 @@ export class VideosCommand extends AbstractCommand {
})
}
- getSource (options: OverrideCommandOptions & {
- id: number | string
- }) {
+ getSource (
+ options: OverrideCommandOptions & {
+ id: number | string
+ }
+ ) {
const path = '/api/v1/videos/' + options.id + '/source'
return this.getRequestBody<VideoSource>({
@@ -172,9 +184,11 @@ export class VideosCommand extends AbstractCommand {
})
}
- deleteSource (options: OverrideCommandOptions & {
- id: number | string
- }) {
+ deleteSource (
+ options: OverrideCommandOptions & {
+ id: number | string
+ }
+ ) {
const path = '/api/v1/videos/' + options.id + '/source/file'
return this.deleteRequest({
@@ -186,9 +200,11 @@ export class VideosCommand extends AbstractCommand {
})
}
- async getId (options: OverrideCommandOptions & {
- uuid: number | string
- }) {
+ async getId (
+ options: OverrideCommandOptions & {
+ uuid: number | string
+ }
+ ) {
const { uuid } = options
if (validator.default.isUUID('' + uuid) === false) return uuid as number
@@ -198,9 +214,11 @@ export class VideosCommand extends AbstractCommand {
return id
}
- async listFiles (options: OverrideCommandOptions & {
- id: number | string
- }) {
+ async listFiles (
+ options: OverrideCommandOptions & {
+ id: number | string
+ }
+ ) {
const video = await this.get(options)
const files = video.files || []
@@ -211,22 +229,14 @@ export class VideosCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- listMyVideos (options: OverrideCommandOptions & {
- start?: number
- count?: number
- sort?: string
- search?: string
- isLive?: boolean
- channelId?: number
- autoTagOneOf?: string[]
- } = {}) {
+ listMyVideos (options: OverrideCommandOptions & VideosCommonQuery & { channelId?: number, channelNameOneOf?: string[] } = {}) {
const path = '/api/v1/users/me/videos'
return this.getRequestBody<ResultList<Video>>({
...options,
path,
- query: pick(options, [ 'start', 'count', 'sort', 'search', 'isLive', 'channelId', 'autoTagOneOf' ]),
+ query: { ...this.buildListQuery(options), ...pick(options, [ 'channelId', 'channelNameOneOf' ]) },
implicitToken: true,
defaultExpectedStatus: HttpStatusCode.OK_200
})
@@ -287,9 +297,11 @@ export class VideosCommand extends AbstractCommand {
})
}
- listByAccount (options: OverrideCommandOptions & VideosCommonQuery & {
- handle: string
- }) {
+ listByAccount (
+ options: OverrideCommandOptions & VideosCommonQuery & {
+ handle: string
+ }
+ ) {
const { handle, search } = options
const path = '/api/v1/accounts/' + handle + '/videos'
@@ -303,9 +315,11 @@ export class VideosCommand extends AbstractCommand {
})
}
- listByChannel (options: OverrideCommandOptions & VideosCommonQuery & {
- handle: string
- }) {
+ listByChannel (
+ options: OverrideCommandOptions & VideosCommonQuery & {
+ handle: string
+ }
+ ) {
const { handle } = options
const path = '/api/v1/video-channels/' + handle + '/videos'
@@ -321,17 +335,21 @@ export class VideosCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- async find (options: OverrideCommandOptions & {
- name: string
- }) {
+ async find (
+ options: OverrideCommandOptions & {
+ name: string
+ }
+ ) {
const { data } = await this.list(options)
return data.find(v => v.name === options.name)
}
- async findFull (options: OverrideCommandOptions & {
- name: string
- }) {
+ async findFull (
+ options: OverrideCommandOptions & {
+ name: string
+ }
+ ) {
const { uuid } = await this.find(options)
return this.get({ id: uuid })
@@ -339,10 +357,12 @@ export class VideosCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- update (options: OverrideCommandOptions & {
- id: number | string
- attributes?: VideoEdit
- }) {
+ update (
+ options: OverrideCommandOptions & {
+ id: number | string
+ attributes?: VideoEdit
+ }
+ ) {
const { id, attributes = {} } = options
const path = '/api/v1/videos/' + id
@@ -376,9 +396,11 @@ export class VideosCommand extends AbstractCommand {
})
}
- remove (options: OverrideCommandOptions & {
- id: number | string
- }) {
+ remove (
+ options: OverrideCommandOptions & {
+ id: number | string
+ }
+ ) {
const path = '/api/v1/videos/' + options.id
return unwrapBody(this.deleteRequest({
@@ -462,9 +484,11 @@ export class VideosCommand extends AbstractCommand {
return created
}
- async buildLegacyUpload (options: OverrideCommandOptions & {
- attributes: VideoEdit
- }): Promise<VideoCreateResult> {
+ async buildLegacyUpload (
+ options: OverrideCommandOptions & {
+ attributes: VideoEdit
+ }
+ ): Promise<VideoCreateResult> {
const path = '/api/v1/videos/upload'
return unwrapBody<{ video: VideoCreateResult }>(this.postUploadRequest({
@@ -478,14 +502,16 @@ export class VideosCommand extends AbstractCommand {
})).then(body => body.video || body as any)
}
- quickUpload (options: OverrideCommandOptions & {
- name: string
- nsfw?: boolean
- privacy?: VideoPrivacyType
- fixture?: string
- videoPasswords?: string[]
- channelId?: number
- }) {
+ quickUpload (
+ options: OverrideCommandOptions & {
+ name: string
+ nsfw?: boolean
+ privacy?: VideoPrivacyType
+ fixture?: string
+ videoPasswords?: string[]
+ channelId?: number
+ }
+ ) {
const attributes: VideoEdit = { name: options.name }
if (options.nsfw) attributes.nsfw = options.nsfw
if (options.privacy) attributes.privacy = options.privacy
@@ -515,11 +541,13 @@ export class VideosCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- replaceSourceFile (options: OverrideCommandOptions & {
- videoId: number | string
- fixture: string
- completedExpectedStatus?: HttpStatusCodeType
- }) {
+ replaceSourceFile (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ fixture: string
+ completedExpectedStatus?: HttpStatusCodeType
+ }
+ ) {
return this.buildResumeUpload({
...options,
@@ -530,9 +558,11 @@ export class VideosCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- removeHLSPlaylist (options: OverrideCommandOptions & {
- videoId: number | string
- }) {
+ removeHLSPlaylist (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ }
+ ) {
const path = '/api/v1/videos/' + options.videoId + '/hls'
return this.deleteRequest({
@@ -544,10 +574,12 @@ export class VideosCommand extends AbstractCommand {
})
}
- removeHLSFile (options: OverrideCommandOptions & {
- videoId: number | string
- fileId: number
- }) {
+ removeHLSFile (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ fileId: number
+ }
+ ) {
const path = '/api/v1/videos/' + options.videoId + '/hls/' + options.fileId
return this.deleteRequest({
@@ -559,9 +591,11 @@ export class VideosCommand extends AbstractCommand {
})
}
- removeAllWebVideoFiles (options: OverrideCommandOptions & {
- videoId: number | string
- }) {
+ removeAllWebVideoFiles (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ }
+ ) {
const path = '/api/v1/videos/' + options.videoId + '/web-videos'
return this.deleteRequest({
@@ -573,10 +607,12 @@ export class VideosCommand extends AbstractCommand {
})
}
- removeWebVideoFile (options: OverrideCommandOptions & {
- videoId: number | string
- fileId: number
- }) {
+ removeWebVideoFile (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ fileId: number
+ }
+ ) {
const path = '/api/v1/videos/' + options.videoId + '/web-videos/' + options.fileId
return this.deleteRequest({
@@ -588,9 +624,11 @@ export class VideosCommand extends AbstractCommand {
})
}
- runTranscoding (options: OverrideCommandOptions & VideoTranscodingCreate & {
- videoId: number | string
- }) {
+ runTranscoding (
+ options: OverrideCommandOptions & VideoTranscodingCreate & {
+ videoId: number | string
+ }
+ ) {
const path = '/api/v1/videos/' + options.videoId + '/transcoding'
return this.postBodyRequest({
@@ -632,7 +670,7 @@ export class VideosCommand extends AbstractCommand {
}
buildUploadAttaches (attributes: VideoEdit, includeFixture: boolean) {
- const attaches: { [ name: string ]: string } = {}
+ const attaches: { [name: string]: string } = {}
for (const key of [ 'thumbnailfile', 'previewfile' ]) {
if (attributes[key]) attaches[key] = buildAbsoluteFixturePath(attributes[key])
@@ -666,11 +704,13 @@ export class VideosCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
- generateDownload (options: OverrideCommandOptions & {
- videoId: number | string
- videoFileIds: number[]
- query?: Record<string, string>
- }) {
+ generateDownload (
+ options: OverrideCommandOptions & {
+ videoId: number | string
+ videoFileIds: number[]
+ query?: Record<string, string>
+ }
+ ) {
const { videoFileIds, videoId, query = {} } = options
const path = '/download/videos/generate/' + videoId
diff --git a/packages/tests/src/api/check-params/videos-common-filters.ts b/packages/tests/src/api/check-params/videos-common-filters.ts
index 95860ba39c..3920d9b72f 100644
--- a/packages/tests/src/api/check-params/videos-common-filters.ts
+++ b/packages/tests/src/api/check-params/videos-common-filters.ts
@@ -44,7 +44,6 @@ describe('Test video filters validators', function () {
})
describe('When setting video filters', function () {
-
const validIncludes = [
VideoInclude.NONE,
VideoInclude.BLOCKED_OWNER,
@@ -70,6 +69,10 @@ describe('Test video filters validators', function () {
'/api/v1/search/videos'
]
+ if (options.unauthenticatedUser !== true) {
+ paths.push('/api/v1/users/me/videos')
+ }
+
for (const path of paths) {
const token = options.unauthenticatedUser
? undefined
diff --git a/packages/tests/src/api/check-params/videos.ts b/packages/tests/src/api/check-params/videos.ts
index 49d04842a1..1897406c3a 100644
--- a/packages/tests/src/api/check-params/videos.ts
+++ b/packages/tests/src/api/check-params/videos.ts
@@ -1,13 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { omit, randomInt } from '@peertube/peertube-core-utils'
-import {
- HttpStatusCode,
- PeerTubeProblemDocument,
- VideoCommentPolicy,
- VideoCreateResult,
- VideoPrivacy
-} from '@peertube/peertube-models'
+import { HttpStatusCode, PeerTubeProblemDocument, VideoCommentPolicy, VideoCreateResult, VideoPrivacy } from '@peertube/peertube-models'
import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils'
import {
PeerTubeServer,
@@ -17,7 +11,8 @@ import {
makeGetRequest,
makePutBodyRequest,
makeUploadRequest,
- setAccessTokensToServers
+ setAccessTokensToServers,
+ setDefaultVideoChannel
} from '@peertube/peertube-server-commands'
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js'
import { checkUploadVideoParam } from '@tests/shared/videos.js'
@@ -42,6 +37,7 @@ describe('Test videos API validator', function () {
server = await createSingleServer(1)
await setAccessTokensToServers([ server ])
+ await setDefaultVideoChannel([ server ])
userAccessToken = await server.users.generateUserAndToken('user1')
@@ -80,7 +76,6 @@ describe('Test videos API validator', function () {
})
describe('When searching a video', function () {
-
it('Should fail with nothing', async function () {
await makeGetRequest({
url: server.url,
@@ -135,6 +130,40 @@ describe('Test videos API validator', function () {
})
})
+ it('Should not list videos of a channel of another user', async function () {
+ {
+ {
+ const { total, data } = await server.videos.listMyVideos({ token: userAccessToken, channelNameOneOf: [ 'root_channel' ] })
+
+ expect(total).to.equal(0)
+ expect(data).to.have.lengthOf(0)
+ }
+
+ {
+ const { total, data } = await server.videos.listMyVideos({ token: userAccessToken, channelId: server.store.channel.id })
+
+ expect(total).to.equal(0)
+ expect(data).to.have.lengthOf(0)
+ }
+ }
+
+ {
+ {
+ const { total, data } = await server.videos.listMyVideos({ channelNameOneOf: [ 'root_channel' ] })
+
+ expect(total).to.not.equal(0)
+ expect(data).to.not.have.lengthOf(0)
+ }
+
+ {
+ const { total, data } = await server.videos.listMyVideos({ channelId: server.store.channel.id })
+
+ expect(total).to.not.equal(0)
+ expect(data).to.not.have.lengthOf(0)
+ }
+ }
+ })
+
it('Should success with the correct parameters', async function () {
await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 })
})
@@ -216,7 +245,6 @@ describe('Test videos API validator', function () {
})
function runSuite (mode: 'legacy' | 'resumable') {
-
const baseOptions = () => {
return {
server,
diff --git a/packages/tests/src/api/live/live-save-replay.ts b/packages/tests/src/api/live/live-save-replay.ts
index 70abcf20b9..6187c944cb 100644
--- a/packages/tests/src/api/live/live-save-replay.ts
+++ b/packages/tests/src/api/live/live-save-replay.ts
@@ -4,7 +4,6 @@ import { wait } from '@peertube/peertube-core-utils'
import {
HttpStatusCode,
HttpStatusCodeType,
- LiveVideoCreate,
LiveVideoError,
VideoPrivacy,
VideoPrivacyType,
@@ -51,19 +50,19 @@ describe('Save replay setting', function () {
} catch {}
}
- const attributes: LiveVideoCreate = {
- channelId: servers[0].store.channel.id,
- privacy: VideoPrivacy.PUBLIC,
- name: 'live'.repeat(30),
- tags: [ 'tag1', 'tag2' ],
- saveReplay: options.replay,
- replaySettings: options.replaySettings,
- permanentLive: options.permanent,
- thumbnailfile: options.thumbnailfile,
- previewfile: options.previewfile
- }
-
- const { uuid } = await servers[0].live.create({ fields: attributes })
+ const { uuid } = await servers[0].live.create({
+ fields: {
+ channelId: servers[0].store.channel.id,
+ privacy: VideoPrivacy.PUBLIC,
+ name: 'live'.repeat(30),
+ tags: [ 'tag1', 'tag2' ],
+ saveReplay: options.replay,
+ replaySettings: options.replaySettings,
+ permanentLive: options.permanent,
+ thumbnailfile: options.thumbnailfile,
+ previewfile: options.previewfile
+ }
+ })
return uuid
}
@@ -292,7 +291,6 @@ describe('Save replay setting', function () {
})
describe('With save replay enabled on non permanent live', function () {
-
it('Should correctly create and federate the "waiting for stream" live', async function () {
this.timeout(120000)
@@ -419,7 +417,6 @@ describe('Save replay setting', function () {
let lastReplayUUID: string
describe('With a first live and its replay', function () {
-
before(async function () {
this.timeout(120000)
@@ -534,7 +531,6 @@ describe('Save replay setting', function () {
})
describe('With a second live session', function () {
-
it('Should update the replay settings', async function () {
await servers[0].live.update({ videoId: liveVideoUUID, fields: { replaySettings: { privacy: VideoPrivacy.PUBLIC } } })
await waitJobs(servers)
@@ -620,7 +616,6 @@ describe('Save replay setting', function () {
})
describe('With terminated sessions', function () {
-
it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () {
this.timeout(120000)
@@ -662,7 +657,6 @@ describe('Save replay setting', function () {
})
describe('With a live without custom thumbnail', function () {
-
it('Should correctly set the default thumbnail to the live replay', async function () {
this.timeout(120000)
diff --git a/packages/tests/src/api/live/live.ts b/packages/tests/src/api/live/live.ts
index a9ebff5057..44955109c0 100644
--- a/packages/tests/src/api/live/live.ts
+++ b/packages/tests/src/api/live/live.ts
@@ -5,7 +5,6 @@ import { ffprobePromise } from '@peertube/peertube-ffmpeg'
import {
HttpStatusCode,
LiveVideo,
- LiveVideoCreate,
LiveVideoLatencyMode,
VideoCommentPolicy,
VideoDetails,
@@ -79,28 +78,28 @@ describe('Test live', function () {
it('Should create a live with the appropriate parameters', async function () {
this.timeout(20000)
- const attributes: LiveVideoCreate = {
- category: 1,
- licence: 2,
- language: 'fr',
- description: 'super live description',
- support: 'support field',
- channelId: servers[0].store.channel.id,
- nsfw: false,
- waitTranscoding: false,
- name: 'my super live',
- tags: [ 'tag1', 'tag2' ],
- commentsPolicy: VideoCommentPolicy.DISABLED,
- downloadEnabled: false,
- saveReplay: true,
- replaySettings: { privacy: VideoPrivacy.PUBLIC },
- latencyMode: LiveVideoLatencyMode.SMALL_LATENCY,
- privacy: VideoPrivacy.PUBLIC,
- previewfile: 'video_short1-preview.webm.jpg',
- thumbnailfile: 'video_short1.webm.jpg'
- }
-
- const live = await commands[0].create({ fields: attributes })
+ const live = await commands[0].create({
+ fields: {
+ category: 1,
+ licence: 2,
+ language: 'fr',
+ description: 'super live description',
+ support: 'support field',
+ channelId: servers[0].store.channel.id,
+ nsfw: false,
+ waitTranscoding: false,
+ name: 'my super live',
+ tags: [ 'tag1', 'tag2' ],
+ commentsPolicy: VideoCommentPolicy.DISABLED,
+ downloadEnabled: false,
+ saveReplay: true,
+ replaySettings: { privacy: VideoPrivacy.PUBLIC },
+ latencyMode: LiveVideoLatencyMode.SMALL_LATENCY,
+ privacy: VideoPrivacy.PUBLIC,
+ previewfile: 'video_short1-preview.webm.jpg',
+ thumbnailfile: 'video_short1.webm.jpg'
+ }
+ })
liveVideoUUID = live.uuid
await waitJobs(servers)
@@ -153,14 +152,14 @@ describe('Test live', function () {
it('Should have a default preview and thumbnail', async function () {
this.timeout(20000)
- const attributes: LiveVideoCreate = {
- name: 'default live thumbnail',
- channelId: servers[0].store.channel.id,
- privacy: VideoPrivacy.UNLISTED,
- nsfw: true
- }
-
- const live = await commands[0].create({ fields: attributes })
+ const live = await commands[0].create({
+ fields: {
+ name: 'default live thumbnail',
+ channelId: servers[0].store.channel.id,
+ privacy: VideoPrivacy.UNLISTED,
+ nsfw: true
+ }
+ })
const videoId = live.uuid
await waitJobs(servers)
@@ -675,15 +674,15 @@ describe('Test live', function () {
let beforeServerRestart: Date
async function createLiveWrapper (options: { saveReplay: boolean, permanent: boolean }) {
- const liveAttributes: LiveVideoCreate = {
- name: 'live video',
- channelId: servers[0].store.channel.id,
- privacy: VideoPrivacy.PUBLIC,
- saveReplay: options.saveReplay,
- permanentLive: options.permanent
- }
-
- const { uuid } = await commands[0].create({ fields: liveAttributes })
+ const { uuid } = await commands[0].create({
+ fields: {
+ name: 'live video',
+ channelId: servers[0].store.channel.id,
+ privacy: VideoPrivacy.PUBLIC,
+ saveReplay: options.saveReplay,
+ permanentLive: options.permanent
+ }
+ })
return uuid
}
diff --git a/packages/tests/src/api/users/user-videos.ts b/packages/tests/src/api/users/user-videos.ts
index 47310e75e4..24f822d786 100644
--- a/packages/tests/src/api/users/user-videos.ts
+++ b/packages/tests/src/api/users/user-videos.ts
@@ -36,7 +36,6 @@ describe('Test user videos', function () {
})
describe('List my videos', function () {
-
it('Should list my videos', async function () {
const { data, total } = await server.videos.listMyVideos()
@@ -46,7 +45,6 @@ describe('Test user videos', function () {
})
describe('Upload', function () {
-
it('Should upload the video with the correct token', async function () {
await server.videos.upload({ token })
const { data } = await server.videos.list()
@@ -63,7 +61,6 @@ describe('Test user videos', function () {
})
describe('Ratings', function () {
-
it('Should retrieve a video rating', async function () {
await server.videos.rate({ id: videoId, token, rating: 'like' })
const rating = await server.users.getMyRating({ token, videoId })
@@ -96,7 +93,6 @@ describe('Test user videos', function () {
})
describe('Remove video', function () {
-
it('Should not be able to remove the video with an incorrect token', async function () {
await server.videos.remove({ token: 'bad_token', id: videoId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
@@ -112,7 +108,6 @@ describe('Test user videos', function () {
})
describe('My videos & quotas', function () {
-
it('Should be able to upload a video with a user', async function () {
this.timeout(30000)
@@ -147,7 +142,7 @@ describe('Test user videos', function () {
expect(video.previewPath).to.not.be.null
})
- it('Should be able to filter by channel in my videos', async function () {
+ it('Should be able to filter by a specific channel in my videos', async function () {
const myInfo = await server.users.getMyInfo({ token })
const mainChannel = myInfo.videoChannels.find(c => c.name !== 'other_channel')
const otherChannel = myInfo.videoChannels.find(c => c.name === 'other_channel')
@@ -170,6 +165,26 @@ describe('Test user videos', function () {
}
})
+ it('Should be able to filter by multiple channels in my videos', async function () {
+ {
+ const { total, data } = await server.videos.listMyVideos({ token, channelNameOneOf: [ 'user_channel' ] })
+ expect(total).to.equal(1)
+ expect(data).to.have.lengthOf(1)
+ }
+
+ {
+ const { total, data } = await server.videos.listMyVideos({ token, channelNameOneOf: [ 'other_channel' ] })
+ expect(total).to.equal(0)
+ expect(data).to.have.lengthOf(0)
+ }
+
+ {
+ const { total, data } = await server.videos.listMyVideos({ token, channelNameOneOf: [ 'user_channel', 'other_channel' ] })
+ expect(total).to.equal(1)
+ expect(data).to.have.lengthOf(1)
+ }
+ })
+
it('Should be able to search in my videos', async function () {
{
const { total, data } = await server.videos.listMyVideos({ token, sort: '-createdAt', search: 'user video' })
diff --git a/packages/tests/src/api/videos/video-chapters.ts b/packages/tests/src/api/videos/video-chapters.ts
index 848f30b855..e6a4a17577 100644
--- a/packages/tests/src/api/videos/video-chapters.ts
+++ b/packages/tests/src/api/videos/video-chapters.ts
@@ -5,7 +5,9 @@ import { areHttpImportTestsDisabled, areYoutubeImportTestsDisabled } from '@peer
import {
cleanupTests,
createMultipleServers,
- doubleFollow, PeerTubeServer, setAccessTokensToServers,
+ doubleFollow,
+ PeerTubeServer,
+ setAccessTokensToServers,
setDefaultVideoChannel,
waitJobs
} from '@peertube/peertube-server-commands'
@@ -199,7 +201,6 @@ describe('Test video chapters', function () {
})
describe('With upload', function () {
-
it('Should upload a mp4 containing chapters and automatically add them', async function () {
const video = await servers[0].videos.quickUpload({ fixture: 'video_chapters.mp4', name: 'chapters' })
await waitJobs(servers)
@@ -311,7 +312,7 @@ describe('Test video chapters', function () {
const attributes = {
channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC,
- targetUrl: FIXTURE_URLS.chatersVideo
+ targetUrl: FIXTURE_URLS.chaptersVideo
}
const { video } = await servers[0].videoImports.importVideo({ attributes })
diff --git a/packages/tests/src/api/videos/videos-common-filters.ts b/packages/tests/src/api/videos/videos-common-filters.ts
index 682220e197..9a811e8d48 100644
--- a/packages/tests/src/api/videos/videos-common-filters.ts
+++ b/packages/tests/src/api/videos/videos-common-filters.ts
@@ -32,6 +32,7 @@ describe('Test videos filter', function () {
let remotePaths: string[]
const subscriptionVideosPath = '/api/v1/users/me/subscriptions/videos'
+ const userVideosPath = '/api/v1/users/me/videos'
// ---------------------------------------------------------------
@@ -86,15 +87,16 @@ describe('Test videos filter', function () {
})
describe('Check videos filters', function () {
+ async function listVideos (
+ options: {
+ server: PeerTubeServer
+ path: string
- async function listVideos (options: {
- server: PeerTubeServer
- path: string
-
- token?: string
- expectedStatus?: HttpStatusCodeType
- excludeAlreadyWatched?: boolean
- } & VideosCommonQuery) {
+ token?: string
+ expectedStatus?: HttpStatusCodeType
+ excludeAlreadyWatched?: boolean
+ } & VideosCommonQuery
+ ) {
const res = await makeGetRequest({
url: options.server.url,
path: options.path,
@@ -131,13 +133,18 @@ describe('Test videos filter', function () {
token?: string
expectedStatus?: HttpStatusCodeType
skipSubscription?: boolean
+ includeUserVideos?: boolean
excludeAlreadyWatched?: boolean
}
) {
- const { skipSubscription = false } = options
+ const { skipSubscription = false, includeUserVideos = false } = options
const videosResults: string[][] = []
- for (const path of paths) {
+ const allPaths = includeUserVideos
+ ? [ ...paths, '/api/v1/users/me/videos' ]
+ : paths
+
+ for (const path of allPaths) {
if (skipSubscription && path === subscriptionVideosPath) continue
const videos = await listVideos({ ...options, path })
@@ -162,7 +169,6 @@ describe('Test videos filter', function () {
it('Should display local videos with hidden privacy by the admin or the moderator', async function () {
for (const server of servers) {
for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) {
-
const namesResults = await getVideosNames(
{
server,
@@ -187,7 +193,6 @@ describe('Test videos filter', function () {
it('Should display all videos by the admin or the moderator', async function () {
for (const server of servers) {
for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) {
-
const [ channelVideos, accountVideos, videos, searchVideos ] = await getVideosNames({
server,
token,
@@ -278,6 +283,13 @@ describe('Test videos filter', function () {
expect(video).to.exist
expect(video.blacklisted).to.be.true
}
+
+ {
+ const { data: videos } = await servers[0].videos.listMyVideos()
+ const video = finder(videos)
+ expect(video).to.exist
+ expect(video.blacklisted).to.be.true
+ }
}
})
@@ -343,7 +355,7 @@ describe('Test videos filter', function () {
})
it('Should include video files', async function () {
- for (const path of paths) {
+ for (const path of [ ...paths, userVideosPath ]) {
{
const videos = await listVideos({ server: servers[0], path })
@@ -359,6 +371,8 @@ describe('Test videos filter', function () {
const videos = await listVideos({ server: servers[0], path, include: VideoInclude.FILES })
for (const video of videos) {
+ if (video.isLive) continue
+
const videoWithFiles = video as VideoDetails
expect(videoWithFiles.files).to.exist
@@ -372,7 +386,7 @@ describe('Test videos filter', function () {
await servers[0].videos.upload({ attributes: { name: 'tag filter', tags: [ 'tag1', 'tag2' ] } })
await servers[0].videos.upload({ attributes: { name: 'tag filter with category', tags: [ 'tag3' ], category: 4 } })
- for (const path of paths) {
+ for (const path of [ ...paths, userVideosPath ]) {
{
const videos = await listVideos({ server: servers[0], path, tagsAllOf: [ 'tag1', 'tag2' ] })
expect(videos).to.have.lengthOf(1)
@@ -401,7 +415,7 @@ describe('Test videos filter', function () {
await servers[0].videos.upload({ attributes: { name: 'english', language: 'en' } })
await servers[0].videos.upload({ attributes: { name: 'french', language: 'fr' } })
- for (const path of paths) {
+ for (const path of [ ...paths, userVideosPath ]) {
{
const videos = await listVideos({ server: servers[0], path, languageOneOf: [ 'fr', 'en' ] })
expect(videos).to.have.lengthOf(2)
@@ -465,7 +479,7 @@ describe('Test videos filter', function () {
await waitJobs(servers)
- for (const path of paths) {
+ for (const path of [ ...paths, userVideosPath ]) {
{
const videos = await listVideos({ server: servers[0], path, hasWebVideoFiles: true })
@@ -519,7 +533,7 @@ describe('Test videos filter', function () {
it('Should filter already watched videos by the user', async function () {
const { id } = await servers[0].videos.upload({ attributes: { name: 'video for history' } })
- for (const path of paths) {
+ for (const path of [ ...paths, userVideosPath ]) {
const videos = await listVideos({ server: servers[0], path, isLocal: true, excludeAlreadyWatched: true })
const foundVideo = videos.find(video => video.id === id)
@@ -527,7 +541,7 @@ describe('Test videos filter', function () {
}
await servers[0].views.view({ id, currentTime: 1, token: servers[0].accessToken })
- for (const path of paths) {
+ for (const path of [ ...paths, userVideosPath ]) {
const videos = await listVideos({ server: servers[0], path, excludeAlreadyWatched: true })
const foundVideo = videos.find(video => video.id === id)
diff --git a/packages/tests/src/shared/fixture-urls.ts b/packages/tests/src/shared/fixture-urls.ts
index 3b26f6eef5..8b46a57d85 100644
--- a/packages/tests/src/shared/fixture-urls.ts
+++ b/packages/tests/src/shared/fixture-urls.ts
@@ -20,15 +20,16 @@ export const FIXTURE_URLS = {
youtubeChannel: 'https://youtube.com/channel/UCtnlZdXv3-xQzxiqfn6cjIA',
youtubePlaylist: 'https://youtube.com/playlist?list=PLRGXHPrcPd2yc2KdswlAWOxIJ8G3vgy4h',
- // eslint-disable-next-line max-len
- magnet: 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Flazy-static%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4',
+ magnet:
+ // eslint-disable-next-line max-len
+ 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Flazy-static%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4',
badVideo: 'https://download.cpy.re/peertube/bad_video.mp4',
goodVideo: 'https://download.cpy.re/peertube/good_video.mp4',
goodVideo720: 'https://download.cpy.re/peertube/good_video_720.mp4',
transcriptionVideo: 'https://download.cpy.re/peertube/the_last_man_on_earth.mp4',
- chatersVideo: 'https://download.cpy.re/peertube/video_chapters.mp4',
+ chaptersVideo: 'https://download.cpy.re/peertube/video_chapters.mp4',
file4K: 'https://download.cpy.re/peertube/4k_file.txt',
diff --git a/server/core/controllers/api/users/me.ts b/server/core/controllers/api/users/me.ts
index 50cfb3261f..c8f58ff883 100644
--- a/server/core/controllers/api/users/me.ts
+++ b/server/core/controllers/api/users/me.ts
@@ -1,18 +1,21 @@
-import { pick } from '@peertube/peertube-core-utils'
+import { getAllPrivacies, pick } from '@peertube/peertube-core-utils'
import {
ActorImageType,
UserVideoRate as FormattedUserVideoRate,
HttpStatusCode,
UserUpdateMe,
- UserVideoQuota
+ UserVideoQuota,
+ VideoInclude
} from '@peertube/peertube-models'
import { AttributesOnly } from '@peertube/peertube-typescript-utils'
import { UserAuditView, auditLoggerFactory, getAuditIdFromRes } from '@server/helpers/audit-logger.js'
+import { pickCommonVideoQuery } from '@server/helpers/query.js'
import { Hooks } from '@server/lib/plugins/hooks.js'
+import { guessAdditionalAttributesFromQuery } from '@server/models/video/formatter/video-api-format.js'
import { VideoCommentModel } from '@server/models/video/video-comment.js'
import express from 'express'
import 'multer'
-import { createReqFiles } from '../../../helpers/express-utils.js'
+import { createReqFiles, getCountVideos } from '../../../helpers/express-utils.js'
import { getFormattedObjects } from '../../../helpers/utils.js'
import { CONFIG } from '../../../initializers/config.js'
import { MIMETYPES } from '../../../initializers/constants.js'
@@ -33,6 +36,7 @@ import {
} from '../../../middlewares/index.js'
import { updateAvatarValidator } from '../../../middlewares/validators/actor-image.js'
import {
+ commonVideosFiltersValidator,
deleteMeValidator,
getMyVideoImportsValidator,
listCommentsOnUserVideosValidator,
@@ -52,22 +56,13 @@ const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_
const meRouter = express.Router()
-meRouter.get('/me',
- authenticate,
- asyncMiddleware(getUserInformation)
-)
-meRouter.delete('/me',
- authenticate,
- deleteMeValidator,
- asyncMiddleware(deleteMe)
-)
+meRouter.get('/me', authenticate, asyncMiddleware(getUserInformation))
+meRouter.delete('/me', authenticate, deleteMeValidator, asyncMiddleware(deleteMe))
-meRouter.get('/me/video-quota-used',
- authenticate,
- asyncMiddleware(getUserVideoQuotaUsed)
-)
+meRouter.get('/me/video-quota-used', authenticate, asyncMiddleware(getUserVideoQuotaUsed))
-meRouter.get('/me/videos/imports',
+meRouter.get(
+ '/me/videos/imports',
authenticate,
paginationValidator,
videoImportsSortValidator,
@@ -77,7 +72,8 @@ meRouter.get('/me/videos/imports',
asyncMiddleware(getUserVideoImports)
)
-meRouter.get('/me/videos/comments',
+meRouter.get(
+ '/me/videos/comments',
authenticate,
paginationValidator,
videosSortValidator,
@@ -87,39 +83,25 @@ meRouter.get('/me/videos/comments',
asyncMiddleware(listCommentsOnUserVideos)
)
-meRouter.get('/me/videos',
+meRouter.get(
+ '/me/videos',
authenticate,
paginationValidator,
videosSortValidator,
setDefaultVideosSort,
setDefaultPagination,
+ commonVideosFiltersValidator,
asyncMiddleware(usersVideosValidator),
asyncMiddleware(listUserVideos)
)
-meRouter.get('/me/videos/:videoId/rating',
- authenticate,
- asyncMiddleware(usersVideoRatingValidator),
- asyncMiddleware(getUserVideoRating)
-)
+meRouter.get('/me/videos/:videoId/rating', authenticate, asyncMiddleware(usersVideoRatingValidator), asyncMiddleware(getUserVideoRating))
-meRouter.put('/me',
- authenticate,
- asyncMiddleware(usersUpdateMeValidator),
- asyncRetryTransactionMiddleware(updateMe)
-)
+meRouter.put('/me', authenticate, asyncMiddleware(usersUpdateMeValidator), asyncRetryTransactionMiddleware(updateMe))
-meRouter.post('/me/avatar/pick',
- authenticate,
- reqAvatarFile,
- updateAvatarValidator,
- asyncRetryTransactionMiddleware(updateMyAvatar)
-)
+meRouter.post('/me/avatar/pick', authenticate, reqAvatarFile, updateAvatarValidator, asyncRetryTransactionMiddleware(updateMyAvatar))
-meRouter.delete('/me/avatar',
- authenticate,
- asyncRetryTransactionMiddleware(deleteMyAvatar)
-)
+meRouter.delete('/me/avatar', authenticate, asyncRetryTransactionMiddleware(deleteMyAvatar))
// ---------------------------------------------------------------------------
@@ -131,30 +113,38 @@ export {
async function listUserVideos (req: express.Request, res: express.Response) {
const user = res.locals.oauth.token.User
+ const countVideos = getCountVideos(req)
+ const query = pickCommonVideoQuery(req.query)
+
+ const include = (query.include || VideoInclude.NONE) | VideoInclude.BLACKLISTED | VideoInclude.NOT_PUBLISHED_STATE
const apiOptions = await Hooks.wrapObject({
+ privacyOneOf: getAllPrivacies(),
+
+ ...query,
+
+ // Display all
+ nsfw: null,
+
+ user,
accountId: user.Account.id,
- start: req.query.start,
- count: req.query.count,
- sort: req.query.sort,
- search: req.query.search,
- channelId: res.locals.videoChannel?.id,
- isLive: req.query.isLive
+ displayOnlyForFollower: null,
+
+ videoChannelId: res.locals.videoChannel?.id,
+ channelNameOneOf: req.query.channelNameOneOf,
+
+ countVideos,
+
+ include
}, 'filter:api.user.me.videos.list.params')
const resultList = await Hooks.wrapPromiseFun(
- VideoModel.listUserVideosForApi.bind(VideoModel),
+ VideoModel.listForApi.bind(VideoModel),
apiOptions,
'filter:api.user.me.videos.list.result'
)
- const additionalAttributes = {
- waitTranscoding: true,
- state: true,
- scheduledUpdate: true,
- blacklistInfo: true
- }
- return res.json(getFormattedObjects(resultList.data, resultList.total, { additionalAttributes }))
+ return res.json(getFormattedObjects(resultList.data, resultList.total, guessAdditionalAttributesFromQuery({ include })))
}
async function listCommentsOnUserVideos (req: express.Request, res: express.Response) {
diff --git a/server/core/middlewares/validators/users/users.ts b/server/core/middlewares/validators/users/users.ts
index 8087a014a7..1dadfa1ba1 100644
--- a/server/core/middlewares/validators/users/users.ts
+++ b/server/core/middlewares/validators/users/users.ts
@@ -1,8 +1,10 @@
-import { forceNumber } from '@peertube/peertube-core-utils'
+import { arrayify, forceNumber } from '@peertube/peertube-core-utils'
import { HttpStatusCode, ServerErrorCode, UserRight, UserRole } from '@peertube/peertube-models'
+import { isStringArray } from '@server/helpers/custom-validators/search.js'
+import { Hooks } from '@server/lib/plugins/hooks.js'
import express from 'express'
import { body, param, query } from 'express-validator'
-import { exists, isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc.js'
+import { exists, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc.js'
import { isThemeNameValid } from '../../../helpers/custom-validators/plugins.js'
import {
isUserAdminFlagsValid,
@@ -40,7 +42,6 @@ import {
doesVideoExist,
isValidVideoIdParam
} from '../shared/index.js'
-import { Hooks } from '@server/lib/plugins/hooks.js'
export const usersListValidator = [
query('blocked')
@@ -314,16 +315,16 @@ export const usersVideoRatingValidator = [
]
export const usersVideosValidator = [
- query('isLive')
- .optional()
- .customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid isLive boolean'),
-
query('channelId')
.optional()
.customSanitizer(toIntOrNull)
.custom(isIdValid),
+ query('channelNameOneOf')
+ .optional()
+ .customSanitizer(arrayify)
+ .custom(isStringArray).withMessage('Should have a valid channelNameOneOf array'),
+
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
diff --git a/server/core/middlewares/validators/videos/shared/video-validators.ts b/server/core/middlewares/validators/videos/shared/video-validators.ts
index b80765d42e..7bff15251f 100644
--- a/server/core/middlewares/validators/videos/shared/video-validators.ts
+++ b/server/core/middlewares/validators/videos/shared/video-validators.ts
@@ -1,3 +1,4 @@
+import { canVideoFileBeEdited } from '@peertube/peertube-core-utils'
import { HttpStatusCode, ServerErrorCode, ServerFilterHookName, VideoState, VideoStateType } from '@peertube/peertube-models'
import { isVideoFileMimeTypeValid, isVideoFileSizeValid } from '@server/helpers/custom-validators/videos.js'
import { logger } from '@server/helpers/logger.js'
@@ -85,14 +86,7 @@ export function checkVideoFileCanBeEdited (video: MVideo, res: express.Response)
return false
}
- const validStates = new Set<VideoStateType>([
- VideoState.PUBLISHED,
- VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED,
- VideoState.TO_MOVE_TO_FILE_SYSTEM_FAILED,
- VideoState.TRANSCODING_FAILED
- ])
-
- if (!validStates.has(video.state)) {
+ if (!canVideoFileBeEdited(video.state)) {
res.fail({
status: HttpStatusCode.BAD_REQUEST_400,
message: 'Video state is not compatible with edition'
diff --git a/server/core/models/abuse/abuse.ts b/server/core/models/abuse/abuse.ts
index 5f57868efb..44cb80f35e 100644
--- a/server/core/models/abuse/abuse.ts
+++ b/server/core/models/abuse/abuse.ts
@@ -4,15 +4,16 @@ import {
AbuseObject,
AbusePredefinedReasonsString,
AbusePredefinedReasonsType,
+ AbuseState,
AbuseVideoIs,
AdminAbuse,
AdminVideoAbuse,
AdminVideoCommentAbuse,
UserAbuse,
UserVideoAbuse,
- type AbuseStateType,
- AbuseState
+ type AbuseStateType
} from '@peertube/peertube-models'
+import { uuidToShort } from '@peertube/peertube-node-utils'
import { isAbuseModerationCommentValid, isAbuseReasonValid, isAbuseStateValid } from '@server/helpers/custom-validators/abuses.js'
import invert from 'lodash-es/invert.js'
import { Op, QueryTypes, literal } from 'sequelize'
@@ -25,7 +26,8 @@ import {
Default,
ForeignKey,
HasOne,
- Is, Scopes,
+ Is,
+ Scopes,
Table,
UpdatedAt
} from 'sequelize-typescript'
@@ -64,7 +66,7 @@ export enum ScopeNames {
'SELECT count(*) ' +
'FROM "abuseMessage" ' +
'WHERE "abuseId" = "AbuseModel"."id"' +
- ')'
+ ')'
),
'countMessages'
],
@@ -76,7 +78,7 @@ export enum ScopeNames {
'FROM "videoAbuse" ' +
'WHERE "videoId" IN (SELECT "videoId" FROM "videoAbuse" WHERE "abuseId" = "AbuseModel"."id") ' +
'AND "videoId" IS NOT NULL' +
- ')'
+ ')'
),
'countReportsForVideo'
],
@@ -86,11 +88,11 @@ export enum ScopeNames {
'(' +
'SELECT t.nth ' +
'FROM ( ' +
- 'SELECT id, "abuseId", row_number() OVER (PARTITION BY "videoId" ORDER BY "createdAt") AS nth ' +
- 'FROM "videoAbuse" ' +
+ 'SELECT id, "abuseId", row_number() OVER (PARTITION BY "videoId" ORDER BY "createdAt") AS nth ' +
+ 'FROM "videoAbuse" ' +
') t ' +
'WHERE t."abuseId" = "AbuseModel"."id" ' +
- ')'
+ ')'
),
'nthReportForVideo'
],
@@ -100,7 +102,7 @@ export enum ScopeNames {
'SELECT count("abuse"."id") ' +
'FROM "abuse" ' +
'WHERE "abuse"."reporterAccountId" = "AbuseModel"."reporterAccountId"' +
- ')'
+ ')'
),
'countReportsForReporter'
],
@@ -110,7 +112,7 @@ export enum ScopeNames {
'SELECT count("abuse"."id") ' +
'FROM "abuse" ' +
'WHERE "abuse"."flaggedAccountId" = "AbuseModel"."flaggedAccountId"' +
- ')'
+ ')'
),
'countReportsForReportee'
]
@@ -194,7 +196,6 @@ export enum ScopeNames {
]
})
export class AbuseModel extends SequelizeModel<AbuseModel> {
-
@AllowNull(false)
@Default(null)
@Is('AbuseReason', value => throwIfNotValid(value, isAbuseReasonValid, 'reason'))
@@ -448,8 +449,8 @@ export class AbuseModel extends SequelizeModel<AbuseModel> {
static getStats () {
const query = `SELECT ` +
`AVG(EXTRACT(EPOCH FROM ("processedAt" - "createdAt") * 1000)) ` +
- `FILTER (WHERE "processedAt" IS NOT NULL AND "createdAt" > CURRENT_DATE - INTERVAL '3 months')` +
- `AS "avgResponseTime", ` +
+ `FILTER (WHERE "processedAt" IS NOT NULL AND "createdAt" > CURRENT_DATE - INTERVAL '3 months')` +
+ `AS "avgResponseTime", ` +
// "processedAt" has been introduced in PeerTube 6.1 so also check the abuse state to check processed abuses
`COUNT(*) FILTER (WHERE "processedAt" IS NOT NULL OR "state" != ${AbuseState.PENDING}) AS "processedAbuses", ` +
`COUNT(*) AS "totalAbuses" ` +
@@ -504,6 +505,7 @@ export class AbuseModel extends SequelizeModel<AbuseModel> {
return {
id: entity.id,
uuid: entity.uuid,
+ shortUUID: uuidToShort(entity.uuid),
name: entity.name,
nsfw: entity.nsfw,
@@ -639,15 +641,15 @@ export class AbuseModel extends SequelizeModel<AbuseModel> {
if (ids.length === 0) return []
return AbuseModel.scope(ScopeNames.FOR_API)
- .findAll({
- order: getSort(parameters.sort),
- where: {
- id: {
- [Op.in]: ids
- }
- },
- limit: parameters.count
- })
+ .findAll({
+ order: getSort(parameters.sort),
+ where: {
+ id: {
+ [Op.in]: ids
+ }
+ },
+ limit: parameters.count
+ })
}
private static getStateLabel (id: number) {
diff --git a/server/core/models/video/formatter/video-api-format.ts b/server/core/models/video/formatter/video-api-format.ts
index 4557053efc..87c04fa2e3 100644
--- a/server/core/models/video/formatter/video-api-format.ts
+++ b/server/core/models/video/formatter/video-api-format.ts
@@ -43,7 +43,7 @@ export type VideoFormattingJSONOptions = {
}
}
-export function guessAdditionalAttributesFromQuery (query: VideosCommonQueryAfterSanitize): VideoFormattingJSONOptions {
+export function guessAdditionalAttributesFromQuery (query: Pick<VideosCommonQueryAfterSanitize, 'include'>): VideoFormattingJSONOptions {
if (!query?.include) return {}
return {
@@ -336,10 +336,9 @@ function buildAdditionalAttributes (video: MVideoFormattable, options: VideoForm
if (add?.blacklistInfo === true) {
result.blacklisted = !!video.VideoBlacklist
- result.blacklistedReason =
- video.VideoBlacklist
- ? video.VideoBlacklist.reason
- : null
+ result.blacklistedReason = video.VideoBlacklist
+ ? video.VideoBlacklist.reason
+ : null
}
if (add?.blockedOwner === true) {
diff --git a/server/core/models/video/sql/video/shared/video-model-builder.ts b/server/core/models/video/sql/video/shared/video-model-builder.ts
index 2713568e88..bdc6119912 100644
--- a/server/core/models/video/sql/video/shared/video-model-builder.ts
+++ b/server/core/models/video/sql/video/shared/video-model-builder.ts
@@ -25,15 +25,13 @@ import { VideoTableAttributes } from './video-table-attributes.js'
type SQLRow = { [id: string]: string | number }
/**
- *
* Build video models from SQL rows
- *
*/
export class VideoModelBuilder {
- private videosMemo: { [ id: number ]: VideoModel }
- private videoStreamingPlaylistMemo: { [ id: number ]: VideoStreamingPlaylistModel }
- private videoFileMemo: { [ id: number ]: VideoFileModel }
+ private videosMemo: { [id: number]: VideoModel }
+ private videoStreamingPlaylistMemo: { [id: number]: VideoStreamingPlaylistModel }
+ private videoFileMemo: { [id: number]: VideoFileModel }
private thumbnailsDone: Set<any>
private actorImagesDone: Set<any>
@@ -58,7 +56,6 @@ export class VideoModelBuilder {
private readonly mode: 'get' | 'list',
private readonly tables: VideoTableAttributes
) {
-
}
buildVideosFromRows (options: {
@@ -114,6 +111,10 @@ export class VideoModelBuilder {
this.setBlockedServer(row, videoModel)
}
+ if (include & VideoInclude.NOT_PUBLISHED_STATE) {
+ this.setScheduleVideoUpdate(row, videoModel)
+ }
+
if (include & VideoInclude.SOURCE) {
this.setSource(row, videoModel)
}
@@ -438,7 +439,7 @@ export class VideoModelBuilder {
}
private grab (row: SQLRow, attributes: string[], prefix: string) {
- const result: { [ id: string ]: string | number } = {}
+ const result: { [id: string]: string | number } = {}
for (const a of attributes) {
const key = prefix
diff --git a/server/core/models/video/sql/video/videos-id-list-query-builder.ts b/server/core/models/video/sql/video/videos-id-list-query-builder.ts
index bbfc5f50d3..5851dd4709 100644
--- a/server/core/models/video/sql/video/videos-id-list-query-builder.ts
+++ b/server/core/models/video/sql/video/videos-id-list-query-builder.ts
@@ -10,9 +10,7 @@ import { AbstractRunQuery } from '../../../shared/abstract-run-query.js'
import { createSafeIn, parseRowCountResult } from '../../../shared/index.js'
/**
- *
* Build videos list SQL query to fetch rows
- *
*/
export type DisplayOnlyForFollowerOptions = {
@@ -56,7 +54,9 @@ export type BuildVideosListQueryOptions = {
hasWebVideoFiles?: boolean
accountId?: number
+
videoChannelId?: number
+ channelNameOneOf?: string[]
videoPlaylistId?: number
@@ -179,6 +179,10 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
this.whereChannelId(options.videoChannelId)
}
+ if (options.channelNameOneOf) {
+ this.whereChannelOneOf(options.channelNameOneOf)
+ }
+
if (options.displayOnlyForFollower) {
this.whereFollowerActorId(options.displayOnlyForFollower)
}
@@ -335,7 +339,7 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
private joinPlaylist (playlistId: number) {
this.joins.push(
'INNER JOIN "videoPlaylistElement" "video"."id" = "videoPlaylistElement"."videoId" ' +
- 'AND "videoPlaylistElement"."videoPlaylistId" = :videoPlaylistId'
+ 'AND "videoPlaylistElement"."videoPlaylistId" = :videoPlaylistId'
)
this.replacements.videoPlaylistId = playlistId
@@ -344,7 +348,7 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
private whereStateAvailable () {
this.and.push(
`("video"."state" = ${VideoState.PUBLISHED} OR ` +
- `("video"."state" = ${VideoState.TO_TRANSCODE} AND "video"."waitTranscoding" IS false))`
+ `("video"."state" = ${VideoState.TO_TRANSCODE} AND "video"."waitTranscoding" IS false))`
)
}
@@ -389,22 +393,27 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
this.replacements.videoChannelId = channelId
}
+ private whereChannelOneOf (channelOneOf: string[]) {
+ this.joins.push('INNER JOIN "actor" "channelActor" ON "videoChannel"."actorId" = "channelActor"."id"')
+ this.and.push('"channelActor"."preferredUsername" IN (:channelOneOf)')
+ this.replacements.channelOneOf = channelOneOf
+ }
+
private whereFollowerActorId (options: { actorId: number, orLocalVideos: boolean }) {
- let query =
- '(' +
- ' EXISTS (' + // Videos shared by actors we follow
- ' SELECT 1 FROM "videoShare" ' +
- ' INNER JOIN "actorFollow" "actorFollowShare" ON "actorFollowShare"."targetActorId" = "videoShare"."actorId" ' +
- ' AND "actorFollowShare"."actorId" = :followerActorId AND "actorFollowShare"."state" = \'accepted\' ' +
- ' WHERE "videoShare"."videoId" = "video"."id"' +
- ' )' +
- ' OR' +
- ' EXISTS (' + // Videos published by channels or accounts we follow
- ' SELECT 1 from "actorFollow" ' +
- ' WHERE ("actorFollow"."targetActorId" = "account"."actorId" OR "actorFollow"."targetActorId" = "videoChannel"."actorId") ' +
- ' AND "actorFollow"."actorId" = :followerActorId ' +
- ' AND "actorFollow"."state" = \'accepted\'' +
- ' )'
+ let query = '(' +
+ ' EXISTS (' + // Videos shared by actors we follow
+ ' SELECT 1 FROM "videoShare" ' +
+ ' INNER JOIN "actorFollow" "actorFollowShare" ON "actorFollowShare"."targetActorId" = "videoShare"."actorId" ' +
+ ' AND "actorFollowShare"."actorId" = :followerActorId AND "actorFollowShare"."state" = \'accepted\' ' +
+ ' WHERE "videoShare"."videoId" = "video"."id"' +
+ ' )' +
+ ' OR' +
+ ' EXISTS (' + // Videos published by channels or accounts we follow
+ ' SELECT 1 from "actorFollow" ' +
+ ' WHERE ("actorFollow"."targetActorId" = "account"."actorId" OR "actorFollow"."targetActorId" = "videoChannel"."actorId") ' +
+ ' AND "actorFollow"."actorId" = :followerActorId ' +
+ ' AND "actorFollow"."state" = \'accepted\'' +
+ ' )'
if (options.orLocalVideos) {
query += ' OR "video"."remote" IS FALSE'
@@ -438,10 +447,10 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
const prefix = exists ? '' : 'NOT '
return prefix + 'EXISTS (' +
- ' SELECT 1 FROM "videoStreamingPlaylist" ' +
- ' INNER JOIN "videoFile" ON "videoFile"."videoStreamingPlaylistId" = "videoStreamingPlaylist"."id" ' +
- ' WHERE "videoStreamingPlaylist"."videoId" = "video"."id"' +
- ')'
+ ' SELECT 1 FROM "videoStreamingPlaylist" ' +
+ ' INNER JOIN "videoFile" ON "videoFile"."videoStreamingPlaylistId" = "videoStreamingPlaylist"."id" ' +
+ ' WHERE "videoStreamingPlaylist"."videoId" = "video"."id"' +
+ ')'
}
private whereTagsOneOf (tagsOneOf: string[]) {
@@ -449,10 +458,10 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
this.cte.push(
'"tagsOneOf" AS (' +
- ' SELECT "videoTag"."videoId" AS "videoId" FROM "videoTag" ' +
- ' INNER JOIN "tag" ON "tag"."id" = "videoTag"."tagId" ' +
- ' WHERE lower("tag"."name") IN (' + createSafeIn(this.sequelize, tagsOneOfLower) + ') ' +
- ')'
+ ' SELECT "videoTag"."videoId" AS "videoId" FROM "videoTag" ' +
+ ' INNER JOIN "tag" ON "tag"."id" = "videoTag"."tagId" ' +
+ ' WHERE lower("tag"."name") IN (' + createSafeIn(this.sequelize, tagsOneOfLower) + ') ' +
+ ')'
)
this.joins.push('INNER JOIN "tagsOneOf" ON "video"."id" = "tagsOneOf"."videoId"')
@@ -463,10 +472,10 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
this.cte.push(
'"autoTagsOneOf" AS (' +
- ' SELECT "videoAutomaticTag"."videoId" AS "videoId" FROM "videoAutomaticTag" ' +
- ' INNER JOIN "automaticTag" ON "automaticTag"."id" = "videoAutomaticTag"."automaticTagId" ' +
- ' WHERE lower("automaticTag"."name") IN (' + createSafeIn(this.sequelize, tags) + ') ' +
- ')'
+ ' SELECT "videoAutomaticTag"."videoId" AS "videoId" FROM "videoAutomaticTag" ' +
+ ' INNER JOIN "automaticTag" ON "automaticTag"."id" = "videoAutomaticTag"."automaticTagId" ' +
+ ' WHERE lower("automaticTag"."name") IN (' + createSafeIn(this.sequelize, tags) + ') ' +
+ ')'
)
this.joins.push('INNER JOIN "autoTagsOneOf" ON "video"."id" = "autoTagsOneOf"."videoId"')
@@ -477,11 +486,11 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
this.cte.push(
'"tagsAllOf" AS (' +
- ' SELECT "videoTag"."videoId" AS "videoId" FROM "videoTag" ' +
- ' INNER JOIN "tag" ON "tag"."id" = "videoTag"."tagId" ' +
- ' WHERE lower("tag"."name") IN (' + createSafeIn(this.sequelize, tagsAllOfLower) + ') ' +
- ' GROUP BY "videoTag"."videoId" HAVING COUNT(*) = ' + tagsAllOfLower.length +
- ')'
+ ' SELECT "videoTag"."videoId" AS "videoId" FROM "videoTag" ' +
+ ' INNER JOIN "tag" ON "tag"."id" = "videoTag"."tagId" ' +
+ ' WHERE lower("tag"."name") IN (' + createSafeIn(this.sequelize, tagsAllOfLower) + ') ' +
+ ' GROUP BY "videoTag"."videoId" HAVING COUNT(*) = ' + tagsAllOfLower.length +
+ ')'
)
this.joins.push('INNER JOIN "tagsAllOf" ON "video"."id" = "tagsAllOf"."videoId"')
@@ -516,10 +525,10 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
languagesQueryParts.push(
'EXISTS (' +
- ' SELECT 1 FROM "videoCaption" WHERE "videoCaption"."language" ' +
- ' IN (' + createSafeIn(this.sequelize, languages) + ') AND ' +
- ' "videoCaption"."videoId" = "video"."id"' +
- ')'
+ ' SELECT 1 FROM "videoCaption" WHERE "videoCaption"."language" ' +
+ ' IN (' + createSafeIn(this.sequelize, languages) + ') AND ' +
+ ' "videoCaption"."videoId" = "video"."id"' +
+ ')'
)
}
@@ -556,14 +565,14 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
this.and.push(
'NOT EXISTS (' +
- ' SELECT 1 FROM "accountBlocklist" ' +
- ' WHERE "accountBlocklist"."accountId" IN (' + inClause + ') ' +
- ' AND "accountBlocklist"."targetAccountId" = "account"."id" ' +
- ')' +
- 'AND NOT EXISTS (' +
- ' SELECT 1 FROM "serverBlocklist" WHERE "serverBlocklist"."accountId" IN (' + inClause + ') ' +
- ' AND "serverBlocklist"."targetServerId" = "accountActor"."serverId"' +
- ')'
+ ' SELECT 1 FROM "accountBlocklist" ' +
+ ' WHERE "accountBlocklist"."accountId" IN (' + inClause + ') ' +
+ ' AND "accountBlocklist"."targetAccountId" = "account"."id" ' +
+ ')' +
+ 'AND NOT EXISTS (' +
+ ' SELECT 1 FROM "serverBlocklist" WHERE "serverBlocklist"."accountId" IN (' + inClause + ') ' +
+ ' AND "serverBlocklist"."targetServerId" = "accountActor"."serverId"' +
+ ')'
)
}
@@ -580,24 +589,24 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
this.cte.push(
'"trigramSearch" AS (' +
- ' SELECT "video"."id", ' +
- ` word_similarity(lower(immutable_unaccent(${escapedSearch})), lower(immutable_unaccent("video"."name"))) as similarity ` +
- ' FROM "video" ' +
- ' WHERE lower(immutable_unaccent(' + escapedSearch + ')) <% lower(immutable_unaccent("video"."name")) OR ' +
- ' lower(immutable_unaccent("video"."name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))' +
- ')'
+ ' SELECT "video"."id", ' +
+ ` word_similarity(lower(immutable_unaccent(${escapedSearch})), lower(immutable_unaccent("video"."name"))) as similarity ` +
+ ' FROM "video" ' +
+ ' WHERE lower(immutable_unaccent(' + escapedSearch + ')) <% lower(immutable_unaccent("video"."name")) OR ' +
+ ' lower(immutable_unaccent("video"."name")) LIKE lower(immutable_unaccent(' + escapedLikeSearch + '))' +
+ ')'
)
this.joins.push('LEFT JOIN "trigramSearch" ON "video"."id" = "trigramSearch"."id"')
let base = '(' +
- ' "trigramSearch"."id" IS NOT NULL OR ' +
- ' EXISTS (' +
- ' SELECT 1 FROM "videoTag" ' +
- ' INNER JOIN "tag" ON "tag"."id" = "videoTag"."tagId" ' +
- ` WHERE lower("tag"."name") = lower(${escapedSearch}) ` +
- ' AND "video"."id" = "videoTag"."videoId"' +
- ' )'
+ ' "trigramSearch"."id" IS NOT NULL OR ' +
+ ' EXISTS (' +
+ ' SELECT 1 FROM "videoTag" ' +
+ ' INNER JOIN "tag" ON "tag"."id" = "videoTag"."tagId" ' +
+ ` WHERE lower("tag"."name") = lower(${escapedSearch}) ` +
+ ' AND "video"."id" = "videoTag"."videoId"' +
+ ' )'
if (validator.default.isUUID(search)) {
base += ` OR "video"."uuid" = ${escapedSearch}`
@@ -646,11 +655,11 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
private whereExcludeAlreadyWatched (userId: number) {
this.and.push(
'NOT EXISTS (' +
- ' SELECT 1' +
- ' FROM "userVideoHistory"' +
- ' WHERE "video"."id" = "userVideoHistory"."videoId"' +
- ' AND "userVideoHistory"."userId" = :excludeAlreadyWatchedUserId' +
- ')'
+ ' SELECT 1' +
+ ' FROM "userVideoHistory"' +
+ ' WHERE "video"."id" = "userVideoHistory"."videoId"' +
+ ' AND "userVideoHistory"."userId" = :excludeAlreadyWatchedUserId' +
+ ')'
)
this.replacements.excludeAlreadyWatchedUserId = userId
}
@@ -692,8 +701,7 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
this.joins.push('LEFT JOIN "videoComment" ON "video"."id" = "videoComment"."videoId"')
- let attribute =
- `LOG(GREATEST(1, "video"."likes" - 1)) * ${weights.like} ` + // likes (+)
+ let attribute = `LOG(GREATEST(1, "video"."likes" - 1)) * ${weights.like} ` + // likes (+)
`+ LOG(GREATEST(1, "video"."dislikes" - 1)) * ${weights.dislike} ` + // dislikes (-)
`+ LOG("video"."views" + 1) * ${weights.view} ` + // views (+)
`+ LOG(GREATEST(1, COUNT(DISTINCT "videoComment"."id"))) * ${weights.comment} ` + // comments (+)
@@ -723,22 +731,22 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
this.attributes.push(
'(' +
'CASE ' +
- 'WHEN "video"."remote" IS TRUE THEN 0 ' + // Consider remote videos with size of 0
- 'ELSE (' +
- '(SELECT COALESCE(SUM(size), 0) FROM "videoFile" WHERE "videoFile"."videoId" = "video"."id")' +
- ' + ' +
- '(' +
- 'SELECT COALESCE(SUM(size), 0) FROM "videoFile" ' +
- 'INNER JOIN "videoStreamingPlaylist" ON "videoStreamingPlaylist"."id" = "videoFile"."videoStreamingPlaylistId" ' +
- 'AND "videoStreamingPlaylist"."videoId" = "video"."id"' +
- ')' +
- ' + ' +
- '(' +
- 'SELECT COALESCE(SUM(size), 0) FROM "videoSource" ' +
- 'WHERE "videoSource"."videoId" = "video"."id" AND "videoSource"."storage" IS NOT NULL' +
- ')' +
- ') END' +
- ') AS "localVideoFilesSize"'
+ 'WHEN "video"."remote" IS TRUE THEN 0 ' + // Consider remote videos with size of 0
+ 'ELSE (' +
+ '(SELECT COALESCE(SUM(size), 0) FROM "videoFile" WHERE "videoFile"."videoId" = "video"."id")' +
+ ' + ' +
+ '(' +
+ 'SELECT COALESCE(SUM(size), 0) FROM "videoFile" ' +
+ 'INNER JOIN "videoStreamingPlaylist" ON "videoStreamingPlaylist"."id" = "videoFile"."videoStreamingPlaylistId" ' +
+ 'AND "videoStreamingPlaylist"."videoId" = "video"."id"' +
+ ')' +
+ ' + ' +
+ '(' +
+ 'SELECT COALESCE(SUM(size), 0) FROM "videoSource" ' +
+ 'WHERE "videoSource"."videoId" = "video"."id" AND "videoSource"."storage" IS NOT NULL' +
+ ')' +
+ ') END' +
+ ') AS "localVideoFilesSize"'
)
}
diff --git a/server/core/models/video/sql/video/videos-model-list-query-builder.ts b/server/core/models/video/sql/video/videos-model-list-query-builder.ts
index d4697bedc5..675b9dae61 100644
--- a/server/core/models/video/sql/video/videos-model-list-query-builder.ts
+++ b/server/core/models/video/sql/video/videos-model-list-query-builder.ts
@@ -9,9 +9,7 @@ import { getServerActor } from '@server/models/application/application.js'
import { MActorAccount } from '@server/types/models/index.js'
/**
- *
* Build videos list SQL query and create video models
- *
*/
export class VideosModelListQueryBuilder extends AbstractVideoQueryBuilder {
@@ -113,6 +111,10 @@ export class VideosModelListQueryBuilder extends AbstractVideoQueryBuilder {
this.includeTags()
}
+ if (options.include & VideoInclude.NOT_PUBLISHED_STATE) {
+ this.includeScheduleUpdate()
+ }
+
const select = this.buildSelect()
this.query = `${select} FROM (${this.innerQuery}) AS "tmp" ${this.joins} ${this.innerSort}`
diff --git a/server/core/models/video/video.ts b/server/core/models/video/video.ts
index 377e5d4054..2e57704147 100644
--- a/server/core/models/video/video.ts
+++ b/server/core/models/video/video.ts
@@ -40,7 +40,7 @@ import { ModelCache } from '@server/models/shared/model-cache.js'
import { MVideoSource } from '@server/types/models/video/video-source.js'
import Bluebird from 'bluebird'
import { remove } from 'fs-extra/esm'
-import { FindOptions, Includeable, Op, QueryTypes, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize'
+import { FindOptions, Includeable, Op, QueryTypes, Sequelize, Transaction } from 'sequelize'
import {
AfterCreate,
AfterDestroy,
@@ -59,13 +59,14 @@ import {
Is,
IsInt,
IsUUID,
- Min, Scopes,
+ Min,
+ Scopes,
Table,
UpdatedAt
} from 'sequelize-typescript'
import { peertubeTruncate } from '../../helpers/core-utils.js'
import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js'
-import { exists, isArray, isBooleanValid, isUUIDValid } from '../../helpers/custom-validators/misc.js'
+import { isArray, isBooleanValid, isUUIDValid } from '../../helpers/custom-validators/misc.js'
import {
isVideoDescriptionValid,
isVideoDurationValid,
@@ -93,7 +94,6 @@ import {
MVideoCaptionLanguageUrl,
MVideoDetails,
MVideoFileVideo,
- MVideoForUser,
MVideoFormattable,
MVideoFormattableDetails,
MVideoFullLight,
@@ -171,7 +171,6 @@ export enum ScopeNames {
WITH_ACCOUNT_DETAILS = 'WITH_ACCOUNT_DETAILS',
WITH_TAGS = 'WITH_TAGS',
WITH_WEB_VIDEO_FILES = 'WITH_WEB_VIDEO_FILES',
- WITH_SCHEDULED_UPDATE = 'WITH_SCHEDULED_UPDATE',
WITH_BLACKLISTED = 'WITH_BLACKLISTED',
WITH_STREAMING_PLAYLISTS = 'WITH_STREAMING_PLAYLISTS',
WITH_IMMUTABLE_ATTRIBUTES = 'WITH_IMMUTABLE_ATTRIBUTES',
@@ -196,7 +195,8 @@ export type ForAPIOptions = {
{
model: VideoChannelModel.scope({
method: [
- VideoChannelScopeNames.SUMMARY, {
+ VideoChannelScopeNames.SUMMARY,
+ {
withAccount: true,
withAccountBlockerIds: options.withAccountBlockerIds
} as SummaryOptions
@@ -337,14 +337,6 @@ export type ForAPIOptions = {
]
}
},
- [ScopeNames.WITH_SCHEDULED_UPDATE]: {
- include: [
- {
- model: ScheduleVideoUpdateModel.unscoped(),
- required: false
- }
- ]
- },
[ScopeNames.WITH_USER_HISTORY]: (userId: number) => {
return {
include: [
@@ -441,7 +433,6 @@ export type ForAPIOptions = {
]
})
export class VideoModel extends SequelizeModel<VideoModel> {
-
@AllowNull(false)
@Default(DataType.UUIDV4)
@IsUUID(4)
@@ -1041,85 +1032,6 @@ export class VideoModel extends SequelizeModel<VideoModel> {
return result.map(v => v.uuid)
}
- static listUserVideosForApi (options: {
- accountId: number
- start: number
- count: number
- sort: string
-
- channelId?: number
- isLive?: boolean
- search?: string
- }) {
- const { accountId, channelId, start, count, sort, search, isLive } = options
-
- function buildBaseQuery (forCount: boolean): FindOptions {
- const where: WhereOptions = {}
-
- if (search) {
- where.name = {
- [Op.iLike]: '%' + search + '%'
- }
- }
-
- if (exists(isLive)) {
- where.isLive = isLive
- }
-
- const channelWhere = channelId
- ? { id: channelId }
- : {}
-
- const baseQuery = {
- offset: start,
- limit: count,
- where,
- order: getVideoSort(sort),
- include: [
- {
- model: forCount
- ? VideoChannelModel.unscoped()
- : VideoChannelModel,
- required: true,
- where: channelWhere,
- include: [
- {
- model: forCount
- ? AccountModel.unscoped()
- : AccountModel,
- where: {
- id: accountId
- },
- required: true
- }
- ]
- }
- ]
- }
-
- return baseQuery
- }
-
- const countQuery = buildBaseQuery(true)
- const findQuery = buildBaseQuery(false)
-
- const findScopes: (string | ScopeOptions)[] = [
- ScopeNames.WITH_SCHEDULED_UPDATE,
- ScopeNames.WITH_BLACKLISTED,
- ScopeNames.WITH_THUMBNAILS
- ]
-
- return Promise.all([
- VideoModel.count(countQuery),
- VideoModel.scope(findScopes).findAll<MVideoForUser>(findQuery)
- ]).then(([ count, rows ]) => {
- return {
- data: rows,
- total: count
- }
- })
- }
-
static async listForApi (options: {
start: number
count: number
@@ -1146,7 +1058,9 @@ export class VideoModel extends SequelizeModel<VideoModel> {
host?: string
accountId?: number
+
videoChannelId?: number
+ channelNameOneOf?: string[]
displayOnlyForFollower: DisplayOnlyForFollowerOptions | null
@@ -1157,16 +1071,16 @@ export class VideoModel extends SequelizeModel<VideoModel> {
user?: MUserAccountId
historyOfUser?: MUserId
- countVideos?: boolean
+ countVideos?: boolean // default true
search?: string
- excludeAlreadyWatched?: boolean
+ excludeAlreadyWatched?: boolean // default false
autoTagOneOf?: string[]
}) {
- VideoModel.throwIfPrivateIncludeWithoutUser(options.include, options.user)
- VideoModel.throwIfPrivacyOneOfWithoutUser(options.privacyOneOf, options.user)
+ VideoModel.throwIfPrivateIncludeWithoutUser(options)
+ VideoModel.throwIfPrivacyOneOfWithoutUser(options)
const trendingDays = options.sort.endsWith('trending')
? CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS
@@ -1199,6 +1113,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
'hasFiles',
'accountId',
'videoChannelId',
+ 'channelNameOneOf',
'videoPlaylistId',
'user',
'historyOfUser',
@@ -1259,8 +1174,8 @@ export class VideoModel extends SequelizeModel<VideoModel> {
autoTagOneOf?: string[]
}) {
- VideoModel.throwIfPrivateIncludeWithoutUser(options.include, options.user)
- VideoModel.throwIfPrivacyOneOfWithoutUser(options.privacyOneOf, options.user)
+ VideoModel.throwIfPrivateIncludeWithoutUser(options)
+ VideoModel.throwIfPrivacyOneOfWithoutUser(options)
const serverActor = await getServerActor()
@@ -1560,7 +1475,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
const rawQuery = `UPDATE "video" SET "${field}" = ` +
'(' +
- 'SELECT COUNT(id) FROM "accountVideoRate" WHERE "accountVideoRate"."videoId" = "video"."id" AND type = :rateType' +
+ 'SELECT COUNT(id) FROM "accountVideoRate" WHERE "accountVideoRate"."videoId" = "video"."id" AND type = :rateType' +
') ' +
'WHERE "video"."id" = :videoId'
@@ -1591,7 +1506,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
}
return VideoModel.sequelize.query(query, options)
- .then(results => results.length === 1)
+ .then(results => results.length === 1)
}
static bulkUpdateSupportField (ofChannel: MChannel, t: Transaction) {
@@ -1729,22 +1644,40 @@ export class VideoModel extends SequelizeModel<VideoModel> {
}
}
- private static throwIfPrivateIncludeWithoutUser (include: VideoIncludeType, user: MUserAccountId) {
- if (VideoModel.isPrivateInclude(include) && !user?.hasRight(UserRight.SEE_ALL_VIDEOS)) {
- throw new Error('Try to include protected videos but user cannot see all videos')
- }
+ private static throwIfPrivateIncludeWithoutUser (options: {
+ include?: VideoIncludeType
+ user?: MUserAccountId
+ accountId?: number
+ }) {
+ const { include, user, accountId } = options
+
+ if (!VideoModel.isPrivateInclude(include)) return
+ if (user?.hasRight(UserRight.SEE_ALL_VIDEOS)) return
+ if (user.Account.id === accountId) return
+
+ throw new Error('Try to include protected videos but user cannot see all videos')
}
- private static throwIfPrivacyOneOfWithoutUser (privacyOneOf: VideoPrivacyType[], user: MUserAccountId) {
- if (privacyOneOf && !user?.hasRight(UserRight.SEE_ALL_VIDEOS)) {
- throw new Error('Try to choose video privacies but user cannot see all videos')
- }
+ private static throwIfPrivacyOneOfWithoutUser (options: {
+ user?: MUserAccountId
+ privacyOneOf?: VideoPrivacyType[]
+ accountId?: number
+ }) {
+ const { user, privacyOneOf, accountId } = options
+
+ if (!privacyOneOf) return
+ if (user?.hasRight(UserRight.SEE_ALL_VIDEOS)) return
+ if (user.Account.id === accountId) return
+
+ throw new Error('Try to choose video privacies but user cannot see all videos')
}
private static isPrivateInclude (include: VideoIncludeType) {
- return include & VideoInclude.BLACKLISTED ||
- include & VideoInclude.BLOCKED_OWNER ||
- include & VideoInclude.NOT_PUBLISHED_STATE
+ return !!(
+ include & VideoInclude.BLACKLISTED ||
+ include & VideoInclude.BLOCKED_OWNER ||
+ include & VideoInclude.NOT_PUBLISHED_STATE
+ )
}
isBlacklisted () {
@@ -1757,7 +1690,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
// ---------------------------------------------------------------------------
- getMaxQualityAudioAndVideoFiles <T extends MVideoWithFile> (this: T) {
+ getMaxQualityAudioAndVideoFiles<T extends MVideoWithFile> (this: T) {
const videoFile = this.getMaxQualityFile(VideoFileStream.VIDEO)
if (!videoFile) {
@@ -1783,7 +1716,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
return this.getQualityFileBy(streamFilter, maxBy)
}
- getMaxQualityBytes <T extends MVideoWithFile> (this: T) {
+ getMaxQualityBytes<T extends MVideoWithFile> (this: T) {
const { videoFile, separatedAudioFile } = this.getMaxQualityAudioAndVideoFiles()
let size = videoFile?.size || 0
@@ -2022,7 +1955,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
}
setHLSPlaylist (playlist: MStreamingPlaylist) {
- const toAdd = [ playlist ] as [ VideoStreamingPlaylistModel ]
+ const toAdd = [ playlist ] as [VideoStreamingPlaylistModel]
if (Array.isArray(this.VideoStreamingPlaylists) === false || this.VideoStreamingPlaylists.length === 0) {
this.VideoStreamingPlaylists = toAdd
@@ -2030,8 +1963,8 @@ export class VideoModel extends SequelizeModel<VideoModel> {
}
this.VideoStreamingPlaylists = this.VideoStreamingPlaylists
- .filter(s => s.type !== VideoStreamingPlaylistType.HLS)
- .concat(toAdd)
+ .filter(s => s.type !== VideoStreamingPlaylistType.HLS)
+ .concat(toAdd)
}
// ---------------------------------------------------------------------------
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml
index a3380343dc..088d3459d6 100644
--- a/support/doc/api/openapi.yaml
+++ b/support/doc/api/openapi.yaml
@@ -2176,9 +2176,27 @@ paths:
- My User
- Videos
parameters:
+ - $ref: '#/components/parameters/categoryOneOf'
+ - $ref: '#/components/parameters/isLive'
+ - $ref: '#/components/parameters/tagsOneOf'
+ - $ref: '#/components/parameters/tagsAllOf'
+ - $ref: '#/components/parameters/licenceOneOf'
+ - $ref: '#/components/parameters/languageOneOf'
+ - $ref: '#/components/parameters/host'
+ - $ref: '#/components/parameters/autoTagOneOfVideo'
+ - $ref: '#/components/parameters/nsfw'
+ - $ref: '#/components/parameters/isLocal'
+ - $ref: '#/components/parameters/include'
+ - $ref: '#/components/parameters/privacyOneOf'
+ - $ref: '#/components/parameters/hasHLSFiles'
+ - $ref: '#/components/parameters/hasWebVideoFiles'
+ - $ref: '#/components/parameters/skipCount'
- $ref: '#/components/parameters/start'
- $ref: '#/components/parameters/count'
- - $ref: '#/components/parameters/sort'
+ - $ref: '#/components/parameters/videosSort'
+ - $ref: '#/components/parameters/excludeAlreadyWatched'
+ - $ref: '#/components/parameters/search'
+ - $ref: '#/components/parameters/channelNameOneOf'
responses:
'200':
description: successful operation
@@ -7490,6 +7508,19 @@ components:
type: string
style: form
explode: true
+ channelNameOneOf:
+ name: channelNameOneOf
+ in: query
+ required: false
+ description: "**PeerTube >= 7.2** Filter on videos that are published by a channel with one of these names"
+ schema:
+ oneOf:
+ - type: string
+ - type: array
+ items:
+ type: string
+ style: form
+ explode: true
autoTagOneOfComment:
name: autoTagOneOf
in: query
@@ -7538,13 +7569,12 @@ components:
name: nsfw
in: query
required: false
- description: Whether to include nsfw videos, if any. The default value is set by the admin.
+ description: whether to include nsfw videos, if any
schema:
type: string
enum:
- 'true'
- 'false'
- - 'both'
isLocal:
name: isLocal
in: query
@@ -7571,27 +7601,8 @@ components:
in: query
required: false
schema:
- allOf:
- - $ref: '#/components/schemas/VideoPrivacySet'
- description: >
- **Only administrators and moderators can use this parameter**
-
-
- Display only videos in this specific privacy/privacies. By default, list public videos for anonymous users and public/internal videos for authenticated users
-
- - `1` PUBLIC
-
- - `2` UNLISTED
-
- - `3` PRIVATE
-
- - `4` INTERNAL
-
- - `5` PASSWORD_PROTECTED
- examples:
- password:
- value: 5
- summary: Display only password protected videos
+ $ref: '#/components/schemas/VideoPrivacySet'
+ description: '**PeerTube >= 4.0** Display only videos in this specific privacy/privacies'
excludeAlreadyWatched:
name: excludeAlreadyWatched
in: query
@@ -7635,14 +7646,11 @@ components:
- 8
- 16
- 32
- - 64
- - 128
description: >
**Only administrators and moderators can use this parameter**
- Include additional videos in results (can be combined using bitwise or operator).
- By default PeerTube only list published videos that are not blocked.
+ Include additional videos in results (can be combined using bitwise or operator)
- `0` NONE
@@ -7657,17 +7665,6 @@ components:
- `16` CAPTIONS
- `32` VIDEO SOURCE
-
- - `64`: AUTOMATIC_TAGS
-
- - `128`: TAGS
- examples:
- includeAll:
- value: 3
- summary: Include not published and blacklisted videos (1 + 2)
- includeAllWithFiles:
- value: 24
- summary: Add files and captions to video JSON representation (8 + 16)
subscriptionsUris:
name: uris
in: query
@@ -8733,7 +8730,32 @@ components:
minLength: 2
maxLength: 3000
video:
- $ref: '#/components/schemas/VideoInfo'
+ type: object
+ properties:
+ id:
+ type: integer
+ uuid:
+ $ref: '#/components/schemas/UUIDv4'
+ shortUUID:
+ $ref: '#/components/schemas/shortUUID'
+ name:
+ type: string
+ nsfw:
+ type: boolean
+ startAt:
+ type: string
+ format: date-time
+ endAt:
+ type: string
+ format: date-time
+ deleted:
+ type: boolean
+ blacklisted:
+ type: boolean
+ thumbnailPath:
+ type: string
+ channel:
+ $ref: '#/components/schemas/VideoChannel'
createdAt:
type: string
format: date-time
diff --git a/yarn.lock b/yarn.lock
index a86f1f554b..fb3c324494 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -10816,6 +10816,11 @@ type-fest@^4.26.1:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.35.0.tgz#007ed74d65c2ca0fb3b564b3dc8170d5c872d665"
integrity sha512-2/AwEFQDFEy30iOLjrvHDIH7e4HEWH+f1Yl1bI5XMqzuoCUqwYCdxachgsgv0og/JdVZUhbfjcJAoHj5L1753A==
+type-fest@^4.37.0:
+ version "4.37.0"
+ resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.37.0.tgz#7cf008bf77b63a33f7ca014fa2a3f09fd69e8937"
+ integrity sha512-S/5/0kFftkq27FPNye0XM1e2NsnoD/3FS+pBmbjmmtLT6I+i344KoOf7pvXreaFsDamWeaJX55nczA1m5PsBDg==
+
[email protected], type-is@^1.6.4, type-is@~1.6.18:
version "1.6.18"
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131"