feat: add refresh button to simulation page

User can now click 'Refresh' to update simulation data (portfolio, signals, trade log) without reloading the page.
This commit is contained in:
shokollm
2026-04-12 08:39:55 +00:00
parent 84d8a6f4a6
commit 90fa66bd39

View File

@@ -11,6 +11,7 @@
let tokenAddress = $state(''); let tokenAddress = $state('');
let klineInterval = $state('1m'); let klineInterval = $state('1m');
let isRunning = $state(false); let isRunning = $state(false);
let isRefreshing = $state(false);
onMount(async () => { onMount(async () => {
if (!$isAuthenticated && !$isLoading) { if (!$isAuthenticated && !$isLoading) {
@@ -42,6 +43,7 @@
} }
async function loadSimulations() { async function loadSimulations() {
isRefreshing = true;
try { try {
const simulations = await api.simulate.list(botId); const simulations = await api.simulate.list(botId);
@@ -58,6 +60,8 @@
} }
} catch (e) { } catch (e) {
console.error('Failed to load simulations:', e); console.error('Failed to load simulations:', e);
} finally {
isRefreshing = false;
} }
} }
@@ -105,6 +109,18 @@
<a href="/bot/{botId}" class="back-link">← Back to Chat</a> <a href="/bot/{botId}" class="back-link">← Back to Chat</a>
<h1>Simulation</h1> <h1>Simulation</h1>
</div> </div>
<div class="header-right">
{#if $simulationStore.currentSimulation}
<button
type="button"
class="refresh-btn"
onclick={() => loadSimulations()}
class:refreshing={isRefreshing}
>
{isRefreshing ? '⟳ Refreshing...' : '⟳ Refresh'}
</button>
{/if}
</div>
</header> </header>
<div class="notice"> <div class="notice">
@@ -224,6 +240,42 @@
padding: 2rem; padding: 2rem;
} }
header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1rem;
}
.header-right {
display: flex;
gap: 0.5rem;
}
.refresh-btn {
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
color: #fff;
padding: 0.5rem 1rem;
border-radius: 6px;
cursor: pointer;
font-size: 0.875rem;
display: flex;
align-items: center;
gap: 0.5rem;
transition: all 0.2s;
}
.refresh-btn:hover {
background: rgba(255, 255, 255, 0.15);
border-color: rgba(255, 255, 255, 0.3);
}
.refresh-btn.refreshing {
opacity: 0.7;
cursor: not-allowed;
}
header { header {
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
} }