[FA-misc] Reporting service now has a status page on the frontend
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
using FictionArchive.Service.ReportingService.Models;
|
||||
using FictionArchive.Service.ReportingService.Services;
|
||||
using HotChocolate.Authorization;
|
||||
using HotChocolate.Data;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.GraphQL;
|
||||
|
||||
[QueryType]
|
||||
public static class JobQueries
|
||||
{
|
||||
[UseProjection]
|
||||
[Authorize]
|
||||
[UseFirstOrDefault]
|
||||
public static IQueryable<Job> GetJobById(
|
||||
Guid jobId,
|
||||
ReportingDbContext db)
|
||||
=> db.Jobs.Where(j => j.Id == jobId);
|
||||
|
||||
[UsePaging]
|
||||
[UseProjection]
|
||||
[UseFiltering]
|
||||
[UseSorting]
|
||||
[Authorize]
|
||||
public static IQueryable<Job> GetJobs(ReportingDbContext db)
|
||||
=> db.Jobs;
|
||||
}
|
||||
71
FictionArchive.Service.ReportingService/GraphQL/Query.cs
Normal file
71
FictionArchive.Service.ReportingService/GraphQL/Query.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using FictionArchive.Service.ReportingService.Models.DTOs;
|
||||
using FictionArchive.Service.ReportingService.Services;
|
||||
using HotChocolate.Authorization;
|
||||
using HotChocolate.Data;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.GraphQL;
|
||||
|
||||
public class Query
|
||||
{
|
||||
[Authorize]
|
||||
//[UseProjection]
|
||||
[UseFirstOrDefault]
|
||||
public IQueryable<JobDto> GetJobById(
|
||||
Guid jobId,
|
||||
ReportingDbContext db)
|
||||
=> db.Jobs.Where(j => j.Id == jobId).Select(j => new JobDto
|
||||
{
|
||||
Id = j.Id,
|
||||
CreatedTime = j.CreatedTime,
|
||||
LastUpdatedTime = j.LastUpdatedTime,
|
||||
ParentJobId = j.ParentJobId,
|
||||
JobType = j.JobType,
|
||||
DisplayName = j.DisplayName,
|
||||
Status = j.Status,
|
||||
ErrorMessage = j.ErrorMessage,
|
||||
Metadata = j.Metadata,
|
||||
ChildJobs = j.ChildJobs.Select(c => new JobDto
|
||||
{
|
||||
Id = c.Id,
|
||||
CreatedTime = c.CreatedTime,
|
||||
LastUpdatedTime = c.LastUpdatedTime,
|
||||
ParentJobId = c.ParentJobId,
|
||||
JobType = c.JobType,
|
||||
DisplayName = c.DisplayName,
|
||||
Status = c.Status,
|
||||
ErrorMessage = c.ErrorMessage,
|
||||
Metadata = c.Metadata
|
||||
})
|
||||
});
|
||||
|
||||
[Authorize]
|
||||
[UsePaging]
|
||||
//[UseProjection]
|
||||
[UseFiltering]
|
||||
[UseSorting]
|
||||
public IQueryable<JobDto> GetJobs(ReportingDbContext db)
|
||||
=> db.Jobs.Select(j => new JobDto
|
||||
{
|
||||
Id = j.Id,
|
||||
CreatedTime = j.CreatedTime,
|
||||
LastUpdatedTime = j.LastUpdatedTime,
|
||||
ParentJobId = j.ParentJobId,
|
||||
JobType = j.JobType,
|
||||
DisplayName = j.DisplayName,
|
||||
Status = j.Status,
|
||||
ErrorMessage = j.ErrorMessage,
|
||||
Metadata = j.Metadata,
|
||||
ChildJobs = j.ChildJobs.Select(c => new JobDto
|
||||
{
|
||||
Id = c.Id,
|
||||
CreatedTime = c.CreatedTime,
|
||||
LastUpdatedTime = c.LastUpdatedTime,
|
||||
ParentJobId = c.ParentJobId,
|
||||
JobType = c.JobType,
|
||||
DisplayName = c.DisplayName,
|
||||
Status = c.Status,
|
||||
ErrorMessage = c.ErrorMessage,
|
||||
Metadata = c.Metadata
|
||||
})
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
using HotChocolate.Data;
|
||||
using NodaTime;
|
||||
|
||||
namespace FictionArchive.Service.ReportingService.Models.DTOs;
|
||||
|
||||
public class JobDto
|
||||
{
|
||||
public Guid Id { get; init; }
|
||||
public Instant CreatedTime { get; init; }
|
||||
public Instant LastUpdatedTime { get; init; }
|
||||
public Guid? ParentJobId { get; init; }
|
||||
public required string JobType { get; init; }
|
||||
public required string DisplayName { get; init; }
|
||||
public JobStatus Status { get; init; }
|
||||
public string? ErrorMessage { get; init; }
|
||||
public Dictionary<string, string>? Metadata { get; init; }
|
||||
public IEnumerable<JobDto>? ChildJobs { get; init; }
|
||||
}
|
||||
@@ -36,9 +36,8 @@ public class Program
|
||||
#region GraphQL
|
||||
|
||||
builder.Services.AddGraphQLServer()
|
||||
.AddQueryConventions()
|
||||
.AddTypeExtension(typeof(JobQueries))
|
||||
.ApplySaneDefaults()
|
||||
.AddQueryType<Query>()
|
||||
.AddAuthorization();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "graphql",
|
||||
"applicationUrl": "https://localhost:7310;http://localhost:5140",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"subgraph": "Reporting",
|
||||
"http": {
|
||||
"baseAddress": "http://localhost:5140/graphql"
|
||||
"baseAddress": "https://localhost:7310/graphql"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user