mirror of https://github.com/Ombi-app/Ombi
parent
cb84ff0e34
commit
c0a4b20152
@ -0,0 +1,19 @@
|
||||
<mat-card>
|
||||
|
||||
<a *ngIf="result.url" href="{{result.url}}" target="_blank">
|
||||
<img mat-card-image src="{{result.posterPath}}" class="card-poster" alt="{{result.title}}">
|
||||
</a>
|
||||
<img *ngIf="!result.url" mat-card-image src="{{result.posterPath}}" class="card-poster" alt="{{result.title}}">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<h5 *ngIf="result.title.length <= 10">{{result.title}}</h5>
|
||||
<h6 *ngIf="result.title.length > 10 && result.title.length <= 13">{{result.title}}</h6>
|
||||
<h6 *ngIf="result.title.length > 13" matTooltip="{{result.title}}">{{result.title | truncate:13}}</h6>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button *ngIf="!result.requested && !result.available" mat-raised-button color="primary">Request</button>
|
||||
<button *ngIf="result.requested && !result.available" mat-raised-button color="warn">Requested</button>
|
||||
<button *ngIf="!result.requested && result.available" mat-raised-button color="accent">Available</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
@ -0,0 +1,3 @@
|
||||
.card-poster {
|
||||
max-height: 225px;
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
import { Component, OnInit, Input } from "@angular/core";
|
||||
import { IDiscoverCardResult } from "../interfaces";
|
||||
import { RequestType, ISearchTvResult, ISearchMovieResult } from "../../interfaces";
|
||||
import { SearchService } from "../../services";
|
||||
|
||||
@Component({
|
||||
selector: "discover-card",
|
||||
templateUrl: "./discover-card.component.html",
|
||||
styleUrls: ["./discover-card.component.scss"],
|
||||
})
|
||||
export class DiscoverCardComponent implements OnInit {
|
||||
|
||||
@Input() public result: IDiscoverCardResult;
|
||||
|
||||
constructor(private searchService: SearchService) { }
|
||||
|
||||
public ngOnInit() {
|
||||
if (this.result.type == RequestType.tvShow) {
|
||||
this.getExtraTvInfo();
|
||||
}
|
||||
if (this.result.type == RequestType.movie) {
|
||||
this.getExtraMovieInfo();
|
||||
}
|
||||
}
|
||||
|
||||
public getExtraTvInfo() {
|
||||
this.searchService.getShowInformation(this.result.id)
|
||||
.subscribe(x => {
|
||||
if (x) {
|
||||
this.setTvDefaults(x);
|
||||
this.updateTvItem(x);
|
||||
}
|
||||
});
|
||||
}
|
||||
private getExtraMovieInfo() {
|
||||
this.searchService.getMovieInformation(this.result.id)
|
||||
.subscribe(m => {
|
||||
this.updateMovieItem(m);
|
||||
});
|
||||
}
|
||||
|
||||
private updateMovieItem(updated: ISearchMovieResult) {
|
||||
this.result.url = "http://www.imdb.com/title/" + updated.imdbId + "/";
|
||||
this.result.available = updated.available;
|
||||
this.result.requested = updated.requested;
|
||||
this.result.requested = updated.requestProcessing;
|
||||
}
|
||||
|
||||
|
||||
private setTvDefaults(x: ISearchTvResult) {
|
||||
if (!x.imdbId) {
|
||||
x.imdbId = "https://www.tvmaze.com/shows/" + x.seriesId;
|
||||
} else {
|
||||
x.imdbId = "http://www.imdb.com/title/" + x.imdbId + "/";
|
||||
}
|
||||
}
|
||||
|
||||
private updateTvItem(updated: ISearchTvResult) {
|
||||
this.result.title = updated.title;
|
||||
this.result.id = updated.id;
|
||||
this.result.available = updated.fullyAvailable;
|
||||
this.result.posterPath = updated.banner;
|
||||
this.result.requested = updated.requested;
|
||||
this.result.url = updated.imdbId;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<div *ngIf="discoverResults" class="row">
|
||||
<div class="col-lg-2 col-md-4 col-6" *ngFor="let result of discoverResults">
|
||||
<discover-card [result]="result"></discover-card>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,58 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { SearchService } from "../services";
|
||||
import { ISearchMovieResult, ISearchTvResult, RequestType } from "../interfaces";
|
||||
import { IDiscoverCardResult } from "./interfaces";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./discover.component.html",
|
||||
})
|
||||
export class DiscoverComponent implements OnInit {
|
||||
|
||||
public discoverResults: IDiscoverCardResult[] = [];
|
||||
private movies: ISearchMovieResult[];
|
||||
private tvShows: ISearchTvResult[];
|
||||
|
||||
public defaultTvPoster: string;
|
||||
|
||||
constructor(private searchService: SearchService) {
|
||||
|
||||
}
|
||||
public async ngOnInit() {
|
||||
this.movies = await this.searchService.popularMovies().toPromise();
|
||||
this.tvShows = await this.searchService.popularTv().toPromise();
|
||||
|
||||
this.movies.forEach(m => {
|
||||
debugger;
|
||||
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}/`
|
||||
});
|
||||
});
|
||||
this.tvShows.forEach(m => {
|
||||
this.discoverResults.push({
|
||||
available: m.available,
|
||||
posterPath: "../../../images/default_tv_poster.png",
|
||||
requested: m.requested,
|
||||
title: m.title,
|
||||
type: RequestType.tvShow,
|
||||
id: m.id,
|
||||
url: undefined
|
||||
});
|
||||
});
|
||||
|
||||
this.shuffle(this.discoverResults);
|
||||
}
|
||||
|
||||
private shuffle(discover: IDiscoverCardResult[]) : IDiscoverCardResult[] {
|
||||
for (let i = discover.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[discover[i], discover[j]] = [discover[j], discover[i]];
|
||||
}
|
||||
return discover;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import { RequestType } from "../interfaces";
|
||||
|
||||
export interface IDiscoverCardResult {
|
||||
id: number;
|
||||
posterPath: string;
|
||||
url: string | undefined;
|
||||
title: string;
|
||||
type: RequestType;
|
||||
available: boolean;
|
||||
requested: boolean;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<h3>Movies</h3>
|
||||
<popular-movies></popular-movies>
|
||||
<mat-divider></mat-divider>
|
||||
<h3>TV Shows</h3>
|
||||
|
||||
<popular-tv></popular-tv>
|
@ -1,23 +0,0 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { SearchService } from "../services";
|
||||
import { ISearchMovieResult, ISearchTvResult } from "../interfaces";
|
||||
|
||||
@Component({
|
||||
templateUrl: "./home.component.html",
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
|
||||
public movies: ISearchMovieResult[];
|
||||
public tvShows: ISearchTvResult[];
|
||||
|
||||
public defaultTvPoster: string;
|
||||
|
||||
constructor(private searchService: SearchService) {
|
||||
|
||||
}
|
||||
public ngOnInit() {
|
||||
this.defaultTvPoster = "../../../images/default_tv_poster.png";
|
||||
this.searchService.popularMovies().subscribe(x => this.movies = x);
|
||||
this.searchService.popularTv().subscribe(x => this.tvShows = x);
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
|
||||
<div *ngIf="movies" class="row">
|
||||
<div class="col-lg-2 col-md-4 col-6" *ngFor="let movie of movies">
|
||||
<mat-card>
|
||||
|
||||
<img mat-card-image src="https://image.tmdb.org/t/p/w300/{{movie.posterPath}}" alt="{{movie.title}}">
|
||||
<mat-card-content>
|
||||
|
||||
<h5>{{movie.title}}</h5>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button color="primary">Request</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
@ -1,19 +0,0 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { SearchService } from "../../services";
|
||||
import { ISearchMovieResult, ISearchTvResult } from "../../interfaces";
|
||||
|
||||
@Component({
|
||||
selector:"popular-movies",
|
||||
templateUrl: "./popular-movies.component.html",
|
||||
})
|
||||
export class PopularMoviesComponent implements OnInit {
|
||||
|
||||
public movies: ISearchMovieResult[];
|
||||
|
||||
constructor(private searchService: SearchService) {
|
||||
|
||||
}
|
||||
public ngOnInit() {
|
||||
this.searchService.popularMovies().subscribe(x => this.movies = x);
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
<div *ngIf="tvShows" class="row">
|
||||
<div class="col-lg-2 col-md-4 col-6" *ngFor="let tv of tvShows">
|
||||
<mat-card>
|
||||
|
||||
<img mat-card-image src="{{tv.banner}}" alt="{{tv.title}}">
|
||||
<mat-card-content>
|
||||
|
||||
<h5>{{tv.title}}</h5>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button color="primary">Request</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
@ -1,66 +0,0 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { SearchService } from "../../services";
|
||||
import { ISearchTvResult } from "../../interfaces";
|
||||
|
||||
@Component({
|
||||
selector: "popular-tv",
|
||||
templateUrl: "./popular-tv.component.html",
|
||||
})
|
||||
export class PopularTvComponent implements OnInit {
|
||||
|
||||
public tvShows: ISearchTvResult[];
|
||||
|
||||
public defaultPoster: string;
|
||||
|
||||
constructor(private searchService: SearchService) {
|
||||
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.defaultPoster = "../../../images/default_tv_poster.png";
|
||||
this.searchService.popularTv().subscribe(x => {this.tvShows = x; this.getExtraInfo();});
|
||||
}
|
||||
|
||||
public getExtraInfo() {
|
||||
this.tvShows.forEach((val, index) => {
|
||||
this.searchService.getShowInformation(val.id)
|
||||
.subscribe(x => {
|
||||
if (x) {
|
||||
this.setDefaults(x);
|
||||
this.updateItem(val, x);
|
||||
} else {
|
||||
const index = this.tvShows.indexOf(val, 0);
|
||||
if (index > -1) {
|
||||
this.tvShows.splice(index, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private setDefaults(x: ISearchTvResult) {
|
||||
if (x.banner === null) {
|
||||
x.banner = this.defaultPoster;
|
||||
}
|
||||
|
||||
if (x.imdbId === null) {
|
||||
x.imdbId = "https://www.tvmaze.com/shows/" + x.seriesId;
|
||||
} else {
|
||||
x.imdbId = "http://www.imdb.com/title/" + x.imdbId + "/";
|
||||
}
|
||||
}
|
||||
|
||||
private updateItem(key: ISearchTvResult, updated: ISearchTvResult) {
|
||||
const index = this.tvShows.indexOf(key, 0);
|
||||
if (index > -1) {
|
||||
// Update certain properties, otherwise we will loose some data
|
||||
this.tvShows[index].title = updated.title;
|
||||
this.tvShows[index].banner = updated.banner;
|
||||
this.tvShows[index].imdbId = updated.imdbId;
|
||||
this.tvShows[index].seasonRequests = updated.seasonRequests;
|
||||
this.tvShows[index].seriesId = updated.seriesId;
|
||||
this.tvShows[index].fullyAvailable = updated.fullyAvailable;
|
||||
this.tvShows[index].background = updated.banner;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue