diff --git a/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.ts b/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.ts index ccb131031..f892f74c6 100644 --- a/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.ts +++ b/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.ts @@ -17,6 +17,7 @@ export class MoviesGridComponent implements AfterViewInit { public isLoadingResults = true; public displayedColumns: string[] = ['requestedUser.requestedBy', 'title', 'requestedDate', 'status', 'requestStatus', 'actions']; public gridCount: string = "15"; + public showUnavailableRequests: boolean; @ViewChild(MatPaginator, {static: false}) paginator: MatPaginator; @ViewChild(MatSort, {static: false}) sort: MatSort; @@ -41,7 +42,7 @@ export class MoviesGridComponent implements AfterViewInit { this.isLoadingResults = true; // eturn this.exampleDatabase!.getRepoIssues( // this.sort.active, this.sort.direction, this.paginator.pageIndex); - return this.requestService.getMovieRequests(+this.gridCount, this.paginator.pageIndex * +this.gridCount, this.sort.active, this.sort.direction); + return this.loadData(); }), map((data: IRequestsViewModel) => { // Flip flag to show that loading has finished. @@ -56,4 +57,12 @@ export class MoviesGridComponent implements AfterViewInit { }) ).subscribe(data => this.dataSource = data); } + + public loadData(): Observable> { + if (this.showUnavailableRequests) { + return this.requestService.getMovieUnavailableRequests(+this.gridCount, this.paginator.pageIndex * +this.gridCount, this.sort.active, this.sort.direction); + } else { + return this.requestService.getMovieRequests(+this.gridCount, this.paginator.pageIndex * +this.gridCount, this.sort.active, this.sort.direction); + } + } } diff --git a/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.ts b/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.ts index 7487405e3..bf1e8069d 100644 --- a/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.ts +++ b/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.ts @@ -1,7 +1,7 @@ import { Component, AfterViewInit, ViewChild } from "@angular/core"; -import { IRequestsViewModel, ITvRequests, IChildRequests } from "../../../interfaces"; +import { IRequestsViewModel, IChildRequests } from "../../../interfaces"; import { MatPaginator, MatSort } from "@angular/material"; -import { merge, Observable, of as observableOf } from 'rxjs'; +import { merge, of as observableOf, Observable } from 'rxjs'; import { catchError, map, startWith, switchMap } from 'rxjs/operators'; import { RequestServiceV2 } from "../../../services/requestV2.service"; @@ -17,6 +17,7 @@ export class TvGridComponent implements AfterViewInit { public isLoadingResults = true; public displayedColumns: string[] = ['series', 'requestedBy', 'status', 'requestStatus', 'requestedDate','actions']; public gridCount: string = "15"; + public showUnavailableRequests: boolean; @ViewChild(MatPaginator, {static: false}) paginator: MatPaginator; @ViewChild(MatSort, {static: false}) sort: MatSort; @@ -35,7 +36,7 @@ export class TvGridComponent implements AfterViewInit { startWith({}), switchMap(() => { this.isLoadingResults = true; - return this.requestService.getTvRequests(+this.gridCount, this.paginator.pageIndex * +this.gridCount, this.sort.active, this.sort.direction); + return this.loadData(); }), map((data: IRequestsViewModel) => { // Flip flag to show that loading has finished. @@ -50,4 +51,12 @@ export class TvGridComponent implements AfterViewInit { }) ).subscribe(data => this.dataSource = data); } + + private loadData(): Observable> { + if(this.showUnavailableRequests) { + return this.requestService.getTvUnavailableRequests(+this.gridCount, this.paginator.pageIndex * +this.gridCount, this.sort.active, this.sort.direction); + } else { + return this.requestService.getTvRequests(+this.gridCount, this.paginator.pageIndex * +this.gridCount, this.sort.active, this.sort.direction); + } + } } diff --git a/src/Ombi/ClientApp/src/app/services/filedownload.service.ts b/src/Ombi/ClientApp/src/app/services/filedownload.service.ts new file mode 100644 index 000000000..a87f3b178 --- /dev/null +++ b/src/Ombi/ClientApp/src/app/services/filedownload.service.ts @@ -0,0 +1,35 @@ + +import { APP_BASE_HREF } from "@angular/common"; +import { Injectable, Inject } from "@angular/core"; + +import { HttpClient } from "@angular/common/http"; + +import { ServiceHelpers } from "./service.helpers"; + +@Injectable() +export class FileDownloadService extends ServiceHelpers { + constructor(http: HttpClient, @Inject(APP_BASE_HREF) href:string) { + super(http, "/api/v2/system/", href); + } + + downloadFile(url: string, contentType: string): void { + this.http.get(url).subscribe((response: any) => { + + // It is necessary to create a new blob object with mime-type explicitly set + // otherwise only Chrome works like it should + const newBlob = new Blob([(response)], { type: contentType }); + + // IE doesn't allow using a blob object directly as link href + // instead it is necessary to use msSaveOrOpenBlob + if (window.navigator && window.navigator.msSaveOrOpenBlob) { + window.navigator.msSaveOrOpenBlob(newBlob); + return; + } + + // For other browsers: + // Create a link pointing to the ObjectURL containing the blob. + const downloadURL = URL.createObjectURL(response); + window.open(downloadURL); + }); + } +} diff --git a/src/Ombi/ClientApp/src/app/services/index.ts b/src/Ombi/ClientApp/src/app/services/index.ts index 7cc93827a..107cd07f2 100644 --- a/src/Ombi/ClientApp/src/app/services/index.ts +++ b/src/Ombi/ClientApp/src/app/services/index.ts @@ -20,3 +20,5 @@ export * from "./searchV2.service"; export * from "./custompage.service"; export * from "./message.service"; export * from "./hub.service"; +export * from "./system.service"; +export * from "./filedownload.service"; diff --git a/src/Ombi/ClientApp/src/app/services/system.service.ts b/src/Ombi/ClientApp/src/app/services/system.service.ts new file mode 100644 index 000000000..20f60c8d8 --- /dev/null +++ b/src/Ombi/ClientApp/src/app/services/system.service.ts @@ -0,0 +1,21 @@ + +import { APP_BASE_HREF } from "@angular/common"; +import { Injectable, Inject } from "@angular/core"; + +import { HttpClient, HttpHeaders } from "@angular/common/http"; +import { Observable } from "rxjs"; + +import { ServiceHelpers } from "./service.helpers"; + +@Injectable() +export class SystemService extends ServiceHelpers { + constructor(http: HttpClient, @Inject(APP_BASE_HREF) href:string) { + super(http, "/api/v2/system/", href); + } + public getAvailableLogs(): Observable { + return this.http.get(`${this.url}logs/`, {headers: this.headers}); + } + public getLog(logName: string): Observable { + return this.http.get(`${this.url}logs/${logName}`, {responseType: 'text'}); + } +} diff --git a/src/Ombi/ClientApp/src/app/settings/logs/logs.component.html b/src/Ombi/ClientApp/src/app/settings/logs/logs.component.html new file mode 100644 index 000000000..1ba6128b9 --- /dev/null +++ b/src/Ombi/ClientApp/src/app/settings/logs/logs.component.html @@ -0,0 +1,19 @@ + +
+ Logs + + + + + + +
+          
+          {{logDetail}}
+        
+      
+ +
+
+
+
\ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/settings/logs/logs.component.scss b/src/Ombi/ClientApp/src/app/settings/logs/logs.component.scss new file mode 100644 index 000000000..637848b40 --- /dev/null +++ b/src/Ombi/ClientApp/src/app/settings/logs/logs.component.scss @@ -0,0 +1,8 @@ +.small-middle-container{ + margin: auto; + width: 80%; +} + +.code-block { + font-size: 10px; +} \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/settings/logs/logs.component.ts b/src/Ombi/ClientApp/src/app/settings/logs/logs.component.ts new file mode 100644 index 000000000..5a8a47b74 --- /dev/null +++ b/src/Ombi/ClientApp/src/app/settings/logs/logs.component.ts @@ -0,0 +1,23 @@ + +import { Component, OnInit } from "@angular/core"; +import { SystemService } from "../../services"; + +@Component({ + templateUrl: "./logs.component.html", + styleUrls:["./logs.component.scss"] +}) +export class LogsComponent implements OnInit { + + public logs: string[]; + public logDetail: string; + + constructor(private readonly systemService: SystemService) { } + + public async ngOnInit() { + this.logs = await this.systemService.getAvailableLogs().toPromise(); + } + + public async loadLog(logName: string) { + this.logDetail = await this.systemService.getLog(logName).toPromise(); + } +} diff --git a/src/Ombi/ClientApp/src/app/settings/settings.module.ts b/src/Ombi/ClientApp/src/app/settings/settings.module.ts index 0c8b7cd45..0420df48c 100644 --- a/src/Ombi/ClientApp/src/app/settings/settings.module.ts +++ b/src/Ombi/ClientApp/src/app/settings/settings.module.ts @@ -9,7 +9,7 @@ import { AuthGuard } from "../auth/auth.guard"; import { AuthService } from "../auth/auth.service"; import { CouchPotatoService, EmbyService, IssuesService, JobService, LidarrService, MobileService, NotificationMessageService, PlexService, RadarrService, - RequestRetryService, SonarrService, TesterService, ValidationService, + RequestRetryService, SonarrService, TesterService, ValidationService, SystemService, FileDownloadService, } from "../services"; import { PipeModule } from "../pipes/pipe.module"; @@ -52,6 +52,7 @@ import { AutoCompleteModule, CalendarModule, DialogModule, InputSwitchModule, In import { MatMenuModule} from "@angular/material"; import { SharedModule } from "../shared/shared.module"; import { HubService } from "../services/hub.service"; +import { LogsComponent } from "./logs/logs.component"; const routes: Routes = [ { path: "Ombi", component: OmbiComponent, canActivate: [AuthGuard] }, @@ -84,6 +85,7 @@ const routes: Routes = [ { path: "Lidarr", component: LidarrComponent, canActivate: [AuthGuard] }, { path: "Vote", component: VoteComponent, canActivate: [AuthGuard] }, { path: "FailedRequests", component: FailedRequestsComponent, canActivate: [AuthGuard] }, + { path: "Logs", component: LogsComponent, canActivate: [AuthGuard] }, ]; @NgModule({ @@ -141,6 +143,7 @@ const routes: Routes = [ LidarrComponent, VoteComponent, FailedRequestsComponent, + LogsComponent, ], exports: [ RouterModule, @@ -162,6 +165,8 @@ const routes: Routes = [ LidarrService, RequestRetryService, HubService, + SystemService, + FileDownloadService ], }) diff --git a/src/Ombi/ClientApp/src/app/settings/settingsmenu.component.html b/src/Ombi/ClientApp/src/app/settings/settingsmenu.component.html index 8280a711d..510d6ce90 100644 --- a/src/Ombi/ClientApp/src/app/settings/settingsmenu.component.html +++ b/src/Ombi/ClientApp/src/app/settings/settingsmenu.component.html @@ -56,7 +56,7 @@ - +
\ No newline at end of file