Merge pull request #4596 from sephrat/localize-tv-requests

Localize TV requests messages on TV details page
pull/4621/head
Jamie 2 years ago committed by GitHub
commit 48111827bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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<SenderResult> SendToLidarr(AlbumRequest model, LidarrSettings settings) private async Task<SenderResult> SendToLidarr(AlbumRequest model, LidarrSettings settings)

@ -133,8 +133,7 @@ namespace Ombi.Core.Senders
return new SenderResult return new SenderResult
{ {
Success = false, Success = false
Message = "Something went wrong!"
}; };
} }

@ -36,7 +36,7 @@ export class TvRequestGridComponent {
// Make sure something has been selected // Make sure something has been selected
const selected = this.selection.hasValue(); const selected = this.selection.hasValue();
if (!selected && !this.tv.requestAll && !this.tv.firstSeason && !this.tv.latestSeason) { 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; return;
} }
@ -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() { public async requestAllSeasons() {
this.tv.requestAll = true; this.tv.requestAll = true;
await this.submitRequests(); await this.submitRequests();

@ -6,6 +6,7 @@ import { MatDialog } from "@angular/material/dialog";
import { MessageService } from "../../../../../services"; import { MessageService } from "../../../../../services";
import { RequestService } from "../../../../../services/request.service"; import { RequestService } from "../../../../../services/request.service";
import { RequestServiceV2 } from "../../../../../services/requestV2.service"; import { RequestServiceV2 } from "../../../../../services/requestV2.service";
import { TranslateService } from "@ngx-translate/core";
@Component({ @Component({
templateUrl: "./tv-requests-panel.component.html", templateUrl: "./tv-requests-panel.component.html",
@ -24,7 +25,8 @@ export class TvRequestsPanelComponent {
constructor(private requestService: RequestService, constructor(private requestService: RequestService,
private requestService2: RequestServiceV2, private requestService2: RequestServiceV2,
private messageService: MessageService, private messageService: MessageService,
public dialog: MatDialog) { public dialog: MatDialog,
private translateService: TranslateService) {
} }
@ -41,7 +43,7 @@ export class TvRequestsPanelComponent {
ep.approved = true; ep.approved = true;
}); });
}); });
this.messageService.send("Request has been approved", "Ok"); this.messageService.send(this.translateService.instant("Requests.SuccessfullyApproved"));
} else { } else {
this.messageService.sendRequestEngineResultError(result); this.messageService.sendRequestEngineResultError(result);
} }
@ -52,7 +54,7 @@ export class TvRequestsPanelComponent {
if (result) { if (result) {
this.tvRequest.splice(this.tvRequest.indexOf(request),1); 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 => { this.requestService.markTvAvailable({ id: request.id }).subscribe(x => {
if (x.result) { if (x.result) {
this.messageService.send( this.messageService.send(
`This request is now available`); this.translateService.instant("Requests.NowAvailable"));
} else { } else {
this.messageService.send("Request Available", x.message ? x.message : x.errorMessage); this.messageService.sendRequestEngineResultError(x);
request.approved = false; request.approved = false;
} }
}); });
@ -77,9 +79,9 @@ export class TvRequestsPanelComponent {
this.requestService.markTvUnavailable({ id: request.id }).subscribe(x => { this.requestService.markTvUnavailable({ id: request.id }).subscribe(x => {
if (x.result) { if (x.result) {
this.messageService.send( this.messageService.send(
`This request is now unavailable`); this.translateService.instant("Requests.NowUnavailable"));
} else { } else {
this.messageService.send("Request Available", x.message ? x.message : x.errorMessage); this.messageService.sendRequestEngineResultError(x);
request.approved = false; request.approved = false;
} }
}); });
@ -102,11 +104,11 @@ export class TvRequestsPanelComponent {
} }
public reProcessRequest(request: IChildRequests) { public reProcessRequest(request: IChildRequests) {
this.requestService2.reprocessRequest(request.id, RequestType.tvShow, false).subscribe(result => { this.requestService2.reprocessRequest(request.id, RequestType.tvShow, false).subscribe(x => {
if (result.result) { if (x.result) {
this.messageService.send(result.message ? result.message : "Successfully Re-processed the request", "Ok"); this.messageService.send(this.translateService.instant("Requests.SuccessfullyReprocessed"));
} else { } else {
this.messageService.sendRequestEngineResultError(result); this.messageService.sendRequestEngineResultError(x);
} }
}); });
} }

@ -22,11 +22,15 @@ export class MessageService {
} }
public sendRequestEngineResultError(result: IRequestEngineResult, action: string = "Ok") { public sendRequestEngineResultError(result: IRequestEngineResult, action: string = "Ok") {
const textKey = 'Requests.ErrorCodes.' + result.errorCode; const textKey = 'Requests.ErrorCodes.' + result.errorCode;
const text = this.translate.instant(textKey); var text = this.translate.instant(textKey);
if (text !== textKey) { if (text === textKey) { // Error code on backend may not exist in frontend
this.send(text, action); if (result.errorMessage || result.message) {
} else { text = result.errorMessage ? result.errorMessage : result.message;
this.send(result.errorMessage ? result.errorMessage : result.message, action); } else {
text = this.translate.instant('ErrorPages.SomethingWentWrong');
}
} }
this.send(text, action);
} }
} }

@ -60,7 +60,8 @@
"CheckPageForUpdates": "Check this page for continuous site updates." "CheckPageForUpdates": "Check this page for continuous site updates."
}, },
"ErrorPages": { "ErrorPages": {
"NotFound": "Page not found" "NotFound": "Page not found",
"SomethingWentWrong": "Something went wrong!"
}, },
"NavigationBar": { "NavigationBar": {
"Discover": "Discover", "Discover": "Discover",

Loading…
Cancel
Save