Made some good process on getting the backend up and running for requesting albums etc

pull/3895/head
Jamie Rees 5 years ago
parent f921d84b0b
commit 4b7d7410ae

@ -67,13 +67,16 @@ namespace Ombi.Core.Engine.V2
foreach (var g in artist.ReleaseGroups) foreach (var g in artist.ReleaseGroups)
{ {
info.ReleaseGroups.Add(new ReleaseGroup var release = new ReleaseGroup
{ {
Type = g.PrimaryType, ReleaseType = g.PrimaryType,
Id = g.Id, Id = g.Id,
Title = g.Title, Title = g.Title,
ReleaseDate = g.FirstReleaseDate, ReleaseDate = g.FirstReleaseDate,
}); };
await RunSearchRules(release);
info.ReleaseGroups.Add(release);
} }
info.Links = GetLinksForArtist(artist); info.Links = GetLinksForArtist(artist);

@ -28,7 +28,6 @@ namespace Ombi.Core.Models.Search
[NotMapped] [NotMapped]
public string TheMovieDbId { get; set; } public string TheMovieDbId { get; set; }
[NotMapped] [NotMapped]
public bool Subscribed { get; set; } public bool Subscribed { get; set; }
[NotMapped] [NotMapped]

@ -53,13 +53,4 @@ namespace Ombi.Core.Models.Search.V2.Music
public string Google { get; set; } public string Google { get; set; }
public string Apple { get; set; } public string Apple { get; set; }
} }
public class ReleaseGroup
{
public string Id { get; set; }
public string Title { get; set; }
public string ReleaseDate { get; set; }
public string Type { get; set; }
}
} }

@ -0,0 +1,17 @@
using Ombi.Store.Entities;
namespace Ombi.Core.Models.Search.V2.Music
{
public class ReleaseGroup : SearchViewModel
{
public new string Id { get; set; }
public override RequestType Type => RequestType.Album;
public string Title { get; set; }
public string ReleaseDate { get; set; }
public string ReleaseType { get; set; }
public decimal PercentOfTracks { get; set; }
public bool Monitored { get; set; }
public bool PartiallyAvailable => PercentOfTracks != 100 && PercentOfTracks > 0;
public bool FullyAvailable => PercentOfTracks == 100;
}
}

@ -3,6 +3,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Ombi.Core.Models.Search; using Ombi.Core.Models.Search;
using Ombi.Core.Models.Search.V2.Music;
using Ombi.Core.Rule.Interfaces; using Ombi.Core.Rule.Interfaces;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using Ombi.Store.Repository; using Ombi.Store.Repository;
@ -89,17 +90,33 @@ namespace Ombi.Core.Rule.Rules.Search
} }
if (obj.Type == RequestType.Album) if (obj.Type == RequestType.Album)
{ {
var album = (SearchAlbumViewModel) obj; if (obj is SearchAlbumViewModel album)
var albumRequest = await Music.GetRequestAsync(album.ForeignAlbumId);
if (albumRequest != null) // Do we already have a request for this?
{ {
obj.Requested = true; var albumRequest = await Music.GetRequestAsync(album.ForeignAlbumId);
obj.RequestId = albumRequest.Id; if (albumRequest != null) // Do we already have a request for this?
obj.Approved = albumRequest.Approved; {
obj.Available = albumRequest.Available; obj.Requested = true;
obj.RequestId = albumRequest.Id;
obj.Approved = albumRequest.Approved;
obj.Available = albumRequest.Available;
return Success(); return Success();
}
}
if (obj is ReleaseGroup release)
{
var albumRequest = await Music.GetRequestAsync(release.Id);
if (albumRequest != null) // Do we already have a request for this?
{
obj.Requested = true;
obj.RequestId = albumRequest.Id;
obj.Approved = albumRequest.Approved;
obj.Available = albumRequest.Available;
return Success();
}
} }
return Success(); return Success();
} }
return Success(); return Success();

