Skip to content

Commit

Permalink
Merge pull request #4406 from Ombi-app/issue-fixes
Browse files Browse the repository at this point in the history
Issue fixes
  • Loading branch information
tidusjar authored Nov 15, 2021
2 parents 1023574 + a3739f3 commit f16c4e0
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 64 deletions.
18 changes: 18 additions & 0 deletions src/Ombi.Helpers/NotificationSubstitues.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Ombi.Helpers
{
public static class NotificationSubstitues
{
public const string Title = nameof(Title);
public const string IssueDescription = nameof(IssueDescription);
public const string IssueCategory = nameof(IssueCategory);
public const string IssueStatus = nameof(IssueStatus);
public const string IssueSubject = nameof(IssueSubject);
public const string IssueUser = nameof(IssueUser);
public const string IssueUserAlias = nameof(IssueUserAlias);
public const string RequestType = nameof(RequestType);
public const string PosterPath = nameof(PosterPath);
public const string NewIssueComment = nameof(NewIssueComment);
public const string IssueId = nameof(IssueId);
public const string AdminComment = nameof(AdminComment);
}
}
32 changes: 21 additions & 11 deletions src/Ombi.Notifications/NotificationMessageCurlys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ public void Setup(NotificationOptions opts, MovieRequests req, CustomizationSett
Year = req?.ReleaseDate.Year.ToString();
Overview = req?.Overview;
AdditionalInformation = opts?.AdditionalInformation ?? string.Empty;
PosterImage = $"https://image.tmdb.org/t/p/w300/{req?.PosterPath?.TrimStart('/') ?? string.Empty}";

var img = req?.PosterPath ?? string.Empty;
if (img.HasValue())
{
PosterImage = $"https://image.tmdb.org/t/p/w300/{req?.PosterPath?.TrimStart('/') ?? string.Empty}";
}
CalculateRequestStatus(req);
}

