summaryrefslogtreecommitdiff
path: root/src/marlin.web/Controllers/JobsController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/marlin.web/Controllers/JobsController.cs')
-rw-r--r--src/marlin.web/Controllers/JobsController.cs31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/marlin.web/Controllers/JobsController.cs b/src/marlin.web/Controllers/JobsController.cs
index 1cfdadb..c86cb2d 100644
--- a/src/marlin.web/Controllers/JobsController.cs
+++ b/src/marlin.web/Controllers/JobsController.cs
@@ -30,10 +30,23 @@ public class JobsController(ApplicationDbContext dbContext) : Controller
return this.View(results);
}
+ public record JobSpawnDetails(
+ ICollection<VersionControlSource> Sources,
+ Guid? Vcs = null,
+ string? Ref = null,
+ string? Commit = null,
+ string? Recipe = null);
+
[HttpGet("spawn")]
- public async Task<IActionResult> Spawn()
+ public async Task<IActionResult> Spawn(CancellationToken ct)
{
- return this.View();
+ var sources = await dbContext.Sources
+ .Include(x => x.Branches)
+ .ThenInclude(x => x.Commit)
+ .ToListAsync(ct);
+
+ var details = new JobSpawnDetails(sources);
+ return this.View(details);
}
public record JobSpawnRequest(Guid Vcs, string Ref, string Commit, string Recipe);
@@ -62,4 +75,18 @@ public class JobsController(ApplicationDbContext dbContext) : Controller
// cancel job
// details job (recipe, status, agent, target, plan, log, artifacts)
+ [HttpGet("details/{id}")]
+ public async Task<IActionResult> Details(Guid id)
+ {
+ var job = await dbContext.Jobs
+ .Include(x => x.Agent)
+ .Include(x => x.Source)
+ .Include(x => x.StatusUpdates)
+ .FirstOrDefaultAsync(x => x.Id == id);
+
+ if (job == null)
+ return this.NotFound();
+
+ return this.View(job);
+ }
} \ No newline at end of file