++
This commit is contained in:
+121
-16
@@ -34,6 +34,9 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
if (config.transformer.data_type) {
|
||||
document.getElementById('dataType').value = config.transformer.data_type;
|
||||
}
|
||||
if (config.transformer.alpha_id) {
|
||||
document.getElementById('alphaId').value = config.transformer.alpha_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -46,6 +49,7 @@ const submitBtn = document.getElementById('submitBtn');
|
||||
const downloadBtn = document.getElementById('downloadBtn');
|
||||
const loginAndFetchBtn = document.getElementById('loginAndFetchBtn');
|
||||
const testLLMBtn = document.getElementById('testLLMBtn');
|
||||
const downloadDatafieldsBtn = document.getElementById('downloadDatafieldsBtn');
|
||||
const regionSelect = document.getElementById('region');
|
||||
const delaySelect = document.getElementById('delay');
|
||||
const universeSelect = document.getElementById('universe');
|
||||
@@ -178,17 +182,20 @@ function populateCategoryButtons(categories) {
|
||||
function toggleCategory(btn) {
|
||||
const allBtn = document.getElementById('cat-all');
|
||||
const isAllBtn = (btn === allBtn);
|
||||
|
||||
|
||||
if (isAllBtn) {
|
||||
// 点击"不筛选"按钮:选中所有具体类别
|
||||
allBtn.style.backgroundColor = '#000080';
|
||||
allBtn.style.color = 'white';
|
||||
|
||||
|
||||
const otherBtns = categoryButtons.querySelectorAll('button:not(#cat-all)');
|
||||
otherBtns.forEach(b => {
|
||||
b.style.backgroundColor = '#c0c0c0';
|
||||
b.style.color = 'black';
|
||||
// 选中所有具体类别按钮
|
||||
b.style.backgroundColor = '#000080';
|
||||
b.style.color = 'white';
|
||||
});
|
||||
} else {
|
||||
// 点击具体类别按钮
|
||||
if (btn.style.backgroundColor === 'rgb(0, 0, 128)') {
|
||||
btn.style.backgroundColor = '#c0c0c0';
|
||||
btn.style.color = 'black';
|
||||
@@ -196,7 +203,8 @@ function toggleCategory(btn) {
|
||||
btn.style.backgroundColor = '#000080';
|
||||
btn.style.color = 'white';
|
||||
}
|
||||
|
||||
|
||||
// 检查是否有选中的具体类别
|
||||
const anySelected = categoryButtons.querySelectorAll('button:not(#cat-all)');
|
||||
let hasSelected = false;
|
||||
anySelected.forEach(b => {
|
||||
@@ -204,34 +212,72 @@ function toggleCategory(btn) {
|
||||
hasSelected = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (hasSelected) {
|
||||
allBtn.style.backgroundColor = '#c0c0c0';
|
||||
allBtn.style.color = 'black';
|
||||
} else {
|
||||
|
||||
// 如果没有选中任何具体类别,恢复"不筛选"按钮
|
||||
if (!hasSelected) {
|
||||
allBtn.style.backgroundColor = '#000080';
|
||||
allBtn.style.color = 'white';
|
||||
// 自动选中所有类别
|
||||
anySelected.forEach(b => {
|
||||
b.style.backgroundColor = '#000080';
|
||||
b.style.color = 'white';
|
||||
});
|
||||
} else {
|
||||
allBtn.style.backgroundColor = '#c0c0c0';
|
||||
allBtn.style.color = 'black';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取选中的类别列表
|
||||
function getSelectedCategories() {
|
||||
const allBtn = document.getElementById('cat-all');
|
||||
const otherBtns = categoryButtons.querySelectorAll('button:not(#cat-all)');
|
||||
|
||||
// 如果"不筛选"按钮被选中,返回所有具体类别的值
|
||||
if (allBtn.style.backgroundColor === 'rgb(0, 0, 128)') {
|
||||
const allCategories = [];
|
||||
otherBtns.forEach(b => {
|
||||
allCategories.push(b.dataset.value);
|
||||
});
|
||||
return allCategories;
|
||||
}
|
||||
|
||||
// 否则返回选中的具体类别
|
||||
const selected = [];
|
||||
otherBtns.forEach(b => {
|
||||
if (b.style.backgroundColor === 'rgb(0, 0, 128)') {
|
||||
selected.push(b.dataset.value);
|
||||
}
|
||||
});
|
||||
return selected;
|
||||
}
|
||||
|
||||
regionSelect.addEventListener('change', () => {
|
||||
const selectedRegion = regionSelect.value;
|
||||
|
||||
delaySelect.innerHTML = '<option value="">-- 先选择地区 --</option>';
|
||||
|
||||
universeSelect.innerHTML = '<option value="">-- 先选择Delay --</option>';
|
||||
delaySelect.disabled = true;
|
||||
universeSelect.disabled = true;
|
||||
|
||||
|
||||
if (selectedRegion && optionsData[selectedRegion]) {
|
||||
const delays = Object.keys(optionsData[selectedRegion]);
|
||||
// 保留 delaySelect 的当前值(如果有效)
|
||||
const currentDelay = delaySelect.value;
|
||||
delaySelect.innerHTML = '';
|
||||
delays.forEach(delay => {
|
||||
const option = document.createElement('option');
|
||||
option.value = delay;
|
||||
option.textContent = delay;
|
||||
if (delay === currentDelay) {
|
||||
option.selected = true;
|
||||
}
|
||||
delaySelect.appendChild(option);
|
||||
});
|
||||
delaySelect.disabled = false;
|
||||
// 触发 delay change 事件来更新 universe
|
||||
if (currentDelay && optionsData[selectedRegion][currentDelay]) {
|
||||
delaySelect.dispatchEvent(new Event('change'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -309,12 +355,13 @@ form.addEventListener('submit', async (e) => {
|
||||
|
||||
if (result.success) {
|
||||
const successCount = result.expressions_success ? result.expressions_success.length : 0;
|
||||
const candidateCount = result.candidates ? result.candidates.length : 0;
|
||||
const candidatesData = result.candidates || {};
|
||||
const candidateTemplatesCount = Object.keys(candidatesData).length;
|
||||
const errorCount = result.expressions_error ? result.expressions_error.length : 0;
|
||||
|
||||
// 显示下载按钮
|
||||
downloadBtn.style.display = 'block';
|
||||
downloadBtn.textContent = '下载结果 (' + successCount + '成功, ' + candidateCount + '候选)';
|
||||
downloadBtn.textContent = '下载结果 (' + successCount + '成功, ' + candidateTemplatesCount + '模板)';
|
||||
downloadBtn.onclick = function() {
|
||||
const alphaId = document.getElementById('alphaId').value.trim();
|
||||
window.location.href = '/api/download/' + alphaId;
|
||||
@@ -332,3 +379,61 @@ form.addEventListener('submit', async (e) => {
|
||||
submitBtn.textContent = '生成变种';
|
||||
}
|
||||
});
|
||||
|
||||
// 下载数据字段缓存按钮
|
||||
downloadDatafieldsBtn.addEventListener('click', async () => {
|
||||
const region = regionSelect.value;
|
||||
const delay = delaySelect.value;
|
||||
const universe = universeSelect.value;
|
||||
|
||||
if (!region || !delay || !universe) {
|
||||
alert('请先选择地区、Delay和股票池');
|
||||
return;
|
||||
}
|
||||
|
||||
const brainUsername = document.getElementById('brainUsername').value.trim();
|
||||
const brainPassword = document.getElementById('brainPassword').value.trim();
|
||||
|
||||
if (!brainUsername || !brainPassword) {
|
||||
alert('请先输入BRAIN用户名和密码');
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取选中的类别(使用新函数)
|
||||
const selectedCategories = getSelectedCategories();
|
||||
console.log('选中的类别:', selectedCategories);
|
||||
|
||||
downloadDatafieldsBtn.disabled = true;
|
||||
downloadDatafieldsBtn.textContent = '正在下载...';
|
||||
|
||||
try {
|
||||
const requestBody = {
|
||||
username: brainUsername,
|
||||
password: brainPassword,
|
||||
region: region,
|
||||
delay: parseInt(delay),
|
||||
universe: universe,
|
||||
data_type: dataTypeSelect.value,
|
||||
category: selectedCategories // 总是传递类别列表
|
||||
};
|
||||
|
||||
const response = await fetch('/api/download-datafields', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestBody)
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (!result.success) {
|
||||
alert('下载失败: ' + (result.error || '未知错误'));
|
||||
}
|
||||
} catch (error) {
|
||||
alert('下载出错: ' + error.message);
|
||||
} finally {
|
||||
downloadDatafieldsBtn.disabled = false;
|
||||
downloadDatafieldsBtn.textContent = '下载数据字段缓存';
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,15 +14,6 @@
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="instructions">
|
||||
<h3>使用说明</h3>
|
||||
<ul>
|
||||
<li>输入您的种子Alpha ID,系统将基于BRAIN平台生成多个变种</li>
|
||||
<li>配置您的LLM(支持OpenAI兼容接口)和BRAIN凭证</li>
|
||||
<li>点击生成按钮,系统将自动完成所有处理并返回结果</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<form id="transformerForm">
|
||||
<div class="form-section">
|
||||
<h2>BRAIN 凭证</h2>
|
||||
@@ -92,7 +83,7 @@
|
||||
<div class="form-group">
|
||||
<label for="topNDatafield">Datafield Top N (候选数量,建议低于50)</label>
|
||||
<input type="number" id="topNDatafield" name="top_n_datafield"
|
||||
value="50" min="1" max="100">
|
||||
value="10" min="1" max="100">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -117,9 +108,10 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="delay">目标Delay (可选 - 留空则使用种子Alpha的默认值)</label>
|
||||
<select id="delay" name="delay" disabled>
|
||||
<option value="">-- 先选择地区 --</option>
|
||||
<label for="delay">目标Delay</label>
|
||||
<select id="delay" name="delay">
|
||||
<option value="1" selected>1</option>
|
||||
<option value="0">0</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -139,7 +131,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<button type="button" class="btn" id="downloadDatafieldsBtn" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); margin-bottom: 10px;">
|
||||
下载数据字段缓存
|
||||
</button>
|
||||
|
||||
<button type="submit" class="btn submit-btn" id="submitBtn">
|
||||
生成变种
|
||||
</button>
|
||||
@@ -148,7 +144,14 @@
|
||||
下载结果 (ZIP)
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="instructions">
|
||||
<h3>使用说明</h3>
|
||||
<ul>
|
||||
<li>输入您的种子Alpha ID,系统将基于BRAIN平台生成多个变种</li>
|
||||
<li>配置您的LLM(支持OpenAI兼容接口)和BRAIN凭证</li>
|
||||
<li>点击生成按钮,系统将自动完成所有处理并返回结果</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user