diff options
Diffstat (limited to 'client/src/app/shared')
12 files changed, 152 insertions, 49 deletions
diff --git a/client/src/app/shared/shared-main/angular/index.ts b/client/src/app/shared/shared-main/angular/index.ts index 8ea47bb33..069b7f654 100644 --- a/client/src/app/shared/shared-main/angular/index.ts +++ b/client/src/app/shared/shared-main/angular/index.ts | |||
@@ -3,5 +3,6 @@ export * from './bytes.pipe' | |||
3 | export * from './duration-formatter.pipe' | 3 | export * from './duration-formatter.pipe' |
4 | export * from './from-now.pipe' | 4 | export * from './from-now.pipe' |
5 | export * from './infinite-scroller.directive' | 5 | export * from './infinite-scroller.directive' |
6 | export * from './link.component' | ||
6 | export * from './number-formatter.pipe' | 7 | export * from './number-formatter.pipe' |
7 | export * from './peertube-template.directive' | 8 | export * from './peertube-template.directive' |
diff --git a/client/src/app/shared/shared-main/angular/link.component.html b/client/src/app/shared/shared-main/angular/link.component.html new file mode 100644 index 000000000..e61a1e085 --- /dev/null +++ b/client/src/app/shared/shared-main/angular/link.component.html | |||
@@ -0,0 +1,11 @@ | |||
1 | <ng-template #content> | ||
2 | <ng-content></ng-content> | ||
3 | </ng-template> | ||
4 | |||
5 | <a *ngIf="!href" [routerLink]="internalLink" [attr.title]="title" [tabindex]="tabindex"> | ||
6 | <ng-template *ngTemplateOutlet="content"></ng-template> | ||
7 | </a> | ||
8 | |||
9 | <a *ngIf="href" [href]="href" [target]="target" [attr.title]="title" [tabindex]="tabindex"> | ||
10 | <ng-template *ngTemplateOutlet="content"></ng-template> | ||
11 | </a> | ||
diff --git a/client/src/app/shared/shared-main/angular/link.component.scss b/client/src/app/shared/shared-main/angular/link.component.scss new file mode 100644 index 000000000..bb86d5488 --- /dev/null +++ b/client/src/app/shared/shared-main/angular/link.component.scss | |||
@@ -0,0 +1,7 @@ | |||
1 | a { | ||
2 | color: inherit; | ||
3 | text-decoration: inherit; | ||
4 | position: inherit; | ||
5 | width: inherit; | ||
6 | height: inherit; | ||
7 | } | ||
diff --git a/client/src/app/shared/shared-main/angular/link.component.ts b/client/src/app/shared/shared-main/angular/link.component.ts new file mode 100644 index 000000000..76d1201b9 --- /dev/null +++ b/client/src/app/shared/shared-main/angular/link.component.ts | |||
@@ -0,0 +1,17 @@ | |||
1 | import { Component, Input, ViewEncapsulation } from '@angular/core' | ||
2 | |||
3 | @Component({ | ||
4 | selector: 'my-link', | ||
5 | styleUrls: [ './link.component.scss' ], | ||
6 | templateUrl: './link.component.html' | ||
7 | }) | ||
8 | export class LinkComponent { | ||
9 | @Input() internalLink?: any[] | ||
10 | |||
11 | @Input() href?: string | ||
12 | @Input() target?: string | ||
13 | |||
14 | @Input() title?: string | ||
15 | |||
16 | @Input() tabindex: string | number | ||
17 | } | ||
diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts index c8dd01429..e5dfc59b2 100644 --- a/client/src/app/shared/shared-main/shared-main.module.ts +++ b/client/src/app/shared/shared-main/shared-main.module.ts | |||
@@ -4,7 +4,7 @@ import { CommonModule, DatePipe } from '@angular/common' | |||
4 | import { HttpClientModule } from '@angular/common/http' | 4 | import { HttpClientModule } from '@angular/common/http' |
5 | import { NgModule } from '@angular/core' | 5 | import { NgModule } from '@angular/core' |
6 | import { FormsModule, ReactiveFormsModule } from '@angular/forms' | 6 | import { FormsModule, ReactiveFormsModule } from '@angular/forms' |
7 | import { ActivatedRouteSnapshot, RouterModule } from '@angular/router' | 7 | import { RouterModule } from '@angular/router' |
8 | import { | 8 | import { |
9 | NgbButtonsModule, | 9 | NgbButtonsModule, |
10 | NgbCollapseModule, | 10 | NgbCollapseModule, |
@@ -24,6 +24,7 @@ import { | |||
24 | DurationFormatterPipe, | 24 | DurationFormatterPipe, |
25 | FromNowPipe, | 25 | FromNowPipe, |
26 | InfiniteScrollerDirective, | 26 | InfiniteScrollerDirective, |
27 | LinkComponent, | ||
27 | NumberFormatterPipe, | 28 | NumberFormatterPipe, |
28 | PeerTubeTemplateDirective | 29 | PeerTubeTemplateDirective |
29 | } from './angular' | 30 | } from './angular' |
@@ -35,11 +36,11 @@ import { FeedComponent } from './feeds' | |||
35 | import { LoaderComponent, SmallLoaderComponent } from './loaders' | 36 | import { LoaderComponent, SmallLoaderComponent } from './loaders' |
36 | import { HelpComponent, ListOverflowComponent, SimpleSearchInputComponent, TopMenuDropdownComponent } from './misc' | 37 | import { HelpComponent, ListOverflowComponent, SimpleSearchInputComponent, TopMenuDropdownComponent } from './misc' |
37 | import { PluginPlaceholderComponent } from './plugins' | 38 | import { PluginPlaceholderComponent } from './plugins' |
39 | import { ActorRedirectGuard } from './router' | ||
38 | import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' | 40 | import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' |
39 | import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' | 41 | import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' |
40 | import { VideoCaptionService } from './video-caption' | 42 | import { VideoCaptionService } from './video-caption' |
41 | import { VideoChannelService } from './video-channel' | 43 | import { VideoChannelService } from './video-channel' |
42 | import { ActorRedirectGuard } from './router' | ||
43 | 44 | ||
44 | @NgModule({ | 45 | @NgModule({ |
45 | imports: [ | 46 | imports: [ |
@@ -76,6 +77,7 @@ import { ActorRedirectGuard } from './router' | |||
76 | 77 | ||
77 | InfiniteScrollerDirective, | 78 | InfiniteScrollerDirective, |
78 | PeerTubeTemplateDirective, | 79 | PeerTubeTemplateDirective, |
80 | LinkComponent, | ||
79 | 81 | ||
80 | ActionDropdownComponent, | 82 | ActionDropdownComponent, |
81 | ButtonComponent, | 83 | ButtonComponent, |
@@ -130,6 +132,7 @@ import { ActorRedirectGuard } from './router' | |||
130 | 132 | ||
131 | InfiniteScrollerDirective, | 133 | InfiniteScrollerDirective, |
132 | PeerTubeTemplateDirective, | 134 | PeerTubeTemplateDirective, |
135 | LinkComponent, | ||
133 | 136 | ||
134 | ActionDropdownComponent, | 137 | ActionDropdownComponent, |
135 | ButtonComponent, | 138 | ButtonComponent, |
diff --git a/client/src/app/shared/shared-search/search.service.ts b/client/src/app/shared/shared-search/search.service.ts index 15c4a7012..ad258f5e5 100644 --- a/client/src/app/shared/shared-search/search.service.ts +++ b/client/src/app/shared/shared-search/search.service.ts | |||
@@ -3,10 +3,17 @@ import { catchError, map, switchMap } from 'rxjs/operators' | |||
3 | import { HttpClient, HttpParams } from '@angular/common/http' | 3 | import { HttpClient, HttpParams } from '@angular/common/http' |
4 | import { Injectable } from '@angular/core' | 4 | import { Injectable } from '@angular/core' |
5 | import { ComponentPaginationLight, RestExtractor, RestPagination, RestService } from '@app/core' | 5 | import { ComponentPaginationLight, RestExtractor, RestPagination, RestService } from '@app/core' |
6 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | ||
7 | import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' | 6 | import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' |
8 | import { ResultList, SearchTargetType, Video as VideoServerModel, VideoChannel as VideoChannelServerModel } from '@shared/models' | 7 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' |
8 | import { | ||
9 | ResultList, | ||
10 | SearchTargetType, | ||
11 | Video as VideoServerModel, | ||
12 | VideoChannel as VideoChannelServerModel, | ||
13 | VideoPlaylist as VideoPlaylistServerModel | ||
14 | } from '@shared/models' | ||
9 | import { environment } from '../../../environments/environment' | 15 | import { environment } from '../../../environments/environment' |
16 | import { VideoPlaylist, VideoPlaylistService } from '../shared-video-playlist' | ||
10 | import { AdvancedSearch } from './advanced-search.model' | 17 | import { AdvancedSearch } from './advanced-search.model' |
11 | 18 | ||
12 | @Injectable() | 19 | @Injectable() |
@@ -17,7 +24,8 @@ export class SearchService { | |||
17 | private authHttp: HttpClient, | 24 | private authHttp: HttpClient, |
18 | private restExtractor: RestExtractor, | 25 | private restExtractor: RestExtractor, |
19 | private restService: RestService, | 26 | private restService: RestService, |
20 | private videoService: VideoService | 27 | private videoService: VideoService, |
28 | private playlistService: VideoPlaylistService | ||
21 | ) { | 29 | ) { |
22 | // Add ability to override search endpoint if the user updated this local storage key | 30 | // Add ability to override search endpoint if the user updated this local storage key |
23 | const searchUrl = peertubeLocalStorage.getItem('search-url') | 31 | const searchUrl = peertubeLocalStorage.getItem('search-url') |
@@ -85,4 +93,34 @@ export class SearchService { | |||
85 | catchError(err => this.restExtractor.handleError(err)) | 93 | catchError(err => this.restExtractor.handleError(err)) |
86 | ) | 94 | ) |
87 | } | 95 | } |
96 | |||
97 | searchVideoPlaylists (parameters: { | ||
98 | search: string, | ||
99 | searchTarget?: SearchTargetType, | ||
100 | componentPagination?: ComponentPaginationLight | ||
101 | }): Observable<ResultList<VideoPlaylist>> { | ||
102 | const { search, componentPagination, searchTarget } = parameters | ||
103 | |||
104 | const url = SearchService.BASE_SEARCH_URL + 'video-playlists' | ||
105 | |||
106 | let pagination: RestPagination | ||
107 | if (componentPagination) { | ||
108 | pagination = this.restService.componentPaginationToRestPagination(componentPagination) | ||
109 | } | ||
110 | |||
111 | let params = new HttpParams() | ||
112 | params = this.restService.addRestGetParams(params, pagination) | ||
113 | params = params.append('search', search) | ||
114 | |||
115 | if (searchTarget) { | ||
116 | params = params.append('searchTarget', searchTarget as string) | ||
117 | } | ||
118 | |||
119 | return this.authHttp | ||
120 | .get<ResultList<VideoPlaylistServerModel>>(url, { params }) | ||
121 | .pipe( | ||
122 | switchMap(res => this.playlistService.extractPlaylists(res)), | ||
123 | catchError(err => this.restExtractor.handleError(err)) | ||
124 | ) | ||
125 | } | ||
88 | } | 126 | } |
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.html b/client/src/app/shared/shared-video-miniature/video-miniature.component.html index 6c34123ed..7765d5be7 100644 --- a/client/src/app/shared/shared-video-miniature/video-miniature.component.html +++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.html | |||
@@ -21,13 +21,12 @@ | |||
21 | ></my-actor-avatar> | 21 | ></my-actor-avatar> |
22 | 22 | ||
23 | <div class="w-100 d-flex flex-column"> | 23 | <div class="w-100 d-flex flex-column"> |
24 | <a *ngIf="!videoHref" tabindex="-1" class="video-miniature-name" | 24 | <my-link |
25 | [routerLink]="videoRouterLink" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur }" | 25 | [internalLink]="videoRouterLink" [href]="videoHref" [target]="videoTarget" |
26 | >{{ video.name }}</a> | 26 | [title]="video.name"class="video-miniature-name" [ngClass]="{ 'blur-filter': isVideoBlur }" tabindex="-1" |
27 | 27 | > | |
28 | <a *ngIf="videoHref" tabindex="-1" class="video-miniature-name" | 28 | {{ video.name }} |
29 | [href]="videoHref" [target]="videoTarget" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur }" | 29 | </my-link> |
30 | >{{ video.name }}</a> | ||
31 | 30 | ||
32 | <span class="video-miniature-created-at-views"> | 31 | <span class="video-miniature-created-at-views"> |
33 | <my-date-toggle *ngIf="displayOptions.date" [date]="video.publishedAt"></my-date-toggle> | 32 | <my-date-toggle *ngIf="displayOptions.date" [date]="video.publishedAt"></my-date-toggle> |
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts index fc066846a..fe161c977 100644 --- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts | |||
@@ -12,6 +12,7 @@ import { | |||
12 | } from '@angular/core' | 12 | } from '@angular/core' |
13 | import { AuthService, ScreenService, ServerService, User } from '@app/core' | 13 | import { AuthService, ScreenService, ServerService, User } from '@app/core' |
14 | import { HTMLServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '@shared/models' | 14 | import { HTMLServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '@shared/models' |
15 | import { LinkType } from '../../../types/link.type' | ||
15 | import { ActorAvatarSize } from '../shared-actor-image/actor-avatar.component' | 16 | import { ActorAvatarSize } from '../shared-actor-image/actor-avatar.component' |
16 | import { Video } from '../shared-main' | 17 | import { Video } from '../shared-main' |
17 | import { VideoPlaylistService } from '../shared-video-playlist' | 18 | import { VideoPlaylistService } from '../shared-video-playlist' |
@@ -28,8 +29,6 @@ export type MiniatureDisplayOptions = { | |||
28 | blacklistInfo?: boolean | 29 | blacklistInfo?: boolean |
29 | nsfw?: boolean | 30 | nsfw?: boolean |
30 | } | 31 | } |
31 | export type VideoLinkType = 'internal' | 'lazy-load' | 'external' | ||
32 | |||
33 | @Component({ | 32 | @Component({ |
34 | selector: 'my-video-miniature', | 33 | selector: 'my-video-miniature', |
35 | styleUrls: [ './video-miniature.component.scss' ], | 34 | styleUrls: [ './video-miniature.component.scss' ], |
@@ -56,7 +55,7 @@ export class VideoMiniatureComponent implements OnInit { | |||
56 | 55 | ||
57 | @Input() displayAsRow = false | 56 | @Input() displayAsRow = false |
58 | 57 | ||
59 | @Input() videoLinkType: VideoLinkType = 'internal' | 58 | @Input() videoLinkType: LinkType = 'internal' |
60 | 59 | ||
61 | @Output() videoBlocked = new EventEmitter() | 60 | @Output() videoBlocked = new EventEmitter() |
62 | @Output() videoUnblocked = new EventEmitter() | 61 | @Output() videoUnblocked = new EventEmitter() |
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html index 81c36e6fe..95f11f030 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html +++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html | |||
@@ -1,7 +1,7 @@ | |||
1 | <div class="miniature" [ngClass]="{ 'no-videos': playlist.videosLength === 0, 'to-manage': toManage, 'display-as-row': displayAsRow }"> | 1 | <div class="miniature" [ngClass]="{ 'no-videos': playlist.videosLength === 0, 'to-manage': toManage, 'display-as-row': displayAsRow }"> |
2 | <a | 2 | <my-link |
3 | [routerLink]="getPlaylistUrl()" [attr.title]="playlist.description" | 3 | [internalLink]="routerLink" [href]="playlistHref" [target]="playlistTarget" |
4 | class="miniature-thumbnail" | 4 | [title]="playlist.description" class="miniature-thumbnail" |
5 | > | 5 | > |
6 | <img alt="" [attr.aria-labelledby]="playlist.displayName" [attr.src]="playlist.thumbnailUrl" /> | 6 | <img alt="" [attr.aria-labelledby]="playlist.displayName" [attr.src]="playlist.thumbnailUrl" /> |
7 | 7 | ||
@@ -12,12 +12,15 @@ | |||
12 | <div class="play-overlay"> | 12 | <div class="play-overlay"> |
13 | <div class="icon"></div> | 13 | <div class="icon"></div> |
14 | </div> | 14 | </div> |
15 | </a> | 15 | </my-link> |
16 | 16 | ||
17 | <div class="miniature-info"> | 17 | <div class="miniature-info"> |
18 | <a tabindex="-1" class="miniature-name" [routerLink]="getPlaylistUrl()" [attr.title]="playlist.description"> | 18 | <my-link |
19 | [internalLink]="routerLink" [href]="playlistHref" [target]="playlistTarget" | ||
20 | [title]="playlist.description" class="miniature-name" tabindex="-1" | ||
21 | > | ||
19 | {{ playlist.displayName }} | 22 | {{ playlist.displayName }} |
20 | </a> | 23 | </my-link> |
21 | 24 | ||
22 | <a i18n [routerLink]="[ '/c', playlist.videoChannelBy ]" class="by" *ngIf="displayChannel && playlist.videoChannelBy"> | 25 | <a i18n [routerLink]="[ '/c', playlist.videoChannelBy ]" class="by" *ngIf="displayChannel && playlist.videoChannelBy"> |
23 | {{ playlist.videoChannelBy }} | 26 | {{ playlist.videoChannelBy }} |
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.scss b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.scss index 95bf469ac..cf7513984 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.scss +++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.scss | |||
@@ -75,7 +75,10 @@ | |||
75 | } | 75 | } |
76 | 76 | ||
77 | .miniature:not(.display-as-row) { | 77 | .miniature:not(.display-as-row) { |
78 | |||
78 | .miniature-thumbnail { | 79 | .miniature-thumbnail { |
80 | @include block-ratio($selector: '::ng-deep a'); | ||
81 | |||
79 | margin-top: 10px; | 82 | margin-top: 10px; |
80 | margin-bottom: 5px; | 83 | margin-bottom: 5px; |
81 | } | 84 | } |
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts index 9bbec6038..8de5092a9 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { Component, Input } from '@angular/core' | 1 | import { LinkType } from 'src/types/link.type' |
2 | import { Component, Input, OnInit } from '@angular/core' | ||
2 | import { VideoPlaylist } from './video-playlist.model' | 3 | import { VideoPlaylist } from './video-playlist.model' |
3 | 4 | ||
4 | @Component({ | 5 | @Component({ |
@@ -6,18 +7,52 @@ import { VideoPlaylist } from './video-playlist.model' | |||
6 | styleUrls: [ './video-playlist-miniature.component.scss' ], | 7 | styleUrls: [ './video-playlist-miniature.component.scss' ], |
7 | templateUrl: './video-playlist-miniature.component.html' | 8 | templateUrl: './video-playlist-miniature.component.html' |
8 | }) | 9 | }) |
9 | export class VideoPlaylistMiniatureComponent { | 10 | export class VideoPlaylistMiniatureComponent implements OnInit { |
10 | @Input() playlist: VideoPlaylist | 11 | @Input() playlist: VideoPlaylist |
12 | |||
11 | @Input() toManage = false | 13 | @Input() toManage = false |
14 | |||
12 | @Input() displayChannel = false | 15 | @Input() displayChannel = false |
13 | @Input() displayDescription = false | 16 | @Input() displayDescription = false |
14 | @Input() displayPrivacy = false | 17 | @Input() displayPrivacy = false |
15 | @Input() displayAsRow = false | 18 | @Input() displayAsRow = false |
16 | 19 | ||
17 | getPlaylistUrl () { | 20 | @Input() linkType: LinkType = 'internal' |
18 | if (this.toManage) return [ '/my-library/video-playlists', this.playlist.uuid ] | 21 | |
19 | if (this.playlist.videosLength === 0) return null | 22 | routerLink: any |
23 | playlistHref: string | ||
24 | playlistTarget: string | ||
25 | |||
26 | ngOnInit () { | ||
27 | this.buildPlaylistUrl() | ||
28 | } | ||
29 | |||
30 | buildPlaylistUrl () { | ||
31 | if (this.toManage) { | ||
32 | this.routerLink = [ '/my-library/video-playlists', this.playlist.uuid ] | ||
33 | return | ||
34 | } | ||
35 | |||
36 | if (this.playlist.videosLength === 0) { | ||
37 | this.routerLink = null | ||
38 | return | ||
39 | } | ||
40 | |||
41 | if (this.linkType === 'internal' || !this.playlist.url) { | ||
42 | this.routerLink = [ '/w/p', this.playlist.uuid ] | ||
43 | return | ||
44 | } | ||
45 | |||
46 | if (this.linkType === 'external') { | ||
47 | this.routerLink = null | ||
48 | this.playlistHref = this.playlist.url | ||
49 | this.playlistTarget = '_blank' | ||
50 | return | ||
51 | } | ||
52 | |||
53 | // Lazy load | ||
54 | this.routerLink = [ '/search/lazy-load-playlist', { url: this.playlist.url } ] | ||
20 | 55 | ||
21 | return [ '/w/p', this.playlist.uuid ] | 56 | return |
22 | } | 57 | } |
23 | } | 58 | } |
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 5b6ba9dbf..d67f372f4 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,5 +1,5 @@ | |||
1 | import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' | 1 | import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' |
2 | import { Account, Actor, VideoChannel } from '@app/shared/shared-main' | 2 | import { Actor } from '@app/shared/shared-main' |
3 | import { peertubeTranslate } from '@shared/core-utils/i18n' | 3 | import { peertubeTranslate } from '@shared/core-utils/i18n' |
4 | import { | 4 | import { |
5 | AccountSummary, | 5 | AccountSummary, |
@@ -15,12 +15,12 @@ export class VideoPlaylist implements ServerVideoPlaylist { | |||
15 | uuid: string | 15 | uuid: string |
16 | isLocal: boolean | 16 | isLocal: boolean |
17 | 17 | ||
18 | url: string | ||
19 | |||
18 | displayName: string | 20 | displayName: string |
19 | description: string | 21 | description: string |
20 | privacy: VideoConstant<VideoPlaylistPrivacy> | 22 | privacy: VideoConstant<VideoPlaylistPrivacy> |
21 | 23 | ||
22 | thumbnailPath: string | ||
23 | |||
24 | videosLength: number | 24 | videosLength: number |
25 | 25 | ||
26 | type: VideoConstant<VideoPlaylistType> | 26 | type: VideoConstant<VideoPlaylistType> |
@@ -31,6 +31,7 @@ export class VideoPlaylist implements ServerVideoPlaylist { | |||
31 | ownerAccount: AccountSummary | 31 | ownerAccount: AccountSummary |
32 | videoChannel?: VideoChannelSummary | 32 | videoChannel?: VideoChannelSummary |
33 | 33 | ||
34 | thumbnailPath: string | ||
34 | thumbnailUrl: string | 35 | thumbnailUrl: string |
35 | 36 | ||
36 | embedPath: string | 37 | embedPath: string |
@@ -40,14 +41,12 @@ export class VideoPlaylist implements ServerVideoPlaylist { | |||
40 | 41 | ||
41 | videoChannelBy?: string | 42 | videoChannelBy?: string |
42 | 43 | ||
43 | private thumbnailVersion: number | ||
44 | private originThumbnailUrl: string | ||
45 | |||
46 | constructor (hash: ServerVideoPlaylist, translations: {}) { | 44 | constructor (hash: ServerVideoPlaylist, translations: {}) { |
47 | const absoluteAPIUrl = getAbsoluteAPIUrl() | 45 | const absoluteAPIUrl = getAbsoluteAPIUrl() |
48 | 46 | ||
49 | this.id = hash.id | 47 | this.id = hash.id |
50 | this.uuid = hash.uuid | 48 | this.uuid = hash.uuid |
49 | this.url = hash.url | ||
51 | this.isLocal = hash.isLocal | 50 | this.isLocal = hash.isLocal |
52 | 51 | ||
53 | this.displayName = hash.displayName | 52 | this.displayName = hash.displayName |
@@ -57,15 +56,12 @@ export class VideoPlaylist implements ServerVideoPlaylist { | |||
57 | 56 | ||
58 | this.thumbnailPath = hash.thumbnailPath | 57 | this.thumbnailPath = hash.thumbnailPath |
59 | 58 | ||
60 | if (this.thumbnailPath) { | 59 | this.thumbnailUrl = this.thumbnailPath |
61 | this.thumbnailUrl = absoluteAPIUrl + hash.thumbnailPath | 60 | ? hash.thumbnailUrl || (absoluteAPIUrl + hash.thumbnailPath) |
62 | this.originThumbnailUrl = this.thumbnailUrl | 61 | : absoluteAPIUrl + '/client/assets/images/default-playlist.jpg' |
63 | } else { | ||
64 | this.thumbnailUrl = window.location.origin + '/client/assets/images/default-playlist.jpg' | ||
65 | } | ||
66 | 62 | ||
67 | this.embedPath = hash.embedPath | 63 | this.embedPath = hash.embedPath |
68 | this.embedUrl = getAbsoluteEmbedUrl() + hash.embedPath | 64 | this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath) |
69 | 65 | ||
70 | this.videosLength = hash.videosLength | 66 | this.videosLength = hash.videosLength |
71 | 67 | ||
@@ -88,13 +84,4 @@ export class VideoPlaylist implements ServerVideoPlaylist { | |||
88 | this.displayName = peertubeTranslate(this.displayName, translations) | 84 | this.displayName = peertubeTranslate(this.displayName, translations) |
89 | } | 85 | } |
90 | } | 86 | } |
91 | |||
92 | refreshThumbnail () { | ||
93 | if (!this.originThumbnailUrl) return | ||
94 | |||
95 | if (!this.thumbnailVersion) this.thumbnailVersion = 0 | ||
96 | this.thumbnailVersion++ | ||
97 | |||
98 | this.thumbnailUrl = this.originThumbnailUrl + '?v' + this.thumbnailVersion | ||
99 | } | ||
100 | } | 87 | } |