Jimin Huang commited on
Commit
edd5045
·
1 Parent(s): f96fb0b

Change settings

Browse files
Files changed (1) hide show
  1. src/views/LiveView.vue +15 -6
src/views/LiveView.vue CHANGED
@@ -1,13 +1,12 @@
1
  <!-- src/views/LiveView.vue -->
2
  <script setup>
3
- import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
4
  import CompareChartE from '../components/CompareChartE.vue'
5
  import { dataService } from '../lib/dataService.js'
6
 
7
  const ASSETS = ['BTC','ETH','SOL','BNB','DOGE','XRP']
8
  const asset = ref(ASSETS[0])
9
  const agents = ref([])
10
- let unsub = null
11
 
12
  function score(row){ return typeof row.balance === 'number' ? row.balance : -Infinity }
13
 
@@ -37,10 +36,16 @@ const winnersSorted = computed(() => [...winners.value].sort((a,b) => score(b) -
37
  const fmtUSD = n => (n ?? 0).toLocaleString(undefined,{ style:'currency', currency:'USD', maximumFractionDigits:2 })
38
 
39
  onMounted(async () => {
40
- unsub = dataService.subscribe((snap) => { agents.value = snap.agents || [] })
41
- if (!dataService.loaded && !dataService.loading) { try { await dataService.load(false) } catch {} }
 
 
 
 
 
 
 
42
  })
43
- onBeforeUnmount(() => unsub && unsub())
44
  </script>
45
 
46
  <template>
@@ -54,7 +59,11 @@ onBeforeUnmount(() => unsub && unsub())
54
  >{{ a }}</button>
55
  </div>
56
 
57
- <CompareChartE :selected="winnersForChart" :visible="true" />
 
 
 
 
58
 
59
  <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3">
60
  <div v-for="row in winnersSorted" :key="row.agent_name+'|'+row.asset+'|'+row.model" class="p-3 rounded-xl border flex justify-between items-center">
 
1
  <!-- src/views/LiveView.vue -->
2
  <script setup>
3
+ import { ref, computed, onMounted } from 'vue'
4
  import CompareChartE from '../components/CompareChartE.vue'
5
  import { dataService } from '../lib/dataService.js'
6
 
7
  const ASSETS = ['BTC','ETH','SOL','BNB','DOGE','XRP']
8
  const asset = ref(ASSETS[0])
9
  const agents = ref([])
 
10
 
11
  function score(row){ return typeof row.balance === 'number' ? row.balance : -Infinity }
12
 
 
36
  const fmtUSD = n => (n ?? 0).toLocaleString(undefined,{ style:'currency', currency:'USD', maximumFractionDigits:2 })
37
 
38
  onMounted(async () => {
39
+ try {
40
+ // run the service load if needed (this populates tableRows + caches decisions)
41
+ if (!dataService.loaded) await dataService.load(false)
42
+ } catch (e) {
43
+ console.error('LiveView: dataService.load failed', e)
44
+ }
45
+ // copy rows to local reactive state
46
+ agents.value = Array.isArray(dataService.tableRows) ? dataService.tableRows : []
47
+ console.log('LiveView: loaded rows =', agents.value.length)
48
  })
 
49
  </script>
50
 
51
  <template>
 
59
  >{{ a }}</button>
60
  </div>
61
 
62
+ <CompareChartE v-if="winnersForChart.length" :selected="winnersForChart" :visible="true" />
63
+ <div v-else class="p-4 text-sm text-gray-500 border rounded-lg">
64
+ No data for {{ asset }} yet. Make sure Supabase has decisions/runs for this asset and that
65
+ <code>dataService.load()</code> completes. Check console for “LiveView: loaded rows” count.
66
+ </div>
67
 
68
  <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3">
69
  <div v-for="row in winnersSorted" :key="row.agent_name+'|'+row.asset+'|'+row.model" class="p-3 rounded-xl border flex justify-between items-center">