mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Merge pull request #4855 from Ombi-app/bugs
Fixed a few different things
This commit is contained in:
commit
e05333e7aa
12 changed files with 73 additions and 22 deletions
|
@ -182,20 +182,25 @@ namespace Ombi.Core.Tests.Services
|
|||
var releaseDate = new DateTime(2019, 01, 01);
|
||||
var requestDate = DateTime.Now;
|
||||
|
||||
var movies = _fixture.CreateMany<MovieRequests>(10);
|
||||
var movies = _fixture.CreateMany<MovieRequests>(10).ToList();
|
||||
var albums = _fixture.CreateMany<AlbumRequest>(10);
|
||||
var chilRequests = _fixture.CreateMany<ChildRequests>(10);
|
||||
movies.Add(_fixture.Build<MovieRequests>().With(x => x.RequestedUserId, "a").With(x => x.Title, "unit").Create());
|
||||
|
||||
_mocker.Setup<IMovieRequestRepository, IQueryable<MovieRequests>>(x => x.GetAll()).Returns(movies.AsQueryable().BuildMock());
|
||||
_mocker.Setup<IMusicRequestRepository, IQueryable<AlbumRequest>>(x => x.GetAll()).Returns(albums.AsQueryable().BuildMock());
|
||||
_mocker.Setup<ITvRequestRepository, IQueryable<ChildRequests>>(x => x.GetChild()).Returns(chilRequests.AsQueryable().BuildMock());
|
||||
_mocker.Setup<ICurrentUser, Task<OmbiUser>>(x => x.GetUser()).ReturnsAsync(new OmbiUser { UserName = "test", Alias = "alias", UserType = UserType.LocalUser });
|
||||
_mocker.Setup<ICurrentUser, Task<OmbiUser>>(x => x.GetUser()).ReturnsAsync(new OmbiUser { UserName = "test", Id = "a", Alias = "alias", UserType = UserType.LocalUser });
|
||||
_mocker.Setup<ICurrentUser, string>(x => x.Username).Returns("test");
|
||||
_mocker.Setup<OmbiUserManager, Task<bool>>(x => x.IsInRoleAsync(It.IsAny<OmbiUser>(), It.IsAny<string>())).ReturnsAsync(false);
|
||||
|
||||
var result = await _subject.GetRecentlyRequested(CancellationToken.None);
|
||||
|
||||
CollectionAssert.IsEmpty(result.Where(x => !string.IsNullOrEmpty(x.Username) && !string.IsNullOrEmpty(x.UserId)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(result.Count, Is.EqualTo(1));
|
||||
Assert.That(result.First().Title, Is.EqualTo("unit"));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,10 @@ namespace Ombi.Core.Services
|
|||
var lang = await DefaultLanguageCode();
|
||||
foreach (var item in await recentMovieRequests.ToListAsync(cancellationToken))
|
||||
{
|
||||
if (hideUsers.Hide && item.RequestedUserId != hideUsers.UserId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var images = await _cache.GetOrAddAsync($"{CacheKeys.TmdbImages}movie{item.TheMovieDbId}", () => _movieDbApi.GetMovieImages(item.TheMovieDbId.ToString(), cancellationToken), DateTimeOffset.Now.AddDays(1));
|
||||
model.Add(new RecentlyRequestedModel
|
||||
{
|
||||
|
@ -84,8 +88,8 @@ namespace Ombi.Core.Services
|
|||
Title = item.Title,
|
||||
Type = RequestType.Movie,
|
||||
Approved = item.Approved,
|
||||
UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId,
|
||||
Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias,
|
||||
UserId = item.RequestedUserId,
|
||||
Username = item.RequestedUser.UserAlias,
|
||||
MediaId = item.TheMovieDbId.ToString(),
|
||||
PosterPath = images?.posters?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(),
|
||||
Background = images?.backdrops?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(),
|
||||
|
@ -94,6 +98,10 @@ namespace Ombi.Core.Services
|
|||
|
||||
foreach (var item in await recentMusicRequests.ToListAsync(cancellationToken))
|
||||
{
|
||||
if (hideUsers.Hide && item.RequestedUserId != hideUsers.UserId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
model.Add(new RecentlyRequestedModel
|
||||
{
|
||||
RequestId = item.Id,
|
||||
|
@ -104,14 +112,18 @@ namespace Ombi.Core.Services
|
|||
RequestDate = item.RequestedDate,
|
||||
Title = item.Title,
|
||||
Type = RequestType.Album,
|
||||
UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId,
|
||||
Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias,
|
||||
UserId = item.RequestedUserId,
|
||||
Username = item.RequestedUser.UserAlias,
|
||||
MediaId = item.ForeignAlbumId,
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var item in await recentTvRequests.ToListAsync(cancellationToken))
|
||||
{
|
||||
if (hideUsers.Hide && item.RequestedUserId != hideUsers.UserId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var providerId = item.ParentRequest.ExternalProviderId.ToString();
|
||||
var images = await _cache.GetOrAddAsync($"{CacheKeys.TmdbImages}tv{providerId}", () => _movieDbApi.GetTvImages(providerId.ToString(), cancellationToken), DateTimeOffset.Now.AddDays(1));
|
||||
|
||||
|
@ -127,8 +139,8 @@ namespace Ombi.Core.Services
|
|||
TvPartiallyAvailable = partialAvailability,
|
||||
Title = item.ParentRequest.Title,
|
||||
Type = RequestType.TvShow,
|
||||
UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId,
|
||||
Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias,
|
||||
UserId = item.RequestedUserId,
|
||||
Username = item.RequestedUser.UserAlias,
|
||||
MediaId = providerId.ToString(),
|
||||
PosterPath = images?.posters?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(),
|
||||
Background = images?.backdrops?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { APP_BASE_HREF, CommonModule, PlatformLocation } from "@angular/common";
|
||||
import { CustomPageService, ImageService, RequestService, SettingsService, SonarrService } from "./services";
|
||||
import { CustomPageService, ImageService, LidarrService, RequestService, SettingsService, SonarrService } from "./services";
|
||||
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||
import { HTTP_INTERCEPTORS, HttpClient, HttpClientModule } from "@angular/common/http";
|
||||
import { IdentityService, IssuesService, JobService, MessageService, PlexTvService, SearchService, StatusService } from "./services";
|
||||
|
@ -209,6 +209,7 @@ export function JwtTokenGetter() {
|
|||
StorageService,
|
||||
RequestService,
|
||||
SonarrService,
|
||||
LidarrService,
|
||||
SignalRNotificationService,
|
||||
FEATURES_INITIALIZER,
|
||||
SONARR_INITIALIZER,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, OnInit, Input, ViewChild, Output, EventEmitter } from "@angular/core";
|
||||
import { Component, OnInit, Input, ViewChild, Output, EventEmitter, Inject } from "@angular/core";
|
||||
import { DiscoverOption, IDiscoverCardResult } from "../../interfaces";
|
||||
import { ISearchMovieResult, ISearchTvResult, RequestType } from "../../../interfaces";
|
||||
import { SearchV2Service } from "../../../services";
|
||||
|
@ -6,6 +6,7 @@ import { StorageService } from "../../../shared/storage/storage-service";
|
|||
import { MatButtonToggleChange } from '@angular/material/button-toggle';
|
||||
import { Carousel } from 'primeng/carousel';
|
||||
import { FeaturesFacade } from "../../../state/features/features.facade";
|
||||
import { APP_BASE_HREF } from "@angular/common";
|
||||
|
||||
export enum DiscoverType {
|
||||
Upcoming,
|
||||
|
@ -44,10 +45,18 @@ export class CarouselListComponent implements OnInit {
|
|||
};
|
||||
private amountToLoad = 17;
|
||||
private currentlyLoaded = 0;
|
||||
private baseUrl: string = "";
|
||||
|
||||
|
||||
constructor(private searchService: SearchV2Service,
|
||||
private storageService: StorageService,
|
||||
private featureFacade: FeaturesFacade) {
|
||||
private featureFacade: FeaturesFacade,
|
||||
@Inject(APP_BASE_HREF) private href: string) {
|
||||
|
||||
if (this.href.length > 1) {
|
||||
this.baseUrl = this.href;
|
||||
}
|
||||
|
||||
Carousel.prototype.onTouchMove = () => { },
|
||||
this.responsiveOptions = [
|
||||
{
|
||||
|
@ -294,7 +303,7 @@ export class CarouselListComponent implements OnInit {
|
|||
this.movies.forEach(m => {
|
||||
tempResults.push({
|
||||
available: m.available,
|
||||
posterPath: m.posterPath ? `https://image.tmdb.org/t/p/w500/${m.posterPath}` : "../../../images/default_movie_poster.png",
|
||||
posterPath: m.posterPath ? `https://image.tmdb.org/t/p/w500/${m.posterPath}` : this.baseUrl + "/images/default_movie_poster.png",
|
||||
requested: m.requested,
|
||||
title: m.title,
|
||||
type: RequestType.movie,
|
||||
|
@ -316,7 +325,7 @@ export class CarouselListComponent implements OnInit {
|
|||
this.tvShows.forEach(m => {
|
||||
tempResults.push({
|
||||
available: m.fullyAvailable,
|
||||
posterPath: m.backdropPath ? `https://image.tmdb.org/t/p/w500/${m.backdropPath}` : "../../../images/default_tv_poster.png",
|
||||
posterPath: m.backdropPath ? `https://image.tmdb.org/t/p/w500/${m.backdropPath}` : this.baseUrl + "/images/default_tv_poster.png",
|
||||
requested: m.requested,
|
||||
title: m.title,
|
||||
type: RequestType.tvShow,
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<mat-slide-toggle id="filterTv" class="mat-menu-item slide-menu" [checked]="searchFilter.tvShows"
|
||||
(click)="$event.stopPropagation()" (change)="changeFilter($event,SearchFilterType.TvShow)">
|
||||
{{ 'NavigationBar.Filter.TvShows' | translate}}</mat-slide-toggle>
|
||||
<mat-slide-toggle id="filterMusic" class="mat-menu-item slide-menu" [checked]="searchFilter.music"
|
||||
<mat-slide-toggle *ngIf="musicEnabled$ | async" id="filterMusic" class="mat-menu-item slide-menu" [checked]="searchFilter.music"
|
||||
(click)="$event.stopPropagation()" (change)="changeFilter($event,SearchFilterType.Music)">
|
||||
{{ 'NavigationBar.Filter.Music' | translate}}</mat-slide-toggle>
|
||||
<!-- <mat-slide-toggle class="mat-menu-item slide-menu" [checked]="searchFilter.people"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
|
||||
import { Component, EventEmitter, Input, OnInit, Output, SimpleChanges } from '@angular/core';
|
||||
import { ICustomizationSettings, IUser, RequestType, UserType } from '../interfaces';
|
||||
import { SettingsService, SettingsStateService } from '../services';
|
||||
import { LidarrService, SettingsService, SettingsStateService } from '../services';
|
||||
|
||||
import { AdvancedSearchDialogComponent } from '../shared/advanced-search-dialog/advanced-search-dialog.component';
|
||||
import { CustomizationFacade } from '../state/customization';
|
||||
|
@ -15,7 +15,7 @@ import { Observable } from 'rxjs';
|
|||
import { Router } from '@angular/router';
|
||||
import { SearchFilter } from './SearchFilter';
|
||||
import { StorageService } from '../shared/storage/storage-service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
|
||||
export enum SearchFilterType {
|
||||
Movie = 1,
|
||||
|
@ -56,9 +56,12 @@ export class MyNavComponent implements OnInit {
|
|||
|
||||
private customizationSettings: ICustomizationSettings;
|
||||
|
||||
public readonly musicEnabled$ = this.lidarrService.enabled().pipe(take(1));
|
||||
|
||||
constructor(private breakpointObserver: BreakpointObserver,
|
||||
private settingsService: SettingsService,
|
||||
private customizationFacade: CustomizationFacade,
|
||||
private lidarrService: LidarrService,
|
||||
private store: StorageService,
|
||||
private filterService: FilterService,
|
||||
private dialogService: MatDialog,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { MoviesGridComponent } from "./movies-grid/movies-grid.component";
|
||||
|
||||
import { RequestServiceV2 } from "../../services/requestV2.service";
|
||||
import { RequestService } from "../../services";
|
||||
import { LidarrService, RequestService } from "../../services";
|
||||
import { TvGridComponent } from "./tv-grid/tv-grid.component";
|
||||
import { GridSpinnerComponent } from "./grid-spinner/grid-spinner.component";
|
||||
import { RequestOptionsComponent } from "./options/request-options.component";
|
||||
|
@ -20,4 +20,5 @@ export const components: any[] = [
|
|||
export const providers: any[] = [
|
||||
RequestService,
|
||||
RequestServiceV2,
|
||||
LidarrService,
|
||||
];
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<tv-grid (onOpenOptions)="onOpenOptions($event)"></tv-grid>
|
||||
</ng-template>
|
||||
</mat-tab>
|
||||
<mat-tab label="{{ 'NavigationBar.Filter.Music' | translate }}">
|
||||
<mat-tab *ngIf="musicEnabled$ | async" label="{{ 'NavigationBar.Filter.Music' | translate }}">
|
||||
<ng-template matTabContent>
|
||||
<albums-grid (onOpenOptions)="onOpenOptions($event)"></albums-grid>
|
||||
</ng-template>
|
||||
|
|
|
@ -3,6 +3,8 @@ import { Component, ViewChild } from "@angular/core";
|
|||
import { MatBottomSheet } from "@angular/material/bottom-sheet";
|
||||
import { RequestOptionsComponent } from "./options/request-options.component";
|
||||
import { UpdateType } from "../models/UpdateType";
|
||||
import { LidarrService } from "app/services";
|
||||
import { take } from "rxjs";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./requests-list.component.html",
|
||||
|
@ -10,7 +12,9 @@ import { UpdateType } from "../models/UpdateType";
|
|||
})
|
||||
export class RequestsListComponent {
|
||||
|
||||
constructor(private bottomSheet: MatBottomSheet) { }
|
||||
constructor(private bottomSheet: MatBottomSheet, private lidarrService: LidarrService) { }
|
||||
|
||||
public readonly musicEnabled$ = this.lidarrService.enabled().pipe(take(1));
|
||||
|
||||
public onOpenOptions(event: { request: any, filter: any, onChange: any, manageOwnRequests: boolean, isAdmin: boolean, has4kRequest: boolean, hasRegularRequest: boolean }) {
|
||||
const ref = this.bottomSheet.open(RequestOptionsComponent, { data: { id: event.request.id, type: event.request.requestType, canApprove: event.request.canApprove, manageOwnRequests: event.manageOwnRequests, isAdmin: event.isAdmin, has4kRequest: event.has4kRequest, hasRegularRequest: event.hasRegularRequest } });
|
||||
|
|
|
@ -13,9 +13,14 @@ export class LidarrService extends ServiceHelpers {
|
|||
super(http, "/api/v1/Lidarr", href);
|
||||
}
|
||||
|
||||
public enabled(): Observable<boolean> {
|
||||
return this.http.get<boolean>(`${this.url}/enabled/`, {headers: this.headers});
|
||||
}
|
||||
|
||||
public getRootFolders(settings: ILidarrSettings): Observable<ILidarrRootFolder[]> {
|
||||
return this.http.post<ILidarrRootFolder[]>(`${this.url}/RootFolders/`, JSON.stringify(settings), {headers: this.headers});
|
||||
}
|
||||
|
||||
public getQualityProfiles(settings: ILidarrSettings): Observable<ILidarrProfile[]> {
|
||||
return this.http.post<ILidarrProfile[]>(`${this.url}/Profiles/`, JSON.stringify(settings), {headers: this.headers});
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ export class AdvancedSearchDialogDataService {
|
|||
getOptions(): any {
|
||||
return this._options;
|
||||
}
|
||||
|
||||
|
||||
getLoaded(): number {
|
||||
return this._options.loaded;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ using Ombi.Settings.Settings.Models.External;
|
|||
|
||||
namespace Ombi.Controllers.V1.External
|
||||
{
|
||||
[PowerUser]
|
||||
[ApiV1]
|
||||
[Produces("application/json")]
|
||||
public class LidarrController : Controller
|
||||
|
@ -28,11 +27,19 @@ namespace Ombi.Controllers.V1.External
|
|||
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
|
||||
private ICacheService Cache { get; }
|
||||
|
||||
[HttpGet("enabled")]
|
||||
public async Task<bool> Enabled()
|
||||
{
|
||||
var settings = await _lidarrSettings.GetSettingsAsync();
|
||||
return settings.Enabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Lidarr profiles.
|
||||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[PowerUser]
|
||||
[HttpPost("Profiles")]
|
||||
public async Task<IEnumerable<LidarrProfile>> GetProfiles([FromBody] LidarrSettings settings)
|
||||
{
|
||||
|
@ -44,6 +51,7 @@ namespace Ombi.Controllers.V1.External
|
|||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[PowerUser]
|
||||
[HttpPost("RootFolders")]
|
||||
public async Task<IEnumerable<LidarrRootFolder>> GetRootFolders([FromBody] LidarrSettings settings)
|
||||
{
|
||||
|
@ -55,6 +63,7 @@ namespace Ombi.Controllers.V1.External
|
|||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
[PowerUser]
|
||||
[HttpPost("Metadata")]
|
||||
public async Task<IEnumerable<MetadataProfile>> GetMetadataProfiles([FromBody] LidarrSettings settings)
|
||||
{
|
||||
|
@ -66,6 +75,7 @@ namespace Ombi.Controllers.V1.External
|
|||
/// <remarks>The data is cached for an hour</remarks>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[PowerUser]
|
||||
[HttpGet("Profiles")]
|
||||
public async Task<IEnumerable<LidarrProfile>> GetProfiles()
|
||||
{
|
||||
|
@ -85,6 +95,7 @@ namespace Ombi.Controllers.V1.External
|
|||
/// <remarks>The data is cached for an hour</remarks>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[PowerUser]
|
||||
[HttpGet("RootFolders")]
|
||||
public async Task<IEnumerable<LidarrRootFolder>> GetRootFolders()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue