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",