pull/2089/head
Jamie 7 years ago
parent 1101abf92c
commit 0a97724731

@ -38,7 +38,7 @@
<ul class="nav navbar-nav">
<li id="Requests" [routerLinkActive]="['active']">
<a [routerLink]="['/recentlyadded']">
<i class="fa fa-th-list"></i> {{ 'NavigationBar.RecentlyAdded' | translate }}</a>
<i class="fa fa-check"></i> {{ 'NavigationBar.RecentlyAdded' | translate }}</a>
</li>
</ul>
<ul *ngIf="issuesEnabled" class="nav navbar-nav">

@ -7,6 +7,9 @@ export interface IRecentlyAddedMovies {
releaseYear: string;
addedAt: Date;
quality: string;
// For UI only
posterPath: string;
}
export interface IRecentlyAddedRangeModel {

@ -3,4 +3,15 @@
<hr />
<p-calendar [(ngModel)]="range" showButtonBar="true" selectionMode="range" (onClose)="close()"></p-calendar>
<hr />
<p-carousel [value]="movies" [headerText]="'Movies'" (onPage)="page($event)">
<ng-template let-movie pTemplate="movie">
<img class="img-responsive poster" src="{{movie.posterPath}}" style="width: 30px" alt="poster">
{{movie.title}}
</ng-template>
</p-carousel>
<hr/>
{{movies | json}}

@ -1,6 +1,6 @@
import { Component, OnInit } from "@angular/core";
import { RecentlyAddedService } from "../services/index";
import { ImageService, RecentlyAddedService } from "../services";
import { IRecentlyAddedMovies, IRecentlyAddedRangeModel } from "./../interfaces";
@Component({
@ -11,7 +11,8 @@ export class RecentlyAddedComponent implements OnInit {
public movies: IRecentlyAddedMovies[];
public range: Date[];
constructor(private recentlyAddedService: RecentlyAddedService) {}
constructor(private recentlyAddedService: RecentlyAddedService,
private imageService: ImageService) {}
public ngOnInit() {
const weekAgo = new Date();
@ -19,7 +20,19 @@ export class RecentlyAddedComponent implements OnInit {
const today =new Date();
const initModel = <IRecentlyAddedRangeModel>{from: weekAgo, to: today};
this.recentlyAddedService.getRecentlyAddedMovies(initModel).subscribe(x => this.movies = x);
this.recentlyAddedService.getRecentlyAddedMovies(initModel).subscribe(x => {
this.movies = x;
this.movies.forEach((movie) => {
if(movie.theMovieDbId) {
this.imageService.getMoviePoster(movie.theMovieDbId).subscribe(p => {
movie.posterPath = p;
});
} else {
movie.posterPath = "";
}
});
});
}
public close() {
@ -33,4 +46,9 @@ export class RecentlyAddedComponent implements OnInit {
const initModel = <IRecentlyAddedRangeModel>{from: this.range[0], to: this.range[1]};
this.recentlyAddedService.getRecentlyAddedMovies(initModel).subscribe(x => this.movies = x);
}
public page(event: any) {
debugger;
console.log(event);
}
}

@ -3,9 +3,9 @@ import { RouterModule, Routes } from "@angular/router";
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
import { OrderModule } from "ngx-order-pipe";
import { CalendarModule, PaginatorModule, SharedModule, TabViewModule } from "primeng/primeng";
import { CalendarModule, CarouselModule, PaginatorModule, SharedModule, TabViewModule } from "primeng/primeng";
import { IdentityService, RecentlyAddedService } from "../services";
import { IdentityService, ImageService, RecentlyAddedService } from "../services";
import { AuthGuard } from "../auth/auth.guard";
@ -27,6 +27,7 @@ const routes: Routes = [
PaginatorModule,
TabViewModule,
CalendarModule,
CarouselModule,
],
declarations: [
RecentlyAddedComponent,
@ -37,6 +38,7 @@ const routes: Routes = [
providers: [
IdentityService,
RecentlyAddedService,
ImageService,
],
})

@ -19,5 +19,11 @@ export class ImageService extends ServiceHelpers {
public getTvBanner(tvdbid: number): Observable<string> {
return this.http.get<string>(`${this.url}tv/${tvdbid}`, {headers: this.headers});
}
public getMoviePoster(themoviedbid: string): Observable<string> {
return this.http.get<string>(`${this.url}poster/movie/${themoviedbid}`, {headers: this.headers});
}
public getTvPoster(tvdbid: number): Observable<string> {
return this.http.get<string>(`${this.url}poster/tv/${tvdbid}`, {headers: this.headers});
}
}

@ -37,6 +37,10 @@ namespace Ombi.Controllers
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
var images = await Api.GetTvImages(tvdbid, key.Value);
if (images == null)
{
return string.Empty;
}
if (images.tvbanner != null)
{
return images.tvbanner.FirstOrDefault()?.url ?? string.Empty;
@ -48,6 +52,56 @@ namespace Ombi.Controllers
return string.Empty;
}
[HttpGet("poster/movie/{movieDbId}")]
public async Task<string> GetMoviePoster(int movieDbId)
{
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
var images = await Api.GetMovieImages(movieDbId, key.Value);
if (images == null)
{
return string.Empty;
}
if (images.movieposter?.Any() ?? false)
{
return images.movieposter.OrderBy(x => x.likes).Select(x => x.url).FirstOrDefault();
}
if (images.hdmovieclearart?.Any() ?? false)
{
return images.hdmovieclearart.OrderBy(x => x.likes).Select(x => x.url).FirstOrDefault();
}
return string.Empty;
}
[HttpGet("poster/tv/{tvdbid}")]
public async Task<string> GetTvPoster(int tvdbid)
{
var key = await _cache.GetOrAdd(CacheKeys.FanartTv, async () => await Config.Get(Store.Entities.ConfigurationTypes.FanartTv), DateTime.Now.AddDays(1));
var images = await Api.GetTvImages(tvdbid, key.Value);
if (images == null)
{
return string.Empty;
}
if (images.tvposter?.Any() ?? false)
{
return images.tvposter.OrderBy(x => x.likes).Select(x => x.url).FirstOrDefault();
}
if (images.tvthumb?.Any() ?? false)
{
return images.tvthumb.OrderBy(x => x.likes).Select(x => x.url).FirstOrDefault();
}
return string.Empty;
}
[HttpGet("background")]
public async Task<object> GetBackgroundImage()
{
@ -64,7 +118,7 @@ namespace Ombi.Controllers
{
var item = rand.Next(moviesArray.Length);
var result = await Api.GetMovieImages(moviesArray[item], key.Value);
while (!result.moviebackground.Any())
{
result = await Api.GetMovieImages(moviesArray[item], key.Value);

Loading…
Cancel
Save