Add display toggles to hide monitor cards and strategy tabs.
Keep unused exchanges/docs out of the UI without disabling accounts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,12 +9,42 @@
|
||||
return !!d[key];
|
||||
}
|
||||
|
||||
window.hubDisplayPref = displayPref;
|
||||
|
||||
function showAccountPnlPref() {
|
||||
return displayPref("show_account_pnl", true);
|
||||
}
|
||||
|
||||
window.hubShowAccountPnlPref = showAccountPnlPref;
|
||||
|
||||
function showMonitorBinancePref() {
|
||||
return displayPref("show_monitor_binance", true);
|
||||
}
|
||||
|
||||
function showMonitorOkxPerpPref() {
|
||||
return displayPref("show_monitor_okx_perp", true);
|
||||
}
|
||||
|
||||
function showMonitorOkxOptionsPref() {
|
||||
return displayPref("show_monitor_okx_options", true);
|
||||
}
|
||||
|
||||
function showMonitorGatePref() {
|
||||
return displayPref("show_monitor_gate", true);
|
||||
}
|
||||
|
||||
function monitorExchangeKeyVisible(key) {
|
||||
const k = String(key || "").toLowerCase();
|
||||
if (k === "binance") return showMonitorBinancePref();
|
||||
if (k === "gate") return showMonitorGatePref();
|
||||
if (k === "okx") return showMonitorOkxPerpPref() || showMonitorOkxOptionsPref();
|
||||
return true;
|
||||
}
|
||||
|
||||
function filterVisibleMonitorRows(rows) {
|
||||
return (rows || []).filter((r) => monitorExchangeKeyVisible(r && r.key));
|
||||
}
|
||||
|
||||
function showNavFundsPref() {
|
||||
return displayPref("show_nav_funds", true);
|
||||
}
|
||||
@@ -157,32 +187,33 @@
|
||||
|
||||
function syncDisplayPrefsUI(data) {
|
||||
const d = (data && data.display) || {};
|
||||
const pnlCb = document.getElementById("pref-show-account-pnl");
|
||||
const fundsCb = document.getElementById("pref-show-nav-funds");
|
||||
const dashCb = document.getElementById("pref-show-nav-dashboard");
|
||||
const planCb = document.getElementById("pref-show-nav-plan");
|
||||
const archiveCb = document.getElementById("pref-show-nav-archive");
|
||||
const quotesCb = document.getElementById("pref-show-nav-quotes");
|
||||
const aiCb = document.getElementById("pref-show-nav-ai");
|
||||
const calcCb = document.getElementById("pref-show-nav-calculator");
|
||||
const compareCb = document.getElementById("pref-show-nav-compare");
|
||||
const strategyCb = document.getElementById("pref-show-nav-strategy");
|
||||
const ampCb = document.getElementById("pref-show-nav-amp-stats");
|
||||
const helpCb = document.getElementById("pref-show-nav-help");
|
||||
const logsCb = document.getElementById("pref-show-nav-logs");
|
||||
if (pnlCb) pnlCb.checked = d.show_account_pnl !== false;
|
||||
if (fundsCb) fundsCb.checked = d.show_nav_funds !== false;
|
||||
if (dashCb) dashCb.checked = d.show_nav_dashboard !== false;
|
||||
if (planCb) planCb.checked = d.show_nav_plan !== false;
|
||||
if (archiveCb) archiveCb.checked = d.show_nav_archive !== false;
|
||||
if (quotesCb) quotesCb.checked = d.show_nav_quotes !== false;
|
||||
if (aiCb) aiCb.checked = d.show_nav_ai !== false;
|
||||
if (calcCb) calcCb.checked = d.show_nav_calculator !== false;
|
||||
if (compareCb) compareCb.checked = d.show_nav_compare !== false;
|
||||
if (strategyCb) strategyCb.checked = d.show_nav_strategy !== false;
|
||||
if (ampCb) ampCb.checked = d.show_nav_amp_stats !== false;
|
||||
if (helpCb) helpCb.checked = d.show_nav_help !== false;
|
||||
if (logsCb) logsCb.checked = d.show_nav_logs !== false;
|
||||
const setChk = (id, key) => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.checked = d[key] !== false;
|
||||
};
|
||||
setChk("pref-show-account-pnl", "show_account_pnl");
|
||||
setChk("pref-show-nav-funds", "show_nav_funds");
|
||||
setChk("pref-show-nav-dashboard", "show_nav_dashboard");
|
||||
setChk("pref-show-nav-plan", "show_nav_plan");
|
||||
setChk("pref-show-nav-archive", "show_nav_archive");
|
||||
setChk("pref-show-nav-quotes", "show_nav_quotes");
|
||||
setChk("pref-show-nav-ai", "show_nav_ai");
|
||||
setChk("pref-show-nav-calculator", "show_nav_calculator");
|
||||
setChk("pref-show-nav-compare", "show_nav_compare");
|
||||
setChk("pref-show-nav-strategy", "show_nav_strategy");
|
||||
setChk("pref-show-nav-amp-stats", "show_nav_amp_stats");
|
||||
setChk("pref-show-nav-help", "show_nav_help");
|
||||
setChk("pref-show-nav-logs", "show_nav_logs");
|
||||
setChk("pref-show-monitor-binance", "show_monitor_binance");
|
||||
setChk("pref-show-monitor-okx-perp", "show_monitor_okx_perp");
|
||||
setChk("pref-show-monitor-okx-options", "show_monitor_okx_options");
|
||||
setChk("pref-show-monitor-gate", "show_monitor_gate");
|
||||
setChk("pref-show-strategy-playbook-v2", "show_strategy_playbook_v2");
|
||||
setChk("pref-show-strategy-playbook", "show_strategy_playbook");
|
||||
setChk("pref-show-strategy-behavior", "show_strategy_behavior");
|
||||
setChk("pref-show-strategy-binance", "show_strategy_binance");
|
||||
setChk("pref-show-strategy-okx", "show_strategy_okx");
|
||||
setChk("pref-show-strategy-gate", "show_strategy_gate");
|
||||
syncNavVisibility(data);
|
||||
}
|
||||
|
||||
@@ -1569,7 +1600,7 @@
|
||||
if (upd) upd.textContent = txt;
|
||||
if (updSum) updSum.textContent = txt;
|
||||
}
|
||||
updateMonitorAlertSummary(rows || []);
|
||||
updateMonitorAlertSummary(filterVisibleMonitorRows(rows || []));
|
||||
void refreshMacroRiskBanner(rows || []);
|
||||
renderMonitorGrid(rows || []);
|
||||
}
|
||||
@@ -2080,19 +2111,20 @@
|
||||
if (lastMonitorRows.length && nowMobile !== wasMobile) {
|
||||
wasMobile = nowMobile;
|
||||
renderMonitorGrid(lastMonitorRows);
|
||||
updateMonitorAlertSummary(lastMonitorRows);
|
||||
updateMonitorAlertSummary(filterVisibleMonitorRows(lastMonitorRows));
|
||||
syncHubMobileTabActive(currentPage());
|
||||
return;
|
||||
}
|
||||
wasMobile = nowMobile;
|
||||
const box = document.getElementById("monitor-grid");
|
||||
if (box && lastMonitorRows.length) {
|
||||
const split = monitorOptionsSplitActive(lastMonitorRows);
|
||||
syncMonitorGridColumns(box, lastMonitorRows.length + (lastMonitorTotals ? 1 : 0), {
|
||||
const visible = filterVisibleMonitorRows(lastMonitorRows);
|
||||
const split = monitorOptionsSplitActive(visible);
|
||||
syncMonitorGridColumns(box, visible.length + (lastMonitorTotals ? 1 : 0), {
|
||||
statsFirst: !!lastMonitorTotals && !split,
|
||||
optionsSplit: split,
|
||||
});
|
||||
updateMonitorAlertSummary(lastMonitorRows);
|
||||
updateMonitorAlertSummary(visible);
|
||||
}
|
||||
syncHubMobileTabActive(currentPage());
|
||||
}, 120);
|
||||
@@ -2486,11 +2518,12 @@
|
||||
const fs = document.getElementById("exchange-fullscreen");
|
||||
const fsInner = document.getElementById("exchange-fullscreen-inner");
|
||||
if (!box) return;
|
||||
if (expandedExchangeId && !rows.some((r) => String(r.id) === String(expandedExchangeId))) {
|
||||
const visibleSource = filterVisibleMonitorRows(rows);
|
||||
if (expandedExchangeId && !visibleSource.some((r) => String(r.id) === String(expandedExchangeId))) {
|
||||
closeExchangeFullscreen();
|
||||
}
|
||||
const mobileTiles = isMobileLayout() && !expandedExchangeId;
|
||||
const displayRows = mobileTiles ? sortRowsForMobileDashboard(rows) : rows;
|
||||
const displayRows = mobileTiles ? sortRowsForMobileDashboard(visibleSource) : visibleSource;
|
||||
const optionsSplit = monitorOptionsSplitActive(displayRows);
|
||||
monitorGridOptionsSplit = optionsSplit;
|
||||
const showStatsCard = !expandedExchangeId;
|
||||
@@ -2503,20 +2536,33 @@
|
||||
let cardsHtml = "";
|
||||
if (optionsSplit) {
|
||||
const okxRow = displayRows.find((r) => rowHasOptionsLayout(r));
|
||||
const otherRows = displayRows.filter((r) => !rowHasOptionsLayout(r));
|
||||
const ph =
|
||||
'<div class="card card-monitor-split-side card-monitor-placeholder" aria-hidden="true"></div>';
|
||||
/* 平铺 2×2 顺序:永续|币安 / 期权|Gate —— 同行左右同高,多仓时该行一起长高 */
|
||||
const cells = [
|
||||
okxRow ? renderMonitorCard(okxRow, { okxPart: "perp", splitSide: true }) : ph,
|
||||
otherRows[0] ? renderMonitorCard(otherRows[0], { splitSide: true }) : ph,
|
||||
okxRow ? renderMonitorCard(okxRow, { okxPart: "options", splitSide: true }) : ph,
|
||||
otherRows[1] ? renderMonitorCard(otherRows[1], { splitSide: true }) : ph,
|
||||
];
|
||||
for (let i = 2; i < otherRows.length; i++) {
|
||||
cells.push(renderMonitorCard(otherRows[i], { splitSide: true }));
|
||||
const otherByKey = {};
|
||||
displayRows
|
||||
.filter((r) => !rowHasOptionsLayout(r))
|
||||
.forEach((r) => {
|
||||
otherByKey[String(r.key || "").toLowerCase()] = r;
|
||||
});
|
||||
/* 平铺顺序尽量保持:永续|币安 / 期权|Gate;隐藏项不占位 */
|
||||
const cells = [];
|
||||
if (okxRow && showMonitorOkxPerpPref()) {
|
||||
cells.push(renderMonitorCard(okxRow, { okxPart: "perp", splitSide: true }));
|
||||
}
|
||||
cardsHtml = `<div class="monitor-split-body monitor-split-2x2">${cells.join("")}</div>`;
|
||||
if (otherByKey.binance && showMonitorBinancePref()) {
|
||||
cells.push(renderMonitorCard(otherByKey.binance, { splitSide: true }));
|
||||
}
|
||||
if (okxRow && showMonitorOkxOptionsPref()) {
|
||||
cells.push(renderMonitorCard(okxRow, { okxPart: "options", splitSide: true }));
|
||||
}
|
||||
if (otherByKey.gate && showMonitorGatePref()) {
|
||||
cells.push(renderMonitorCard(otherByKey.gate, { splitSide: true }));
|
||||
}
|
||||
Object.keys(otherByKey).forEach((k) => {
|
||||
if (k === "binance" || k === "gate") return;
|
||||
cells.push(renderMonitorCard(otherByKey[k], { splitSide: true }));
|
||||
});
|
||||
cardsHtml = cells.length
|
||||
? `<div class="monitor-split-body monitor-split-2x2">${cells.join("")}</div>`
|
||||
: "";
|
||||
} else {
|
||||
cardsHtml =
|
||||
displayRows
|
||||
@@ -2545,7 +2591,7 @@
|
||||
}
|
||||
|
||||
if (expandedExchangeId && fs && fsInner) {
|
||||
const row = rows.find((r) => String(r.id) === String(expandedExchangeId));
|
||||
const row = visibleSource.find((r) => String(r.id) === String(expandedExchangeId));
|
||||
if (row) {
|
||||
try {
|
||||
fsInner.innerHTML = renderFullscreenExchange(row);
|
||||
@@ -3900,7 +3946,8 @@
|
||||
|
||||
function monitorOptionsSplitActive(rows) {
|
||||
if (isMobileLayout() || expandedExchangeId) return false;
|
||||
return (rows || []).some((r) => rowHasOptionsLayout(r));
|
||||
if (!(rows || []).some((r) => rowHasOptionsLayout(r))) return false;
|
||||
return showMonitorOkxPerpPref() || showMonitorOkxOptionsPref();
|
||||
}
|
||||
|
||||
function renderPerpetualInnerCard(row, ag, pos, orders, trends, tickMap, intraday) {
|
||||
@@ -5112,19 +5159,10 @@
|
||||
|
||||
function collectSettingsFromUI() {
|
||||
const rows = [...document.querySelectorAll("#settings-list .settings-card")];
|
||||
const pnlCb = document.getElementById("pref-show-account-pnl");
|
||||
const fundsCb = document.getElementById("pref-show-nav-funds");
|
||||
const dashCb = document.getElementById("pref-show-nav-dashboard");
|
||||
const planCb = document.getElementById("pref-show-nav-plan");
|
||||
const archiveCb = document.getElementById("pref-show-nav-archive");
|
||||
const quotesCb = document.getElementById("pref-show-nav-quotes");
|
||||
const aiCb = document.getElementById("pref-show-nav-ai");
|
||||
const calcCb = document.getElementById("pref-show-nav-calculator");
|
||||
const compareCb = document.getElementById("pref-show-nav-compare");
|
||||
const strategyCb = document.getElementById("pref-show-nav-strategy");
|
||||
const ampCb = document.getElementById("pref-show-nav-amp-stats");
|
||||
const helpCb = document.getElementById("pref-show-nav-help");
|
||||
const logsCb = document.getElementById("pref-show-nav-logs");
|
||||
const chk = (id) => {
|
||||
const el = document.getElementById(id);
|
||||
return el ? !!el.checked : true;
|
||||
};
|
||||
const supEnabled = document.getElementById("supervisor-enabled");
|
||||
const supProg = document.getElementById("supervisor-wechat-program");
|
||||
const supWebhook = document.getElementById("supervisor-wechat-webhook");
|
||||
@@ -5137,19 +5175,29 @@
|
||||
return {
|
||||
version: 1,
|
||||
display: {
|
||||
show_account_pnl: pnlCb ? !!pnlCb.checked : true,
|
||||
show_nav_funds: fundsCb ? !!fundsCb.checked : true,
|
||||
show_nav_dashboard: dashCb ? !!dashCb.checked : true,
|
||||
show_nav_plan: planCb ? !!planCb.checked : true,
|
||||
show_nav_archive: archiveCb ? !!archiveCb.checked : true,
|
||||
show_nav_quotes: quotesCb ? !!quotesCb.checked : true,
|
||||
show_nav_ai: aiCb ? !!aiCb.checked : true,
|
||||
show_nav_calculator: calcCb ? !!calcCb.checked : true,
|
||||
show_nav_compare: compareCb ? !!compareCb.checked : true,
|
||||
show_nav_strategy: strategyCb ? !!strategyCb.checked : true,
|
||||
show_nav_amp_stats: ampCb ? !!ampCb.checked : true,
|
||||
show_nav_help: helpCb ? !!helpCb.checked : true,
|
||||
show_nav_logs: logsCb ? !!logsCb.checked : true,
|
||||
show_account_pnl: chk("pref-show-account-pnl"),
|
||||
show_nav_funds: chk("pref-show-nav-funds"),
|
||||
show_nav_dashboard: chk("pref-show-nav-dashboard"),
|
||||
show_nav_plan: chk("pref-show-nav-plan"),
|
||||
show_nav_archive: chk("pref-show-nav-archive"),
|
||||
show_nav_quotes: chk("pref-show-nav-quotes"),
|
||||
show_nav_ai: chk("pref-show-nav-ai"),
|
||||
show_nav_calculator: chk("pref-show-nav-calculator"),
|
||||
show_nav_compare: chk("pref-show-nav-compare"),
|
||||
show_nav_strategy: chk("pref-show-nav-strategy"),
|
||||
show_nav_amp_stats: chk("pref-show-nav-amp-stats"),
|
||||
show_nav_help: chk("pref-show-nav-help"),
|
||||
show_nav_logs: chk("pref-show-nav-logs"),
|
||||
show_monitor_binance: chk("pref-show-monitor-binance"),
|
||||
show_monitor_okx_perp: chk("pref-show-monitor-okx-perp"),
|
||||
show_monitor_okx_options: chk("pref-show-monitor-okx-options"),
|
||||
show_monitor_gate: chk("pref-show-monitor-gate"),
|
||||
show_strategy_playbook_v2: chk("pref-show-strategy-playbook-v2"),
|
||||
show_strategy_playbook: chk("pref-show-strategy-playbook"),
|
||||
show_strategy_behavior: chk("pref-show-strategy-behavior"),
|
||||
show_strategy_binance: chk("pref-show-strategy-binance"),
|
||||
show_strategy_okx: chk("pref-show-strategy-okx"),
|
||||
show_strategy_gate: chk("pref-show-strategy-gate"),
|
||||
},
|
||||
supervisor: {
|
||||
enabled: supEnabled ? !!supEnabled.checked : true,
|
||||
@@ -5210,6 +5258,9 @@
|
||||
if (window.hubDashboardPage && window.hubDashboardPage.refresh) {
|
||||
window.hubDashboardPage.refresh();
|
||||
}
|
||||
if (window.hubStrategyPage && typeof window.hubStrategyPage.reloadMeta === "function") {
|
||||
window.hubStrategyPage.reloadMeta();
|
||||
}
|
||||
if (!pageNavAllowed(currentPage())) {
|
||||
history.replaceState({}, "", "/monitor");
|
||||
setActiveNav();
|
||||
|
||||
Reference in New Issue
Block a user