mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -07:00
Move to seperate component and display for both TV and movies
This commit is contained in:
parent
7ef2a1679d
commit
3959a79ea8
15 changed files with 198 additions and 26 deletions
46
.vscode/launch.json
vendored
Normal file
46
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||
// Use hover for the description of the existing attributes
|
||||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (web)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/src/Ombi/bin/Debug/netcoreapp2.1/Ombi.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}/src/Ombi",
|
||||
"stopAtEntry": false,
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"launchBrowser": {
|
||||
"enabled": false,
|
||||
"args": "${auto-detect-url}",
|
||||
"windows": {
|
||||
"command": "cmd.exe",
|
||||
"args": "/C start ${auto-detect-url}"
|
||||
},
|
||||
"osx": {
|
||||
"command": "open"
|
||||
},
|
||||
"linux": {
|
||||
"command": "xdg-open"
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/Views": "${workspaceFolder}/Views"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}"
|
||||
}
|
||||
,]
|
||||
}
|
15
.vscode/tasks.json
vendored
Normal file
15
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/src/Ombi/Ombi.csproj"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -489,9 +489,10 @@ namespace Ombi.Core.Engine
|
|||
{
|
||||
return new RequestQuotaCountModel()
|
||||
{
|
||||
HasLimit = true,
|
||||
HasLimit = false,
|
||||
Limit = 5,
|
||||
Remaining = 4,
|
||||
NextRequest = DateTime.Parse("2018-08-27T00:00:00+01"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -618,7 +618,10 @@ namespace Ombi.Core.Engine
|
|||
{
|
||||
return new RequestQuotaCountModel()
|
||||
{
|
||||
HasLimit = false,
|
||||
HasLimit = true,
|
||||
Limit = 5,
|
||||
Remaining = 4,
|
||||
NextRequest = DateTime.Parse("2018-08-30T00:00:00+01"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using System;
|
||||
|
||||
namespace Ombi.Core.Models
|
||||
{
|
||||
public class RequestQuotaCountModel
|
||||
|
@ -7,5 +9,7 @@ namespace Ombi.Core.Models
|
|||
public int Limit { get; set; }
|
||||
|
||||
public int Remaining { get; set; }
|
||||
|
||||
public DateTime NextRequest { get; set; }
|
||||
}
|
||||
}
|
|
@ -2,4 +2,5 @@ export interface IRemainingRequests {
|
|||
hasLimit: boolean;
|
||||
limit: number;
|
||||
remaining: number;
|
||||
nextRequest: Date;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<div *ngIf="remaining?.hasLimit">
|
||||
<h4 id="remainingRequests" class="text-center">
|
||||
{{remaining.remaining}}/{{remaining.limit}} requests remaining
|
||||
</h4>
|
||||
<h4 class="text-center" *ngIf="daysUntil > 1">
|
||||
Another request will be added in {{daysUntil}} {{daysUntil == 1 ? "day" : "days"}}
|
||||
</h4>
|
||||
<h4 class="text-center" *ngIf="hoursUntil > 1 && daysUntil <= 1">
|
||||
Another request will be added in {{hoursUntil}} {{hoursUntil == 1 ? "hour" : "hours"}}
|
||||
</h4>
|
||||
<h4 class="text-center" *ngIf="minutesUntil > 1 && hoursUntil <= 1 && daysUntil <= 1" #minutes>
|
||||
Another request will be added in {{minutesUntil}} {{minutesUntil == 1 ? "minute" : "minutes"}}
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
<br *ngIf="!remaining?.hasLimit" />
|
||||
<br *ngIf="!remaining?.hasLimit" />
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import { Component, OnInit, Input } from "@angular/core";
|
||||
import { RequestService } from "../services";
|
||||
import { IRemainingRequests } from "../interfaces/IRemainingRequests";
|
||||
|
||||
@Component({
|
||||
selector: "remaining-requests",
|
||||
templateUrl: "./remainingrequests.component.html",
|
||||
})
|
||||
|
||||
export class RemainingRequestsComponent implements OnInit {
|
||||
public remaining: IRemainingRequests;
|
||||
@Input() public movie: boolean;
|
||||
public daysUntil: number;
|
||||
public hoursUntil: number;
|
||||
public minutesUntil: number;
|
||||
|
||||
constructor(private requestService: RequestService)
|
||||
{
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
var self = this;
|
||||
this.update();
|
||||
setInterval(function(){
|
||||
self.update()
|
||||
}, 10000)
|
||||
}
|
||||
|
||||
update(): void {
|
||||
var callback = (remaining => {
|
||||
this.remaining = remaining;
|
||||
this.daysUntil = Math.ceil(this.daysUntilNextRequest());
|
||||
this.hoursUntil = Math.ceil(this.hoursUntilNextRequest());
|
||||
this.minutesUntil = Math.ceil(this.minutesUntilNextRequest())
|
||||
});
|
||||
|
||||
if (this.movie) {
|
||||
this.requestService.getRemainingMovieRequests().subscribe(callback);
|
||||
} else {
|
||||
this.requestService.getRemainingTvRequests().subscribe(callback);
|
||||
}
|
||||
}
|
||||
|
||||
daysUntilNextRequest(): number {
|
||||
return (new Date(this.remaining.nextRequest).getTime() - new Date().getTime()) / 1000 / 60 / 60 / 24;
|
||||
}
|
||||
|
||||
hoursUntilNextRequest(): number {
|
||||
return (new Date(this.remaining.nextRequest).getTime() - new Date().getTime()) / 1000 / 60 / 60;
|
||||
}
|
||||
|
||||
minutesUntilNextRequest(): number {
|
||||
return (new Date(this.remaining.nextRequest).getTime() - new Date().getTime()) / 1000 / 60;
|
||||
}
|
||||
}
|
32
src/Ombi/ClientApp/app/requests/remainingrequests.module.ts
Normal file
32
src/Ombi/ClientApp/app/requests/remainingrequests.module.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { CommonModule } from "@angular/common";
|
||||
import { NgModule } from "@angular/core";
|
||||
import { FormsModule } from "@angular/forms";
|
||||
import { RouterModule } from "@angular/router";
|
||||
|
||||
import { NgbModule } from "@ng-bootstrap/ng-bootstrap";
|
||||
|
||||
import { SidebarModule, TooltipModule, TreeTableModule } from "primeng/primeng";
|
||||
import { RequestService } from "../services";
|
||||
|
||||
import { SharedModule } from "../shared/shared.module";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
NgbModule.forRoot(),
|
||||
TreeTableModule,
|
||||
SharedModule,
|
||||
SidebarModule,
|
||||
TooltipModule,
|
||||
],
|
||||
declarations: [
|
||||
],
|
||||
exports: [
|
||||
RouterModule,
|
||||
],
|
||||
providers: [
|
||||
RequestService,
|
||||
],
|
||||
})
|
||||
export class SearchModule { }
|
|
@ -20,12 +20,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<h4 *ngIf="remaining?.hasLimit" id="remainingRequests" class="text-center">
|
||||
{{remaining.remaining}}/{{remaining.limit}} requests remaining.
|
||||
</h4>
|
||||
|
||||
<br *ngIf="!remaining?.hasLimit" />
|
||||
<br *ngIf="!remaining?.hasLimit" />
|
||||
<remaining-requests [movie]="true"></remaining-requests>
|
||||
|
||||
<!-- Movie content -->
|
||||
<div id="movieList">
|
||||
|
|
|
@ -8,7 +8,6 @@ import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
|||
import { AuthService } from "../auth/auth.service";
|
||||
import { IIssueCategory, IRequestEngineResult, ISearchMovieResult } from "../interfaces";
|
||||
import { NotificationService, RequestService, SearchService } from "../services";
|
||||
import { IRemainingRequests } from "../interfaces/IRemainingRequests";
|
||||
|
||||
@Component({
|
||||
selector: "movie-search",
|
||||
|
@ -20,7 +19,7 @@ export class MovieSearchComponent implements OnInit {
|
|||
public searchChanged: Subject<string> = new Subject<string>();
|
||||
public movieResults: ISearchMovieResult[];
|
||||
public result: IRequestEngineResult;
|
||||
public remaining: IRemainingRequests;
|
||||
|
||||
public searchApplied = false;
|
||||
|
||||
@Input() public issueCategories: IIssueCategory[];
|
||||
|
@ -70,18 +69,8 @@ export class MovieSearchComponent implements OnInit {
|
|||
result: false,
|
||||
errorMessage: "",
|
||||
};
|
||||
this.remaining = {
|
||||
hasLimit: false,
|
||||
limit: 0,
|
||||
remaining: 0,
|
||||
};
|
||||
|
||||
this.popularMovies();
|
||||
|
||||
this.requestService.getRemainingMovieRequests().subscribe(remaining => {
|
||||
this.remaining = remaining;
|
||||
});
|
||||
|
||||
}
|
||||
public search(text: any) {
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import { SearchService } from "../services";
|
|||
import { AuthGuard } from "../auth/auth.guard";
|
||||
|
||||
import { SharedModule } from "../shared/shared.module";
|
||||
import { RemainingRequestsComponent } from "../requests/remainingrequests.component";
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: "", component: SearchComponent, canActivate: [AuthGuard] },
|
||||
|
@ -41,6 +42,7 @@ const routes: Routes = [
|
|||
TvSearchComponent,
|
||||
SeriesInformationComponent,
|
||||
MovieSearchGridComponent,
|
||||
RemainingRequestsComponent,
|
||||
],
|
||||
exports: [
|
||||
RouterModule,
|
||||
|
|
|
@ -26,15 +26,13 @@
|
|||
<i id="tvSearchButton" class="fa fa-search"></i>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<remaining-requests [movie]="false"></remaining-requests>
|
||||
|
||||
<!-- Movie content -->
|
||||
<div id="actorMovieList">
|
||||
</div>
|
||||
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<!-- TV content -->
|
||||
<div id="tvList">
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@ export class RequestService extends ServiceHelpers {
|
|||
return this.http.get<IRemainingRequests>(`${this.url}movie/remaining`, {headers: this.headers});
|
||||
}
|
||||
|
||||
public getRemainingTvRequests(): Observable<IRemainingRequests> {
|
||||
return this.http.get<IRemainingRequests>(`${this.url}tv/remaining`, {headers: this.headers});
|
||||
}
|
||||
|
||||
public requestMovie(movie: IMovieRequestModel): Observable<IRequestEngineResult> {
|
||||
return this.http.post<IRequestEngineResult>(`${this.url}Movie/`, JSON.stringify(movie), {headers: this.headers});
|
||||
}
|
||||
|
|
|
@ -470,9 +470,18 @@ namespace Ombi.Controllers
|
|||
/// Gets model containing remaining number of requests.
|
||||
/// </summary>
|
||||
[HttpGet("movie/remaining")]
|
||||
public async Task<RequestQuotaCountModel> GetRemainingRequests()
|
||||
public async Task<RequestQuotaCountModel> GetRemainingMovieRequests()
|
||||
{
|
||||
return await MovieRequestEngine.GetRemainingRequests();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets model containing remaining number of requests.
|
||||
/// </summary>
|
||||
[HttpGet("tv/remaining")]
|
||||
public async Task<RequestQuotaCountModel> GetRemainingTvRequests()
|
||||
{
|
||||
return await TvRequestEngine.GetRemainingRequests();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue