|
|
|
@ -1,10 +1,7 @@
|
|
|
|
|
import { Component, Input } from "@angular/core";
|
|
|
|
|
import { TranslateService } from "@ngx-translate/core";
|
|
|
|
|
import { Component, EventEmitter, Input, Output } from "@angular/core";
|
|
|
|
|
|
|
|
|
|
import { AuthService } from "../../auth/auth.service";
|
|
|
|
|
import { IRequestEngineResult, ISearchMovieResult } from "../../interfaces";
|
|
|
|
|
import { ISearchArtistResult } from "../../interfaces/ISearchMusicResult";
|
|
|
|
|
import { NotificationService, RequestService } from "../../services";
|
|
|
|
|
import { ISearchAlbumResult, ISearchArtistResult } from "../../interfaces/ISearchMusicResult";
|
|
|
|
|
import { SearchService } from "../../services";
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: "artist-search",
|
|
|
|
@ -13,51 +10,16 @@ import { NotificationService, RequestService } from "../../services";
|
|
|
|
|
export class ArtistSearchComponent {
|
|
|
|
|
|
|
|
|
|
@Input() public result: ISearchArtistResult;
|
|
|
|
|
public engineResult: IRequestEngineResult;
|
|
|
|
|
@Input() public defaultPoster: string;
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private requestService: RequestService,
|
|
|
|
|
private notificationService: NotificationService, private authService: AuthService,
|
|
|
|
|
private readonly translate: TranslateService) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public request(searchResult: ISearchMovieResult) {
|
|
|
|
|
searchResult.requested = true;
|
|
|
|
|
searchResult.requestProcessing = true;
|
|
|
|
|
searchResult.showSubscribe = false;
|
|
|
|
|
if (this.authService.hasRole("admin") || this.authService.hasRole("AutoApproveMovie")) {
|
|
|
|
|
searchResult.approved = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
this.requestService.requestMovie({ theMovieDbId: searchResult.id })
|
|
|
|
|
.subscribe(x => {
|
|
|
|
|
this.engineResult = x;
|
|
|
|
|
@Output() public viewAlbumsResult = new EventEmitter<ISearchAlbumResult[]>();
|
|
|
|
|
|
|
|
|
|
if (this.engineResult.result) {
|
|
|
|
|
this.translate.get("Search.RequestAdded", { title: searchResult.title }).subscribe(x => {
|
|
|
|
|
this.notificationService.success(x);
|
|
|
|
|
searchResult.processed = true;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
if (this.engineResult.errorMessage && this.engineResult.message) {
|
|
|
|
|
this.notificationService.warning("Request Added", `${this.engineResult.message} - ${this.engineResult.errorMessage}`);
|
|
|
|
|
} else {
|
|
|
|
|
this.notificationService.warning("Request Added", this.engineResult.message ? this.engineResult.message : this.engineResult.errorMessage);
|
|
|
|
|
}
|
|
|
|
|
searchResult.requested = false;
|
|
|
|
|
searchResult.approved = false;
|
|
|
|
|
searchResult.processed = false;
|
|
|
|
|
searchResult.requestProcessing = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {
|
|
|
|
|
constructor(private searchService: SearchService) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchResult.processed = false;
|
|
|
|
|
searchResult.requestProcessing = false;
|
|
|
|
|
this.notificationService.error(e);
|
|
|
|
|
}
|
|
|
|
|
public viewAllAlbums() {
|
|
|
|
|
this.searchService.getAlbumsForArtist(this.result.forignArtistId).subscribe(x => {
|
|
|
|
|
this.viewAlbumsResult.emit(x);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|