Merge branch 'develop' of https://github.com/tidusjar/Ombi into develop

pull/2292/head
Anojh 6 years ago
commit 36c522cc01

@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Ombi.Core.Rule.Interfaces;
using Microsoft.Extensions.Caching.Memory;
using Ombi.Core.Authentication;
@ -166,10 +167,31 @@ namespace Ombi.Core.Engine
viewMovie.TheMovieDbId = viewMovie.Id.ToString();
await RunSearchRules(viewMovie);
// This requires the rules to be run first to populate the RequestId property
await CheckForSubscription(viewMovie);
return viewMovie;
}
private async Task CheckForSubscription(SearchMovieViewModel viewModel)
{
// Check if this user requested it
var user = await GetUser();
var request = await RequestService.MovieRequestService.GetAll()
.AnyAsync(x => x.RequestedUserId.Equals(user.Id) && x.Id == viewModel.Id);
if (request)
{
viewModel.ShowSubscribe = false;
}
else
{
viewModel.ShowSubscribe = true;
var sub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(s => s.UserId == user.Id
&& s.RequestId == viewModel.RequestId && s.RequestType == RequestType.Movie);
viewModel.Subscribed = sub != null;
}
}
private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieSearchResult movie)
{

@ -56,7 +56,6 @@ namespace Ombi.Core.Models.Search
public bool FullyAvailable { get; set; }
// We only have some episodes
public bool PartlyAvailable { get; set; }
public override RequestType Type => RequestType.TvShow;
}
}

@ -8,13 +8,13 @@ namespace Ombi.Core.Models.Search
public int Id { get; set; }
public bool Approved { get; set; }
public bool Requested { get; set; }
public int RequestId { get; set; }
public bool Available { get; set; }
public string PlexUrl { get; set; }
public string EmbyUrl { get; set; }
public string Quality { get; set; }
public abstract RequestType Type { get; }
/// <summary>
/// This is used for the PlexAvailabilityCheck/EmbyAvailabilityRule rule
/// </summary>
@ -27,5 +27,11 @@ namespace Ombi.Core.Models.Search
public string TheTvDbId { get; set; }
[NotMapped]
public string TheMovieDbId { get; set; }
[NotMapped]
public bool Subscribed { get; set; }
[NotMapped]
public bool ShowSubscribe { get; set; }
}
}

@ -29,6 +29,7 @@ namespace Ombi.Core.Rule.Rules.Search
{
obj.Requested = true;
obj.RequestId = movieRequests.Id;
obj.Approved = movieRequests.Approved;
obj.Available = movieRequests.Available;
@ -67,6 +68,7 @@ namespace Ombi.Core.Rule.Rules.Search
existingRequestChildRequest.SeasonRequests.FirstOrDefault(x => x.SeasonNumber == season.SeasonNumber);
if (existingSeason == null) continue;
foreach (var ep in existingSeason.Episodes)
{
// Find the episode from what we are searching
@ -92,7 +94,6 @@ namespace Ombi.Core.Rule.Rules.Search
request.PartlyAvailable = true;
}
return Task.FromResult(Success());
}
}

@ -19,11 +19,14 @@
imdbId: string;
approved: boolean;
requested: boolean;
requestId: number;
available: boolean;
plexUrl: string;
embyUrl: string;
quality: string;
digitalReleaseDate: Date;
subscribed: boolean;
showSubscribe: boolean;
// for the UI
requestProcessing: boolean;

@ -65,7 +65,13 @@
<div class="col-sm-2 small-padding">
<div class="row" *ngIf="result.requested">
<div class="col-md-2 col-md-push-10">
<a *ngIf="result.showSubscribe && !result.subscribed" style="color:white" (click)="subscribe(result)" pTooltip="Subscribe for notifications"> <i class="fa fa-rss"></i></a>
<a *ngIf="result.showSubscribe && result.subscribed" style="color:red" (click)="unSubscribe(result)" pTooltip="Unsubscribe notification"> <i class="fa fa-rss"></i></a>
</div>
</div>
<div *ngIf="result.available">
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> {{ 'Common.Available' | translate }}</button>
</div>

@ -162,6 +162,22 @@ export class MovieSearchComponent implements OnInit {
this.getExtraInfo();
});
}
public subscribe(r: ISearchMovieResult) {
r.subscribed = true;
this.requestService.subscribeToMovie(r.requestId)
.subscribe(x => {
this.notificationService.success("Subscribed To Movie!");
});
}
public unSubscribe(r: ISearchMovieResult) {
r.subscribed = false;
this.requestService.unSubscribeToMovie(r.requestId)
.subscribe(x => {
this.notificationService.success("Unsubscribed Movie!");
});
}
private getExtraInfo() {

@ -11,7 +11,7 @@ import { SearchComponent } from "./search.component";
import { SeriesInformationComponent } from "./seriesinformation.component";
import { TvSearchComponent } from "./tvsearch.component";
import { SidebarModule, TreeTableModule } from "primeng/primeng";
import { SidebarModule, TooltipModule, TreeTableModule } from "primeng/primeng";
import { RequestService } from "../services";
import { SearchService } from "../services";
@ -33,6 +33,7 @@ const routes: Routes = [
TreeTableModule,
SharedModule,
SidebarModule,
TooltipModule,
],
declarations: [
SearchComponent,

Loading…
Cancel
Save