|
|
@ -1,14 +1,15 @@
|
|
|
|
|
|
|
|
import { ActivatedRoute, NavigationEnd, Router } from "@angular/router";
|
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
import { Component, OnInit } from "@angular/core";
|
|
|
|
import { ActivatedRoute } from "@angular/router";
|
|
|
|
import { IMultiSearchResult, ISearchMovieResult, RequestType } from "../../../interfaces";
|
|
|
|
import { SearchV2Service } from "../../../services";
|
|
|
|
|
|
|
|
import { IDiscoverCardResult } from "../../interfaces";
|
|
|
|
import { AdvancedSearchDialogDataService } from "../../../shared/advanced-search-dialog/advanced-search-dialog-data.service";
|
|
|
|
import { IMultiSearchResult, RequestType } from "../../../interfaces";
|
|
|
|
import { AuthService } from "../../../auth/auth.service";
|
|
|
|
import { FilterService } from "../../services/filter-service";
|
|
|
|
import { FilterService } from "../../services/filter-service";
|
|
|
|
|
|
|
|
import { IDiscoverCardResult } from "../../interfaces";
|
|
|
|
import { SearchFilter } from "../../../my-nav/SearchFilter";
|
|
|
|
import { SearchFilter } from "../../../my-nav/SearchFilter";
|
|
|
|
|
|
|
|
import { SearchV2Service } from "../../../services";
|
|
|
|
import { StorageService } from "../../../shared/storage/storage-service";
|
|
|
|
import { StorageService } from "../../../shared/storage/storage-service";
|
|
|
|
|
|
|
|
|
|
|
|
import { isEqual } from "lodash";
|
|
|
|
import { isEqual } from "lodash";
|
|
|
|
import { AuthService } from "../../../auth/auth.service";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
templateUrl: "./search-results.component.html",
|
|
|
|
templateUrl: "./search-results.component.html",
|
|
|
@ -25,22 +26,41 @@ export class DiscoverSearchResultsComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
public filter: SearchFilter;
|
|
|
|
public filter: SearchFilter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private isAdvancedSearch: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private searchService: SearchV2Service,
|
|
|
|
constructor(private searchService: SearchV2Service,
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private filterService: FilterService,
|
|
|
|
private filterService: FilterService,
|
|
|
|
|
|
|
|
private router: Router,
|
|
|
|
|
|
|
|
private advancedDataService: AdvancedSearchDialogDataService,
|
|
|
|
private store: StorageService,
|
|
|
|
private store: StorageService,
|
|
|
|
private authService: AuthService) {
|
|
|
|
private authService: AuthService) {
|
|
|
|
this.route.params.subscribe((params: any) => {
|
|
|
|
this.route.params.subscribe((params: any) => {
|
|
|
|
|
|
|
|
this.isAdvancedSearch = this.router.url === '/discover/advanced/search';
|
|
|
|
|
|
|
|
if (this.isAdvancedSearch) {
|
|
|
|
|
|
|
|
this.loadAdvancedData();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
this.searchTerm = params.searchTerm;
|
|
|
|
this.searchTerm = params.searchTerm;
|
|
|
|
this.clear();
|
|
|
|
this.clear();
|
|
|
|
this.init();
|
|
|
|
this.init();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.advancedDataService.onDataChange.subscribe(() => {
|
|
|
|
|
|
|
|
this.clear();
|
|
|
|
|
|
|
|
this.loadAdvancedData();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async ngOnInit() {
|
|
|
|
public async ngOnInit() {
|
|
|
|
this.loadingFlag = true;
|
|
|
|
|
|
|
|
this.isAdmin = this.authService.isAdmin();
|
|
|
|
this.isAdmin = this.authService.isAdmin();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.advancedDataService) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.loadingFlag = true;
|
|
|
|
|
|
|
|
|
|
|
|
this.filterService.onFilterChange.subscribe(async x => {
|
|
|
|
this.filterService.onFilterChange.subscribe(async x => {
|
|
|
|
if (!isEqual(this.filter, x)) {
|
|
|
|
if (!isEqual(this.filter, x)) {
|
|
|
|
this.filter = { ...x };
|
|
|
|
this.filter = { ...x };
|
|
|
@ -115,6 +135,48 @@ export class DiscoverSearchResultsComponent implements OnInit {
|
|
|
|
this.discoverResults = [];
|
|
|
|
this.discoverResults = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private loadAdvancedData() {
|
|
|
|
|
|
|
|
const advancedData = this.advancedDataService.getData();
|
|
|
|
|
|
|
|
this.mapAdvancedData(advancedData);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public mapAdvancedData(advancedData: ISearchMovieResult[]) {
|
|
|
|
|
|
|
|
this.finishLoading();
|
|
|
|
|
|
|
|
const type = this.advancedDataService.getType();
|
|
|
|
|
|
|
|
advancedData.forEach(m => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mediaType = type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let poster = `https://image.tmdb.org/t/p/w300/${m.posterPath}`;
|
|
|
|
|
|
|
|
if (!m.posterPath) {
|
|
|
|
|
|
|
|
if (mediaType === RequestType.movie) {
|
|
|
|
|
|
|
|
poster = "images/default_movie_poster.png"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mediaType === RequestType.tvShow) {
|
|
|
|
|
|
|
|
poster = "images/default_tv_poster.png"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.discoverResults.push({
|
|
|
|
|
|
|
|
posterPath: poster,
|
|
|
|
|
|
|
|
requested: false,
|
|
|
|
|
|
|
|
title: m.title,
|
|
|
|
|
|
|
|
type: mediaType,
|
|
|
|
|
|
|
|
id: m.id,
|
|
|
|
|
|
|
|
url: "",
|
|
|
|
|
|
|
|
rating: 0,
|
|
|
|
|
|
|
|
overview: m.overview,
|
|
|
|
|
|
|
|
approved: false,
|
|
|
|
|
|
|
|
imdbid: "",
|
|
|
|
|
|
|
|
denied: false,
|
|
|
|
|
|
|
|
background: "",
|
|
|
|
|
|
|
|
available: false,
|
|
|
|
|
|
|
|
tvMovieDb: false
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async search() {
|
|
|
|
private async search() {
|
|
|
|
this.clear();
|
|
|
|
this.clear();
|
|
|
|
this.results = await this.searchService
|
|
|
|
this.results = await this.searchService
|
|
|
|