|
|
@ -1,10 +1,12 @@
|
|
|
|
import { Component } from "@angular/core";
|
|
|
|
import { Component } from "@angular/core";
|
|
|
|
import { ActivatedRoute } from "@angular/router";
|
|
|
|
import { ActivatedRoute } from "@angular/router";
|
|
|
|
import { SearchV2Service } from "../../../services";
|
|
|
|
import { SearchV2Service } from "../../../services";
|
|
|
|
import { IActorCredits } from "../../../interfaces/ISearchTvResultV2";
|
|
|
|
import { IActorCredits, IActorCast } from "../../../interfaces/ISearchTvResultV2";
|
|
|
|
import { IDiscoverCardResult } from "../../interfaces";
|
|
|
|
import { IDiscoverCardResult } from "../../interfaces";
|
|
|
|
import { RequestType } from "../../../interfaces";
|
|
|
|
import { RequestType } from "../../../interfaces";
|
|
|
|
import { AuthService } from "../../../auth/auth.service";
|
|
|
|
import { AuthService } from "../../../auth/auth.service";
|
|
|
|
|
|
|
|
import { forkJoin } from "rxjs";
|
|
|
|
|
|
|
|
import { isEqual } from "lodash";
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
templateUrl: "./discover-actor.component.html",
|
|
|
|
templateUrl: "./discover-actor.component.html",
|
|
|
@ -12,7 +14,6 @@ import { AuthService } from "../../../auth/auth.service";
|
|
|
|
})
|
|
|
|
})
|
|
|
|
export class DiscoverActorComponent {
|
|
|
|
export class DiscoverActorComponent {
|
|
|
|
public actorId: number;
|
|
|
|
public actorId: number;
|
|
|
|
public actorCredits: IActorCredits;
|
|
|
|
|
|
|
|
public loadingFlag: boolean;
|
|
|
|
public loadingFlag: boolean;
|
|
|
|
public isAdmin: boolean;
|
|
|
|
public isAdmin: boolean;
|
|
|
|
|
|
|
|
|
|
|
@ -24,24 +25,32 @@ export class DiscoverActorComponent {
|
|
|
|
this.route.params.subscribe((params: any) => {
|
|
|
|
this.route.params.subscribe((params: any) => {
|
|
|
|
this.actorId = params.actorId;
|
|
|
|
this.actorId = params.actorId;
|
|
|
|
this.isAdmin = this.auth.isAdmin();
|
|
|
|
this.isAdmin = this.auth.isAdmin();
|
|
|
|
this.loading();
|
|
|
|
this.search();
|
|
|
|
this.searchService.getMoviesByActor(this.actorId).subscribe(res => {
|
|
|
|
|
|
|
|
this.actorCredits = res;
|
|
|
|
|
|
|
|
this.createModel();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private createModel() {
|
|
|
|
private search() {
|
|
|
|
this.finishLoading();
|
|
|
|
|
|
|
|
this.discoverResults = [];
|
|
|
|
this.discoverResults = [];
|
|
|
|
this.actorCredits.cast.forEach(m => {
|
|
|
|
this.loading();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
forkJoin([
|
|
|
|
|
|
|
|
this.searchService.getMoviesByActor(this.actorId),
|
|
|
|
|
|
|
|
this.searchService.getTvByActor(this.actorId)
|
|
|
|
|
|
|
|
]).subscribe(([movie, tv]) => {
|
|
|
|
|
|
|
|
this.pushDiscoverResults(movie.cast, RequestType.movie);
|
|
|
|
|
|
|
|
this.pushDiscoverResults(tv.cast, RequestType.tvShow);
|
|
|
|
|
|
|
|
this.finishLoading();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pushDiscoverResults(cast: IActorCast[], type: RequestType) {
|
|
|
|
|
|
|
|
cast.forEach(m => {
|
|
|
|
this.discoverResults.push({
|
|
|
|
this.discoverResults.push({
|
|
|
|
available: false,
|
|
|
|
available: false,
|
|
|
|
posterPath: m.poster_path ? `https://image.tmdb.org/t/p/w300/${m.poster_path}` : "../../../images/default_movie_poster.png",
|
|
|
|
posterPath: m.poster_path ? `https://image.tmdb.org/t/p/w300/${m.poster_path}` : "../../../images/default_movie_poster.png",
|
|
|
|
requested: false,
|
|
|
|
requested: false,
|
|
|
|
title: m.title,
|
|
|
|
title: m.title,
|
|
|
|
type: RequestType.movie,
|
|
|
|
type: type,
|
|
|
|
id: m.id,
|
|
|
|
id: m.id,
|
|
|
|
url: null,
|
|
|
|
url: null,
|
|
|
|
rating: 0,
|
|
|
|
rating: 0,
|
|
|
|