safesight-control/internal/web/ui/templates/system.html

117 lines
4.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.

{{define "system"}}
<div class="card">
<h2 class="title-with-icon">{{icon "heartbeat"}}<span>本机时间</span></h2>
<div class="info-list compact-list">
<div><span>当前时间</span><strong id="local-time">--</strong></div>
</div>
</div>
<div class="detail-grid">
<div class="card">
<h2 class="title-with-icon">{{icon "heartbeat"}}<span>服务状态</span></h2>
<div class="info-list compact-list">
<div><span>管理后台</span><strong id="svc-status">检测中…</strong></div>
<div><span>接口状态</span><strong id="api-status">检测中…</strong></div>
</div>
<div class="actions" style="margin-top:12px">
<button class="btn ghost" type="button" id="btn-refresh">刷新</button>
</div>
</div>
<div class="card">
<h2 class="title-with-icon">{{icon "system"}}<span>系统配置</span></h2>
<form method="post" action="/system/config">
<div class="field-grid">
<label><span>告警保留天数</span><input type="number" name="alarm_retention_days" value="{{.SystemAlarmRetention}}" min="0" /><div class="form-hint">0=永久保留</div></label>
<label><span>公司名称</span><input type="text" name="company_name" value="{{.SystemCompanyName}}" placeholder="将在页面底部显示" /></label>
<label><span>时间同步阈值(秒)</span><input type="number" name="time_sync_threshold_sec" value="{{.TimeSyncThreshold}}" min="1" /><div class="form-hint">偏差超此值显示角标默认5秒</div></label>
</div>
<div class="actions" style="margin-top:12px">
<button type="submit" class="secondary">保存配置</button>
</div>
</form>
</div>
</div>
<div class="detail-grid">
<div class="card">
<h2 class="title-with-icon">{{icon "audit"}}<span>数据备份</span></h2>
<div class="info-list compact-list">
<div><span>数据库文件</span><strong class="mono">{{if .DBPath}}{{.DBPath}}{{else}}未配置{{end}}</strong></div>
</div>
<div class="actions" style="margin-top:12px">
<button type="button" class="btn ghost js-export-db" data-export-url="/system/db-backup" data-default-filename="app.db">备份数据库</button>
</div>
</div>
<div class="card">
<h2 class="title-with-icon">{{icon "apply"}}<span>数据恢复</span></h2>
<form method="post" action="/system/db-restore" enctype="multipart/form-data">
<div class="field-grid">
<label class="full"><span>选择备份文件</span><input type="file" name="file" accept=".db,application/octet-stream" required /></label>
</div>
<div class="actions" style="margin-top:12px">
<button type="submit" class="secondary">恢复数据库</button>
</div>
</form>
</div>
</div>
<script>
(function() {
var svcEl = document.getElementById("svc-status");
var apiEl = document.getElementById("api-status");
function check() {
svcEl.textContent = "检测中…";
svcEl.style.color = "";
apiEl.textContent = "检测中…";
apiEl.style.color = "";
fetch("/health")
.then(function(r) { return r.text(); })
.then(function(t) {
if (t.indexOf("ok") !== -1) {
svcEl.textContent = "运行正常";
svcEl.style.color = "var(--green)";
} else {
svcEl.textContent = "异常";
svcEl.style.color = "var(--danger-soft-text)";
}
})
.catch(function() {
svcEl.textContent = "无法连接";
svcEl.style.color = "var(--danger-soft-text)";
});
fetch("/openapi.json")
.then(function(r) {
if (r.ok) {
apiEl.textContent = "正常";
apiEl.style.color = "var(--green)";
} else {
apiEl.textContent = "异常 (" + r.status + ")";
apiEl.style.color = "var(--danger-soft-text)";
}
})
.catch(function() {
apiEl.textContent = "无法连接";
apiEl.style.color = "var(--danger-soft-text)";
});
}
document.getElementById("btn-refresh").addEventListener("click", check);
check();
function updateTime() {
var now = new Date();
var s = now.getFullYear() + '-' +
String(now.getMonth()+1).padStart(2,'0') + '-' +
String(now.getDate()).padStart(2,'0') + ' ' +
String(now.getHours()).padStart(2,'0') + ':' +
String(now.getMinutes()).padStart(2,'0') + ':' +
String(now.getSeconds()).padStart(2,'0');
document.getElementById('local-time').textContent = s;
}
updateTime();
setInterval(updateTime, 1000);
})();
</script>
{{end}}