summaryrefslogtreecommitdiff
path: root/src/marlin.web/Views
diff options
context:
space:
mode:
Diffstat (limited to 'src/marlin.web/Views')
-rw-r--r--src/marlin.web/Views/Jobs/Details.cshtml5
-rw-r--r--src/marlin.web/Views/Jobs/List.cshtml4
-rw-r--r--src/marlin.web/Views/Jobs/Spawn.cshtml56
-rw-r--r--src/marlin.web/Views/Shared/_Layout.cshtml5
-rw-r--r--src/marlin.web/Views/VCS/Create.cshtml8
-rw-r--r--src/marlin.web/Views/VCS/CreateSecret.cshtml12
-rw-r--r--src/marlin.web/Views/VCS/Details.cshtml44
-rw-r--r--src/marlin.web/Views/VCS/List.cshtml2
-rw-r--r--src/marlin.web/Views/VCS/ListSecret.cshtml45
9 files changed, 168 insertions, 13 deletions
diff --git a/src/marlin.web/Views/Jobs/Details.cshtml b/src/marlin.web/Views/Jobs/Details.cshtml
new file mode 100644
index 0000000..e1fd184
--- /dev/null
+++ b/src/marlin.web/Views/Jobs/Details.cshtml
@@ -0,0 +1,5 @@
+@model marlin.core.models.Job
+
+@Model.Id
+
+<a asp-action="List">Back</a> \ No newline at end of file
diff --git a/src/marlin.web/Views/Jobs/List.cshtml b/src/marlin.web/Views/Jobs/List.cshtml
index 2c10e46..6ae1d96 100644
--- a/src/marlin.web/Views/Jobs/List.cshtml
+++ b/src/marlin.web/Views/Jobs/List.cshtml
@@ -1,5 +1,7 @@
@model ICollection<marlin.core.models.Job>
+<a asp-action="Spawn">Spawn new...</a>
+
<table>
<thead>
<tr>
@@ -10,6 +12,7 @@
<th>vcs</th>
<th>branch</th>
<th>agent</th>
+ <th>created</th>
</tr>
</thead>
<tbody>
@@ -23,6 +26,7 @@
<td>@source.Source.UpstreamUrl</td>
<td>@source.Ref</td>
<td>@(source.Agent?.Name ?? "no agent assigned")</td>
+ <td>@(source.CreatedReason)</td>
</tr>
}
</tbody>
diff --git a/src/marlin.web/Views/Jobs/Spawn.cshtml b/src/marlin.web/Views/Jobs/Spawn.cshtml
new file mode 100644
index 0000000..8f7ee43
--- /dev/null
+++ b/src/marlin.web/Views/Jobs/Spawn.cshtml
@@ -0,0 +1,56 @@
+@using System.Linq
+@using System.Text.Json
+@using marlin.web.Controllers
+@model marlin.web.Controllers.JobsController.JobSpawnDetails
+
+@{
+ var sourcesJson = JsonSerializer.Serialize(Model.Sources.Select(s => new
+ {
+ id = s.Id,
+ label = s.UpstreamUrl,
+ mainBranch = s.MainBranch,
+ branches = s.Branches.Select(b => new { name = b.Name, commit = b.Commit.Hash })
+ }));
+}
+
+<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/>
+ <button type="submit">Save</button>
+</form>
+
+<script>
+ const sources = @Html.Raw(sourcesJson);
+ const vcsSelect = document.getElementById('vcs');
+ const refSelect = document.getElementById('ref');
+ const commitInput = document.getElementById('commit');
+
+ for (const s of sources) {
+ vcsSelect.add(new Option(s.label, s.id));
+ }
+
+ function currentSource() {
+ return sources.find(s => s.id === vcsSelect.value);
+ }
+
+ function populateRefs() {
+ refSelect.innerHTML = '';
+ for (const b of currentSource()?.branches ?? []) {
+ refSelect.add(new Option(b.name, b.name));
+ }
+ refSelect.value = currentSource()?.mainBranch ?? '';
+ populateCommit();
+ }
+
+ function populateCommit() {
+ const branch = currentSource()?.branches.find(b => b.name === refSelect.value);
+ commitInput.value = branch?.commit ?? '';
+ }
+
+ vcsSelect.addEventListener('change', populateRefs);
+ refSelect.addEventListener('change', populateCommit);
+
+ populateRefs();
+</script>
diff --git a/src/marlin.web/Views/Shared/_Layout.cshtml b/src/marlin.web/Views/Shared/_Layout.cshtml
index f060fcf..e8be2af 100644
--- a/src/marlin.web/Views/Shared/_Layout.cshtml
+++ b/src/marlin.web/Views/Shared/_Layout.cshtml
@@ -24,7 +24,10 @@
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
- <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
+ <a class="nav-link text-dark" asp-area="" asp-controller="VCS" asp-action="List">VCS Configuration</a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link text-dark" asp-area="" asp-controller="Jobs" asp-action="List">Jobs</a>
</li>
</ul>
</div>
diff --git a/src/marlin.web/Views/VCS/Create.cshtml b/src/marlin.web/Views/VCS/Create.cshtml
index adaa913..e04592d 100644
--- a/src/marlin.web/Views/VCS/Create.cshtml
+++ b/src/marlin.web/Views/VCS/Create.cshtml
@@ -2,10 +2,10 @@
@using marlin.core.models
<form method="post" asp-action="Create">
- URL: <input type="text" name="@nameof(VersionControlSource.UpstreamUrl)" />
- Filter: <input type="text" name="@nameof(VersionControlSource.BranchFilter)" />
- Main Branch: <input type="text" name="@nameof(VersionControlSource.MainBranch)" />
- Polling Interval: <input type="number" name="@nameof(VersionControlSource.MinPollingInterval)" />
+ URL: <input type="text" name="@nameof(VersionControlSource.UpstreamUrl)" /><br/>
+ Filter: <input type="text" name="@nameof(VersionControlSource.BranchFilter)" /><br/>
+ Main Branch: <input type="text" name="@nameof(VersionControlSource.MainBranch)" /><br/>
+ Polling Interval: <input type="number" name="@nameof(VersionControlSource.MinPollingInterval)" /><br/>
<button type="submit">Create</button>
</form>
diff --git a/src/marlin.web/Views/VCS/CreateSecret.cshtml b/src/marlin.web/Views/VCS/CreateSecret.cshtml
new file mode 100644
index 0000000..6453056
--- /dev/null
+++ b/src/marlin.web/Views/VCS/CreateSecret.cshtml
@@ -0,0 +1,12 @@
+@using marlin.core.models
+@model VersionControlSource
+
+<form method="post" asp-action="CreateSecret" asp-route-sourceId="@Model.Id">
+ Label: <input type="text" name="Label"/><br/>
+ Kind: <input type="text" name="Kind"/><br/>
+ May Reveal: <input type="checkbox" name="MayReveal" value="true"/><br/>
+ Content (JSON): <textarea name="ContentJson">{}</textarea><br/>
+ <button type="submit">Create</button>
+</form>
+
+<a asp-action="ListSecret" asp-route-sourceId="@Model.Id">Back</a>
diff --git a/src/marlin.web/Views/VCS/Details.cshtml b/src/marlin.web/Views/VCS/Details.cshtml
index 8d25472..45c1a8f 100644
--- a/src/marlin.web/Views/VCS/Details.cshtml
+++ b/src/marlin.web/Views/VCS/Details.cshtml
@@ -1,13 +1,43 @@
@using marlin.core
@using marlin.core.models
-@model marlin.core.models.VersionControlSource
+@using marlin.web.Controllers
+@model (VersionControlSource Source, List<VCSController.SecretOption> SecretOptions)
-<form method="post" asp-route-id="@Model.Id" asp-action="Edit">
- URL: <input type="text" name="@nameof(VersionControlSource.UpstreamUrl)" value="@Model.UpstreamUrl"/>
- Filter: <input type="text" name="@nameof(VersionControlSource.BranchFilter)" value="@Model.BranchFilter"/>
- Main Branch: <input type="text" name="@nameof(VersionControlSource.MainBranch)" value="@Model.MainBranch"/>
- Polling Interval: <input type="number" name="@nameof(VersionControlSource.MinPollingInterval)" value="@Model.MinPollingInterval"/>
+<form method="post" asp-route-id="@Model.Source.Id" asp-action="Edit">
+ URL: <input type="text" name="@nameof(VersionControlSource.UpstreamUrl)" value="@Model.Source.UpstreamUrl"/><br/>
+ Filter: <input type="text" name="@nameof(VersionControlSource.BranchFilter)" value="@Model.Source.BranchFilter"/><br/>
+ Main Branch: <input type="text" name="@nameof(VersionControlSource.MainBranch)" value="@Model.Source.MainBranch"/><br/>
+ Polling Interval: <input type="number" name="@nameof(VersionControlSource.MinPollingInterval)" value="@Model.Source.MinPollingInterval"/><br/>
+ Access Secret:
+ <select name="@nameof(VersionControlSource.AccessSecretId)">
+ <option value="">(none)</option>
+ @foreach (var secret in Model.SecretOptions)
+ {
+ <option value="@secret.Id" selected="@(secret.Id == Model.Source.AccessSecretId)">@secret.Label</option>
+ }
+ </select><br/>
<button type="submit">Save</button>
</form>
-<a asp-action="List">Back</a> \ No newline at end of file
+<table>
+ <thead>
+ <tr>
+ <th></th>
+ <th>branch</th>
+ <th>commit</th>
+ </tr>
+ </thead>
+ <tbody>
+ @foreach (var branch in Model.Source.Branches)
+ {
+ <tr>
+ <td>@(branch.Name == Model.Source.MainBranch ? "@" : "")</td>
+ <td>@branch.Name</td>
+ <td>@branch.Commit.Hash</td>
+ </tr>
+ }
+ </tbody>
+</table>
+
+<a asp-action="ListSecret" asp-route-sourceId="@Model.Source.Id">Secrets</a>
+<a asp-action="List">Back</a>
diff --git a/src/marlin.web/Views/VCS/List.cshtml b/src/marlin.web/Views/VCS/List.cshtml
index 90c3f48..4c248e4 100644
--- a/src/marlin.web/Views/VCS/List.cshtml
+++ b/src/marlin.web/Views/VCS/List.cshtml
@@ -1,4 +1,4 @@
-@model IReadOnlyList<marlin.core.models.VersionControlSource>
+@model ICollection<marlin.core.models.VersionControlSource>
<a asp-action="Create">New</a>
diff --git a/src/marlin.web/Views/VCS/ListSecret.cshtml b/src/marlin.web/Views/VCS/ListSecret.cshtml
new file mode 100644
index 0000000..aa5f15c
--- /dev/null
+++ b/src/marlin.web/Views/VCS/ListSecret.cshtml
@@ -0,0 +1,45 @@
+@model (marlin.core.models.VersionControlSource Source, List<ISecret> Secrets)
+
+<a asp-action="CreateSecret" asp-route-sourceId="@Model.Source.Id">New</a>
+
+<table>
+ <thead>
+ <tr>
+ <th>id</th>
+ <th>label</th>
+ <th>kind</th>
+ <th>value</th>
+ <th>actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ @foreach (var secret in Model.Secrets)
+ {
+ <tr>
+ <td>@secret.Id</td>
+ <td>@secret.Label</td>
+ <td>@secret.Kind</td>
+ <td>
+ @if (secret.MayReveal)
+ {
+ @foreach (var pair in secret.Content)
+ {
+ <span>@pair.Key = @pair.Value</span>
+ }
+ }
+ else
+ {
+ <span>secret cannot be revealed</span>
+ }
+ </td>
+ <td>
+ <form asp-action="DeleteSecret" method="post" asp-route-sourceId="@Model.Source.Id" asp-route-id="@secret.Id">
+ <button type="submit">delete</button>
+ </form>
+ </td>
+ </tr>
+ }
+ </tbody>
+</table>
+
+<a asp-action="Details", asp-route-id="@Model.Source.Id">back</a>