1
0
Fork 0

Add ability to preview embed in share modal

This commit is contained in:
Chocobozzz 2021-11-02 10:01:28 +01:00
parent eeae81428e
commit f1c861727c
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 40 additions and 8 deletions

View File

@ -1,7 +1,7 @@
<div class="input-group input-group-sm"> <div class="input-group input-group-sm">
<input <input
[id]="inputId" [autocomplete]="autocomplete" [value]="value" [placeholder]="placeholder" [tabindex]="tabindex" [id]="inputId" [autocomplete]="autocomplete" [value]="value" [placeholder]="placeholder" [tabindex]="tabindex"
[(ngModel)]="value" (ngModelChange)="update()" [ngClass]="{ 'readonly': readonly }" [readonly]="readonly" [(ngModel)]="value" (ngModelChange)="update()" [readonly]="readonly"
#input (click)="input.select()" (input)="update()" (change)="update()" [type]="inputType" class="form-control" #input (click)="input.select()" (input)="update()" (change)="update()" [type]="inputType" class="form-control"
/> />

View File

@ -10,7 +10,6 @@
<div class="playlist" *ngIf="playlist"> <div class="playlist" *ngIf="playlist">
<div class="title-page title-page-single" i18n *ngIf="video">Share the playlist</div> <div class="title-page title-page-single" i18n *ngIf="video">Share the playlist</div>
<div *ngIf="isPrivatePlaylist()" class="alert-private alert alert-warning"> <div *ngIf="isPrivatePlaylist()" class="alert-private alert alert-warning">
<div i18n>This playlist is private so you won't be able to share it with external users</div> <div i18n>This playlist is private so you won't be able to share it with external users</div>
@ -47,11 +46,16 @@
<ng-template ngbNavContent> <ng-template ngbNavContent>
<div class="nav-content"> <div class="nav-content">
<my-input-toggle-hidden [value]="getPlaylistIframeCode()" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden> <my-input-toggle-hidden
[value]="getPlaylistIframeCode()" (change)="updateEmbedCode()"
[withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"
></my-input-toggle-hidden>
<div i18n *ngIf="notSecure()" class="alert alert-warning"> <div i18n *ngIf="notSecure()" class="alert alert-warning">
The url is not secured (no HTTPS), so the embed video won't work on HTTPS websites (web browsers block non secured HTTP requests on HTTPS websites). The url is not secured (no HTTPS), so the embed video won't work on HTTPS websites (web browsers block non secured HTTP requests on HTTPS websites).
</div> </div>
<div [innerHTML]="playlistEmbedHTML"></div>
</div> </div>
</ng-template> </ng-template>
</ng-container> </ng-container>
@ -109,11 +113,16 @@
<ng-template ngbNavContent> <ng-template ngbNavContent>
<div class="nav-content"> <div class="nav-content">
<my-input-toggle-hidden [value]="getVideoIframeCode()" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden> <my-input-toggle-hidden
[value]="getVideoIframeCode()" (ngModelChange)="updateEmbedCode()"
[withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"
></my-input-toggle-hidden>
<div i18n *ngIf="notSecure()" class="alert alert-warning"> <div i18n *ngIf="notSecure()" class="alert alert-warning">
The url is not secured (no HTTPS), so the embed video won't work on HTTPS websites (web browsers block non secured HTTP requests on HTTPS websites). The url is not secured (no HTTPS), so the embed video won't work on HTTPS websites (web browsers block non secured HTTP requests on HTTPS websites).
</div> </div>
<div [innerHTML]="videoEmbedHTML"></div>
</div> </div>
</ng-template> </ng-template>
</ng-container> </ng-container>

View File

@ -1,4 +1,5 @@
import { Component, ElementRef, Input, ViewChild } from '@angular/core' import { Component, ElementRef, Input, ViewChild } from '@angular/core'
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
import { VideoDetails } from '@app/shared/shared-main' import { VideoDetails } from '@app/shared/shared-main'
import { VideoPlaylist } from '@app/shared/shared-video-playlist' import { VideoPlaylist } from '@app/shared/shared-video-playlist'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
@ -48,7 +49,13 @@ export class VideoShareComponent {
isAdvancedCustomizationCollapsed = true isAdvancedCustomizationCollapsed = true
includeVideoInPlaylist = false includeVideoInPlaylist = false
constructor (private modalService: NgbModal) { } playlistEmbedHTML: SafeHtml
videoEmbedHTML: SafeHtml
constructor (
private modalService: NgbModal,
private sanitizer: DomSanitizer
) { }
show (currentVideoTimestamp?: number, currentPlaylistPosition?: number) { show (currentVideoTimestamp?: number, currentPlaylistPosition?: number) {
let subtitle: string let subtitle: string
@ -56,7 +63,7 @@ export class VideoShareComponent {
subtitle = this.videoCaptions[0].language.id subtitle = this.videoCaptions[0].language.id
} }
this.customizations = { this.customizations = new Proxy({
startAtCheckbox: false, startAtCheckbox: false,
startAt: currentVideoTimestamp ? Math.floor(currentVideoTimestamp) : 0, startAt: currentVideoTimestamp ? Math.floor(currentVideoTimestamp) : 0,
@ -76,10 +83,20 @@ export class VideoShareComponent {
warningTitle: true, warningTitle: true,
controls: true, controls: true,
peertubeLink: true peertubeLink: true
} }, {
set: (target, prop, value) => {
target[prop] = value
this.updateEmbedCode()
return true
}
})
this.playlistPosition = currentPlaylistPosition this.playlistPosition = currentPlaylistPosition
this.updateEmbedCode()
this.modalService.open(this.modal, { centered: true }) this.modalService.open(this.modal, { centered: true })
} }
@ -114,6 +131,12 @@ export class VideoShareComponent {
return decoratePlaylistLink({ url, playlistPosition: this.playlistPosition }) return decoratePlaylistLink({ url, playlistPosition: this.playlistPosition })
} }
updateEmbedCode () {
if (this.playlist) this.playlistEmbedHTML = this.sanitizer.bypassSecurityTrustHtml(this.getPlaylistIframeCode())
if (this.video) this.videoEmbedHTML = this.sanitizer.bypassSecurityTrustHtml(this.getVideoIframeCode())
}
notSecure () { notSecure () {
return window.location.protocol === 'http:' return window.location.protocol === 'http:'
} }

View File

@ -92,7 +92,7 @@ strong {
font-weight: $font-semibold; font-weight: $font-semibold;
} }
input.readonly { input[readonly] {
/* Force blank on readonly inputs */ /* Force blank on readonly inputs */
background-color: pvar(--inputBackgroundColor) !important; background-color: pvar(--inputBackgroundColor) !important;
} }