@@ -23,16 +23,16 @@ import { computed, onMounted, ref } from "vue";
2323import axios , { AxiosError } from " axios" ;
2424import { StatCardItem } from " @/interfaces/IStats" ;
2525import StatCard from " @/components/StatCard.vue" ;
26- import { useStore } from " ../store" ;
2726import handleError from " @/utils/handleError" ;
2827import useSnackbar from " @/helpers/snackbar" ;
2928import useNamespacesStore from " @/store/modules/namespaces" ;
29+ import useStatsStore from " @/store/modules/stats" ;
3030
31- const store = useStore ();
3231const namespacesStore = useNamespacesStore ();
32+ const statsStore = useStatsStore ();
3333const snackbar = useSnackbar ();
3434const hasStatus = ref (false );
35- const itemsStats = computed (() => store . getters [ " stats/stats " ] );
35+ const stats = computed (() => statsStore . stats );
3636const hasNamespace = computed (() => namespacesStore .namespaceList .length !== 0 );
3737
3838const items = computed <StatCardItem []>(() => [
@@ -42,31 +42,31 @@ const items = computed<StatCardItem[]>(() => [
4242 icon: " mdi-devices" ,
4343 buttonLabel: " Add Device" ,
4444 path: " devices" ,
45- stat: itemsStats .value .registered_devices || 0 ,
45+ stat: stats .value .registered_devices || 0 ,
4646 },
4747 {
4848 title: " Online Devices" ,
4949 content: " Devices are online and ready for connecting" ,
5050 icon: " mdi-devices" ,
5151 buttonLabel: " View all Devices" ,
5252 path: " devices" ,
53- stat: itemsStats .value .online_devices || 0 ,
53+ stat: stats .value .online_devices || 0 ,
5454 },
5555 {
5656 title: " Active Sessions" ,
5757 content: " Active SSH Sessions opened by users" ,
5858 icon: " mdi-devices" ,
5959 buttonLabel: " View all Sessions" ,
6060 path: " sessions" ,
61- stat: itemsStats .value .active_sessions || 0 ,
61+ stat: stats .value .active_sessions || 0 ,
6262 },
6363]);
6464
6565onMounted (async () => {
6666 if (! hasNamespace .value ) return ;
6767
6868 try {
69- await store . dispatch ( " stats/get " );
69+ await statsStore . fetchStats ( );
7070 } catch (error : unknown ) {
7171 if (axios .isAxiosError (error )) {
7272 const axiosError = error as AxiosError ;
0 commit comments