mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 03:28:28 -07:00
Made a start on the issues rework
This commit is contained in:
parent
23705d5069
commit
b7bb0869da
11 changed files with 139 additions and 35 deletions
59
src/Ombi.Core/Engine/V2/IssuesEngine.cs
Normal file
59
src/Ombi.Core/Engine/V2/IssuesEngine.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Ombi.Store.Repository;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ombi.Core.Engine.V2
|
||||
{
|
||||
|
||||
public interface IIssuesEngine
|
||||
{
|
||||
Task<IEnumerable<IssuesSummaryModel>> GetIssues(int position, int take, IssueStatus status);
|
||||
}
|
||||
|
||||
public class IssuesEngine : IIssuesEngine
|
||||
{
|
||||
private readonly IRepository<IssueCategory> _categories;
|
||||
private readonly IRepository<Issues> _issues;
|
||||
private readonly IRepository<IssueComments> _comments;
|
||||
|
||||
public IssuesEngine(IRepository<IssueCategory> categories,
|
||||
IRepository<Issues> issues,
|
||||
IRepository<IssueComments> comments)
|
||||
{
|
||||
_categories = categories;
|
||||
_issues = issues;
|
||||
_comments = comments;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<IssuesSummaryModel>> GetIssues(int position, int take, IssueStatus status)
|
||||
{
|
||||
var issues = await _issues.GetAll().Where(x => x.Status == status).Skip(position).Take(take).ToListAsync();
|
||||
var grouped = issues.GroupBy(x => x.Title, (key, g) => new { Title = key, Issues = g });
|
||||
|
||||
var model = new List<IssuesSummaryModel>();
|
||||
|
||||
foreach(var group in grouped)
|
||||
{
|
||||
model.Add(new IssuesSummaryModel
|
||||
{
|
||||
Count = group.Issues.Count(),
|
||||
Title = group.Title,
|
||||
Issues = group.Issues
|
||||
});
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class IssuesSummaryModel
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public int Count { get; set; }
|
||||
public IEnumerable<Issues> Issues { get; set; }
|
||||
}
|
||||
}
|
|
@ -114,6 +114,7 @@ namespace Ombi.DependencyInjection
|
|||
services.AddTransient<ITVSearchEngineV2, TvSearchEngineV2>();
|
||||
services.AddTransient<ICalendarEngine, CalendarEngine>();
|
||||
services.AddTransient<IMusicSearchEngineV2, MusicSearchEngineV2>();
|
||||
services.AddTransient<IIssuesEngine, IssuesEngine>();
|
||||
}
|
||||
|
||||
public static void RegisterHttp(this IServiceCollection services)
|
||||
|
|
|
@ -124,5 +124,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"defaultProject": "ombi"
|
||||
"defaultProject": "ombi",
|
||||
"cli": {
|
||||
"analytics": false
|
||||
}
|
||||
}
|
|
@ -62,3 +62,9 @@ export interface IUpdateStatus {
|
|||
issueId: number;
|
||||
status: IssueStatus;
|
||||
}
|
||||
|
||||
export interface IIssuesSummary {
|
||||
title: string;
|
||||
count: number;
|
||||
issues: IIssues[];
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
import { AuthGuard } from "../../auth/auth.guard";
|
||||
import { IssuesListComponent } from "./issues-list/issues-list.component";
|
||||
import { Routes } from "@angular/router";
|
||||
import { IssuesV2Service } from "../../services/issuesv2.service";
|
||||
import { IdentityService, SearchService } from "../../services";
|
||||
|
||||
|
||||
|
||||
|
@ -13,6 +15,9 @@ export const entryComponents: any[] = [
|
|||
];
|
||||
|
||||
export const providers: any[] = [
|
||||
IssuesV2Service,
|
||||
IdentityService,
|
||||
SearchService,
|
||||
];
|
||||
|
||||
export const routes: Routes = [
|
||||
|
|
|
@ -2,9 +2,10 @@ import { Component, OnInit } from "@angular/core";
|
|||
|
||||
import { IssuesService } from "../services";
|
||||
|
||||
import { IIssueCount, IIssues, IPagenator, IssueStatus } from "../interfaces";
|
||||
import { IIssueCount, IIssues, IIssuesSummary, IPagenator, IssueStatus } from "../interfaces";
|
||||
|
||||
import { PageEvent } from '@angular/material/paginator';
|
||||
import { IssuesV2Service } from "../services/issuesv2.service";
|
||||
|
||||
@Component({
|
||||
templateUrl: "issues.component.html",
|
||||
|
@ -12,9 +13,9 @@ import { PageEvent } from '@angular/material/paginator';
|
|||
})
|
||||
export class IssuesComponent implements OnInit {
|
||||
|
||||
public pendingIssues: IIssues[];
|
||||
public inProgressIssues: IIssues[];
|
||||
public resolvedIssues: IIssues[];
|
||||
public pendingIssues: IIssuesSummary[];
|
||||
public inProgressIssues: IIssuesSummary[];
|
||||
public resolvedIssues: IIssuesSummary[];
|
||||
|
||||
public count: IIssueCount;
|
||||
|
||||
|
@ -23,7 +24,7 @@ export class IssuesComponent implements OnInit {
|
|||
private inProgressSkip = 0;
|
||||
private resolvedSkip = 0;
|
||||
|
||||
constructor(private issueService: IssuesService) { }
|
||||
constructor(private issuev2Service: IssuesV2Service, private issueService: IssuesService) { }
|
||||
|
||||
public ngOnInit() {
|
||||
this.getPending();
|
||||
|
@ -48,19 +49,19 @@ export class IssuesComponent implements OnInit {
|
|||
}
|
||||
|
||||
private getPending() {
|
||||
this.issueService.getIssuesPage(this.takeAmount, this.pendingSkip, IssueStatus.Pending).subscribe(x => {
|
||||
this.issuev2Service.getIssues(this.pendingSkip, this.takeAmount, IssueStatus.Pending).subscribe(x => {
|
||||
this.pendingIssues = x;
|
||||
});
|
||||
}
|
||||
|
||||
private getInProg() {
|
||||
this.issueService.getIssuesPage(this.takeAmount, this.inProgressSkip, IssueStatus.InProgress).subscribe(x => {
|
||||
this.issuev2Service.getIssues(this.inProgressSkip, this.takeAmount, IssueStatus.InProgress).subscribe(x => {
|
||||
this.inProgressIssues = x;
|
||||
});
|
||||
}
|
||||
|
||||
private getResolved() {
|
||||
this.issueService.getIssuesPage(this.takeAmount, this.resolvedSkip, IssueStatus.Resolved).subscribe(x => {
|
||||
this.issuev2Service.getIssues(this.resolvedSkip, this.takeAmount, IssueStatus.Resolved).subscribe(x => {
|
||||
this.resolvedIssues = x;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@ const routes: Routes = [
|
|||
RouterModule,
|
||||
],
|
||||
providers: [
|
||||
IdentityService,
|
||||
SearchService,
|
||||
...fromComponents.providers
|
||||
],
|
||||
|
||||
})
|
||||
|
|
|
@ -6,32 +6,15 @@
|
|||
<td mat-cell *matCellDef="let element"> {{element.title}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="category">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> {{ 'Issues.Category' | translate}} </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.issueCategory.value}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="subject">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> {{ 'Issues.Subject' | translate}} </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.subject}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="status">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> {{ 'Issues.Status' | translate}} </th>
|
||||
<td mat-cell *matCellDef="let element"> {{IssueStatus[element.status] | humanize}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="reportedBy">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> {{ 'Issues.ReportedBy' | translate}} </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.userReported.userAlias}} </td>
|
||||
<ng-container matColumnDef="count">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disableClear> {{ 'Issues.Count' | translate}} </th>
|
||||
<td mat-cell *matCellDef="let element"> {{element.count}} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="actions">
|
||||
<th mat-header-cell *matHeaderCellDef> </th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<button *ngIf="element.requestType === 1" mat-raised-button color="accent" [routerLink]="'/details/movie/' + element.providerId">{{ 'Issues.Details' | translate}}</button>
|
||||
<button *ngIf="element.requestType === 0" mat-raised-button color="accent" [routerLink]="'/details/tv/' + element.providerId">{{ 'Issues.Details' | translate}}</button>
|
||||
<button *ngIf="element.requestType === 2" mat-raised-button color="accent" [routerLink]="'/details/artist/request/' + element.providerId">{{ 'Issues.Details' | translate}}</button>
|
||||
<button mat-raised-button color="accent" (click)="openDetails(element)">{{ 'Issues.Details' | translate}}</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Component, EventEmitter, Input, Output } from "@angular/core";
|
||||
|
||||
import { IIssues, IPagenator, IssueStatus } from "../interfaces";
|
||||
import { IIssues, IIssuesSummary, IPagenator, IssueStatus } from "../interfaces";
|
||||
|
||||
@Component({
|
||||
selector: "issues-table",
|
||||
|
@ -8,12 +8,12 @@ import { IIssues, IPagenator, IssueStatus } from "../interfaces";
|
|||
})
|
||||
export class IssuesTableComponent {
|
||||
|
||||
@Input() public issues: IIssues[];
|
||||
@Input() public issues: IIssuesSummary[];
|
||||
@Input() public totalRecords: number;
|
||||
|
||||
@Output() public changePage = new EventEmitter<IPagenator>();
|
||||
|
||||
public displayedColumns = ["title", "category", "subject", "status", "reportedBy", "actions"]
|
||||
public displayedColumns = ["title", "count", "actions"]
|
||||
public IssueStatus = IssueStatus;
|
||||
public resultsLength: number;
|
||||
public gridCount: string = "15";
|
||||
|
@ -49,4 +49,8 @@ export class IssuesTableComponent {
|
|||
this.changePage.emit(event);
|
||||
}
|
||||
|
||||
public openDetails(summary: IIssuesSummary) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
19
src/Ombi/ClientApp/src/app/services/issuesv2.service.ts
Normal file
19
src/Ombi/ClientApp/src/app/services/issuesv2.service.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { PlatformLocation, APP_BASE_HREF } from "@angular/common";
|
||||
import { Injectable, Inject } from "@angular/core";
|
||||
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
import { IIssueCategory, IIssueComments, IIssueCount, IIssues, IIssuesChat, IIssuesSummary, INewIssueComments, IssueStatus, IUpdateStatus } from "../interfaces";
|
||||
import { ServiceHelpers } from "./service.helpers";
|
||||
|
||||
@Injectable()
|
||||
export class IssuesV2Service extends ServiceHelpers {
|
||||
constructor(http: HttpClient, @Inject(APP_BASE_HREF) href:string) {
|
||||
super(http, "/api/v2/Issues/", href);
|
||||
}
|
||||
|
||||
public getIssues(position: number, take: number, status: IssueStatus): Observable<IIssuesSummary[]> {
|
||||
return this.http.get<IIssuesSummary[]>(`${this.url}${position}/${take}/${status}`, {headers: this.headers});
|
||||
}
|
||||
}
|
24
src/Ombi/Controllers/V2/IssuesController.cs
Normal file
24
src/Ombi/Controllers/V2/IssuesController.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Ombi.Core.Engine.V2;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ombi.Controllers.V2
|
||||
{
|
||||
public class IssuesController : V2Controller
|
||||
{
|
||||
private readonly IIssuesEngine _engine;
|
||||
|
||||
public IssuesController(IIssuesEngine engine)
|
||||
{
|
||||
_engine = engine;
|
||||
}
|
||||
|
||||
[HttpGet("{position}/{take}/{status}")]
|
||||
public Task<IEnumerable<IssuesSummaryModel>> GetIssuesSummary(int position, int take, IssueStatus status)
|
||||
{
|
||||
return _engine.GetIssues(position, take, status);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue