feat: landing page + logo, dev-mode banner + sync cap, non-blocking sync with progress splash
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using Asp.Versioning;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace InboxIntel.Api.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Public metadata the SPA reads on load to decide whether to show the dev
|
||||
/// banner. devMode falls back to the hosting environment when App:DevMode is
|
||||
/// unset, and can be forced on/off via the App:DevMode config / App__DevMode env.
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/v{version:apiVersion}/app")]
|
||||
public class AppInfoController : ControllerBase
|
||||
{
|
||||
private readonly IConfiguration _config;
|
||||
private readonly IWebHostEnvironment _env;
|
||||
|
||||
public AppInfoController(IConfiguration config, IWebHostEnvironment env)
|
||||
{
|
||||
_config = config;
|
||||
_env = env;
|
||||
}
|
||||
|
||||
[HttpGet("info")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult Info()
|
||||
{
|
||||
var devMode = _config.GetValue<bool?>("App:DevMode") ?? _env.IsDevelopment();
|
||||
return Ok(new
|
||||
{
|
||||
environment = _env.EnvironmentName,
|
||||
devMode,
|
||||
maxMessages = _config.GetValue<int>("GmailSync:MaxMessages")
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -10,20 +10,21 @@ public class SyncController : ApiControllerBase
|
||||
|
||||
[HttpGet("status")]
|
||||
public async Task<IActionResult> Status(CancellationToken ct)
|
||||
=> Ok(new { status = (await _sync.GetStatusAsync(UserId, ct)).ToString() });
|
||||
=> Ok(await _sync.GetProgressAsync(UserId, ct));
|
||||
|
||||
/// <summary>Triggers a full inbox sync (runs in the background task queue in production).</summary>
|
||||
/// <summary>Queues a full inbox sync. Returns immediately; poll /sync/status for progress.</summary>
|
||||
[HttpPost("full")]
|
||||
public async Task<IActionResult> Full(CancellationToken ct)
|
||||
{
|
||||
await _sync.RunFullSyncAsync(UserId, ct);
|
||||
await _sync.QueueSyncAsync(UserId, fullSync: true, ct);
|
||||
return Accepted();
|
||||
}
|
||||
|
||||
/// <summary>Queues an incremental sync (becomes a full sync on first run).</summary>
|
||||
[HttpPost("incremental")]
|
||||
public async Task<IActionResult> Incremental(CancellationToken ct)
|
||||
{
|
||||
await _sync.RunIncrementalSyncAsync(UserId, ct);
|
||||
await _sync.QueueSyncAsync(UserId, fullSync: false, ct);
|
||||
return Accepted();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user