条件单客户端勾选按 sim / live 分组,没有对应模式则不显示该组。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -635,6 +635,10 @@ def api_cond_order_candidates():
|
||||
has_pos = isinstance(brief, list) and len(brief) > 0
|
||||
locked = bool(snap.get("cond_order_locked"))
|
||||
selectable = bool(row.get("online")) and not has_pos and not locked
|
||||
inst = snap.get("instance") if isinstance(snap.get("instance"), dict) else {}
|
||||
mode = str(inst.get("mode") or "").strip().lower()
|
||||
if mode not in ("sim", "live"):
|
||||
mode = ""
|
||||
out.append(
|
||||
{
|
||||
"id": row.get("id"),
|
||||
@@ -643,6 +647,7 @@ def api_cond_order_candidates():
|
||||
"has_position": has_pos,
|
||||
"cond_order_locked": locked,
|
||||
"selectable": selectable,
|
||||
"mode": mode,
|
||||
"error": row.get("error") or "",
|
||||
}
|
||||
)
|
||||
|
||||
+61
-13
@@ -53,18 +53,12 @@
|
||||
return "st-done";
|
||||
}
|
||||
|
||||
async function loadCandidates() {
|
||||
const box = document.getElementById("cf-instances");
|
||||
if (!box) return;
|
||||
const r = await fetch("/api/cond_orders/candidates");
|
||||
const d = await r.json();
|
||||
const list = d.instances || [];
|
||||
if (!list.length) {
|
||||
box.innerHTML = '<span class="muted">暂无启用实例</span>';
|
||||
return;
|
||||
function instanceMode(it) {
|
||||
const m = String((it && it.mode) || "").toLowerCase();
|
||||
return m === "sim" || m === "live" ? m : "";
|
||||
}
|
||||
box.innerHTML = list
|
||||
.map(function (it) {
|
||||
|
||||
function renderCandidateCard(it, checkedIds) {
|
||||
const disabled = !it.selectable;
|
||||
const tip = disabled
|
||||
? it.has_position
|
||||
@@ -75,6 +69,8 @@
|
||||
? "不可选"
|
||||
: "离线"
|
||||
: "可选";
|
||||
const id = String(it.id);
|
||||
const checked = !disabled && checkedIds.indexOf(id) >= 0;
|
||||
return (
|
||||
'<label class="cond-inst' +
|
||||
(disabled ? " is-off" : "") +
|
||||
@@ -82,9 +78,10 @@
|
||||
escapeHtml(tip) +
|
||||
'">' +
|
||||
'<input type="checkbox" name="cf-inst" value="' +
|
||||
encodeURIComponent(String(it.id)) +
|
||||
encodeURIComponent(id) +
|
||||
'"' +
|
||||
(disabled ? " disabled" : "") +
|
||||
(checked ? " checked" : "") +
|
||||
">" +
|
||||
'<span class="cond-inst-name">' +
|
||||
escapeHtml(it.name || "") +
|
||||
@@ -93,8 +90,59 @@
|
||||
escapeHtml(tip) +
|
||||
"</span></label>"
|
||||
);
|
||||
}
|
||||
|
||||
function renderCandidateGroup(mode, items, checkedIds) {
|
||||
if (!items.length) return "";
|
||||
const label =
|
||||
mode === "sim" || mode === "live"
|
||||
? '<div class="cond-inst-group-label"><span class="overview-mode-tag overview-mode-tag--' +
|
||||
mode +
|
||||
'">' +
|
||||
mode +
|
||||
"</span></div>"
|
||||
: "";
|
||||
return (
|
||||
'<div class="cond-inst-group">' +
|
||||
label +
|
||||
'<div class="cond-inst-grid">' +
|
||||
items
|
||||
.map(function (it) {
|
||||
return renderCandidateCard(it, checkedIds);
|
||||
})
|
||||
.join("");
|
||||
.join("") +
|
||||
"</div></div>"
|
||||
);
|
||||
}
|
||||
|
||||
async function loadCandidates() {
|
||||
const box = document.getElementById("cf-instances");
|
||||
if (!box) return;
|
||||
const checkedIds = Array.prototype.slice
|
||||
.call(box.querySelectorAll('input[name="cf-inst"]:checked'))
|
||||
.map(function (el) {
|
||||
return decodeURIComponent(el.value || "");
|
||||
});
|
||||
const r = await fetch("/api/cond_orders/candidates");
|
||||
const d = await r.json();
|
||||
const list = d.instances || [];
|
||||
if (!list.length) {
|
||||
box.innerHTML = '<span class="muted">暂无启用实例</span>';
|
||||
return;
|
||||
}
|
||||
const sim = [];
|
||||
const live = [];
|
||||
const other = [];
|
||||
list.forEach(function (it) {
|
||||
const m = instanceMode(it);
|
||||
if (m === "sim") sim.push(it);
|
||||
else if (m === "live") live.push(it);
|
||||
else other.push(it);
|
||||
});
|
||||
box.innerHTML =
|
||||
renderCandidateGroup("sim", sim, checkedIds) +
|
||||
renderCandidateGroup("live", live, checkedIds) +
|
||||
renderCandidateGroup("", other, checkedIds);
|
||||
}
|
||||
|
||||
async function loadOrders() {
|
||||
|
||||
@@ -1350,6 +1350,8 @@ input.readonly {
|
||||
min-height: 62px;
|
||||
}
|
||||
.cond-switch input { width: auto; margin: 0; }
|
||||
.cond-inst-group + .cond-inst-group { margin-top: 14px; }
|
||||
.cond-inst-group-label { margin-bottom: 8px; }
|
||||
.cond-inst-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}期权中控{% endblock %}</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='hub.css') }}?v=19">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='hub.css') }}?v=20">
|
||||
</head>
|
||||
<body class="{% if request.path.startswith('/login') %}page-login{% elif request.path.startswith('/desk') %}page-desk{% elif request.path.startswith('/stats') %}page-stats{% elif request.path.startswith('/instances') %}page-instances{% elif request.path == '/' %}page-dashboard{% endif %}">
|
||||
{% if session.get('logged_in') %}
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
<div class="cond-section">
|
||||
<div class="cond-section-title">客户端</div>
|
||||
<div id="cf-instances" class="cond-inst-grid"></div>
|
||||
<div id="cf-instances"></div>
|
||||
</div>
|
||||
|
||||
<div class="cond-actions">
|
||||
|
||||
Reference in New Issue
Block a user