|
|
|
@ -5,6 +5,7 @@ import { SearchV2Service, RequestService, MessageService } from "../../services"
|
|
|
|
|
import { RequestType } from "../../interfaces";
|
|
|
|
|
import { ISearchMovieResultV2 } from "../../interfaces/ISearchMovieResultV2";
|
|
|
|
|
import { ISearchTvResultV2 } from "../../interfaces/ISearchTvResultV2";
|
|
|
|
|
import { RouterLink, Router } from "@angular/router";
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: "discover-card-details",
|
|
|
|
@ -18,11 +19,12 @@ export class DiscoverCardDetailsComponent implements OnInit {
|
|
|
|
|
public tvCreator: string;
|
|
|
|
|
public tvProducer: string;
|
|
|
|
|
public loading: boolean;;
|
|
|
|
|
public RequestType = RequestType;
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
public dialogRef: MatDialogRef<DiscoverCardDetailsComponent>,
|
|
|
|
|
@Inject(MAT_DIALOG_DATA) public data: IDiscoverCardResult, private searchService: SearchV2Service,
|
|
|
|
|
private requestService: RequestService, public messageService: MessageService) { }
|
|
|
|
|
private requestService: RequestService, public messageService: MessageService, private router: Router) { }
|
|
|
|
|
|
|
|
|
|
public async ngOnInit() {
|
|
|
|
|
this.loading = true;
|
|
|
|
@ -33,12 +35,15 @@ export class DiscoverCardDetailsComponent implements OnInit {
|
|
|
|
|
const creator = this.tv.crew.filter(tv => {
|
|
|
|
|
return tv.type === "Creator";
|
|
|
|
|
})[0];
|
|
|
|
|
if(creator) {
|
|
|
|
|
if (creator && creator.person) {
|
|
|
|
|
this.tvCreator = creator.person.name;
|
|
|
|
|
}
|
|
|
|
|
this.tvProducer = this.tv.crew.filter(tv => {
|
|
|
|
|
const crewResult = this.tv.crew.filter(tv => {
|
|
|
|
|
return tv.type === "Executive Producer";
|
|
|
|
|
})[0].person.name;
|
|
|
|
|
})[0]
|
|
|
|
|
if (crewResult && crewResult.person) {
|
|
|
|
|
this.tvProducer = crewResult.person.name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.loading = false;
|
|
|
|
|
}
|
|
|
|
@ -47,10 +52,22 @@ export class DiscoverCardDetailsComponent implements OnInit {
|
|
|
|
|
this.dialogRef.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public openDetails() {
|
|
|
|
|
if (this.data.type === RequestType.movie) {
|
|
|
|
|
this.router.navigate(['/details/movie/', this.data.id]);
|
|
|
|
|
} else if (this.data.type === RequestType.tvShow) {
|
|
|
|
|
this.router.navigate(['/details/tv/', this.data.id]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.dialogRef.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async request() {
|
|
|
|
|
this.loading = true;
|
|
|
|
|
if (this.data.type === RequestType.movie) {
|
|
|
|
|
const result = await this.requestService.requestMovie({theMovieDbId: this.data.id, languageCode: ""}).toPromise();
|
|
|
|
|
const result = await this.requestService.requestMovie({ theMovieDbId: this.data.id, languageCode: "" }).toPromise();
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
|
|
|
|
if (result.result) {
|
|
|
|
|
this.movie.requested = true;
|
|
|
|
|
this.messageService.send(result.message, "Ok");
|
|
|
|
@ -58,6 +75,8 @@ export class DiscoverCardDetailsComponent implements OnInit {
|
|
|
|
|
this.messageService.send(result.errorMessage, "Ok");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
|
|
|
|
this.dialogRef.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|