Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ Atomizer.sln.DotSettings.user
example.db*
.omc/
.claude/
.planning/
.planning/
.sisyphus/
src/Atomizer.Dashboard/frontend/node_modules/
src/Atomizer.Dashboard/frontend/dist/
7 changes: 7 additions & 0 deletions Atomizer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atomizer.EntityFrameworkCor
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atomizer.Tests.Utilities", "tests\Atomizer.Tests.Utilities\Atomizer.Tests.Utilities.csproj", "{57C7E426-4BD3-4984-9C8F-65F2F6E35852}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atomizer.Dashboard", "src\Atomizer.Dashboard\Atomizer.Dashboard.csproj", "{7284E6AE-8CD5-438E-826C-D6C8E2B58AB8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -64,6 +66,10 @@ Global
{57C7E426-4BD3-4984-9C8F-65F2F6E35852}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57C7E426-4BD3-4984-9C8F-65F2F6E35852}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57C7E426-4BD3-4984-9C8F-65F2F6E35852}.Release|Any CPU.Build.0 = Release|Any CPU
{7284E6AE-8CD5-438E-826C-D6C8E2B58AB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7284E6AE-8CD5-438E-826C-D6C8E2B58AB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7284E6AE-8CD5-438E-826C-D6C8E2B58AB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7284E6AE-8CD5-438E-826C-D6C8E2B58AB8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3FA58AFF-FFAB-4F99-BCFA-FDF7333C2615} = {57DC23B8-FC3C-41A3-AEB0-21C016F935F6}
Expand All @@ -73,5 +79,6 @@ Global
{5FF09171-46CB-4619-BCB9-48C596BB1BEC} = {7233FD90-018C-47BF-9001-EB1681DFE75B}
{7654F745-0CFE-4802-9BE6-5AB4065FBA1F} = {7233FD90-018C-47BF-9001-EB1681DFE75B}
{57C7E426-4BD3-4984-9C8F-65F2F6E35852} = {7233FD90-018C-47BF-9001-EB1681DFE75B}
{7284E6AE-8CD5-438E-826C-D6C8E2B58AB8} = {57DC23B8-FC3C-41A3-AEB0-21C016F935F6}
EndGlobalSection
EndGlobal
Empty file.
28 changes: 28 additions & 0 deletions src/Atomizer.Dashboard/Abstractions/IAtomizerDashboardStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Atomizer.Dashboard;

/// <summary>
/// Provides read-only query access to Atomizer job and schedule data for dashboard display.
/// Implement this interface to support the dashboard with a custom storage backend.
/// </summary>
public interface IAtomizerDashboardStorage
{
/// <summary>
/// Returns a paginated, filtered list of jobs ordered by creation time descending.
/// </summary>
Task<PagedResult<AtomizerJob>> GetJobsAsync(JobQuery query, CancellationToken cancellationToken);

/// <summary>
/// Returns all registered recurring schedules.
/// </summary>
Task<IReadOnlyList<AtomizerSchedule>> GetSchedulesAsync(CancellationToken cancellationToken);

/// <summary>
/// Returns all active servers (instances with a recent heartbeat).
/// </summary>
Task<IReadOnlyList<AtomizerActiveServer>> GetActiveServersAsync(CancellationToken cancellationToken);

/// <summary>
/// Returns job counts grouped by queue and status.
/// </summary>
Task<IReadOnlyList<QueueStats>> GetQueueStatsAsync(CancellationToken cancellationToken);
}
22 changes: 22 additions & 0 deletions src/Atomizer.Dashboard/Abstractions/QueueStats.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Atomizer.Dashboard;

