Files
package-updater/internal/master/web/templates/service.html
T

89 lines
4.7 KiB
HTML

{{define "content"}}
<h1>{{.Service.DisplayName}}</h1>
{{if .Error}}<p class="error">{{.Error}}</p>{{end}}
<table class="details">
<tr><th>Kind</th><td>{{.Service.Kind}}</td></tr>
<tr><th>Agent</th><td>{{if .Service.AgentName}}{{.Service.AgentName}}{{else}}Swarm{{end}}</td></tr>
<tr><th>Image</th><td><code>{{shortRef .Service.ActualRef}}</code></td></tr>
{{if .Service.ActualDigest}}<tr><th>Digest</th><td><code>{{.Service.ActualDigest}}</code></td></tr>{{end}}
<tr><th>Status</th><td class="status status-{{.Service.Status}}">{{.Service.Status}}</td></tr>
{{if .Service.DesiredRef}}<tr><th>Desired image</th><td><code>{{shortRef .Service.DesiredRef}}</code></td></tr>{{end}}
{{if .Service.AvailableRef}}<tr><th>Available</th><td><code>{{.Service.AvailableRef}}</code> <span class="muted">via {{.Service.AvailableSource}}{{with .Service.AvailableAt}}, {{.Format "2006-01-02 15:04"}}{{end}}</span></td></tr>{{end}}
{{if .NewerTag}}<tr><th>Newer tag</th><td><code>{{.Service.NewerRef}}</code> <span class="muted">from the registry's tag list{{with .Service.NewerAt}}, {{.Format "2006-01-02 15:04"}}{{end}}; deploy it from Versions</span></td></tr>{{end}}
<tr><th>Mode</th><td>{{.Service.UpdateMode}}</td></tr>
<tr><th>Polling</th><td{{if .PollFailed}} class="error"{{end}}>{{.Polling}}</td></tr>
{{if .ConfigFiles}}<tr><th>Config files</th><td>{{range .ConfigFiles}}<code>{{.}}</code><br>{{end}}</td></tr>{{end}}
</table>
{{if .Reason}}
<p>Update unavailable: {{.Reason}}.</p>
{{else}}
<form method="post" action="/services/{{.Service.ID}}/update">
<input type="hidden" name="csrf_token" value="{{.CSRF}}">
<button type="submit">Update</button>
</form>
<p class="muted">Pulls the current tag again and redeploys the service.</p>
{{end}}
<form method="post" action="/services/{{.Service.ID}}/poll">
<input type="hidden" name="csrf_token" value="{{.CSRF}}">
<button type="submit"{{if .PollBlocked}} disabled{{end}}>Check now</button>
<p class="muted">{{if .PollBlocked}}Check unavailable: {{.PollBlocked}}.{{else}}Asks the registry now instead of waiting for the next poll.{{end}}</p>
</form>
<form method="post" action="/services/{{.Service.ID}}/mode">
<input type="hidden" name="csrf_token" value="{{.CSRF}}">
{{if eq .Service.UpdateMode "auto"}}<input type="hidden" name="mode" value="manual">
<button type="submit">Make manual</button>
<p class="muted">The webhook will only mark new versions as available.</p>
{{else}}<input type="hidden" name="mode" value="auto">
<button type="submit"{{if .AutoBlocked}} disabled{{end}}>Make auto</button>
<p class="muted">{{if .AutoBlocked}}Auto unavailable: {{.AutoBlocked}}.{{else}}The webhook will update this service as soon as CI pushes a new image.{{end}}</p>
{{end}}
</form>
<h2>Versions</h2>
{{if eq .Service.UpdateMode "auto"}}<p class="warning">This service is in auto mode: a version picked here is replaced again when a newer version is announced or found by polling.</p>{{end}}
<table>
<thead><tr><th>Version</th><th>Seen via</th><th>First seen</th><th></th></tr></thead>
<tbody>
{{range .Versions}}
<tr>
<td><code title="{{.Ref}}">{{shortRef .Ref}}</code>{{if .Running}} <span class="badge">running</span>{{end}}{{if not .Tag}} <span class="muted">the service will follow no tag afterwards</span>{{end}}</td>
<td>{{.Source}}</td>
<td>{{.FirstSeenAt.Format "2006-01-02 15:04"}}</td>
{{/* AutoBlocked is the same check that decides whether the service can be updated with an explicit ref, which is what a pick is. */}}
<td>{{if not $.AutoBlocked}}
<form method="post" action="/services/{{$.Service.ID}}/update">
<input type="hidden" name="csrf_token" value="{{$.CSRF}}">
<input type="hidden" name="version" value="{{.ID}}">
<button type="submit">Deploy</button>
</form>{{end}}</td>
</tr>
{{else}}
<tr><td colspan="4">No versions seen yet.</td></tr>
{{end}}
</tbody>
</table>
<h2>Update history</h2>
<div id="history" hx-get="/fragments/services/{{.Service.ID}}/jobs" hx-trigger="sse:jobs" hx-swap="innerHTML">
{{template "history" .}}
</div>
{{end}}
{{define "history"}}
<table>
<thead><tr><th>Job</th><th>Status</th><th>From → to</th><th>Requested by</th><th>Created</th><th>Duration</th></tr></thead>
<tbody>
{{range .Jobs}}
<tr>
<td><a href="/jobs/{{.ID}}">#{{.ID}}</a></td>
<td class="status status-job-{{.Status}}">{{.Status}}</td>
<td><code>{{shortRef .FromRef}}</code> → <code>{{shortRef .ToRef}}</code></td>
<td>{{.RequestedBy}}</td>
<td>{{.CreatedAt.Format "2006-01-02 15:04"}}</td>
<td>{{duration .}}</td>
</tr>
{{else}}
<tr><td colspan="6">No updates yet.</td></tr>
{{end}}
</tbody>
</table>
{{end}}