mirror of https://github.com/Ombi-app/Ombi
parent
21c0a449ca
commit
1101abf92c
@ -0,0 +1,20 @@
|
||||
export interface IRecentlyAddedMovies {
|
||||
id: number;
|
||||
title: string;
|
||||
overview: string;
|
||||
imdbId: string;
|
||||
theMovieDbId: string;
|
||||
releaseYear: string;
|
||||
addedAt: Date;
|
||||
quality: string;
|
||||
}
|
||||
|
||||
export interface IRecentlyAddedRangeModel {
|
||||
from: Date;
|
||||
to: Date;
|
||||
}
|
||||
|
||||
export enum RecentlyAddedType {
|
||||
Plex,
|
||||
Emby,
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<h1>Recently Added</h1>
|
||||
|
||||
<hr />
|
||||
<p-calendar [(ngModel)]="range" showButtonBar="true" selectionMode="range" (onClose)="close()"></p-calendar>
|
||||
<hr />
|
||||
{{movies | json}}
|
@ -0,0 +1,36 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
|
||||
import { RecentlyAddedService } from "../services/index";
|
||||
import { IRecentlyAddedMovies, IRecentlyAddedRangeModel } from "./../interfaces";
|
||||
|
||||
@Component({
|
||||
templateUrl: "recentlyAdded.component.html",
|
||||
})
|
||||
|
||||
export class RecentlyAddedComponent implements OnInit {
|
||||
public movies: IRecentlyAddedMovies[];
|
||||
public range: Date[];
|
||||
|
||||
constructor(private recentlyAddedService: RecentlyAddedService) {}
|
||||
|
||||
public ngOnInit() {
|
||||
const weekAgo = new Date();
|
||||
weekAgo.setDate(weekAgo.getDate() - 7);
|
||||
|
||||
const today =new Date();
|
||||
const initModel = <IRecentlyAddedRangeModel>{from: weekAgo, to: today};
|
||||
this.recentlyAddedService.getRecentlyAddedMovies(initModel).subscribe(x => this.movies = x);
|
||||
}
|
||||
|
||||
public close() {
|
||||
if(this.range.length < 2) {
|
||||
return;
|
||||
}
|
||||
if(!this.range[1]) {
|
||||
// If we do not have a second date then just set it to now
|
||||
this.range[1] = new Date();
|
||||
}
|
||||
const initModel = <IRecentlyAddedRangeModel>{from: this.range[0], to: this.range[1]};
|
||||
this.recentlyAddedService.getRecentlyAddedMovies(initModel).subscribe(x => this.movies = x);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue