diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html index c7631725c..661c11e86 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html @@ -1,78 +1,79 @@ - - - -
{{'Common.ProcessingRequest' | translate}}
-
- {{'Common.PendingApproval' | translate}} -
-
- {{'Common.NotRequested' | translate}} -
-
{{'Common.Available' | translate}} -
-
- - Requested By '{{request.requestedUser.userAlias}}' on - {{request.requestedDate | amLocal | amDateFormat: 'LL' }} - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{{ 'Requests.Number' | translate }} {{element.episodeNumber}} {{ 'Requests.GridTitle' | translate }} {{element.title}} {{ 'Requests.AirDate' | translate }} {{element.airDate | amLocal | amDateFormat: 'L' }} {{ 'Requests.GridStatus' | translate }} - - - - - - -
-
-
-
-
- -
- - - - - - - -
- -
\ No newline at end of file + + + +
{{'Common.ProcessingRequest' | translate}}
+
{{'Common.Denied' | translate}}
+
+ {{'Common.PendingApproval' | translate}} +
+
+ {{'Common.NotRequested' | translate}} +
+
{{'Common.Available' | translate}} +
+
+ + Requested By '{{request.requestedUser.userAlias}}' on + {{request.requestedDate | amLocal | amDateFormat: 'LL' }} + - {{request.deniedReason}} + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{ 'Requests.Number' | translate }} {{element.episodeNumber}} {{ 'Requests.GridTitle' | translate }} {{element.title}} {{ 'Requests.AirDate' | translate }} {{element.airDate | amLocal | amDateFormat: 'L' }} {{ 'Requests.GridStatus' | translate }} + + + + + +
+
+
+
+
+ +
+ +
+ + + + +
+ + + +
+ + diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.ts index 784c2d50d..fe32ae988 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.ts @@ -1,16 +1,87 @@ -import { Component, ViewEncapsulation, Input, OnInit } from "@angular/core"; -import { IChildRequests } from "../../../../../interfaces"; +import { Component, Input } from "@angular/core"; +import { IChildRequests, RequestType } from "../../../../../interfaces"; +import { RequestService } from "../../../../../services/request.service"; +import { MessageService } from "../../../../../services"; +import { MatDialog } from "@angular/material"; +import { DenyDialogComponent } from "../../../shared/deny-dialog/deny-dialog.component"; @Component({ templateUrl: "./tv-requests-panel.component.html", styleUrls: ["./tv-requests-panel.component.scss"], selector: "tv-requests-panel" }) -export class TvRequestsPanelComponent implements OnInit { +export class TvRequestsPanelComponent { @Input() public tvRequest: IChildRequests[]; - + @Input() public isAdmin: boolean; + public displayedColumns: string[] = ['number', 'title', 'airDate', 'status']; - public ngOnInit(): void { - // + + constructor(private requestService: RequestService, private messageService: MessageService, + public dialog: MatDialog) { + + } + + public async approve(request: IChildRequests) { + const result = await this.requestService.approveChild({ + id: request.id + }).toPromise(); + + if (result.result) { + request.approved = true; + request.denied = false; + request.seasonRequests.forEach((season) => { + season.episodes.forEach((ep) => { + ep.approved = true; + }); + }); + this.messageService.send("Request has been approved", "Ok"); + } else { + this.messageService.send(result.errorMessage, "Ok"); + } + } + + public changeAvailability(request: IChildRequests, available: boolean) { + request.available = available; + request.seasonRequests.forEach((season) => { + season.episodes.forEach((ep) => { + ep.available = available; + }); + }); + if (available) { + this.requestService.markTvAvailable({ id: request.id }).subscribe(x => { + if (x.result) { + this.messageService.send( + `This request is now available`); + } else { + this.messageService.send("Request Available", x.message ? x.message : x.errorMessage); + request.approved = false; + } + }); + } else { + this.requestService.markTvUnavailable({ id: request.id }).subscribe(x => { + if (x.result) { + this.messageService.send( + `This request is now unavailable`); + } else { + this.messageService.send("Request Available", x.message ? x.message : x.errorMessage); + request.approved = false; + } + }); + } + } + public async deny(request: IChildRequests) { + const dialogRef = this.dialog.open(DenyDialogComponent, { + width: '250px', + data: {requestId: request.id, requestType: RequestType.tvShow} + }); + + dialogRef.afterClosed().subscribe(result => { + request.denied = true; + request.seasonRequests.forEach((season) => { + season.episodes.forEach((ep) => { + ep.approved = false; + }); + }); + }); } } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html index 9439ac763..1a860fe65 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html @@ -78,7 +78,7 @@ Requests - + diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts index 4a5c87365..438df619f 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts @@ -1,4 +1,4 @@ -import { Component, ViewEncapsulation } from "@angular/core"; +import { Component, ViewEncapsulation, OnInit } from "@angular/core"; import { ImageService, SearchV2Service, MessageService, RequestService } from "../../../services"; import { ActivatedRoute } from "@angular/router"; import { DomSanitizer } from "@angular/platform-browser"; @@ -7,31 +7,39 @@ import { MatDialog } from "@angular/material"; import { YoutubeTrailerComponent } from "../shared/youtube-trailer.component"; import { EpisodeRequestComponent } from "../../../shared/episode-request/episode-request.component"; import { IChildRequests } from "../../../interfaces"; +import { AuthService } from "../../../auth/auth.service"; @Component({ templateUrl: "./tv-details.component.html", styleUrls: ["../../media-details.component.scss"], encapsulation: ViewEncapsulation.None }) -export class TvDetailsComponent { +export class TvDetailsComponent implements OnInit { + public tv: ISearchTvResultV2; public tvRequest: IChildRequests[]; public fromSearch: boolean; + public isAdmin: boolean; private tvdbId: number; constructor(private searchService: SearchV2Service, private route: ActivatedRoute, private sanitizer: DomSanitizer, private imageService: ImageService, - public dialog: MatDialog, public messageService: MessageService, private requestService: RequestService) { + public dialog: MatDialog, public messageService: MessageService, private requestService: RequestService, + private auth: AuthService) { this.route.params.subscribe((params: any) => { this.tvdbId = params.tvdbId; this.fromSearch = params.search; - - this.load(); }); } + public async ngOnInit() { + await this.load(); + } + public async load() { + + this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser"); if (this.fromSearch) { this.tv = await this.searchService.getTvInfoWithMovieDbId(this.tvdbId); this.tvdbId = this.tv.id; @@ -39,7 +47,7 @@ export class TvDetailsComponent { this.tv = await this.searchService.getTvInfo(this.tvdbId); } - if(this.tv.requestId) { + if (this.tv.requestId) { this.tvRequest = await this.requestService.getChildRequests(this.tv.requestId).toPromise(); }