Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I07f9de61588f61aae003f78c30fd6d326a6a6964
148 lines
4.3 KiB
HTML
148 lines
4.3 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}{{ project.name }} - FC CI{% endblock %}
|
|
{% block auth %}
|
|
{% if !auth_name.is_empty() %}
|
|
<span class="auth-user">{{ auth_name }}</span>
|
|
<form method="POST" action="/logout"><button type="submit">Logout</button></form>
|
|
{% else %}
|
|
<a href="/login">Login</a>
|
|
{% endif %}
|
|
{% endblock %}
|
|
{% block breadcrumbs %}
|
|
<nav class="breadcrumbs">
|
|
<a href="/">Home</a> <span class="sep">/</span>
|
|
<span class="current">{{ project.name }}</span>
|
|
</nav>
|
|
{% endblock %}
|
|
{% block content %}
|
|
<h1>{{ project.name }}</h1>
|
|
{% match project.description %}
|
|
{% when Some with (desc) %}
|
|
<p>{{ desc }}</p>
|
|
{% when None %}
|
|
{% endmatch %}
|
|
<p><strong>Repository:</strong> {{ project.repository_url }}</p>
|
|
<p><strong>Created:</strong> {{ project.created_at.format("%Y-%m-%d %H:%M") }}</p>
|
|
|
|
{% if is_admin %}
|
|
<div class="action-bar">
|
|
<button class="btn btn-danger btn-small" onclick="deleteProject()">Delete Project</button>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<h2>Jobsets</h2>
|
|
|
|
{% if is_admin %}
|
|
<details>
|
|
<summary>Add Jobset</summary>
|
|
<div class="form-card">
|
|
<form id="create-jobset-form">
|
|
<div class="form-group">
|
|
<label for="js-name">Name</label>
|
|
<input type="text" id="js-name" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="js-expr">Nix Expression</label>
|
|
<input type="text" id="js-expr" value="." required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label><input type="checkbox" id="js-flake" checked> Flake mode</label>
|
|
</div>
|
|
<button type="submit" class="btn">Add Jobset</button>
|
|
</form>
|
|
<div id="jobset-msg"></div>
|
|
</div>
|
|
</details>
|
|
{% endif %}
|
|
|
|
{% if jobsets.is_empty() %}
|
|
<div class="empty">
|
|
<div class="empty-title">No jobsets configured</div>
|
|
{% if is_admin %}
|
|
<div class="empty-hint">Add a jobset above to start evaluating this project.</div>
|
|
{% endif %}
|
|
</div>
|
|
{% else %}
|
|
<div class="table-wrap">
|
|
<table>
|
|
<thead>
|
|
<tr><th>Name</th><th>Expression</th><th>Flake</th><th>Enabled</th><th>Interval</th></tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for j in jobsets %}
|
|
<tr>
|
|
<td><a href="/jobset/{{ j.id }}">{{ j.name }}</a></td>
|
|
<td><code>{{ j.nix_expression }}</code></td>
|
|
<td>{% if j.flake_mode %}Yes{% else %}No{% endif %}</td>
|
|
<td>{% if j.enabled %}Yes{% else %}No{% endif %}</td>
|
|
<td>{{ j.check_interval }}s</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<h2>Recent Evaluations</h2>
|
|
{% if recent_evals.is_empty() %}
|
|
<div class="empty">No evaluations yet for this project.</div>
|
|
{% else %}
|
|
<div class="table-wrap">
|
|
<table>
|
|
<thead>
|
|
<tr><th>Commit</th><th>Status</th><th>Time</th></tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for e in recent_evals %}
|
|
<tr>
|
|
<td><a href="/evaluation/{{ e.id }}">{{ e.commit_short }}</a></td>
|
|
<td><span class="badge badge-{{ e.status_class }}">{{ e.status_text }}</span></td>
|
|
<td>{{ e.time }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %}
|
|
{% block scripts %}
|
|
{% if is_admin %}
|
|
<script>
|
|
document.getElementById('create-jobset-form')?.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const msg = document.getElementById('jobset-msg');
|
|
try {
|
|
const res = await fetch('/api/v1/projects/{{ project.id }}/jobsets', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({
|
|
name: document.getElementById('js-name').value,
|
|
nix_expression: document.getElementById('js-expr').value,
|
|
flake_mode: document.getElementById('js-flake').checked,
|
|
}),
|
|
});
|
|
if (!res.ok) {
|
|
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
throw new Error(err.error || err.message || 'Unknown error');
|
|
}
|
|
window.location.reload();
|
|
} catch(err) {
|
|
showError(msg, err.message);
|
|
}
|
|
});
|
|
async function deleteProject() {
|
|
if (!confirm('Delete this project and all its data?')) return;
|
|
try {
|
|
const res = await fetch('/api/v1/projects/{{ project.id }}', { method: 'DELETE' });
|
|
if (!res.ok) {
|
|
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
throw new Error(err.error || err.message || 'Failed to delete project');
|
|
}
|
|
window.location.href = '/projects';
|
|
} catch(err) {
|
|
alert(escapeHtml(err.message));
|
|
}
|
|
}
|
|
</script>
|
|
{% endif %}
|
|
{% endblock %}
|