From 3fbbf74c1b60a41e881cedfe71f0d28c53334fa4 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Thu, 28 Mar 2019 22:15:34 +0000 Subject: [PATCH] Collections done! --- src/Ombi.TheMovieDbApi/TheMovieDbApi.cs | 3 +- src/Ombi/ClientApp/src/app/app.component.ts | 9 ++--- .../discover-collections.component.html | 17 ++------- .../discover-collections.component.ts | 35 ++++++++++++++++++- .../movie/movie-details.component.html | 5 ++- .../movie/movie-details.component.ts | 11 ++++++ 6 files changed, 55 insertions(+), 25 deletions(-) diff --git a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs index ae1df478e..89917243c 100644 --- a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs @@ -58,10 +58,9 @@ namespace Ombi.Api.TheMovieDb public async Task GetCollection(string langCode, int collectionId) { // https://developers.themoviedb.org/3/discover/movie-discover - var request = new Request("discover/movie", BaseUri, HttpMethod.Get); + var request = new Request($"/collection/{collectionId}", BaseUri, HttpMethod.Get); request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken); request.FullUri = request.FullUri.AddQueryParameter("language", langCode); - request.FullUri = request.FullUri.AddQueryParameter("collection_id", collectionId.ToString()); return await Api.Request (request); } diff --git a/src/Ombi/ClientApp/src/app/app.component.ts b/src/Ombi/ClientApp/src/app/app.component.ts index 7f5fde744..a81814844 100644 --- a/src/Ombi/ClientApp/src/app/app.component.ts +++ b/src/Ombi/ClientApp/src/app/app.component.ts @@ -61,8 +61,6 @@ export class AppComponent implements OnInit { public ngOnInit() { const theme = localStorage.getItem("theme"); this.onSetTheme(theme); - this.user = this.authService.claims(); - this.isAdmin = this.authService.hasRole("admin"); this.settingsService.getCustomization().subscribe(x => { this.customizationSettings = x; @@ -88,10 +86,11 @@ export class AppComponent implements OnInit { this.currentUrl = event.url; if (event instanceof NavigationStart) { this.user = this.authService.claims(); + this.isAdmin = this.authService.hasRole("admin"); this.showNav = this.authService.loggedIn(); // tslint:disable-next-line:no-string-literal - if (this.user !== null && this.user.name && !this.checkedForUpdate && this.user.roles["Admin"]) { + if (this.user !== null && this.user.name && !this.checkedForUpdate && this.isAdmin) { this.checkedForUpdate = true; this.jobService.getCachedUpdate().subscribe(x => { this.updateAvailable = x; @@ -111,10 +110,6 @@ export class AppComponent implements OnInit { return "user"; } - public hasRole(role: string): boolean { - return this.user.roles.some(r => r === role); - } - public openMobileApp(event: any) { event.preventDefault(); if (!this.customizationSettings.applicationUrl) { diff --git a/src/Ombi/ClientApp/src/app/discover/collections/discover-collections.component.html b/src/Ombi/ClientApp/src/app/discover/collections/discover-collections.component.html index 4499bdce5..c5a8a0303 100644 --- a/src/Ombi/ClientApp/src/app/discover/collections/discover-collections.component.html +++ b/src/Ombi/ClientApp/src/app/discover/collections/discover-collections.component.html @@ -1,19 +1,8 @@ -
+
-
- - - -
+

{{collection.name}}

+

{{collection.overview}}

diff --git a/src/Ombi/ClientApp/src/app/discover/collections/discover-collections.component.ts b/src/Ombi/ClientApp/src/app/discover/collections/discover-collections.component.ts index 5ee0a485d..27e25f8e2 100644 --- a/src/Ombi/ClientApp/src/app/discover/collections/discover-collections.component.ts +++ b/src/Ombi/ClientApp/src/app/discover/collections/discover-collections.component.ts @@ -2,6 +2,8 @@ import { Component, OnInit } from "@angular/core"; import { ActivatedRoute } from "@angular/router"; import { SearchV2Service } from "../../services"; import { IMovieCollectionsViewModel } from "../../interfaces/ISearchTvResultV2"; +import { IDiscoverCardResult } from "../interfaces"; +import { RequestType } from "../../interfaces"; @Component({ templateUrl: "./discover-collections.component.html", @@ -11,6 +13,9 @@ export class DiscoverCollectionsComponent implements OnInit { public collectionId: number; public collection: IMovieCollectionsViewModel; + public loadingFlag: boolean; + + public discoverResults: IDiscoverCardResult[] = []; constructor(private searchService: SearchV2Service, private route: ActivatedRoute) { this.route.params.subscribe((params: any) => { @@ -19,6 +24,34 @@ export class DiscoverCollectionsComponent implements OnInit { } public async ngOnInit() { - this.collection = await this.searchService.getMovieCollections(this.collectionId); + this.loadingFlag = true; + this.collection = await this.searchService.getMovieCollections(this.collectionId); + this.createModel(); + } + + private createModel() { + this.finishLoading(); + this.collection.collection.forEach(m => { + this.discoverResults.push({ + available: m.available, + posterPath: `https://image.tmdb.org/t/p/w300/${m.posterPath}`, + requested: m.requested, + title: m.title, + type: RequestType.movie, + id: m.id, + url: `http://www.imdb.com/title/${m.imdbId}/`, + rating: 0, + overview: m.overview, + approved: m.approved + }); + }); + } + + private loading() { + this.loadingFlag = true; + } + + private finishLoading() { + this.loadingFlag = false; } } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html index 505440d69..444ce66a4 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html @@ -43,6 +43,9 @@ + + diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts index c8c0e3ed4..0a568d442 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts @@ -109,6 +109,16 @@ export class MovieDetailsComponent { } } + public async markAvailable() { + const result = await this.requestService.markMovieAvailable({id: this.movieRequest.id}).toPromise(); + if (result.result) { + this.movie.available = true; + this.messageService.send(result.message, "Ok"); + } else { + this.messageService.send(result.errorMessage, "Ok"); + } + } + private setQualityOverrides(): void { if (this.radarrProfiles) { const profile = this.radarrProfiles.filter((p) => { @@ -119,6 +129,7 @@ export class MovieDetailsComponent { } } } + private setRootFolderOverrides(): void { if (this.radarrRootFolders) { const path = this.radarrRootFolders.filter((folder) => {