From 6756ee688a0f7d77f94189f6fbe40b04739540b1 Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Thu, 14 Apr 2022 12:59:36 +0200 Subject: [PATCH 1/2] Remove dead code --- .../tv-request-grid.component.ts | 64 ------------------- 1 file changed, 64 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts index 7d1304eff..123e24f11 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts @@ -80,70 +80,6 @@ export class TvRequestGridComponent { } } - 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.notificationService.send("Request has been approved", "Ok"); - } else { - this.notificationService.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.notificationService.send( - `This request is now available`); - } else { - this.notificationService.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.notificationService.send( - `This request is now unavailable`); - } else { - this.notificationService.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; - }); - }); - }); - } - public async requestAllSeasons() { this.tv.requestAll = true; await this.submitRequests(); From fc202f5337930f98133f15592ed5c54ca9b15740 Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Thu, 14 Apr 2022 13:54:04 +0200 Subject: [PATCH 2/2] Localize TV requests messages on TV details page --- src/Ombi.Core/Senders/MusicSender.cs | 2 +- src/Ombi.Core/Senders/TvSender.cs | 3 +-- .../tv-request-grid.component.ts | 2 +- .../tv-requests-panel.component.ts | 24 ++++++++++--------- .../src/app/services/message.service.ts | 14 +++++++---- src/Ombi/wwwroot/translations/en.json | 3 ++- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/Ombi.Core/Senders/MusicSender.cs b/src/Ombi.Core/Senders/MusicSender.cs index 6390578dd..260b008fe 100644 --- a/src/Ombi.Core/Senders/MusicSender.cs +++ b/src/Ombi.Core/Senders/MusicSender.cs @@ -70,7 +70,7 @@ namespace Ombi.Core.Senders } - return new SenderResult { Success = false, Sent = false, Message = "Something went wrong!" }; + return new SenderResult { Success = false, Sent = false }; } private async Task SendToLidarr(AlbumRequest model, LidarrSettings settings) diff --git a/src/Ombi.Core/Senders/TvSender.cs b/src/Ombi.Core/Senders/TvSender.cs index 3676d05ee..c076b2d13 100644 --- a/src/Ombi.Core/Senders/TvSender.cs +++ b/src/Ombi.Core/Senders/TvSender.cs @@ -133,8 +133,7 @@ namespace Ombi.Core.Senders return new SenderResult { - Success = false, - Message = "Something went wrong!" + Success = false }; } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts index 123e24f11..bac88756e 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts @@ -36,7 +36,7 @@ export class TvRequestGridComponent { // Make sure something has been selected const selected = this.selection.hasValue(); if (!selected && !this.tv.requestAll && !this.tv.firstSeason && !this.tv.latestSeason) { - this.notificationService.send("You need to select some episodes!", "OK"); + this.notificationService.send(this.translate.instant("Requests.NeedToSelectEpisodes")); return; } 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 e397e60ea..1aa795850 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 @@ -6,6 +6,7 @@ import { MatDialog } from "@angular/material/dialog"; import { MessageService } from "../../../../../services"; import { RequestService } from "../../../../../services/request.service"; import { RequestServiceV2 } from "../../../../../services/requestV2.service"; +import { TranslateService } from "@ngx-translate/core"; @Component({ templateUrl: "./tv-requests-panel.component.html", @@ -24,7 +25,8 @@ export class TvRequestsPanelComponent { constructor(private requestService: RequestService, private requestService2: RequestServiceV2, private messageService: MessageService, - public dialog: MatDialog) { + public dialog: MatDialog, + private translateService: TranslateService) { } @@ -41,7 +43,7 @@ export class TvRequestsPanelComponent { ep.approved = true; }); }); - this.messageService.send("Request has been approved", "Ok"); + this.messageService.send(this.translateService.instant("Requests.SuccessfullyApproved")); } else { this.messageService.sendRequestEngineResultError(result); } @@ -52,7 +54,7 @@ export class TvRequestsPanelComponent { if (result) { this.tvRequest.splice(this.tvRequest.indexOf(request),1); - this.messageService.send("Request has been Deleted", "Ok"); + this.messageService.send(this.translateService.instant("Requests.SuccessfullyDeleted")); } } @@ -67,9 +69,9 @@ export class TvRequestsPanelComponent { this.requestService.markTvAvailable({ id: request.id }).subscribe(x => { if (x.result) { this.messageService.send( - `This request is now available`); + this.translateService.instant("Requests.NowAvailable")); } else { - this.messageService.send("Request Available", x.message ? x.message : x.errorMessage); + this.messageService.sendRequestEngineResultError(x); request.approved = false; } }); @@ -77,9 +79,9 @@ export class TvRequestsPanelComponent { this.requestService.markTvUnavailable({ id: request.id }).subscribe(x => { if (x.result) { this.messageService.send( - `This request is now unavailable`); + this.translateService.instant("Requests.NowUnavailable")); } else { - this.messageService.send("Request Available", x.message ? x.message : x.errorMessage); + this.messageService.sendRequestEngineResultError(x); request.approved = false; } }); @@ -102,11 +104,11 @@ export class TvRequestsPanelComponent { } public reProcessRequest(request: IChildRequests) { - this.requestService2.reprocessRequest(request.id, RequestType.tvShow, false).subscribe(result => { - if (result.result) { - this.messageService.send(result.message ? result.message : "Successfully Re-processed the request", "Ok"); + this.requestService2.reprocessRequest(request.id, RequestType.tvShow, false).subscribe(x => { + if (x.result) { + this.messageService.send(this.translateService.instant("Requests.SuccessfullyReprocessed")); } else { - this.messageService.sendRequestEngineResultError(result); + this.messageService.sendRequestEngineResultError(x); } }); } diff --git a/src/Ombi/ClientApp/src/app/services/message.service.ts b/src/Ombi/ClientApp/src/app/services/message.service.ts index be1df37be..995bc0f89 100644 --- a/src/Ombi/ClientApp/src/app/services/message.service.ts +++ b/src/Ombi/ClientApp/src/app/services/message.service.ts @@ -22,11 +22,15 @@ export class MessageService { } public sendRequestEngineResultError(result: IRequestEngineResult, action: string = "Ok") { const textKey = 'Requests.ErrorCodes.' + result.errorCode; - const text = this.translate.instant(textKey); - if (text !== textKey) { - this.send(text, action); - } else { - this.send(result.errorMessage ? result.errorMessage : result.message, action); + var text = this.translate.instant(textKey); + if (text === textKey) { // Error code on backend may not exist in frontend + if (result.errorMessage || result.message) { + text = result.errorMessage ? result.errorMessage : result.message; + } else { + text = this.translate.instant('ErrorPages.SomethingWentWrong'); + } } + + this.send(text, action); } } diff --git a/src/Ombi/wwwroot/translations/en.json b/src/Ombi/wwwroot/translations/en.json index a9c40c197..3611b0249 100644 --- a/src/Ombi/wwwroot/translations/en.json +++ b/src/Ombi/wwwroot/translations/en.json @@ -60,7 +60,8 @@ "CheckPageForUpdates": "Check this page for continuous site updates." }, "ErrorPages": { - "NotFound": "Page not found" + "NotFound": "Page not found", + "SomethingWentWrong": "Something went wrong!" }, "NavigationBar": { "Discover": "Discover",