pull/3895/head
Jamie Rees 6 years ago
parent 6fc9db003e
commit 9f5c19ecf6

@ -58,10 +58,9 @@ namespace Ombi.Api.TheMovieDb
public async Task<Collections> 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<Collections> (request);
}

@ -61,12 +61,10 @@ 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;
if (this.customizationSettings && this.customizationSettings.applicationName) {
this.applicationName = this.customizationSettings.applicationName;
}
@ -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;
@ -103,18 +102,16 @@ export class AppComponent implements OnInit {
}
public roleClass() {
if (this.user.roles.some(r => r === "Admin")) {
return "adminUser";
} else if (this.user.roles.some(r => r === "PowerUser")) {
return "powerUser";
if (this.user) {
if (this.user.roles.some(r => r === "Admin")) {
return "adminUser";
} else if (this.user.roles.some(r => r === "PowerUser")) {
return "powerUser";
}
}
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) {

@ -1,19 +1,9 @@
<div class="small-middle-container">
<div class="row justify-content-md-center top-spacing">
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" (click)="popular()" [attr.color]="popularActive ? 'accent' : 'primary'"
[ngClass]="popularActive ? 'mat-accent' : 'mat-primary'" mat-raised-button
class="btn grow" >{{'Discovery.PopularTab' | translate}}</button>
<button type="button" (click)="trending()"
[attr.color]="trendingActive ? 'accent' : 'primary'"
[ngClass]="trendingActive ? 'mat-accent' : 'mat-primary'"
mat-raised-button class="btn grow" color="primary">{{'Discovery.TrendingTab' | translate}}</button>
<button type="button" (click)="upcoming()"
[attr.color]="upcomingActive ? 'accent' : 'primary'"
[ngClass]="upcomingActive ? 'mat-accent' : 'mat-primary'"
mat-raised-button class="btn grow" color="primary">{{'Discovery.UpcomingTab' | translate}}</button>
</div>
<h2>{{collection.title}}</h2>
<p>{{collection.overview}}</p>
</div>
<div *ngIf="loadingFlag" class="row justify-content-md-center top-spacing loading-spinner">
<mat-spinner [color]="'accent'"></mat-spinner>

@ -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) => {
@ -20,5 +25,32 @@ export class DiscoverCollectionsComponent implements OnInit {
public async ngOnInit() {
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: null,
overview: m.overview,
approved: m.approved
});
});
}
private loading() {
this.loadingFlag = true;
}
private finishLoading() {
this.loadingFlag = false;
}
}

@ -64,7 +64,7 @@
<div class="row">
<div class="col-12 col-md-2">
<button *ngIf="movie.belongsToCollection" [routerLink]="/discover/{{movie.belongsToCollection.id}" mat-raised-button class="spacing-below full-width mat-elevation-z8">{{movie.belongsToCollection.name}}</button>
<button *ngIf="movie.belongsToCollection" [routerLink]="'/discover/collection/' + movie.belongsToCollection.id" mat-raised-button class="spacing-below full-width mat-elevation-z8">{{movie.belongsToCollection.name}}</button>
<mat-card class="mat-elevation-z8">
<mat-card-content class="medium-font">

Loading…
Cancel
Save