Files
gold_monitor/app/templates/machines.html
T

80 lines
3.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "base.html" %}
{% block title %}机器 · {{ app_name }}{% endblock %}
{% block content %}
<h2 style="margin:0 0 6px">机器{% if is_admin %}(管理员可预登记){% else %}(与本账户相关){% endif %}</h2>
<p class="muted" style="margin:0 0 14px">
正常用法:不必预登记,客户端激活时会自动创建机器并绑定指纹。
「未绑定 / 无指纹」多为早期占位或预登记未使用,管理员可删除。
</p>
<div class="grid cols-2">
{% if is_admin %}
<div class="card">
<h3>预登记机器(可选)</h3>
<p class="muted">一般可跳过。仅当需要先占名、再发激活码预绑定时使用。</p>
<form method="post" action="{{ url_for('machines_create') }}">
<div class="form-row"><label>名称</label><input name="name" placeholder="如:书房台式机"></div>
<div class="form-row"><label>标注</label><textarea name="note" rows="2"></textarea></div>
<button class="btn" type="submit">添加</button>
</form>
</div>
{% endif %}
<div class="card" {% if not is_admin %}style="grid-column:1/-1"{% endif %}>
<h3>已有机器</h3>
<table>
<thead>
<tr>
<th>名称 / 指纹</th>
<th>状态</th>
<th>最近心跳</th>
<th>标注</th>
{% if is_admin %}<th></th>{% endif %}
</tr>
</thead>
<tbody>
{% for m in items %}
<tr>
<td>
{% if is_admin %}
<form method="post" action="{{ url_for('machines_note', mid=m.id) }}">
<div class="muted" style="margin-bottom:4px">#{{ m.id }}</div>
<input name="name" value="{{ m.name }}" style="margin-bottom:6px">
<div class="muted">{{ m.device_fingerprint or '尚未绑定指纹' }}</div>
{% if not m.bound %}<div class="muted" style="margin-top:4px">预登记 / 占位,激活后才会出现指纹</div>{% endif %}
<textarea name="note" rows="2" style="margin-top:6px" placeholder="备注">{{ m.note or '' }}</textarea>
<button class="btn secondary" style="margin-top:6px" type="submit">保存</button>
</form>
{% else %}
<div>{{ m.name }} <span class="muted">#{{ m.id }}</span></div>
<div class="muted">{{ m.device_fingerprint or '尚未绑定指纹' }}</div>
{% if m.note %}<div class="muted" style="margin-top:6px">{{ m.note }}</div>{% endif %}
{% endif %}
</td>
<td>
{% if m.online %}
<span class="tag green">在线</span>
{% elif m.bound %}
<span class="tag gray">离线</span>
{% else %}
<span class="tag gray">未绑定</span>
{% endif %}
</td>
<td class="muted">{{ m.last_seen_fmt }}</td>
<td class="muted">{{ m.note or '—' }}</td>
{% if is_admin %}
<td>
<form method="post" action="{{ url_for('machines_delete', mid=m.id) }}"
onsubmit="return confirm('确认删除机器 #{{ m.id }} {{ m.name }}?');">
<button class="btn secondary" type="submit" {% if m.online %}disabled title="在线中不可删"{% endif %}>删除</button>
</form>
</td>
{% endif %}
</tr>
{% else %}
<tr><td colspan="{% if is_admin %}5{% else %}4{% endif %}" class="muted">暂无机器。客户端首次激活后会出现在此。</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}