From 1289b840a051141f43e7beb8e3e751325c5c311d Mon Sep 17 00:00:00 2001 From: tidusjar Date: Sat, 13 Feb 2021 22:35:07 +0000 Subject: [PATCH] more wip on the issues --- src/Ombi.Core/Engine/V2/IssuesEngine.cs | 29 +++++++++-- .../details-group.component.html | 27 +++++++++++ .../details-group.component.scss | 9 ++++ .../details-group/details-group.component.ts | 48 +++++++++++++++++++ .../src/app/issues/components/index.ts | 6 +-- .../app/issues/issueDetails.component.html | 2 +- .../src/app/issues/issues.component.html | 40 +++++++--------- .../ClientApp/src/app/issues/issues.module.ts | 4 +- .../src/app/issues/issuestable.component.ts | 9 +++- src/Ombi/Controllers/V1/IssuesController.cs | 2 +- src/Ombi/Controllers/V2/IssuesController.cs | 2 +- 11 files changed, 141 insertions(+), 37 deletions(-) create mode 100644 src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.html create mode 100644 src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.scss create mode 100644 src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.ts diff --git a/src/Ombi.Core/Engine/V2/IssuesEngine.cs b/src/Ombi.Core/Engine/V2/IssuesEngine.cs index a596e7ac9..f154d0eca 100644 --- a/src/Ombi.Core/Engine/V2/IssuesEngine.cs +++ b/src/Ombi.Core/Engine/V2/IssuesEngine.cs @@ -3,6 +3,7 @@ using Ombi.Store.Entities.Requests; using Ombi.Store.Repository; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; namespace Ombi.Core.Engine.V2 @@ -10,7 +11,8 @@ namespace Ombi.Core.Engine.V2 public interface IIssuesEngine { - Task> GetIssues(int position, int take, IssueStatus status); + Task> GetIssues(int position, int take, IssueStatus status, CancellationToken token); + Task> GetIssuesByTitle(string title, CancellationToken token); } public class IssuesEngine : IIssuesEngine @@ -28,9 +30,9 @@ namespace Ombi.Core.Engine.V2 _comments = comments; } - public async Task> GetIssues(int position, int take, IssueStatus status) + public async Task> GetIssues(int position, int take, IssueStatus status, CancellationToken token) { - var issues = await _issues.GetAll().Where(x => x.Status == status).Skip(position).Take(take).ToListAsync(); + var issues = await _issues.GetAll().Include(x => x.UserReported).Include(x => x.IssueCategory).Where(x => x.Status == status).Skip(position).Take(take).OrderBy(x => x.Title).ToListAsync(token); var grouped = issues.GroupBy(x => x.Title, (key, g) => new { Title = key, Issues = g }); var model = new List(); @@ -48,6 +50,27 @@ namespace Ombi.Core.Engine.V2 return model; } + public async Task> GetIssuesByTitle(string title, CancellationToken token) + { + var lowerTitle = title.ToLowerInvariant(); + var issues = await _issues.GetAll().Include(x => x.UserReported).Include(x => x.IssueCategory).Where(x => x.Title.ToLowerInvariant() == lowerTitle).ToListAsync(token); + var grouped = issues.GroupBy(x => x.Title, (key, g) => new { Title = key, Issues = g }); + + var model = new List(); + + foreach (var group in grouped) + { + model.Add(new IssuesSummaryModel + { + Count = group.Issues.Count(), + Title = group.Title, + Issues = group.Issues + }); + } + + return model; + } + } public class IssuesSummaryModel diff --git a/src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.html b/src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.html new file mode 100644 index 000000000..7c3c04fdd --- /dev/null +++ b/src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.html @@ -0,0 +1,27 @@ +

Issues for {{data.title}}

+
+ +
+
+ + + {{issue.subject}} + {{issue.userReported?.userName}} on {{issue.createdDate | date:short}} + + +

+ {{issue.description}} +

