diff options
Diffstat (limited to 'src/marlin.web/Views/Jobs')
| -rw-r--r-- | src/marlin.web/Views/Jobs/Details.cshtml | 2 | ||||
| -rw-r--r-- | src/marlin.web/Views/Jobs/List.cshtml | 8 | ||||
| -rw-r--r-- | src/marlin.web/Views/Jobs/Spawn.cshtml | 37 |
3 files changed, 29 insertions, 18 deletions
diff --git a/src/marlin.web/Views/Jobs/Details.cshtml b/src/marlin.web/Views/Jobs/Details.cshtml index e1fd184..ebba94d 100644 --- a/src/marlin.web/Views/Jobs/Details.cshtml +++ b/src/marlin.web/Views/Jobs/Details.cshtml @@ -1,4 +1,4 @@ -@model marlin.core.models.Job +@model Job @Model.Id diff --git a/src/marlin.web/Views/Jobs/List.cshtml b/src/marlin.web/Views/Jobs/List.cshtml index 6ae1d96..968a94f 100644 --- a/src/marlin.web/Views/Jobs/List.cshtml +++ b/src/marlin.web/Views/Jobs/List.cshtml @@ -1,11 +1,10 @@ -@model ICollection<marlin.core.models.Job> +@model ICollection<Job> <a asp-action="Spawn">Spawn new...</a> <table> <thead> <tr> - <th>link</th> <th>id</th> <th>status</th> <th>recipe</th> @@ -19,12 +18,11 @@ @foreach (var source in Model) { <tr> - <td><a asp-action="Details" asp-route-id="@source.Id">open</a></td> - <td>@source.Id</td> + <td><a asp-action="Details" asp-route-id="@source.Id">@source.Id</a></td> <td>@source.Status</td> <td>@source.Recipe</td> <td>@source.Source.UpstreamUrl</td> - <td>@source.Ref</td> + <td>@source.Branch.Name</td> <td>@(source.Agent?.Name ?? "no agent assigned")</td> <td>@(source.CreatedReason)</td> </tr> diff --git a/src/marlin.web/Views/Jobs/Spawn.cshtml b/src/marlin.web/Views/Jobs/Spawn.cshtml index 8f7ee43..848cae4 100644 --- a/src/marlin.web/Views/Jobs/Spawn.cshtml +++ b/src/marlin.web/Views/Jobs/Spawn.cshtml @@ -9,15 +9,21 @@ id = s.Id, label = s.UpstreamUrl, mainBranch = s.MainBranch, - branches = s.Branches.Select(b => new { name = b.Name, commit = b.Commit.Hash }) + branches = s.Branches.Select(b => new + { + id = b.Id, + name = b.Name, + commit = b.Commit.Hash, + recipes = b.Commit.WorkflowSnapshot?.Workflow.Recipes.Values.Select(r => new { id = r.Id, name = r.Name }) + ?? Enumerable.Empty<object>() + }) })); } <form method="post" asp-action="Spawn"> VCS: <select id="vcs" name="@nameof(JobsController.JobSpawnRequest.Vcs)"></select><br/> - Ref: <select id="ref" name="@nameof(JobsController.JobSpawnRequest.Ref)"></select><br/> - Commit: <input type="text" id="commit" name="@nameof(JobsController.JobSpawnRequest.Commit)" readonly/><br/> - Recipe: <input type="text" name="@nameof(JobsController.JobSpawnRequest.Recipe)" value="@Model.Recipe"/><br/> + Ref: <select id="ref" name="@nameof(JobsController.JobSpawnRequest.Branch)"></select><br/> + Recipe: <select id="recipe" name="@nameof(JobsController.JobSpawnRequest.Recipe)"></select><br/> <button type="submit">Save</button> </form> @@ -25,7 +31,7 @@ const sources = @Html.Raw(sourcesJson); const vcsSelect = document.getElementById('vcs'); const refSelect = document.getElementById('ref'); - const commitInput = document.getElementById('commit'); + const recipeSelect = document.getElementById('recipe'); for (const s of sources) { vcsSelect.add(new Option(s.label, s.id)); @@ -35,22 +41,29 @@ return sources.find(s => s.id === vcsSelect.value); } + function currentBranch() { + return currentSource()?.branches.find(b => b.id === refSelect.value); + } + function populateRefs() { refSelect.innerHTML = ''; for (const b of currentSource()?.branches ?? []) { - refSelect.add(new Option(b.name, b.name)); + refSelect.add(new Option(b.name, b.id)); } - refSelect.value = currentSource()?.mainBranch ?? ''; - populateCommit(); + const mainBranch = currentSource()?.branches.find(b => b.name === currentSource()?.mainBranch); + refSelect.value = mainBranch?.id ?? ''; + populateRecipes(); } - function populateCommit() { - const branch = currentSource()?.branches.find(b => b.name === refSelect.value); - commitInput.value = branch?.commit ?? ''; + function populateRecipes() { + recipeSelect.innerHTML = ''; + for (const r of currentBranch()?.recipes ?? []) { + recipeSelect.add(new Option(r.name, r.id)); + } } vcsSelect.addEventListener('change', populateRefs); - refSelect.addEventListener('change', populateCommit); + refSelect.addEventListener('change', populateRecipes); populateRefs(); </script> |