@ -2,13 +2,14 @@
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Ombi.Core.Models.Search; using Ombi.Core.Models.Search;
using Ombi.Core.Models.Search.V2.Music;
using Ombi.Core.Rule.Interfaces; using Ombi.Core.Rule.Interfaces;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using Ombi.Store.Repository; using Ombi.Store.Repository;
namespace Ombi.Core.Rule.Rules.Search namespace Ombi.Core.Rule.Rules.Search
{ {
public class LidarrAlbumCacheRule : SpecificRule, ISpecificRule<object> public class LidarrAlbumCacheRule : BaseSearchRule, IRules<SearchViewModel>
{ {
public LidarrAlbumCacheRule(IExternalRepository<LidarrAlbumCache> db) public LidarrAlbumCacheRule(IExternalRepository<LidarrAlbumCache> db)
{ {
@ -17,20 +18,33 @@ namespace Ombi.Core.Rule.Rules.Search
private readonly IExternalRepository<LidarrAlbumCache> _db; private readonly IExternalRepository<LidarrAlbumCache> _db;
public Task<RuleResult> Execute(object objec) public Task<RuleResult> Execute(SearchViewModel objec)
{ {
var obj = (SearchAlbumViewModel) objec; if (objec is SearchAlbumViewModel obj)
// Check if it's in Lidarr
var result = _db.GetAll().FirstOrDefault(x => x.ForeignAlbumId.Equals(obj.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
if (result != null)
{ {
obj.PercentOfTracks = result.PercentOfTracks; // Check if it's in Lidarr
obj.Monitored = true; // It's in Lidarr so it's monitored var result = _db.GetAll().FirstOrDefault(x =>
x.ForeignAlbumId.Equals(obj.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
if (result != null)
{
obj.PercentOfTracks = result.PercentOfTracks;
obj.Monitored = true; // It's in Lidarr so it's monitored
}
}
if (objec is ReleaseGroup release)
{
// Check if it's in Lidarr
var result = _db.GetAll().FirstOrDefault(x =>
x.ForeignAlbumId.Equals(release.Id, StringComparison.InvariantCultureIgnoreCase));
if (result != null)
{
release.PercentOfTracks = result.PercentOfTracks;
release.Monitored = true; // It's in Lidarr so it's monitored
}
} }
return Task.FromResult(Success()); return Task.FromResult(Success());
} }
public override SpecificRules Rule => SpecificRules.LidarrAlbum;
} }
} }

@ -23,7 +23,16 @@ export interface IReleaseGroups {
id: string; id: string;
title: string; title: string;
releaseDate: string; releaseDate: string;
type: string; releaseType: string;
approved: boolean;
requested: boolean;
requestId: number;
available: boolean;
subscribed: boolean;
showSubscribe: boolean;
monitored: boolean;
partiallyAvailable: boolean;
fullyAvailable: boolean;
image: string; // Set by another api call image: string; // Set by another api call
} }

@ -28,6 +28,11 @@
<div class="col-12 col-lg-6 col-xl-6 media-row"> <div class="col-12 col-lg-6 col-xl-6 media-row">
<button mat-raised-button class="btn-spacing" color="primary" (click)="requestAllAlbums()">
<i
class="fa fa-plus"></i> {{
'MediaDetails.RequestAllAlbums' | translate }}</button>
<!-- <button mat-raised-button class="btn-green btn-spacing" *ngIf="movie.available"> {{ <!-- <button mat-raised-button class="btn-green btn-spacing" *ngIf="movie.available"> {{
'Common.Available' | translate }}</button> --> 'Common.Available' | translate }}</button> -->
<!-- <span *ngIf="!movie.available"> <!-- <span *ngIf="!movie.available">

@ -55,7 +55,7 @@ export class ArtistDetailsComponent {
return this.artist.background return this.artist.background
} }
public async request() { public async requestAllAlbums() {
// const result = await this.requestService.requestMovie({ theMovieDbId: this.theMovidDbId, languageCode: null }).toPromise(); // const result = await this.requestService.requestMovie({ theMovieDbId: this.theMovidDbId, languageCode: null }).toPromise();
// if (result.result) { // if (result.result) {
// this.movie.requested = true; // this.movie.requested = true;

@ -14,7 +14,7 @@
<span *ngFor="let r of albums"> <span *ngFor="let r of albums">
<div class="col-md-2" > <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" [class.monitored]="r.monitored" [class.available]="r.available">
<img class="real grow" matTooltip="{{r.title}}" <img class="real grow" matTooltip="{{r.title}}"
src="{{r.image ? r.image : 'images/default-music-placeholder.png'}}" alt="Poster" src="{{r.image ? r.image : 'images/default-music-placeholder.png'}}" alt="Poster"
style="display: block;"> style="display: block;">

@ -0,0 +1,10 @@
@import 'Styles/buttons.scss';
// border: solid 3px #fff;
.monitored {
border: solid 3px $orange !important;
}
.available {
border: solid 3px $green !important;
}

@ -5,7 +5,7 @@ import { ActivatedRoute } from "@angular/router";
@Component({ @Component({
templateUrl: "./artist-release-panel.component.html", templateUrl: "./artist-release-panel.component.html",
styleUrls: ["../../../../media-details.component.scss"], styleUrls: ["../../../../media-details.component.scss", "./artist-release-panel.component.scss"],
selector: "artist-release-panel", selector: "artist-release-panel",
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
@ -27,7 +27,7 @@ export class ArtistReleasePanel implements OnChanges {
private loadAlbums(): void { private loadAlbums(): void {
if (this.releases) { if (this.releases) {
this.albums = this.releases.filter(x => x.type === "Album"); this.albums = this.releases.filter(x => x.releaseType === "Album");
this.albums = this.albums.sort((a: IReleaseGroups, b: IReleaseGroups) => { this.albums = this.albums.sort((a: IReleaseGroups, b: IReleaseGroups) => {
return this.getTime(new Date(b.releaseDate)) - this.getTime(new Date(a.releaseDate)); return this.getTime(new Date(b.releaseDate)) - this.getTime(new Date(a.releaseDate));
}); });

@ -138,7 +138,7 @@
} }
#info-wrapper .sidebar .poster { #info-wrapper .sidebar .poster {
border: solid 3px #fff !important; border: solid 3px #fff;
position: relative; position: relative;
-webkit-box-shadow: 0 0 20px 0 #666; -webkit-box-shadow: 0 0 20px 0 #666;
box-shadow: 0 0 20px 0 #666; box-shadow: 0 0 20px 0 #666;

@ -1,15 +1,21 @@
.btn-blue { 
background-color: #1976D2; $blue: #1976D2;
$pink: #C2185B;
$green:#1DE9B6;
$orange:#F57C00;
.btn-blue {
background-color: $blue;
} }
.btn-pink { .btn-pink {
background-color: #C2185B; background-color: $pink;
} }
.btn-green { .btn-green {
background-color: #1DE9B6; background-color: $green;
} }
.btn-orange { .btn-orange {
background-color: #F57C00; background-color: $orange;
} }

@ -204,6 +204,7 @@
"SimilarTitle": "Similar", "SimilarTitle": "Similar",
"VideosTitle": "Videos", "VideosTitle": "Videos",
"AlbumsTitle":"Albums", "AlbumsTitle":"Albums",
"RequestAllAlbums":"Request All Albums",
"Casts": { "Casts": {
"CastTitle": "Cast", "CastTitle": "Cast",
"Character": "Character", "Character": "Character",

Loading…
Cancel
Save