+
+ + + + +
+
+
+
+
+ + +
diff --git a/src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.scss b/src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.scss new file mode 100644 index 000000000..d6dcd67de --- /dev/null +++ b/src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.scss @@ -0,0 +1,9 @@ +@import "~styles/variables.scss"; + +::ng-deep .mat-card { + background: $ombi-background-primary-accent; +} + +.top-spacing { + margin-top:2%; +} \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.ts b/src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.ts new file mode 100644 index 000000000..aea5eb123 --- /dev/null +++ b/src/Ombi/ClientApp/src/app/issues/components/details-group/details-group.component.ts @@ -0,0 +1,48 @@ +import { Component, Inject, OnInit } from "@angular/core"; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { AuthService } from "../../../auth/auth.service"; +import { IIssues, IIssueSettings, IssueStatus } from "../../../interfaces"; +import { SettingsService } from "../../../services"; + + +export interface IssuesDetailsGroupData { + issues: IIssues[]; + title: string; + } + +@Component({ + selector: "issues-details-group", + templateUrl: "details-group.component.html", + styleUrls: ["details-group.component.scss"], +}) +export class DetailsGroupComponent implements OnInit { + + public isAdmin: boolean; + public IssueStatus = IssueStatus; + public settings: IIssueSettings; + public get hasRequest(): boolean { + return this.data.issues.some(x => x.requestId); + } + + constructor(public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: IssuesDetailsGroupData, + private authService: AuthService, private settingsService: SettingsService) { } + + public ngOnInit() { + this.isAdmin = this.authService.hasRole("Admin") || this.authService.hasRole("PowerUser"); + this.settingsService.getIssueSettings().subscribe(x => this.settings = x); + } + + public close() { + this.dialogRef.close(); + } + + public navToRequest() { + var issue = this.data.issues.filter(x => { + return x.requestId; + })[0]; + + // close dialog and tell calling component to navigate + } + +} diff --git a/src/Ombi/ClientApp/src/app/issues/components/index.ts b/src/Ombi/ClientApp/src/app/issues/components/index.ts index 932f1eeb4..7bf8e197a 100644 --- a/src/Ombi/ClientApp/src/app/issues/components/index.ts +++ b/src/Ombi/ClientApp/src/app/issues/components/index.ts @@ -3,15 +3,13 @@ import { IssuesListComponent } from "./issues-list/issues-list.component"; import { Routes } from "@angular/router"; import { IssuesV2Service } from "../../services/issuesv2.service"; import { IdentityService, SearchService } from "../../services"; +import { DetailsGroupComponent } from "./details-group/details-group.component"; export const components: any[] = [ IssuesListComponent, -]; - - -export const entryComponents: any[] = [ + DetailsGroupComponent, ]; export const providers: any[] = [ diff --git a/src/Ombi/ClientApp/src/app/issues/issueDetails.component.html b/src/Ombi/ClientApp/src/app/issues/issueDetails.component.html index c2de76c2b..b5fc59304 100644 --- a/src/Ombi/ClientApp/src/app/issues/issueDetails.component.html +++ b/src/Ombi/ClientApp/src/app/issues/issueDetails.component.html @@ -84,7 +84,7 @@
- +
diff --git a/src/Ombi/ClientApp/src/app/issues/issues.component.html b/src/Ombi/ClientApp/src/app/issues/issues.component.html index ff8440569..4d9daeffc 100644 --- a/src/Ombi/ClientApp/src/app/issues/issues.component.html +++ b/src/Ombi/ClientApp/src/app/issues/issues.component.html @@ -1,25 +1,19 @@
- - - -
- -
-
-
- - -
- -
-
-
- - -
- -
-
-
-
+
+ +
+

{{'Issues.PendingTitle' | translate}}

+ +
+ +
+

{{'Issues.InProgressTitle' | translate}}

+ +
+ +
+

{{'Issues.ResolvedTitle' | translate}}

+ +
+
\ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/issues/issues.module.ts b/src/Ombi/ClientApp/src/app/issues/issues.module.ts index ab55f69cf..70b8a4bb1 100644 --- a/src/Ombi/ClientApp/src/app/issues/issues.module.ts +++ b/src/Ombi/ClientApp/src/app/issues/issues.module.ts @@ -3,8 +3,6 @@ import { RouterModule, Routes } from "@angular/router"; import { OrderModule } from "ngx-order-pipe"; -import { IdentityService, SearchService } from "../services"; - import { AuthGuard } from "../auth/auth.guard"; import { SharedModule as OmbiShared } from "../shared/shared.module"; @@ -27,7 +25,7 @@ const routes: Routes = [ RouterModule.forChild(routes), OrderModule, PipeModule, - OmbiShared, + OmbiShared ], declarations: [ IssuesComponent, diff --git a/src/Ombi/ClientApp/src/app/issues/issuestable.component.ts b/src/Ombi/ClientApp/src/app/issues/issuestable.component.ts index 1ad929741..7ed826fc5 100644 --- a/src/Ombi/ClientApp/src/app/issues/issuestable.component.ts +++ b/src/Ombi/ClientApp/src/app/issues/issuestable.component.ts @@ -1,6 +1,8 @@ import { Component, EventEmitter, Input, Output } from "@angular/core"; +import { MatDialog } from "@angular/material/dialog"; import { IIssues, IIssuesSummary, IPagenator, IssueStatus } from "../interfaces"; +import { DetailsGroupComponent, IssuesDetailsGroupData } from "./components/details-group/details-group.component"; @Component({ selector: "issues-table", @@ -8,6 +10,8 @@ import { IIssues, IIssuesSummary, IPagenator, IssueStatus } from "../interfaces" }) export class IssuesTableComponent { + constructor(public dialog: MatDialog) { } + @Input() public issues: IIssuesSummary[]; @Input() public totalRecords: number; @@ -50,7 +54,10 @@ export class IssuesTableComponent { } public openDetails(summary: IIssuesSummary) { - + const dialogRef = this.dialog.open(DetailsGroupComponent, { + width: "50vw", + data: { issues: summary.issues, title: summary.title }, + }); } } diff --git a/src/Ombi/Controllers/V1/IssuesController.cs b/src/Ombi/Controllers/V1/IssuesController.cs index 4dfd3781a..23b2320d1 100644 --- a/src/Ombi/Controllers/V1/IssuesController.cs +++ b/src/Ombi/Controllers/V1/IssuesController.cs @@ -142,7 +142,7 @@ namespace Ombi.Controllers.V1 var notificationModel = new NotificationOptions { RequestId = i.RequestId ?? 0, - DateTime = DateTime.Now, + DateTime = DateTime.UtcNow, NotificationType = NotificationType.Issue, RequestType = i.RequestType, Recipient = string.Empty, diff --git a/src/Ombi/Controllers/V2/IssuesController.cs b/src/Ombi/Controllers/V2/IssuesController.cs index c2b65cc99..214482b54 100644 --- a/src/Ombi/Controllers/V2/IssuesController.cs +++ b/src/Ombi/Controllers/V2/IssuesController.cs @@ -18,7 +18,7 @@ namespace Ombi.Controllers.V2 [HttpGet("{position}/{take}/{status}")] public Task> GetIssuesSummary(int position, int take, IssueStatus status) { - return _engine.GetIssues(position, take, status); + return _engine.GetIssues(position, take, status, HttpContext.RequestAborted); } } }