From 1c8786ea2706468f5250bb51fd418d4a7c467270 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Sun, 2 Feb 2020 23:28:26 +0000 Subject: [PATCH] Fixed up the TV Grid's request status's --- .../movies-grid/movies-grid.component.html | 6 +- .../movies-grid/movies-grid.component.ts | 19 +++-- .../components/tv-grid/tv-grid.component.html | 76 +++++++++---------- .../components/tv-grid/tv-grid.component.ts | 16 +++- 4 files changed, 65 insertions(+), 52 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.html b/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.html index 7255e42e9..7c91e9900 100644 --- a/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.html +++ b/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.html @@ -41,11 +41,11 @@ {{element.requestStatus | translate}} - + - + - + 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 db59fdc39..513558fa0 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 @@ -5,6 +5,7 @@ import { merge, Observable, of as observableOf } from 'rxjs'; import { catchError, map, startWith, switchMap } from 'rxjs/operators'; import { RequestServiceV2 } from "../../../services/requestV2.service"; +import { AuthService } from "../../../auth/auth.service"; @Component({ templateUrl: "./movies-grid.component.html", @@ -18,13 +19,15 @@ export class MoviesGridComponent implements AfterViewInit { public displayedColumns: string[] = ['requestedUser.requestedBy', 'title', 'requestedDate', 'status', 'requestStatus', 'actions']; public gridCount: string = "15"; public showUnavailableRequests: boolean; - - @Output() public onOpenOptions = new EventEmitter<{request: any, filter: any, onChange: any}>(); + public isAdmin: boolean; + + @Output() public onOpenOptions = new EventEmitter<{ request: any, filter: any, onChange: any }>(); @ViewChild(MatPaginator, { static: false }) paginator: MatPaginator; @ViewChild(MatSort, { static: false }) sort: MatSort; - constructor(private requestService: RequestServiceV2, private ref: ChangeDetectorRef) { + constructor(private requestService: RequestServiceV2, private ref: ChangeDetectorRef, + private auth: AuthService) { } @@ -34,6 +37,8 @@ export class MoviesGridComponent implements AfterViewInit { // this.dataSource = results.collection; // this.resultsLength = results.total; + this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser"); + // If the user changes the sort order, reset back to the first page. this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0); @@ -69,14 +74,16 @@ export class MoviesGridComponent implements AfterViewInit { } public openOptions(request: IMovieRequests) { - const filter = () => { this.dataSource = this.dataSource.filter((req) => { + const filter = () => { + this.dataSource = this.dataSource.filter((req) => { return req.id !== request.id; - })}; + }) + }; const onChange = () => { this.ref.detectChanges(); }; - this.onOpenOptions.emit({request: request, filter: filter, onChange: onChange}); + this.onOpenOptions.emit({ request: request, filter: filter, onChange: onChange }); } } diff --git a/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.html b/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.html index 5d93bb84f..343b9f255 100644 --- a/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.html +++ b/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.html @@ -1,18 +1,18 @@
- + - - 10 - 15 - 30 - 100 - - + + 10 + 15 + 30 + 100 + + - +
@@ -21,44 +21,42 @@ - + - - - - - - - - - + + + + - - - - + + + + + + + + + @@ -67,4 +65,4 @@
Requested By Requested By {{element.requestedUser.userAlias}} Status - {{element.parentRequest.status}} - Requested Date - {{element.requestedDate | amLocal | amDateFormat: 'LL'}} - Status + {{element.parentRequest.status}} + Request Status -
{{'Common.ProcessingRequest' | translate}}
-
{{'Common.PendingApproval' | - translate}} -
-
{{'Common.NotRequested' | - translate}} -
-
Requested Date + {{element.requestedDate | amLocal | amDateFormat: 'LL'}} + Request Status +
{{'Common.ProcessingRequest' | translate}}
+
{{'Common.PendingApproval' |translate}}
+
{{'Common.Available' | translate}}
+ +
- - + +
-
+ \ No newline at end of file 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 efa68838b..78dd23c1a 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,10 +1,11 @@ -import { Component, AfterViewInit, ViewChild, Output, EventEmitter } from "@angular/core"; +import { Component, AfterViewInit, ViewChild, Output, EventEmitter, ChangeDetectorRef } from "@angular/core"; import { IRequestsViewModel, IChildRequests } from "../../../interfaces"; import { MatPaginator, MatSort } from "@angular/material"; import { merge, of as observableOf, Observable } from 'rxjs'; import { catchError, map, startWith, switchMap } from 'rxjs/operators'; import { RequestServiceV2 } from "../../../services/requestV2.service"; +import { AuthService } from "../../../auth/auth.service"; @Component({ templateUrl: "./tv-grid.component.html", @@ -18,18 +19,21 @@ export class TvGridComponent implements AfterViewInit { public displayedColumns: string[] = ['series', 'requestedBy', 'status', 'requestStatus', 'requestedDate','actions']; public gridCount: string = "15"; public showUnavailableRequests: boolean; + public isAdmin: boolean; - @Output() public onOpenOptions = new EventEmitter<{request: any, filter: any}>(); + @Output() public onOpenOptions = new EventEmitter<{request: any, filter: any, onChange: any}>(); @ViewChild(MatPaginator, {static: false}) paginator: MatPaginator; @ViewChild(MatSort, {static: false}) sort: MatSort; - constructor(private requestService: RequestServiceV2) { + constructor(private requestService: RequestServiceV2, private auth: AuthService, + private ref: ChangeDetectorRef) { } public async ngAfterViewInit() { + this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser"); // If the user changes the sort order, reset back to the first page. this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0); @@ -58,8 +62,12 @@ export class TvGridComponent implements AfterViewInit { const filter = () => { this.dataSource = this.dataSource.filter((req) => { return req.id !== request.id; })}; + + const onChange = () => { + this.ref.detectChanges(); + }; - this.onOpenOptions.emit({request: request, filter: filter}); + this.onOpenOptions.emit({request: request, filter: filter, onChange}); } private loadData(): Observable> {