mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-14 01:02:57 -07:00
Added the subscribe button to the search page if we have an existing request.
This commit is contained in:
parent
e8249fa1a8
commit
a82b011ae3
8 changed files with 60 additions and 6 deletions
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Ombi.Core.Rule.Interfaces;
|
using Ombi.Core.Rule.Interfaces;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Ombi.Core.Authentication;
|
using Ombi.Core.Authentication;
|
||||||
|
@ -167,9 +168,30 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
await RunSearchRules(viewMovie);
|
await RunSearchRules(viewMovie);
|
||||||
|
|
||||||
|
// This requires the rules to be run first to populate the RequestId property
|
||||||
|
await CheckForSubscription(viewMovie);
|
||||||
|
|
||||||
return 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)
|
private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieSearchResult movie)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,7 +56,6 @@ namespace Ombi.Core.Models.Search
|
||||||
public bool FullyAvailable { get; set; }
|
public bool FullyAvailable { get; set; }
|
||||||
// We only have some episodes
|
// We only have some episodes
|
||||||
public bool PartlyAvailable { get; set; }
|
public bool PartlyAvailable { get; set; }
|
||||||
|
|
||||||
public override RequestType Type => RequestType.TvShow;
|
public override RequestType Type => RequestType.TvShow;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,13 +8,13 @@ namespace Ombi.Core.Models.Search
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public bool Approved { get; set; }
|
public bool Approved { get; set; }
|
||||||
public bool Requested { get; set; }
|
public bool Requested { get; set; }
|
||||||
|
public int RequestId { get; set; }
|
||||||
public bool Available { get; set; }
|
public bool Available { get; set; }
|
||||||
public string PlexUrl { get; set; }
|
public string PlexUrl { get; set; }
|
||||||
public string EmbyUrl { get; set; }
|
public string EmbyUrl { get; set; }
|
||||||
public string Quality { get; set; }
|
public string Quality { get; set; }
|
||||||
public abstract RequestType Type { get; }
|
public abstract RequestType Type { get; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is used for the PlexAvailabilityCheck/EmbyAvailabilityRule rule
|
/// This is used for the PlexAvailabilityCheck/EmbyAvailabilityRule rule
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -27,5 +27,11 @@ namespace Ombi.Core.Models.Search
|
||||||
public string TheTvDbId { get; set; }
|
public string TheTvDbId { get; set; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string TheMovieDbId { get; set; }
|
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.Requested = true;
|
||||||
|
obj.RequestId = movieRequests.Id;
|
||||||
obj.Approved = movieRequests.Approved;
|
obj.Approved = movieRequests.Approved;
|
||||||
obj.Available = movieRequests.Available;
|
obj.Available = movieRequests.Available;
|
||||||
|
|
||||||
|
@ -67,6 +68,7 @@ namespace Ombi.Core.Rule.Rules.Search
|
||||||
existingRequestChildRequest.SeasonRequests.FirstOrDefault(x => x.SeasonNumber == season.SeasonNumber);
|
existingRequestChildRequest.SeasonRequests.FirstOrDefault(x => x.SeasonNumber == season.SeasonNumber);
|
||||||
if (existingSeason == null) continue;
|
if (existingSeason == null) continue;
|
||||||
|
|
||||||
|
|
||||||
foreach (var ep in existingSeason.Episodes)
|
foreach (var ep in existingSeason.Episodes)
|
||||||
{
|
{
|
||||||
// Find the episode from what we are searching
|
// Find the episode from what we are searching
|
||||||
|
@ -92,7 +94,6 @@ namespace Ombi.Core.Rule.Rules.Search
|
||||||
request.PartlyAvailable = true;
|
request.PartlyAvailable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return Task.FromResult(Success());
|
return Task.FromResult(Success());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,14 @@
|
||||||
imdbId: string;
|
imdbId: string;
|
||||||
approved: boolean;
|
approved: boolean;
|
||||||
requested: boolean;
|
requested: boolean;
|
||||||
|
requestId: number;
|
||||||
available: boolean;
|
available: boolean;
|
||||||
plexUrl: string;
|
plexUrl: string;
|
||||||
embyUrl: string;
|
embyUrl: string;
|
||||||
quality: string;
|
quality: string;
|
||||||
digitalReleaseDate: Date;
|
digitalReleaseDate: Date;
|
||||||
|
subscribed: boolean;
|
||||||
|
showSubscribe: boolean;
|
||||||
|
|
||||||
// for the UI
|
// for the UI
|
||||||
requestProcessing: boolean;
|
requestProcessing: boolean;
|
||||||
|
|
|
@ -65,7 +65,13 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="col-sm-2 small-padding">
|
<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">
|
<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>
|
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> {{ 'Common.Available' | translate }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -163,6 +163,22 @@ export class MovieSearchComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
private getExtraInfo() {
|
||||||
|
|
||||||
this.movieResults.forEach((val, index) => {
|
this.movieResults.forEach((val, index) => {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { SearchComponent } from "./search.component";
|
||||||
import { SeriesInformationComponent } from "./seriesinformation.component";
|
import { SeriesInformationComponent } from "./seriesinformation.component";
|
||||||
import { TvSearchComponent } from "./tvsearch.component";
|
import { TvSearchComponent } from "./tvsearch.component";
|
||||||
|
|
||||||
import { SidebarModule, TreeTableModule } from "primeng/primeng";
|
import { SidebarModule, TooltipModule, TreeTableModule } from "primeng/primeng";
|
||||||
|
|
||||||
import { RequestService } from "../services";
|
import { RequestService } from "../services";
|
||||||
import { SearchService } from "../services";
|
import { SearchService } from "../services";
|
||||||
|
@ -33,6 +33,7 @@ const routes: Routes = [
|
||||||
TreeTableModule,
|
TreeTableModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
SidebarModule,
|
SidebarModule,
|
||||||
|
TooltipModule,
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
SearchComponent,
|
SearchComponent,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue