!wip on Recently Added

pull/2089/head
Jamie 7 years ago
parent 21c0a449ca
commit 1101abf92c

@ -34,6 +34,13 @@
<i class="fa fa-th-list"></i> {{ 'NavigationBar.Requests' | translate }}</a> <i class="fa fa-th-list"></i> {{ 'NavigationBar.Requests' | translate }}</a>
</li> </li>
</ul> </ul>
<ul class="nav navbar-nav">
<li id="Requests" [routerLinkActive]="['active']">
<a [routerLink]="['/recentlyadded']">
<i class="fa fa-th-list"></i> {{ 'NavigationBar.RecentlyAdded' | translate }}</a>
</li>
</ul>
<ul *ngIf="issuesEnabled" class="nav navbar-nav"> <ul *ngIf="issuesEnabled" class="nav navbar-nav">
<li id="Issues" [routerLinkActive]="['active']"> <li id="Issues" [routerLinkActive]="['active']">
<a [routerLink]="['/issues']"> <a [routerLink]="['/issues']">
@ -46,6 +53,7 @@
<i class="fa fa-user"></i> {{ 'NavigationBar.UserManagement' | translate }}</a> <i class="fa fa-user"></i> {{ 'NavigationBar.UserManagement' | translate }}</a>
</li> </li>
</ul> </ul>
<ul *ngIf="hasRole('Admin') || hasRole('PowerUser')" class="nav navbar-nav"> <ul *ngIf="hasRole('Admin') || hasRole('PowerUser')" class="nav navbar-nav">
<li> <li>
<a href="https://www.paypal.me/PlexRequestsNet" target="_blank" pTooltip="{{ 'NavigationBar.DonateTooltip' | translate }}"> <a href="https://www.paypal.me/PlexRequestsNet" target="_blank" pTooltip="{{ 'NavigationBar.DonateTooltip' | translate }}">

@ -52,6 +52,7 @@ const routes: Routes = [
{ loadChildren: "./usermanagement/usermanagement.module#UserManagementModule", path: "usermanagement" }, { loadChildren: "./usermanagement/usermanagement.module#UserManagementModule", path: "usermanagement" },
{ loadChildren: "./requests/requests.module#RequestsModule", path: "requests" }, { loadChildren: "./requests/requests.module#RequestsModule", path: "requests" },
{ loadChildren: "./search/search.module#SearchModule", path: "search" }, { loadChildren: "./search/search.module#SearchModule", path: "search" },
{ loadChildren: "./recentlyAdded/recentlyAdded.module#RecentlyAddedModule", path: "recentlyadded" },
]; ];
// AoT requires an exported function for factories // AoT requires an exported function for factories

@ -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,
}

@ -13,3 +13,4 @@ export * from "./ISettings";
export * from "./ISonarr"; export * from "./ISonarr";
export * from "./IUser"; export * from "./IUser";
export * from "./IIssues"; export * from "./IIssues";
export * from "./IRecentlyAdded";

@ -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);
}
}

@ -0,0 +1,43 @@
import { NgModule } from "@angular/core";
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 { IdentityService, RecentlyAddedService } from "../services";
import { AuthGuard } from "../auth/auth.guard";
import { SharedModule as OmbiShared } from "../shared/shared.module";
import { RecentlyAddedComponent } from "./recentlyAdded.component";
const routes: Routes = [
{ path: "", component: RecentlyAddedComponent, canActivate: [AuthGuard] },
];
@NgModule({
imports: [
RouterModule.forChild(routes),
NgbModule.forRoot(),
SharedModule,
OrderModule,
OmbiShared,
PaginatorModule,
TabViewModule,
CalendarModule,
],
declarations: [
RecentlyAddedComponent,
],
exports: [
RouterModule,
],
providers: [
IdentityService,
RecentlyAddedService,
],
})
export class RecentlyAddedModule { }

@ -12,3 +12,4 @@ export * from "./status.service";
export * from "./job.service"; export * from "./job.service";
export * from "./issues.service"; export * from "./issues.service";
export * from "./mobile.service"; export * from "./mobile.service";
export * from "./recentlyAdded.service";