Expand All @@ -53,8 +58,12 @@ public void Setup(NotificationOptions opts, ChildRequests req, CustomizationSett
Year = req?.ParentRequest?.ReleaseDate.Year.ToString();
Overview = req?.ParentRequest?.Overview;
AdditionalInformation = opts.AdditionalInformation;
PosterImage =
$"https://image.tmdb.org/t/p/w300/{req?.ParentRequest?.PosterPath?.TrimStart('/') ?? string.Empty}";
var img = req?.ParentRequest?.PosterPath ?? string.Empty;
if (img.HasValue())
{
PosterImage =
$"https://image.tmdb.org/t/p/w300/{req?.ParentRequest?.PosterPath?.TrimStart('/') ?? string.Empty}";
}

// Generate episode list.
StringBuilder epSb = new StringBuilder();
Expand Down Expand Up @@ -94,16 +103,17 @@ public void Setup(NotificationOptions opts, AlbumRequest req, CustomizationSetti

private void LoadIssues(NotificationOptions opts)
{
IssueDescription = opts.Substitutes.TryGetValue("IssueDescription", out string val) ? val : string.Empty;
IssueCategory = opts.Substitutes.TryGetValue("IssueCategory", out val) ? val : string.Empty;
IssueStatus = opts.Substitutes.TryGetValue("IssueStatus", out val) ? val : string.Empty;
IssueSubject = opts.Substitutes.TryGetValue("IssueSubject", out val) ? val : string.Empty;
NewIssueComment = opts.Substitutes.TryGetValue("NewIssueComment", out val) ? val : string.Empty;
UserName = opts.Substitutes.TryGetValue("IssueUser", out val) ? val : string.Empty;
Alias = opts.Substitutes.TryGetValue("IssueUserAlias", out val) ? val : string.Empty;
Type = opts.Substitutes.TryGetValue("RequestType", out val) && Enum.TryParse(val, out RequestType type)
IssueDescription = opts.Substitutes.TryGetValue(NotificationSubstitues.IssueDescription, out string val) ? val : string.Empty;
IssueCategory = opts.Substitutes.TryGetValue(NotificationSubstitues.IssueCategory, out val) ? val : string.Empty;
IssueStatus = opts.Substitutes.TryGetValue(NotificationSubstitues.IssueStatus, out val) ? val : string.Empty;
IssueSubject = opts.Substitutes.TryGetValue(NotificationSubstitues.IssueSubject, out val) ? val : string.Empty;
NewIssueComment = opts.Substitutes.TryGetValue(NotificationSubstitues.NewIssueComment, out val) ? val : string.Empty;
UserName = opts.Substitutes.TryGetValue(NotificationSubstitues.IssueUser, out val) ? val : string.Empty;
Alias = opts.Substitutes.TryGetValue(NotificationSubstitues.IssueUserAlias, out val) ? val : string.Empty;
Type = opts.Substitutes.TryGetValue(NotificationSubstitues.RequestType, out val) && Enum.TryParse(val, out RequestType type)
? HumanizeReturnType(type)
: string.Empty;
PosterImage = opts.Substitutes.TryGetValue(NotificationSubstitues.PosterPath, out val) ? $"https://image.tmdb.org/t/p/w300/{val.TrimStart('/')}" : string.Empty;
}

private void LoadCommon(BaseRequest req, CustomizationSettings s, UserNotificationPreferences pref, NotificationOptions opts)
Expand Down
2 changes: 2 additions & 0 deletions src/Ombi.Store/Entities/Requests/Issues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class Issues : Entity
public string UserReportedId { get; set; }
public OmbiUser UserReported { get; set; }
public List<IssueComments> Comments { get; set; }
[NotMapped]
public string PosterPath { get; set; }
}

public enum IssueStatus
Expand Down
3 changes: 2 additions & 1 deletion src/Ombi/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"settings",
"user-management",
"newsletter",
"mass-email"
"mass-email",
"issues"
]
}
1 change: 1 addition & 0 deletions src/Ombi/ClientApp/src/app/interfaces/IIssues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface IIssues {
comments: IIssueComments[];
requestId: number | undefined;
userReported: IUser | undefined;
posterPath: string;
}

export enum IssueStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<mat-card-header>
<mat-card-title>{{issue.subject}}</mat-card-title>
<mat-card-subtitle>{{'Issues.UserOnDate' | translate: { user: issue.userReported?.userName, date: issue.createdDate | amLocal | amUserLocale | amDateFormat: 'LL' } }}</mat-card-subtitle>
<mat-card-subtitle>{{issue.issueCategory.value}}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<p>
Expand All @@ -10,8 +11,8 @@
</mat-card-content>
<mat-card-actions>
<button mat-raised-button (click)="openChat(issue)" color="accent"><i class="far fa-comments"></i> {{'Issues.Chat' | translate }}</button>
<div *ngIf="isAdmin && settings;then content else empty">here is ignored</div>
<ng-template #content>
<div *ngIf="isAdmin && settings;then content else empty"></div>
<ng-template #content>
<button mat-raised-button color="accent"
*ngIf="issue.status === IssueStatus.Pending && settings.enableInProgress"
(click)="inProgress(issue)">{{'Issues.MarkInProgress' | translate }}</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
@import "~styles/variables.scss";

::ng-deep .mat-card {
background: $ombi-background-primary-accent;
}

.top-spacing {
margin-top:2%;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Component, Inject, OnInit, ViewEncapsulation } from "@angular/core";
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { ActivatedRoute, ActivatedRouteSnapshot, Router } from "@angular/router";
import { TranslateService } from "@ngx-translate/core";
import { AuthService } from "../../../auth/auth.service";
import { IIssues, IIssueSettings, IIssuesSummary, IssueStatus, RequestType } from "../../../interfaces";
import { Component, Inject, OnInit, ViewEncapsulation } from "@angular/core";
import { IIssueSettings, IIssues, IIssuesSummary, IssueStatus, RequestType } from "../../../interfaces";
import { IssuesService, NotificationService, SettingsService } from "../../../services";
import { IssuesV2Service } from "../../../services/issuesv2.service";
import { IssueChatComponent } from "../issue-chat/issue-chat.component";
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';

