Compare commits
4 Commits
f170def0ea
...
agent/rex/
| Author | SHA1 | Date | |
|---|---|---|---|
| d06caeab8e | |||
| 49a9a95086 | |||
|
|
c8ca182af0 | ||
|
|
d5a85c4ed0 |
@@ -6,19 +6,13 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Exclude the separate ControlCenter sub-project from this project's compilation -->
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Remove="ControlCenter/**/*.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.14" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.14" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.4">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.4">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
namespace ControlCenter.Api.Models;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Read-only model representing an agent's current state.
|
|
||||||
/// Used as the return type from the Agent State Repository
|
|
||||||
/// to decouple consumers from the persistence layer.
|
|
||||||
/// </summary>
|
|
||||||
public class AgentState
|
|
||||||
{
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
public string Status { get; set; } = string.Empty;
|
|
||||||
public string? Task { get; set; }
|
|
||||||
public int? Progress { get; set; }
|
|
||||||
public string SessionKey { get; set; } = string.Empty;
|
|
||||||
public string Channel { get; set; } = string.Empty;
|
|
||||||
public DateTime LastActivity { get; set; }
|
|
||||||
public DateTime CreatedAt { get; set; }
|
|
||||||
public DateTime UpdatedAt { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using ControlCenter.Api.Data;
|
using ControlCenter.Api.Data;
|
||||||
using ControlCenter.Api.Hubs;
|
using ControlCenter.Api.Hubs;
|
||||||
using ControlCenter.Api.Repositories;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
@@ -11,9 +10,6 @@ builder.Services.AddOpenApi();
|
|||||||
// Register SignalR for real-time agent status updates
|
// Register SignalR for real-time agent status updates
|
||||||
builder.Services.AddSignalR();
|
builder.Services.AddSignalR();
|
||||||
|
|
||||||
// Register Agent State Repository
|
|
||||||
builder.Services.AddScoped<IAgentStateRepository, AgentStateRepository>();
|
|
||||||
|
|
||||||
// Register DbContext with PostgreSQL
|
// Register DbContext with PostgreSQL
|
||||||
builder.Services.AddDbContext<AppDbContext>(options =>
|
builder.Services.AddDbContext<AppDbContext>(options =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
using ControlCenter.Api.Data;
|
|
||||||
using ControlCenter.Api.Entities;
|
|
||||||
using ControlCenter.Api.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace ControlCenter.Api.Repositories;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// EF Core implementation of the Agent State Repository.
|
|
||||||
/// Maps between the persisted <see cref="Agent"/> entity and the
|
|
||||||
/// read-oriented <see cref="AgentState"/> model.
|
|
||||||
/// </summary>
|
|
||||||
public class AgentStateRepository : IAgentStateRepository
|
|
||||||
{
|
|
||||||
private readonly AppDbContext _db;
|
|
||||||
|
|
||||||
public AgentStateRepository(AppDbContext db)
|
|
||||||
{
|
|
||||||
_db = db;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public async Task<IReadOnlyList<AgentState>> GetAllAsync(CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
var agents = await _db.Agents
|
|
||||||
.AsNoTracking()
|
|
||||||
.OrderByDescending(a => a.LastActivity)
|
|
||||||
.ToListAsync(ct);
|
|
||||||
|
|
||||||
return agents.Select(ToModel).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public async Task<AgentState?> GetBySessionKeyAsync(string sessionKey, CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
var agent = await _db.Agents
|
|
||||||
.AsNoTracking()
|
|
||||||
.FirstOrDefaultAsync(a => a.SessionKey == sessionKey, ct);
|
|
||||||
|
|
||||||
return agent is null ? null : ToModel(agent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public async Task<bool> UpdateStatusAsync(Guid id, string status, CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
if (!Enum.TryParse<AgentStatus>(status, ignoreCase: true, out var parsedStatus))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var agent = await _db.Agents.FindAsync([id], ct);
|
|
||||||
if (agent is null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
agent.Status = parsedStatus;
|
|
||||||
agent.UpdatedAt = DateTime.UtcNow;
|
|
||||||
agent.LastActivity = DateTime.UtcNow;
|
|
||||||
|
|
||||||
await _db.SaveChangesAsync(ct);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Maps a persisted <see cref="Agent"/> entity to a <see cref="AgentState"/> model.
|
|
||||||
/// </summary>
|
|
||||||
private static AgentState ToModel(Agent agent) => new()
|
|
||||||
{
|
|
||||||
Id = agent.Id,
|
|
||||||
Status = agent.Status.ToString(),
|
|
||||||
Task = agent.Task,
|
|
||||||
Progress = agent.Progress,
|
|
||||||
SessionKey = agent.SessionKey,
|
|
||||||
Channel = agent.Channel,
|
|
||||||
LastActivity = agent.LastActivity,
|
|
||||||
CreatedAt = agent.CreatedAt,
|
|
||||||
UpdatedAt = agent.UpdatedAt,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
using ControlCenter.Api.Models;
|
|
||||||
|
|
||||||
namespace ControlCenter.Api.Repositories;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Repository interface for accessing and mutating Agent State.
|
|
||||||
/// Provides a clean abstraction over the EF Core data access layer.
|
|
||||||
/// </summary>
|
|
||||||
public interface IAgentStateRepository
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve all agent states.
|
|
||||||
/// </summary>
|
|
||||||
Task<IReadOnlyList<AgentState>> GetAllAsync(CancellationToken ct = default);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve a single agent state by its session key.
|
|
||||||
/// Returns null if no agent is found with the given session key.
|
|
||||||
/// </summary>
|
|
||||||
Task<AgentState?> GetBySessionKeyAsync(string sessionKey, CancellationToken ct = default);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update the status of an agent by its primary key.
|
|
||||||
/// Returns true if the agent was found and updated, false otherwise.
|
|
||||||
/// </summary>
|
|
||||||
Task<bool> UpdateStatusAsync(Guid id, string status, CancellationToken ct = default);
|
|
||||||
}
|
|
||||||
28
frontend/src/app/pages/hub/hub-page.component.scss
Normal file
28
frontend/src/app/pages/hub/hub-page.component.scss
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
// ============================================================================
|
||||||
|
// Hub Page — Responsive AgentCard Grid
|
||||||
|
// Desktop (≥1024px): 2×2 grid
|
||||||
|
// Mobile (<1024px): single-column stack
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
.hub-page {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
gap: 16px;
|
||||||
|
padding: var(--cc-section-padding, 16px);
|
||||||
|
min-height: 400px;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hub-page__placeholder {
|
||||||
|
color: var(--cc-on-surface-variant);
|
||||||
|
font-size: 16px;
|
||||||
|
text-align: center;
|
||||||
|
padding: 24px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desktop / kiosk breakpoint — 2-column grid
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.hub-page {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,18 +9,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|||||||
<p class="hub-page__placeholder">Command Hub — Fleet status grid will render here</p>
|
<p class="hub-page__placeholder">Command Hub — Fleet status grid will render here</p>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
styles: [`
|
styleUrl: './hub-page.component.scss',
|
||||||
.hub-page {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
min-height: 400px;
|
|
||||||
}
|
|
||||||
.hub-page__placeholder {
|
|
||||||
color: var(--cc-on-surface-variant);
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
`],
|
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class HubPageComponent {}
|
export class HubPageComponent {}
|
||||||
@@ -48,6 +48,17 @@ html {
|
|||||||
// These are NOT part of the M3 tonal palette; they are semantic overrides.
|
// These are NOT part of the M3 tonal palette; they are semantic overrides.
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
:root {
|
:root {
|
||||||
|
// --- Tactical Dark Mode color palette (CUB-47) ---
|
||||||
|
--color-surface: #0F172A;
|
||||||
|
--color-surface-light: #1E293B;
|
||||||
|
--color-primary: #38BDF8;
|
||||||
|
--color-secondary: #2DD4BF;
|
||||||
|
--color-accent: #A78BFA;
|
||||||
|
--color-danger: #F87171;
|
||||||
|
--color-text-primary: #FFFFFF;
|
||||||
|
--color-text-secondary: #94A3B8;
|
||||||
|
--color-border: #334155;
|
||||||
|
|
||||||
// --- Status colors ---
|
// --- Status colors ---
|
||||||
--status-active: #38BDF8;
|
--status-active: #38BDF8;
|
||||||
--status-idle: #2DD4BF;
|
--status-idle: #2DD4BF;
|
||||||
@@ -90,7 +101,7 @@ html {
|
|||||||
// Global Body Styles
|
// Global Body Styles
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
body {
|
body {
|
||||||
background-color: var(--cc-background);
|
background-color: var(--color-surface);
|
||||||
color: var(--cc-on-surface);
|
color: var(--cc-on-surface);
|
||||||
font-family: 'Inter', 'Roboto', sans-serif;
|
font-family: 'Inter', 'Roboto', sans-serif;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user