aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-watch/modal
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-23 14:49:20 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-06-23 16:00:49 +0200
commit1942f11d5ee6926ad93dc1b79fae18325ba5de18 (patch)
tree3f2a3cd9466a56c419d197ac832a3e9cbc86bec4 /client/src/app/+videos/+video-watch/modal
parent67ed6552b831df66713bac9e672738796128d33f (diff)
downloadPeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.tar.gz
PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.tar.zst
PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.zip
Lazy load all routes
Diffstat (limited to 'client/src/app/+videos/+video-watch/modal')
-rw-r--r--client/src/app/+videos/+video-watch/modal/video-share.component.html187
-rw-r--r--client/src/app/+videos/+video-watch/modal/video-share.component.scss79
-rw-r--r--client/src/app/+videos/+video-watch/modal/video-share.component.ts126
-rw-r--r--client/src/app/+videos/+video-watch/modal/video-support.component.html15
-rw-r--r--client/src/app/+videos/+video-watch/modal/video-support.component.scss3
-rw-r--r--client/src/app/+videos/+video-watch/modal/video-support.component.ts29
6 files changed, 439 insertions, 0 deletions
diff --git a/client/src/app/+videos/+video-watch/modal/video-share.component.html b/client/src/app/+videos/+video-watch/modal/video-share.component.html
new file mode 100644
index 000000000..5e6a2d518
--- /dev/null
+++ b/client/src/app/+videos/+video-watch/modal/video-share.component.html
@@ -0,0 +1,187 @@
1<ng-template #modal let-hide="close">
2 <div class="modal-header">
3 <h4 i18n class="modal-title">Share</h4>
4 <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon>
5 </div>
6
7
8 <div class="modal-body">
9 <div class="playlist" *ngIf="hasPlaylist()">
10 <div class="title-page title-page-single" i18n>Share the playlist</div>
11
12 <my-input-readonly-copy [value]="getPlaylistUrl()"></my-input-readonly-copy>
13
14 <div class="filters">
15
16 <div class="form-group">
17 <my-peertube-checkbox
18 inputName="includeVideoInPlaylist" [(ngModel)]="includeVideoInPlaylist"
19 i18n-labelText labelText="Share the playlist at this video position"
20 ></my-peertube-checkbox>
21 </div>
22
23 </div>
24 </div>
25
26
27 <div class="video">
28 <div class="title-page title-page-single" *ngIf="hasPlaylist()" i18n>Share the video</div>
29
30 <div ngbNav #nav="ngbNav" class="nav-tabs" [(activeId)]="activeId">
31
32 <ng-container ngbNavItem="url">
33 <a ngbNavLink i18n>URL</a>
34
35 <ng-template ngbNavContent>
36 <div class="nav-content">
37 <my-input-readonly-copy [value]="getVideoUrl()"></my-input-readonly-copy>
38 </div>
39 </ng-template>
40 </ng-container>
41
42 <ng-container ngbNavItem="qrcode">
43 <a ngbNavLink i18n>QR-Code</a>
44
45 <ng-template ngbNavContent>
46 <div class="nav-content">
47 <qrcode [qrdata]="getVideoUrl()" [size]="256" level="Q"></qrcode>
48 </div>
49 </ng-template>
50 </ng-container>
51
52 <ng-container ngbNavItem="embed">
53 <a ngbNavLink i18n>Embed</a>
54
55 <ng-template ngbNavContent>
56 <div class="nav-content">
57 <my-input-readonly-copy [value]="getVideoIframeCode()"></my-input-readonly-copy>
58
59 <div i18n *ngIf="notSecure()" class="alert alert-warning">
60 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).
61 </div>
62 </div>
63 </ng-template>
64 </ng-container>
65
66 </div>
67
68 <div [ngbNavOutlet]="nav"></div>
69
70 <div class="filters">
71 <div>
72 <div class="form-group start-at">
73 <my-peertube-checkbox
74 inputName="startAt" [(ngModel)]="customizations.startAtCheckbox"
75 i18n-labelText labelText="Start at"
76 ></my-peertube-checkbox>
77
78 <my-timestamp-input
79 [timestamp]="customizations.startAt"
80 [maxTimestamp]="video.duration"
81 [disabled]="!customizations.startAtCheckbox"
82 [(ngModel)]="customizations.startAt"
83 >
84 </my-timestamp-input>
85 </div>
86
87 <div *ngIf="videoCaptions.length !== 0" class="form-group video-caption-block">
88 <my-peertube-checkbox
89 inputName="subtitleCheckbox" [(ngModel)]="customizations.subtitleCheckbox"
90 i18n-labelText labelText="Auto select subtitle"
91 ></my-peertube-checkbox>
92
93 <div class="peertube-select-container" [ngClass]="{ disabled: !customizations.subtitleCheckbox }">
94 <select [(ngModel)]="customizations.subtitle" [disabled]="!customizations.subtitleCheckbox">
95 <option *ngFor="let caption of videoCaptions" [value]="caption.language.id">{{ caption.language.label }}</option>
96 </select>
97 </div>
98 </div>
99 </div>
100
101 <div class="advanced-filters collapse-transition" [ngbCollapse]="isAdvancedCustomizationCollapsed">
102 <div>
103 <div class="form-group stop-at">
104 <my-peertube-checkbox
105 inputName="stopAt" [(ngModel)]="customizations.stopAtCheckbox"
106 i18n-labelText labelText="Stop at"
107 ></my-peertube-checkbox>
108
109 <my-timestamp-input
110 [timestamp]="customizations.stopAt"
111 [maxTimestamp]="video.duration"
112 [disabled]="!customizations.stopAtCheckbox"
113 [(ngModel)]="customizations.stopAt"
114 >
115 </my-timestamp-input>
116 </div>
117
118 <div class="form-group">
119 <my-peertube-checkbox
120 inputName="autoplay" [(ngModel)]="customizations.autoplay"
121 i18n-labelText labelText="Autoplay"
122 ></my-peertube-checkbox>
123 </div>
124
125 <div class="form-group">
126 <my-peertube-checkbox
127 inputName="muted" [(ngModel)]="customizations.muted"
128 i18n-labelText labelText="Muted"
129 ></my-peertube-checkbox>
130 </div>
131
132 <div class="form-group">
133 <my-peertube-checkbox
134 inputName="loop" [(ngModel)]="customizations.loop"
135 i18n-labelText labelText="Loop"
136 ></my-peertube-checkbox>
137 </div>
138 </div>
139
140 <ng-container *ngIf="isInEmbedTab()">
141 <div class="form-group">
142 <my-peertube-checkbox
143 inputName="title" [(ngModel)]="customizations.title"
144 i18n-labelText labelText="Display video title"
145 ></my-peertube-checkbox>
146 </div>
147
148 <div class="form-group">
149 <my-peertube-checkbox
150 inputName="warningTitle" [(ngModel)]="customizations.warningTitle"
151 i18n-labelText labelText="Display privacy warning"
152 ></my-peertube-checkbox>
153 </div>
154
155 <div class="form-group">
156 <my-peertube-checkbox
157 inputName="controls" [(ngModel)]="customizations.controls"
158 i18n-labelText labelText="Display player controls"
159 ></my-peertube-checkbox>
160 </div>
161 </ng-container>
162 </div>
163
164 <div (click)="isAdvancedCustomizationCollapsed = !isAdvancedCustomizationCollapsed" role="button" class="advanced-filters-button"
165 [attr.aria-expanded]="!isAdvancedCustomizationCollapsed" aria-controls="collapseBasic">
166
167 <ng-container *ngIf="isAdvancedCustomizationCollapsed">
168 <span class="glyphicon glyphicon-menu-down"></span>
169
170 <ng-container i18n>
171 More customization
172 </ng-container>
173 </ng-container>
174
175 <ng-container *ngIf="!isAdvancedCustomizationCollapsed">
176 <span class="glyphicon glyphicon-menu-up"></span>
177
178 <ng-container i18n>
179 Less customization
180 </ng-container>
181 </ng-container>
182 </div>
183 </div>
184 </div>
185 </div>
186
187</ng-template>
diff --git a/client/src/app/+videos/+video-watch/modal/video-share.component.scss b/client/src/app/+videos/+video-watch/modal/video-share.component.scss
new file mode 100644
index 000000000..091d4dc3b
--- /dev/null
+++ b/client/src/app/+videos/+video-watch/modal/video-share.component.scss
@@ -0,0 +1,79 @@
1@import '_mixins';
2@import '_variables';
3
4my-input-readonly-copy {
5 width: 100%;
6}
7
8.title-page.title-page-single {
9 margin-top: 0;
10}
11
12.playlist {
13 margin-bottom: 50px;
14}
15
16.peertube-select-container {
17 @include peertube-select-container(200px);
18}
19
20.qr-code-group {
21 text-align: center;
22}
23
24.nav-content {
25 margin-top: 30px;
26 display: flex;
27 justify-content: center;
28 align-items: center;
29 flex-direction: column;
30}
31
32.alert {
33 margin-top: 20px;
34}
35
36.filters {
37 margin-top: 30px;
38
39 .advanced-filters-button {
40 display: flex;
41 justify-content: center;
42 align-items: center;
43 margin-top: 20px;
44 font-size: 16px;
45 font-weight: $font-semibold;
46 cursor: pointer;
47
48 .glyphicon {
49 margin-right: 5px;
50 }
51 }
52
53 .form-group {
54 margin-bottom: 0;
55 height: 34px;
56 display: flex;
57 align-items: center;
58 }
59
60 .video-caption-block {
61 display: flex;
62 align-items: center;
63
64 .peertube-select-container {
65 margin-left: 10px;
66 }
67 }
68
69 .start-at,
70 .stop-at {
71 width: 300px;
72 display: flex;
73 align-items: center;
74
75 my-timestamp-input {
76 margin-left: 10px;
77 }
78 }
79}
diff --git a/client/src/app/+videos/+video-watch/modal/video-share.component.ts b/client/src/app/+videos/+video-watch/modal/video-share.component.ts
new file mode 100644
index 000000000..b42b775c1
--- /dev/null
+++ b/client/src/app/+videos/+video-watch/modal/video-share.component.ts
@@ -0,0 +1,126 @@
1import { Component, ElementRef, Input, ViewChild } from '@angular/core'
2import { buildVideoEmbed, buildVideoLink } from '../../../../assets/player/utils'
3import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
4import { VideoCaption } from '@shared/models'
5import { VideoDetails } from '@app/shared/shared-main'
6import { VideoPlaylist } from '@app/shared/shared-video-playlist'
7
8type Customizations = {
9 startAtCheckbox: boolean
10 startAt: number
11
12 stopAtCheckbox: boolean
13 stopAt: number
14
15 subtitleCheckbox: boolean
16 subtitle: string
17
18 loop: boolean
19 autoplay: boolean
20 muted: boolean
21 title: boolean
22 warningTitle: boolean
23 controls: boolean
24}
25
26@Component({
27 selector: 'my-video-share',
28 templateUrl: './video-share.component.html',
29 styleUrls: [ './video-share.component.scss' ]
30})
31export class VideoShareComponent {
32 @ViewChild('modal', { static: true }) modal: ElementRef
33
34 @Input() video: VideoDetails = null
35 @Input() videoCaptions: VideoCaption[] = []
36 @Input() playlist: VideoPlaylist = null
37
38 activeId: 'url' | 'qrcode' | 'embed' = 'url'
39 customizations: Customizations
40 isAdvancedCustomizationCollapsed = true
41 includeVideoInPlaylist = false
42
43 constructor (private modalService: NgbModal) { }
44
45 show (currentVideoTimestamp?: number) {
46 let subtitle: string
47 if (this.videoCaptions.length !== 0) {
48 subtitle = this.videoCaptions[0].language.id
49 }
50
51 this.customizations = {
52 startAtCheckbox: false,
53 startAt: currentVideoTimestamp ? Math.floor(currentVideoTimestamp) : 0,
54
55 stopAtCheckbox: false,
56 stopAt: this.video.duration,
57
58 subtitleCheckbox: false,
59 subtitle,
60
61 loop: false,
62 autoplay: false,
63 muted: false,
64
65 // Embed options
66 title: true,
67 warningTitle: true,
68 controls: true
69 }
70
71 this.modalService.open(this.modal, { centered: true })
72 }
73
74 getVideoIframeCode () {
75 const options = this.getOptions(this.video.embedUrl)
76
77 const embedUrl = buildVideoLink(options)
78 return buildVideoEmbed(embedUrl)
79 }
80
81 getVideoUrl () {
82 const baseUrl = window.location.origin + '/videos/watch/' + this.video.uuid
83 const options = this.getOptions(baseUrl)
84
85 return buildVideoLink(options)
86 }
87
88 getPlaylistUrl () {
89 const base = window.location.origin + '/videos/watch/playlist/' + this.playlist.uuid
90
91 if (!this.includeVideoInPlaylist) return base
92
93 return base + '?videoId=' + this.video.uuid
94 }
95
96 notSecure () {
97 return window.location.protocol === 'http:'
98 }
99
100 isInEmbedTab () {
101 return this.activeId === 'embed'
102 }
103
104 hasPlaylist () {
105 return !!this.playlist
106 }
107
108 private getOptions (baseUrl?: string) {
109 return {
110 baseUrl,
111
112 startTime: this.customizations.startAtCheckbox ? this.customizations.startAt : undefined,
113 stopTime: this.customizations.stopAtCheckbox ? this.customizations.stopAt : undefined,
114
115 subtitle: this.customizations.subtitleCheckbox ? this.customizations.subtitle : undefined,
116
117 loop: this.customizations.loop,
118 autoplay: this.customizations.autoplay,
119 muted: this.customizations.muted,
120
121 title: this.customizations.title,
122 warningTitle: this.customizations.warningTitle,
123 controls: this.customizations.controls
124 }
125 }
126}
diff --git a/client/src/app/+videos/+video-watch/modal/video-support.component.html b/client/src/app/+videos/+video-watch/modal/video-support.component.html
new file mode 100644
index 000000000..935656d23
--- /dev/null
+++ b/client/src/app/+videos/+video-watch/modal/video-support.component.html
@@ -0,0 +1,15 @@
1<ng-template #modal let-hide="close">
2 <div class="modal-header">
3 <h4 i18n class="modal-title">Support {{ video.account.displayName }}</h4>
4 <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon>
5 </div>
6
7 <div class="modal-body" [innerHTML]="videoHTMLSupport"></div>
8
9 <div class="modal-footer inputs">
10 <input
11 type="button" role="button" i18n-value value="Maybe later" class="action-button action-button-cancel"
12 (click)="hide()" (key.enter)="hide()"
13 >
14 </div>
15</ng-template>
diff --git a/client/src/app/+videos/+video-watch/modal/video-support.component.scss b/client/src/app/+videos/+video-watch/modal/video-support.component.scss
new file mode 100644
index 000000000..184e09027
--- /dev/null
+++ b/client/src/app/+videos/+video-watch/modal/video-support.component.scss
@@ -0,0 +1,3 @@
1.action-button-cancel {
2 margin-right: 0 !important;
3}
diff --git a/client/src/app/+videos/+video-watch/modal/video-support.component.ts b/client/src/app/+videos/+video-watch/modal/video-support.component.ts
new file mode 100644
index 000000000..48d5f2948
--- /dev/null
+++ b/client/src/app/+videos/+video-watch/modal/video-support.component.ts
@@ -0,0 +1,29 @@
1import { Component, Input, ViewChild } from '@angular/core'
2import { MarkdownService } from '@app/core'
3import { VideoDetails } from '@app/shared/shared-main'
4import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
5
6@Component({
7 selector: 'my-video-support',
8 templateUrl: './video-support.component.html',
9 styleUrls: [ './video-support.component.scss' ]
10})
11export class VideoSupportComponent {
12 @Input() video: VideoDetails = null
13
14 @ViewChild('modal', { static: true }) modal: NgbModal
15
16 videoHTMLSupport = ''
17
18 constructor (
19 private markdownService: MarkdownService,
20 private modalService: NgbModal
21 ) { }
22
23 show () {
24 this.modalService.open(this.modal, { centered: true })
25
26 this.markdownService.enhancedMarkdownToHTML(this.video.support)
27 .then(r => this.videoHTMLSupport = r)
28 }
29}