import { AuthService } from "../../../auth/auth.service";
import { IssueChatComponent } from "../issue-chat/issue-chat.component";
import { IssuesV2Service } from "../../../services/issuesv2.service";
import { TranslateService } from "@ngx-translate/core";

export interface IssuesDetailsGroupData {
issues: IIssues[];
Expand Down Expand Up @@ -77,15 +77,15 @@ export class IssuesDetailsComponent implements OnInit {
const firstIssue = this.details.issues[0];
switch(firstIssue.requestType) {
case RequestType.movie:
this.router.navigate(['/details/movie/', firstIssue.providerId]);
this.router.navigate(['/details/movie/', this.providerId]);
return;

case RequestType.album:
this.router.navigate(['/details/artist/', firstIssue.providerId]);
this.router.navigate(['/details/artist/', this.providerId]);
return;

case RequestType.tvShow:
this.router.navigate(['/details/tv/', firstIssue.providerId]);
this.router.navigate(['/details/tv/', this.providerId]);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class IssueDetailsComponent implements OnInit {
requestId: x.requestId,
providerId: x.providerId,
userReported: x.userReported,
posterPath: undefined, // Poster Path is not stored in the db, will always be undefined
};
this.setBackground(x);
});
Expand Down
34 changes: 17 additions & 17 deletions src/Ombi/ClientApp/src/app/media-details/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { MovieDetailsComponent } from "./movie/movie-details.component";
import { YoutubeTrailerComponent } from "./shared/youtube-trailer.component";
import { TvDetailsComponent } from "./tv/tv-details.component";
import { MovieInformationPanelComponent } from "./movie/panels/movie-information-panel.component";
import { TvInformationPanelComponent } from "./tv/panels/tv-information-panel/tv-information-panel.component";
import { TopBannerComponent } from "./shared/top-banner/top-banner.component";
import { SocialIconsComponent } from "./shared/social-icons/social-icons.component";
import { MediaPosterComponent } from "./shared/media-poster/media-poster.component";
import { CastCarouselComponent } from "./shared/cast-carousel/cast-carousel.component";
import { DenyDialogComponent } from "./shared/deny-dialog/deny-dialog.component";
import { TvRequestsPanelComponent } from "./tv/panels/tv-requests/tv-requests-panel.component";
import { MovieAdvancedOptionsComponent } from "./movie/panels/movie-advanced-options/movie-advanced-options.component";
import { SearchService, RequestService, RadarrService, IssuesService, SonarrService } from "../../services";
import { RequestServiceV2 } from "../../services/requestV2.service";
import { NewIssueComponent } from "./shared/new-issue/new-issue.component";
import { IssuesService, RadarrService, RequestService, SearchService, SonarrService } from "../../services";

import { ArtistDetailsComponent } from "./artist/artist-details.component";
import { ArtistInformationPanel } from "./artist/panels/artist-information-panel/artist-information-panel.component";
import { ArtistReleasePanel } from "./artist/panels/artist-release-panel/artist-release-panel.component";
import { CastCarouselComponent } from "./shared/cast-carousel/cast-carousel.component";
import { DenyDialogComponent } from "./shared/deny-dialog/deny-dialog.component";
import { IssuesPanelComponent } from "./shared/issues-panel/issues-panel.component";
import { TvAdvancedOptionsComponent } from "./tv/panels/tv-advanced-options/tv-advanced-options.component";
import { MediaPosterComponent } from "./shared/media-poster/media-poster.component";
import { MovieAdvancedOptionsComponent } from "./movie/panels/movie-advanced-options/movie-advanced-options.component";
import { MovieDetailsComponent } from "./movie/movie-details.component";
import { MovieInformationPanelComponent } from "./movie/panels/movie-information-panel.component";
import { NewIssueComponent } from "./shared/new-issue/new-issue.component";
import { RequestBehalfComponent } from "./shared/request-behalf/request-behalf.component";
import { RequestServiceV2 } from "../../services/requestV2.service";
import { SocialIconsComponent } from "./shared/social-icons/social-icons.component";
import { TopBannerComponent } from "./shared/top-banner/top-banner.component";
import { TvAdvancedOptionsComponent } from "./tv/panels/tv-advanced-options/tv-advanced-options.component";
import { TvDetailsComponent } from "./tv/tv-details.component";
import { TvInformationPanelComponent } from "./tv/panels/tv-information-panel/tv-information-panel.component";
import { TvRequestGridComponent } from "./tv/panels/tv-request-grid/tv-request-grid.component";
import { DetailsGroupComponent } from "../../issues/components/details-group/details-group.component";
import { TvRequestsPanelComponent } from "./tv/panels/tv-requests/tv-requests-panel.component";
import { YoutubeTrailerComponent } from "./shared/youtube-trailer.component";

export const components: any[] = [
MovieDetailsComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class MovieDetailsComponent {
}
const dialogRef = this.dialog.open(NewIssueComponent, {
width: '500px',
data: { requestId: this.movieRequest ? this.movieRequest.id : null, requestType: RequestType.movie, providerId: provider, title: this.movie.title }
data: { requestId: this.movieRequest ? this.movieRequest.id : null, requestType: RequestType.movie, providerId: provider, title: this.movie.title, posterPath: this.movie.posterPath }
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export interface IIssueDialogData {
requestId: number;
providerId: string;
title: string;
posterPath: string;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Component, Inject, OnInit } from "@angular/core";
import { IDenyDialogData, IIssueDialogData } from "../interfaces/interfaces";
import { IIssueDialogData } from "../interfaces/interfaces";
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog";
import { MessageService, IssuesService } from "../../../../services";
import { IIssues, IIssueCategory, IssueStatus, RequestType } from "../../../../interfaces";
import { TranslateService } from "@ngx-translate/core";
import { firstValueFrom } from "rxjs";

@Component({
selector: "new-issue",
Expand All @@ -20,7 +21,6 @@ export class NewIssueComponent implements OnInit {
private issueService: IssuesService,
public messageService: MessageService,
private translate: TranslateService) {
debugger;
this.issue = {
subject: "",
description: "",
Expand All @@ -35,16 +35,18 @@ export class NewIssueComponent implements OnInit {
title: data.title,
providerId: data.providerId,
userReported: undefined,
posterPath: data.posterPath,
};
}

public async ngOnInit(): Promise<void> {
this.issueCategories = await this.issueService.getCategories().toPromise();
const categories$ = this.issueService.getCategories();
this.issueCategories = await firstValueFrom(categories$);
}

public async createIssue() {
const result = await this.issueService.createIssue(this.issue).toPromise();
if(result) {
if (result) {
this.messageService.send(this.translate.instant("Issues.IssueDialog.IssueCreated"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ <h3> {{ 'MediaDetails.NotEnoughInfo' | translate }}</h3>
</div>
<div class="col-12 col-md-10">
<div class="issuesPanel">
<issues-panel [providerId]="tv.theTvDbId" [isAdmin]="isAdmin"></issues-panel>
<issues-panel [providerId]="tv.id" [isAdmin]="isAdmin"></issues-panel>
</div>
<mat-accordion id="requests-panel">
<mat-expansion-panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class TvDetailsComponent implements OnInit {
public async issue() {
const dialogRef = this.dialog.open(NewIssueComponent, {
width: '500px',
data: { requestId: this.tvRequest ? this.tv.requestId : null, requestType: RequestType.tvShow, providerId: this.tv.theTvDbId, title: this.tv.title }
data: { requestId: this.tvRequest ? this.tv.requestId : null, requestType: RequestType.tvShow, providerId: this.tv.id, title: this.tv.title, posterPath: this.tv.images.original }
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/Ombi/ClientApp/src/app/shared/issues-report.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, EventEmitter, Input, Output } from "@angular/core";

import { IIssueCategory, IIssues, IssueStatus, RequestType } from "../interfaces";
import { IssuesService, NotificationService } from "../services";

Expand Down Expand Up @@ -44,6 +43,7 @@ export class IssuesReportComponent {
title: "",
providerId: "",
userReported: undefined,
posterPath: undefined
};
}

Expand All @@ -55,6 +55,7 @@ export class IssuesReportComponent {
issue.issueCategoryId = this.issueCategory.id;
issue.title = this.title;
issue.providerId = this.providerId;
issue.posterPath = this.posterPath;
if (this.movie) {
issue.requestType = RequestType.movie;
} else {
Expand Down
23 changes: 12 additions & 11 deletions src/Ombi/Controllers/V1/IssuesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ public async Task<IssueComments> AddComment([FromBody] NewIssueCommentViewModel

var isAdmin = await _userManager.IsInRoleAsync(user, OmbiRoles.Admin) || user.IsSystemUser;
AddIssueNotificationSubstitutes(notificationModel, issue, user.UserName, user.UserAlias);
notificationModel.Substitutes.Add("NewIssueComment", comment.Comment);
notificationModel.Substitutes.Add("IssueId", comment.IssueId.ToString());
notificationModel.Substitutes.Add("AdminComment", isAdmin.ToString());
notificationModel.Substitutes.Add(NotificationSubstitues.NewIssueComment, comment.Comment);
notificationModel.Substitutes.Add(NotificationSubstitues.IssueId, comment.IssueId.ToString());
notificationModel.Substitutes.Add(NotificationSubstitues.AdminComment, isAdmin.ToString());

if (isAdmin)
{
Expand Down Expand Up @@ -331,14 +331,15 @@ public async Task<bool> UpdateStatus([FromBody] IssueStateViewModel model)

private static void AddIssueNotificationSubstitutes(NotificationOptions notificationModel, Issues issue, string issueReportedUsername, string alias)
{
notificationModel.Substitutes.Add("Title", issue.Title);
notificationModel.Substitutes.Add("IssueDescription", issue.Description);
notificationModel.Substitutes.Add("IssueCategory", issue.IssueCategory?.Value);
notificationModel.Substitutes.Add("IssueStatus", issue.Status.ToString());
notificationModel.Substitutes.Add("IssueSubject", issue.Subject);
notificationModel.Substitutes.Add("IssueUser", issueReportedUsername);
notificationModel.Substitutes.Add("IssueUserAlias", alias);
notificationModel.Substitutes.Add("RequestType", notificationModel.RequestType.ToString());
notificationModel.Substitutes.Add(NotificationSubstitues.Title, issue.Title);
notificationModel.Substitutes.Add(NotificationSubstitues.IssueDescription, issue.Description);
notificationModel.Substitutes.Add(NotificationSubstitues.IssueCategory, issue.IssueCategory?.Value);
notificationModel.Substitutes.Add(NotificationSubstitues.IssueStatus, issue.Status.ToString());
notificationModel.Substitutes.Add(NotificationSubstitues.IssueSubject, issue.Subject);
notificationModel.Substitutes.Add(NotificationSubstitues.IssueUser, issueReportedUsername);
notificationModel.Substitutes.Add(NotificationSubstitues.IssueUserAlias, alias);
notificationModel.Substitutes.Add(NotificationSubstitues.RequestType, notificationModel.RequestType.ToString());
notificationModel.Substitutes.Add(NotificationSubstitues.PosterPath, issue.PosterPath);
}
}
}

0 comments on commit f16c4e0

Please sign in to comment.