@ -0,0 +1,18 @@
import { PlatformLocation } from "@angular/common";
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Observable } from "rxjs/Rx";
import { IRecentlyAddedMovies, IRecentlyAddedRangeModel } from "./../interfaces";
import { ServiceHelpers } from "./service.helpers";
@Injectable()
export class RecentlyAddedService extends ServiceHelpers {
constructor(http: HttpClient, public platformLocation: PlatformLocation) {
super(http, "/api/v1/recentlyadded/", platformLocation);
}
public getRecentlyAddedMovies(model: IRecentlyAddedRangeModel): Observable<IRecentlyAddedMovies[]> {
return this.http.post<IRecentlyAddedMovies[]>(`${this.url}movies/`,JSON.stringify(model), {headers: this.headers});
}
}

@ -103,9 +103,9 @@
} }
}, },
"@auth0/angular-jwt": { "@auth0/angular-jwt": {
"version": "1.0.0-beta.10", "version": "1.0.0-beta.9",
"resolved": "https://registry.npmjs.org/@auth0/angular-jwt/-/angular-jwt-1.0.0-beta.10.tgz", "resolved": "https://registry.npmjs.org/@auth0/angular-jwt/-/angular-jwt-1.0.0-beta.9.tgz",
"integrity": "sha512-8ilDlQvXePuOAjIlPOeJg0SRSbalNvsRtwbInjS2ND8krma4rqLv8KR5ORsxe01yc8z5vZa69m838pyhFEdPfA==" "integrity": "sha1-ZQIsNJ7ck97DMS+TO5VccZ6GKmI="
}, },
"@ng-bootstrap/ng-bootstrap": { "@ng-bootstrap/ng-bootstrap": {
"version": "1.0.0", "version": "1.0.0",
@ -9745,9 +9745,9 @@
"integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=" "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE="
}, },
"primeng": { "primeng": {
"version": "5.2.0", "version": "5.0.2",
"resolved": "https://registry.npmjs.org/primeng/-/primeng-5.2.0.tgz", "resolved": "https://registry.npmjs.org/primeng/-/primeng-5.0.2.tgz",
"integrity": "sha512-70+QSR5bCtYV+jmqmsYIdE1pkBse/pCSgU7m71d0VNEagmyY1JNKIp9mKdL7MSbUE/fGdbqfkhkmUeP+x4N2jw==" "integrity": "sha1-BcSkUC79TDvF1QaqAa6Osw+XZNs="
}, },
"private": { "private": {
"version": "0.1.8", "version": "0.1.8",

@ -22,7 +22,7 @@
"@angular/platform-browser-dynamic": "^5.2.5", "@angular/platform-browser-dynamic": "^5.2.5",
"@angular/platform-server": "^5.2.5", "@angular/platform-server": "^5.2.5",
"@angular/router": "^5.2.5", "@angular/router": "^5.2.5",
"@auth0/angular-jwt": "^1.0.0-beta.10", "@auth0/angular-jwt": "1.0.0-beta.9",
"@ng-bootstrap/ng-bootstrap": "^1.0.0", "@ng-bootstrap/ng-bootstrap": "^1.0.0",
"@ngx-translate/core": "^8.0.0", "@ngx-translate/core": "^8.0.0",
"@ngx-translate/http-loader": "^2.0.1", "@ngx-translate/http-loader": "^2.0.1",
@ -59,7 +59,7 @@
"node-sass": "^4.7.2", "node-sass": "^4.7.2",
"npm": "^5.6.0", "npm": "^5.6.0",
"pace-progress": "^1.0.2", "pace-progress": "^1.0.2",
"primeng": "~5.2.0", "primeng": "5.0.2",
"reflect-metadata": "0.1.10", "reflect-metadata": "0.1.10",
"run-sequence": "^2.2.1", "run-sequence": "^2.2.1",
"rxjs": "5.5.2", "rxjs": "5.5.2",

@ -67,7 +67,8 @@
"Dutch": "Dutch", "Dutch": "Dutch",
"Norwegian":"Norwegian" "Norwegian":"Norwegian"
}, },
"OpenMobileApp":"Open Mobile App" "OpenMobileApp":"Open Mobile App",
"RecentlyAdded":"Recently Added"
}, },
"Search": { "Search": {
"Title": "Search", "Title": "Search",

Loading…
Cancel
Save