aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-custom-markup
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-custom-markup')
-rw-r--r--client/src/app/shared/shared-custom-markup/custom-markup-container.component.ts20
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.ts5
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts10
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts13
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts13
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts13
6 files changed, 50 insertions, 24 deletions
diff --git a/client/src/app/shared/shared-custom-markup/custom-markup-container.component.ts b/client/src/app/shared/shared-custom-markup/custom-markup-container.component.ts
index 4e802b14d..b2ee2d8f2 100644
--- a/client/src/app/shared/shared-custom-markup/custom-markup-container.component.ts
+++ b/client/src/app/shared/shared-custom-markup/custom-markup-container.component.ts
@@ -6,9 +6,9 @@ import { CustomMarkupService } from './custom-markup.service'
6 templateUrl: './custom-markup-container.component.html' 6 templateUrl: './custom-markup-container.component.html'
7}) 7})
8export class CustomMarkupContainerComponent implements OnChanges { 8export class CustomMarkupContainerComponent implements OnChanges {
9 @ViewChild('contentWrapper') contentWrapper: ElementRef<HTMLInputElement> 9 @ViewChild('contentWrapper', { static: true }) contentWrapper: ElementRef<HTMLInputElement>
10 10
11 @Input() content: string 11 @Input() content: string | HTMLDivElement
12 12
13 displayed = false 13 displayed = false
14 14
@@ -17,17 +17,23 @@ export class CustomMarkupContainerComponent implements OnChanges {
17 ) { } 17 ) { }
18 18
19 async ngOnChanges () { 19 async ngOnChanges () {
20 await this.buildElement() 20 await this.rebuild()
21 } 21 }
22 22
23 private async buildElement () { 23 private async rebuild () {
24 if (!this.content) return 24 if (this.content instanceof HTMLDivElement) {
25 return this.loadElement(this.content)
26 }
25 27
26 const { rootElement, componentsLoaded } = await this.customMarkupService.buildElement(this.content) 28 const { rootElement, componentsLoaded } = await this.customMarkupService.buildElement(this.content)
27 this.contentWrapper.nativeElement.appendChild(rootElement)
28
29 await componentsLoaded 29 await componentsLoaded
30 30
31 return this.loadElement(rootElement)
32 }
33
34 private loadElement (el: HTMLDivElement) {
35 this.contentWrapper.nativeElement.appendChild(el)
36
31 this.displayed = true 37 this.displayed = true
32 } 38 }
33} 39}
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.ts
index 1af060548..264dd9577 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.ts
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/button-markup.component.ts
@@ -1,4 +1,4 @@
1import { Component, Input } from '@angular/core' 1import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
2import { VideoChannel } from '../../shared-main' 2import { VideoChannel } from '../../shared-main'
3import { CustomMarkupComponent } from './shared' 3import { CustomMarkupComponent } from './shared'
4 4
@@ -9,7 +9,8 @@ import { CustomMarkupComponent } from './shared'
9@Component({ 9@Component({
10 selector: 'my-button-markup', 10 selector: 'my-button-markup',
11 templateUrl: 'button-markup.component.html', 11 templateUrl: 'button-markup.component.html',
12 styleUrls: [ 'button-markup.component.scss' ] 12 styleUrls: [ 'button-markup.component.scss' ],
13 changeDetection: ChangeDetectionStrategy.OnPush
13}) 14})
14export class ButtonMarkupComponent implements CustomMarkupComponent { 15export class ButtonMarkupComponent implements CustomMarkupComponent {
15 @Input() theme: 'primary' | 'secondary' 16 @Input() theme: 'primary' | 'secondary'
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts
index ba12b7139..df7cc95a7 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts
@@ -1,6 +1,6 @@
1import { from } from 'rxjs' 1import { from } from 'rxjs'
2import { finalize, map, switchMap, tap } from 'rxjs/operators' 2import { finalize, map, switchMap, tap } from 'rxjs/operators'
3import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 3import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
4import { MarkdownService, Notifier, UserService } from '@app/core' 4import { MarkdownService, Notifier, UserService } from '@app/core'
5import { FindInBulkService } from '@app/shared/shared-search' 5import { FindInBulkService } from '@app/shared/shared-search'
6import { VideoSortField } from '@shared/models' 6import { VideoSortField } from '@shared/models'
@@ -14,7 +14,8 @@ import { CustomMarkupComponent } from './shared'
14@Component({ 14@Component({
15 selector: 'my-channel-miniature-markup', 15 selector: 'my-channel-miniature-markup',
16 templateUrl: 'channel-miniature-markup.component.html', 16 templateUrl: 'channel-miniature-markup.component.html',
17 styleUrls: [ 'channel-miniature-markup.component.scss' ] 17 styleUrls: [ 'channel-miniature-markup.component.scss' ],
18 changeDetection: ChangeDetectionStrategy.OnPush
18}) 19})
19export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, OnInit { 20export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, OnInit {
20 @Input() name: string 21 @Input() name: string
@@ -33,7 +34,8 @@ export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, O
33 private findInBulk: FindInBulkService, 34 private findInBulk: FindInBulkService,
34 private videoService: VideoService, 35 private videoService: VideoService,
35 private userService: UserService, 36 private userService: UserService,
36 private notifier: Notifier 37 private notifier: Notifier,
38 private cd: ChangeDetectorRef
37 ) { } 39 ) { }
38 40
39 ngOnInit () { 41 ngOnInit () {
@@ -56,6 +58,8 @@ export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, O
56 next: ({ total, data }) => { 58 next: ({ total, data }) => {
57 this.totalVideos = total 59 this.totalVideos = total
58 this.video = data[0] 60 this.video = data[0]
61
62 this.cd.markForCheck()
59 }, 63 },
60 64
61 error: err => this.notifier.error($localize`Error in channel miniature component: ${err.message}`) 65 error: err => this.notifier.error($localize`Error in channel miniature component: ${err.message}`)
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts
index 07fa6fd2d..d2cf1326e 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts
@@ -1,5 +1,5 @@
1import { finalize } from 'rxjs/operators' 1import { finalize } from 'rxjs/operators'
2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 2import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
3import { Notifier } from '@app/core' 3import { Notifier } from '@app/core'
4import { FindInBulkService } from '@app/shared/shared-search' 4import { FindInBulkService } from '@app/shared/shared-search'
5import { MiniatureDisplayOptions } from '../../shared-video-miniature' 5import { MiniatureDisplayOptions } from '../../shared-video-miniature'
@@ -13,7 +13,8 @@ import { CustomMarkupComponent } from './shared'
13@Component({ 13@Component({
14 selector: 'my-playlist-miniature-markup', 14 selector: 'my-playlist-miniature-markup',
15 templateUrl: 'playlist-miniature-markup.component.html', 15 templateUrl: 'playlist-miniature-markup.component.html',
16 styleUrls: [ 'playlist-miniature-markup.component.scss' ] 16 styleUrls: [ 'playlist-miniature-markup.component.scss' ],
17 changeDetection: ChangeDetectionStrategy.OnPush
17}) 18})
18export class PlaylistMiniatureMarkupComponent implements CustomMarkupComponent, OnInit { 19export class PlaylistMiniatureMarkupComponent implements CustomMarkupComponent, OnInit {
19 @Input() uuid: string 20 @Input() uuid: string
@@ -35,14 +36,18 @@ export class PlaylistMiniatureMarkupComponent implements CustomMarkupComponent,
35 36
36 constructor ( 37 constructor (
37 private findInBulkService: FindInBulkService, 38 private findInBulkService: FindInBulkService,
38 private notifier: Notifier 39 private notifier: Notifier,
40 private cd: ChangeDetectorRef
39 ) { } 41 ) { }
40 42
41 ngOnInit () { 43 ngOnInit () {
42 this.findInBulkService.getPlaylist(this.uuid) 44 this.findInBulkService.getPlaylist(this.uuid)
43 .pipe(finalize(() => this.loaded.emit(true))) 45 .pipe(finalize(() => this.loaded.emit(true)))
44 .subscribe({ 46 .subscribe({
45 next: playlist => this.playlist = playlist, 47 next: playlist => {
48 this.playlist = playlist
49 this.cd.markForCheck()
50 },
46 51
47 error: err => this.notifier.error($localize`Error in playlist miniature component: ${err.message}`) 52 error: err => this.notifier.error($localize`Error in playlist miniature component: ${err.message}`)
48 }) 53 })
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts
index cbbacf77c..21774b7aa 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts
@@ -1,5 +1,5 @@
1import { finalize } from 'rxjs/operators' 1import { finalize } from 'rxjs/operators'
2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 2import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
3import { AuthService, Notifier } from '@app/core' 3import { AuthService, Notifier } from '@app/core'
4import { FindInBulkService } from '@app/shared/shared-search' 4import { FindInBulkService } from '@app/shared/shared-search'
5import { Video } from '../../shared-main' 5import { Video } from '../../shared-main'
@@ -13,7 +13,8 @@ import { CustomMarkupComponent } from './shared'
13@Component({ 13@Component({
14 selector: 'my-video-miniature-markup', 14 selector: 'my-video-miniature-markup',
15 templateUrl: 'video-miniature-markup.component.html', 15 templateUrl: 'video-miniature-markup.component.html',
16 styleUrls: [ 'video-miniature-markup.component.scss' ] 16 styleUrls: [ 'video-miniature-markup.component.scss' ],
17 changeDetection: ChangeDetectionStrategy.OnPush
17}) 18})
18export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnInit { 19export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnInit {
19 @Input() uuid: string 20 @Input() uuid: string
@@ -36,7 +37,8 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI
36 constructor ( 37 constructor (
37 private auth: AuthService, 38 private auth: AuthService,
38 private findInBulk: FindInBulkService, 39 private findInBulk: FindInBulkService,
39 private notifier: Notifier 40 private notifier: Notifier,
41 private cd: ChangeDetectorRef
40 ) { } 42 ) { }
41 43
42 getUser () { 44 getUser () {
@@ -55,7 +57,10 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI
55 this.findInBulk.getVideo(this.uuid) 57 this.findInBulk.getVideo(this.uuid)
56 .pipe(finalize(() => this.loaded.emit(true))) 58 .pipe(finalize(() => this.loaded.emit(true)))
57 .subscribe({ 59 .subscribe({
58 next: video => this.video = video, 60 next: video => {
61 this.video = video
62 this.cd.markForCheck()
63 },
59 64
60 error: err => this.notifier.error($localize`Error in video miniature component: ${err.message}`) 65 error: err => this.notifier.error($localize`Error in video miniature component: ${err.message}`)
61 }) 66 })
diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts
index 7d3498d4c..7c2e7db6a 100644
--- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts
+++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts
@@ -1,5 +1,5 @@
1import { finalize } from 'rxjs/operators' 1import { finalize } from 'rxjs/operators'
2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 2import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
3import { AuthService, Notifier } from '@app/core' 3import { AuthService, Notifier } from '@app/core'
4import { VideoSortField } from '@shared/models' 4import { VideoSortField } from '@shared/models'
5import { Video, VideoService } from '../../shared-main' 5import { Video, VideoService } from '../../shared-main'
@@ -13,7 +13,8 @@ import { CustomMarkupComponent } from './shared'
13@Component({ 13@Component({
14 selector: 'my-videos-list-markup', 14 selector: 'my-videos-list-markup',
15 templateUrl: 'videos-list-markup.component.html', 15 templateUrl: 'videos-list-markup.component.html',
16 styleUrls: [ 'videos-list-markup.component.scss' ] 16 styleUrls: [ 'videos-list-markup.component.scss' ],
17 changeDetection: ChangeDetectionStrategy.OnPush
17}) 18})
18export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit { 19export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit {
19 @Input() sort: string 20 @Input() sort: string
@@ -45,7 +46,8 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit
45 constructor ( 46 constructor (
46 private auth: AuthService, 47 private auth: AuthService,
47 private videoService: VideoService, 48 private videoService: VideoService,
48 private notifier: Notifier 49 private notifier: Notifier,
50 private cd: ChangeDetectorRef
49 ) { } 51 ) { }
50 52
51 getUser () { 53 getUser () {
@@ -72,7 +74,10 @@ export class VideosListMarkupComponent implements CustomMarkupComponent, OnInit
72 return this.getVideosObservable() 74 return this.getVideosObservable()
73 .pipe(finalize(() => this.loaded.emit(true))) 75 .pipe(finalize(() => this.loaded.emit(true)))
74 .subscribe({ 76 .subscribe({
75 next: ({ data }) => this.videos = data, 77 next: ({ data }) => {
78 this.videos = data
79 this.cd.markForCheck()
80 },
76 81
77 error: err => this.notifier.error($localize`Error in videos list component: ${err.message}`) 82 error: err => this.notifier.error($localize`Error in videos list component: ${err.message}`)
78 }) 83 })