diff --git a/src/app/app.module.ts b/src/app/app.module.ts index abbe9f46..bd2928bd 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -34,7 +34,7 @@ import { MatTabsModule } from "@angular/material/tabs"; import { PasswordValidator } from "./misc/password-validator"; import { MatCheckboxModule } from "@angular/material/checkbox"; import { MatDialogModule } from "@angular/material/dialog"; -import { FallbackDirective } from "./misc/fallback.directive"; +import { FallbackDirective, FallbackPipe } from "./misc/fallback.directive"; import { AuthModule } from "./auth/auth.module"; import { AuthRoutingModule } from "./auth/auth-routing.module"; import { TrailerDialogComponent } from "./pages/trailer-dialog/trailer-dialog.component"; @@ -73,7 +73,8 @@ import { MatDatepickerModule } from "@angular/material/datepicker"; BufferToWidthPipe, VolumeToButtonPipe, SupportedButtonPipe, - LongPressDirective + LongPressDirective, + FallbackPipe ], imports: [ BrowserModule, @@ -110,7 +111,8 @@ import { MatDatepickerModule } from "@angular/material/datepicker"; ], bootstrap: [AppComponent], exports: [ - FallbackDirective + FallbackDirective, + FallbackPipe ], providers: [ StartupService, diff --git a/src/app/components/episodes-list/episodes-list.component.ts b/src/app/components/episodes-list/episodes-list.component.ts index 4a2b1b47..54338d88 100644 --- a/src/app/components/episodes-list/episodes-list.component.ts +++ b/src/app/components/episodes-list/episodes-list.component.ts @@ -25,6 +25,8 @@ export class EpisodesListComponent extends HorizontalScroller sanitize(url: string): SafeStyle { + if (!url) + return undefined; return this.sanitizer.bypassSecurityTrustStyle("url(" + url + ")"); } diff --git a/src/app/components/items-grid/items-grid.component.ts b/src/app/components/items-grid/items-grid.component.ts index 9c92b05f..4fa03946 100644 --- a/src/app/components/items-grid/items-grid.component.ts +++ b/src/app/components/items-grid/items-grid.component.ts @@ -276,6 +276,8 @@ export class ItemsGridComponent implements OnInit getPoster(obj: LibraryItem | Show | ShowRole | Collection): SafeStyle { + if (!obj.poster) + return undefined; return this.sanitizer.bypassSecurityTrustStyle(`url(${obj.poster})`); } diff --git a/src/app/components/items-list/items-list.component.ts b/src/app/components/items-list/items-list.component.ts index f1c7ad4a..a7812243 100644 --- a/src/app/components/items-list/items-list.component.ts +++ b/src/app/components/items-list/items-list.component.ts @@ -25,6 +25,8 @@ export class ItemsListComponent extends HorizontalScroller getPoster(item: LibraryItem | Show | ShowRole | Collection): SafeUrl { + if (!item.poster) + return undefined; return this.sanitizer.bypassSecurityTrustStyle(`url(${item.poster})`); } diff --git a/src/app/components/people-list/people-list.component.ts b/src/app/components/people-list/people-list.component.ts index a584a4f2..c2de70f9 100644 --- a/src/app/components/people-list/people-list.component.ts +++ b/src/app/components/people-list/people-list.component.ts @@ -21,6 +21,8 @@ export class PeopleListComponent extends HorizontalScroller getPeopleIcon(item: People): SafeStyle { + if (!item.poster) + return undefined; return this.sanitizer.bypassSecurityTrustStyle(`url(${item.poster})`); } } diff --git a/src/app/components/show-grid/show-grid.component.ts b/src/app/components/show-grid/show-grid.component.ts index 47d2ecdb..c959b206 100644 --- a/src/app/components/show-grid/show-grid.component.ts +++ b/src/app/components/show-grid/show-grid.component.ts @@ -18,6 +18,8 @@ export class ShowGridComponent getThumb(show: Show): SafeStyle { + if (!show.poster) + return undefined; return this.sanitizer.bypassSecurityTrustStyle(`url(${show.poster})`); } diff --git a/src/app/misc/fallback.directive.ts b/src/app/misc/fallback.directive.ts index 64d6b398..daffe245 100644 --- a/src/app/misc/fallback.directive.ts +++ b/src/app/misc/fallback.directive.ts @@ -1,4 +1,4 @@ -import { Directive, ElementRef, HostListener, Input } from "@angular/core"; +import { Directive, ElementRef, HostListener, Input, Pipe, PipeTransform } from "@angular/core"; /* tslint:disable:directive-selector */ @Directive({ @@ -17,3 +17,15 @@ export class FallbackDirective html.src = this.fallback; } } + +@Pipe({ + name: "fallback", + pure: true +}) +export class FallbackPipe implements PipeTransform +{ + transform(value: any, ...args: any[]): any + { + return value ?? args.find(x => x); + } +} diff --git a/src/app/models/resources/show.ts b/src/app/models/resources/show.ts index 3fc775b4..abc1900b 100644 --- a/src/app/models/resources/show.ts +++ b/src/app/models/resources/show.ts @@ -15,13 +15,13 @@ export interface Show extends IResource studio: Studio; people: People[]; seasons: Season[]; - trailerUrl: string; + trailer: string; isMovie: boolean; startAir: Date; endAir: Date; poster: string; logo: string; - backdrop: string; + thumbnail: string; externalIDs: ExternalID[]; } diff --git a/src/app/models/watch-item.ts b/src/app/models/watch-item.ts index 08d0e752..aac76994 100644 --- a/src/app/models/watch-item.ts +++ b/src/app/models/watch-item.ts @@ -11,7 +11,7 @@ export interface WatchItem duration: number; releaseDate: string; isMovie: boolean; - + poster: string; backdrop: string; diff --git a/src/app/pages/metadata-edit/metadata-edit.component.html b/src/app/pages/metadata-edit/metadata-edit.component.html index f17b6b1f..ceaba7a9 100644 --- a/src/app/pages/metadata-edit/metadata-edit.component.html +++ b/src/app/pages/metadata-edit/metadata-edit.component.html @@ -71,7 +71,7 @@ Trailer - + diff --git a/src/app/pages/player/player.component.html b/src/app/pages/player/player.component.html index b5b77dd6..9093dd39 100644 --- a/src/app/pages/player/player.component.html +++ b/src/app/pages/player/player.component.html @@ -75,7 +75,7 @@
- poster + poster

S{{this.item.seasonNumber}}:E{{this.item.episodeNumber}} - {{this.item.title}}

diff --git a/src/app/pages/show-details/show-details.component.html b/src/app/pages/show-details/show-details.component.html index 49633de7..1815aa4f 100644 --- a/src/app/pages/show-details/show-details.component.html +++ b/src/app/pages/show-details/show-details.component.html @@ -1,5 +1,5 @@
- backdrop + backdrop