Vastai-ConnectHub/app/admin/templates/job_edit.html

45 lines
1.4 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 "sqladmin/edit.html" %}
{% block content %}
{{ super() }}
<div class="card mt-3">
<div class="card-body">
<div class="row mb-3">
<label class="form-label col-sm-2 col-form-label">密文配置secret_cfg</label>
<div class="col-sm-10">
<textarea id="connecthub-secret-cfg" class="form-control" rows="8" placeholder='留空表示不修改;填写将覆盖并加密保存。示例:{"token":"xxx"}'></textarea>
<div class="form-text">
出于安全考虑,编辑页不回显历史密文。留空表示不修改;填写 JSON 对象将覆盖原值并重新加密保存。
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block tail %}
{{ super() }}
<script>
(function () {
// SQLAdmin 默认 edit 页面会渲染一个 form这里将 textarea 的值注入为隐藏字段,以便提交到后端。
const form = document.querySelector("form");
const textarea = document.getElementById("connecthub-secret-cfg");
if (!form || !textarea) return;
let hidden = form.querySelector('input[name="secret_cfg"]');
if (!hidden) {
hidden = document.createElement("input");
hidden.type = "hidden";
hidden.name = "secret_cfg";
form.appendChild(hidden);
}
form.addEventListener("submit", function () {
hidden.value = textarea.value || "";
});
})();
</script>
{% endblock %}