Fixed up some of the artist albums

This commit is contained in:
tidusjar 2019-08-09 23:56:54 +01:00
commit f921d84b0b
4 changed files with 24 additions and 18 deletions

View file

@ -102,7 +102,7 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<artist-release-panel [releases]="artist.releaseGroups"></artist-release-panel> <artist-release-panel *ngIf="artist.releaseGroups.length > 0" [releases]="artist.releaseGroups"></artist-release-panel>
</div> </div>
</div> </div>

View file

@ -12,11 +12,11 @@
<div class="row card-spacer"> <div class="row card-spacer">
<span *ngFor="let r of albums"> <span *ngFor="let r of albums">
<div class="col-md-2" *ngIf="r.image" > <div class="col-md-2" >
<div class="sidebar affixable affix-top preview-poster"> <div class="sidebar affixable affix-top preview-poster">
<div class="poster"> <div class="poster">
<img class="real grow" matTooltip="{{r.title}}" <img class="real grow" matTooltip="{{r.title}}"
src="{{r.image}}" alt="Poster" src="{{r.image ? r.image : 'images/default-music-placeholder.png'}}" alt="Poster"
style="display: block;"> style="display: block;">
</div> </div>
</div> </div>

View file

@ -1,4 +1,4 @@
import { Component, Input, ViewEncapsulation, OnInit } from "@angular/core"; import { Component, Input, ViewEncapsulation, OnInit, OnChanges, SimpleChanges } from "@angular/core";
import { IReleaseGroups } from "../../../../../interfaces/IMusicSearchResultV2"; import { IReleaseGroups } from "../../../../../interfaces/IMusicSearchResultV2";
import { SearchV2Service } from "../../../../../services/searchV2.service"; import { SearchV2Service } from "../../../../../services/searchV2.service";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
@ -9,19 +9,16 @@ import { ActivatedRoute } from "@angular/router";
selector: "artist-release-panel", selector: "artist-release-panel",
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class ArtistReleasePanel implements OnInit { export class ArtistReleasePanel implements OnChanges {
@Input() public releases: IReleaseGroups[]; @Input() public releases: IReleaseGroups[];
public albums: IReleaseGroups[]; public albums: IReleaseGroups[];
constructor(private searchService: SearchV2Service, private route: ActivatedRoute) { constructor(private searchService: SearchV2Service) {
route.params.subscribe(() => { }
// This is due to when we change the music Id, NgOnInit is not called again
// Since the component has not been destroyed (We are not navigating away) ngOnChanges(changes: SimpleChanges): void {
// so we need to subscribe to custom changes so we can do the data manulipulation below this.loadAlbums();
this.loadAlbums();
});
} }
public ngOnInit() { public ngOnInit() {
@ -29,10 +26,19 @@ export class ArtistReleasePanel implements OnInit {
} }
private loadAlbums(): void { private loadAlbums(): void {
this.albums = this.releases.filter(x => x.type === "Album"); if (this.releases) {
this.albums = this.releases.filter(x => x.type === "Album");
this.albums = this.albums.sort((a: IReleaseGroups, b: IReleaseGroups) => {
return this.getTime(new Date(b.releaseDate)) - this.getTime(new Date(a.releaseDate));
});
this.albums.forEach(a => {
this.searchService.getReleaseGroupArt(a.id).subscribe(x => a.image = x.image);
});
}
}
this.albums.forEach(a => { private getTime(date?: Date) {
this.searchService.getReleaseGroupArt(a.id).subscribe(x => a.image = x.image); return date != null ? date.getTime() : 0;
});
} }
} }

View file

@ -8,7 +8,7 @@
<form novalidate [formGroup]="form" (ngSubmit)="onSubmit(form)" style="padding-top:5%;"> <form novalidate [formGroup]="form" (ngSubmit)="onSubmit(form)" style="padding-top:5%;">
<div class="col-md-6"> <div class="col-md-6">
<small>Changes to any of the below requires you to restart Ombi. </small> <small>Changes to any of the below requires you to restart Ombi. </small>
<small>You can generate valid CRON Expressions here: <a href="http://www.cronmaker.com/" target="_blank">http://www.cronmaker.com/</a></small> <small>You can generate valid CRON Expressions here: <a href="https://www.cronmaker.com/" target="_blank">https://www.cronmaker.com/</a></small>
<div class="form-group"> <div class="form-group">
<label for="sonarrSync" class="control-label">Sonarr Sync</label> <label for="sonarrSync" class="control-label">Sonarr Sync</label>
<input type="text" class="form-control form-control-custom" [ngClass]="{'form-error': form.get('sonarrSync').hasError('required')}" id="sonarrSync" name="sonarrSync" formControlName="sonarrSync"> <input type="text" class="form-control form-control-custom" [ngClass]="{'form-error': form.get('sonarrSync').hasError('required')}" id="sonarrSync" name="sonarrSync" formControlName="sonarrSync">