/// <summary>
/// Job counts for a single queue, broken down by status.
/// </summary>
public sealed class QueueStats
{
/// <summary>The queue these counts apply to.</summary>
public QueueKey QueueKey { get; init; } = null!;

/// <summary>Number of jobs with status Pending.</summary>
public int Pending { get; init; }

/// <summary>Number of jobs with status Processing.</summary>
public int Processing { get; init; }

/// <summary>Number of jobs with status Completed.</summary>
public int Completed { get; init; }

/// <summary>Number of jobs with status Failed.</summary>
public int Failed { get; init; }
}
43 changes: 43 additions & 0 deletions src/Atomizer.Dashboard/Atomizer.Dashboard.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0;net10.0</TargetFrameworks>
<PackageId>Atomizer.Dashboard</PackageId>
<Description>Atomizer.Dashboard provides a real-time monitoring dashboard for Atomizer background jobs and schedules</Description>
<PackageTags>jobs;queue;scheduler;dashboard;monitoring</PackageTags>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>14</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EnablePackageValidation>true</EnablePackageValidation>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>Atomizer.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<ProjectReference Include="..\Atomizer\Atomizer.csproj" />
</ItemGroup>
<PropertyGroup>
<SpaProjectDir>$(MSBuildProjectDirectory)/frontend</SpaProjectDir>
</PropertyGroup>
<Target
Name="BuildSpa"
BeforeTargets="DispatchToInnerBuilds"
Condition=" '$(SkipSpaBuild)' != 'true' AND Exists('$(SpaProjectDir)/package.json') AND '$(TargetFramework)' == '' "
Inputs="$(SpaProjectDir)/package-lock.json;$(SpaProjectDir)/tsconfig.json;$(SpaProjectDir)/vite.config.ts"
Outputs="$(SpaProjectDir)/dist/index.html"
>
<Exec Command="node --version" ConsoleToMSBuild="true" />
<Exec Command="npm ci" WorkingDirectory="$(SpaProjectDir)" />
<Exec Command="npm run build" WorkingDirectory="$(SpaProjectDir)" />
</Target>
<ItemGroup>
<EmbeddedResource
Include="frontend/dist/**/*.*"
LogicalName="Atomizer.Dashboard.Spa.%(RecursiveDir)%(Filename)%(Extension)"
/>
</ItemGroup>
</Project>
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
80 changes: 80 additions & 0 deletions src/Atomizer.Dashboard/Storage/InMemoryDashboardStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using Atomizer.Storage;

namespace Atomizer.Dashboard.Storage;

internal sealed class InMemoryDashboardStorage : IAtomizerDashboardStorage
{
private readonly InMemoryStorage _storage;

public InMemoryDashboardStorage(InMemoryStorage storage)
{
_storage = storage;
}

public Task<PagedResult<AtomizerJob>> GetJobsAsync(JobQuery query, CancellationToken cancellationToken)
{
var take = Math.Min(query.Take, 500);

IEnumerable<AtomizerJob> jobs = _storage.GetAllJobs();

if (query.Statuses is { Count: > 0 })
jobs = jobs.Where(j => query.Statuses.Contains(j.Status));

if (query.QueueKey is not null)
jobs = jobs.Where(j => j.QueueKey == query.QueueKey);

if (query.PayloadTypeName is not null)
jobs = jobs.Where(j =>
j.PayloadType != null
&& j.PayloadType.Name.Contains(query.PayloadTypeName, StringComparison.OrdinalIgnoreCase)
);

if (query.CreatedFromUtc.HasValue)
jobs = jobs.Where(j => j.CreatedAt >= query.CreatedFromUtc.Value);

if (query.CreatedToUtc.HasValue)
jobs = jobs.Where(j => j.CreatedAt <= query.CreatedToUtc.Value);

var ordered = jobs.OrderByDescending(j => j.CreatedAt).ToList();
var total = ordered.Count;
var items = ordered.Skip(query.Skip).Take(take).ToList();

return Task.FromResult(
new PagedResult<AtomizerJob>
{
Items = items,
TotalCount = total,
Skip = query.Skip,
Take = take,
}
);
}

public Task<IReadOnlyList<AtomizerSchedule>> GetSchedulesAsync(CancellationToken cancellationToken)
{
return Task.FromResult(_storage.GetAllSchedules());
}

public Task<IReadOnlyList<AtomizerActiveServer>> GetActiveServersAsync(CancellationToken cancellationToken)
{
return Task.FromResult(_storage.GetAllServers());
}

public Task<IReadOnlyList<QueueStats>> GetQueueStatsAsync(CancellationToken cancellationToken)
{
var groups = _storage
.GetAllJobs()
.GroupBy(j => j.QueueKey)
.Select(g => new QueueStats
{
QueueKey = g.Key,
Pending = g.Count(j => j.Status == AtomizerJobStatus.Pending),
Processing = g.Count(j => j.Status == AtomizerJobStatus.Processing),
Completed = g.Count(j => j.Status == AtomizerJobStatus.Completed),
Failed = g.Count(j => j.Status == AtomizerJobStatus.Failed),
})
.ToList();

return Task.FromResult<IReadOnlyList<QueueStats>>(groups);
}
}
1 change: 1 addition & 0 deletions src/Atomizer.Dashboard/frontend/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
19 changes: 19 additions & 0 deletions src/Atomizer.Dashboard/frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="atomizer-config"
data-route-prefix="{{ROUTE_PREFIX}}"
data-title="{{TITLE}}"
data-stats-refresh-ms="{{STATS_REFRESH_MS}}"
data-jobs-refresh-ms="{{JOBS_REFRESH_MS}}"
/>
<title>{{TITLE}}</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading
Loading