Skip to content

Commit d377694

Browse files
Add dashboard overview
1 parent 9036496 commit d377694

1 file changed

Lines changed: 49 additions & 18 deletions

File tree

  • frontend/kubecloud-v2/pages/dashboard

frontend/kubecloud-v2/pages/dashboard/index.vue

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
<template>
22
<div>
3-
<h1>Dashboard Overview {{ isLoading }}</h1>
4-
5-
<pre>
6-
{{ balance }}
7-
</pre>
8-
9-
<p>
10-
spent balance:
11-
{{ spent }}
12-
</p>
3+
<div class="mb-8">
4+
<h1 class="text-h5 font-weight-bold">
5+
Dashboard Overview
6+
</h1>
7+
<p class="text-body-2 mt-1 opacity-70">
8+
Your Mycelium Cloud platform at a glance
9+
</p>
1310

14-
<p>
15-
clusters Count:
16-
{{ deploymentsCount }}
17-
</p>
11+
<v-row class="mt-4">
12+
<v-col
13+
v-for="stat in stats"
14+
:key="stat.id"
15+
cols="12"
16+
md="6"
17+
lg="4"
18+
>
19+
<StatsCard v-bind="stat" />
20+
</v-col>
21+
</v-row>
22+
</div>
1823

1924
<div>
2025
<p class="text-h6 font-weight-bold mb-4">
@@ -71,20 +76,46 @@ import type { ModelsInvoice } from "~/generated/api"
7176
7277
const api = useApi()
7378
74-
const { state: balance, isLoading } = useAsyncState(async () => {
79+
const { state: balance } = useAsyncState(async () => {
7580
const { data } = await api.users.getUserBalance()
76-
return data
77-
}, null)
81+
return toPrecision(data.data?.balance_usd ?? 0, 2)
82+
}, 0)
7883
7984
const { state: spent } = useAsyncState(async () => {
8085
const { data } = await api.invoices.getInvoices()
8186
const { invoices } = data.data as unknown as { invoices: ModelsInvoice[] }
8287
const total = invoices.reduce((a, b) => a + (b.total ?? 0) * 1000, 0) ?? 0
8388
return toPrecision(total / 1000, 2)
84-
}, null)
89+
}, 0)
8590
8691
const { state: deploymentsCount } = useAsyncState(async () => {
8792
const { data } = await api.deployments.deploymentsGet()
8893
return data.data?.count ?? 0
8994
}, 0)
95+
96+
const stats = computed<StatsResource[]>(() => {
97+
return [
98+
{
99+
id: "clusters",
100+
title: "Active Clusters",
101+
icon: "mdi-server",
102+
color: "#359EFF",
103+
value: deploymentsCount.value,
104+
},
105+
{
106+
id: "balance",
107+
title: "Balance",
108+
icon: "mdi-wallet-bifold",
109+
color: "#607AFB",
110+
value: `$${balance.value}`,
111+
},
112+
{
113+
id: "spent",
114+
title: "Total Spent",
115+
icon: "mdi-currency-usd",
116+
color: "#39E079",
117+
value: `$${spent.value}`,
118+
},
119+
]
120+
})
90121
</script>

0 commit comments

Comments
 (0)