Added backend!

This commit is contained in:
Patrick Hatsune 2024-09-06 01:23:55 -07:00
parent 9bcf82249d
commit 7084683337
2 changed files with 87 additions and 44 deletions

View file

@ -1,4 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { shallowRef, onMounted } from 'vue';
import axios from 'axios';
import internetIcon from '@/assets/overviewSvgs/Internet.svg' import internetIcon from '@/assets/overviewSvgs/Internet.svg'
import wifiIcon from '@/assets/overviewSvgs/Wifi.svg' import wifiIcon from '@/assets/overviewSvgs/Wifi.svg'
import devicesIcon from '@/assets/overviewSvgs/Devices.svg' import devicesIcon from '@/assets/overviewSvgs/Devices.svg'
@ -26,56 +29,88 @@
statusMessage: string; statusMessage: string;
} }
const overviewItems: overviewItemsType[] = [ const backendOnline = shallowRef<boolean>(true);
const overviewItems = shallowRef<overviewItemsType[]>([]);
const internetMode = shallowRef<string | null>(null);
const wifiMode5Ghz = shallowRef<string | null>(null);
const wifiMode2Ghz = shallowRef<number | null>(null);
const devices = shallowRef<string | null>(null);
const fileShare = shallowRef<string | null>(null);
const qos = shallowRef<string | null>(null);
const guestNetwork = shallowRef<string | null>(null);
const fetchOverviewItems = async () => {
try {
const response = await axios.get('http://localhost:8080/overviewItems');
internetMode.value = response.data.internetMode;
wifiMode5Ghz.value = response.data.wifiMode5Ghz;
wifiMode2Ghz.value = response.data.wifiMode2Ghz;
devices.value = response.data.devices;
fileShare.value = response.data.fileShare;
qos.value = response.data.qos;
guestNetwork.value = response.data.guestNetwork
overviewItems.value = [
{ {
name: "Internet", name: "Internet",
link: "/basic/internet", link: "/basic/internet",
icon: internetIcon, icon: internetIcon,
statusColor: statusColors.goodStatus, statusColor: statusColors.goodStatus,
statusMessage: "Online: LAN4", statusMessage: `Online: ${internetMode.value}`,
}, },
{ {
name: "Wifi", name: "Wifi",
link: "/basic/wireless", link: "/basic/wireless",
icon: wifiIcon, icon: wifiIcon,
statusColor: statusColors.warningStatus, statusColor: statusColors.warningStatus,
statusMessage: "5Ghz: On | 2.4Ghz: Off", statusMessage: `5Ghz: ${wifiMode5Ghz.value} | 2.4Ghz: ${wifiMode2Ghz.value}`,
}, },
{ {
name: "Devices", name: "Devices",
link: "/basic/devices", link: "/basic/devices",
icon: devicesIcon, icon: devicesIcon,
statusColor: null, statusColor: null,
statusMessage: "Online: 0", statusMessage: `Online: ${devices.value}`,
}, },
{ {
name: "File Sharing", name: "File Sharing",
link: "/basic/fileshare", link: "/basic/fileshare",
icon: fileSharingIcon, icon: fileSharingIcon,
statusColor: statusColors.badStatus, statusColor: statusColors.badStatus,
statusMessage: "Offline", statusMessage: `${fileShare.value}`,
}, },
{ {
name: "QoS", name: "QoS",
link: "/basic/qos", link: "/basic/qos",
icon: qosIcon, icon: qosIcon,
statusColor: statusColors.goodStatus, statusColor: statusColors.goodStatus,
statusMessage: "Online", statusMessage: `${qos.value}`,
}, },
{ {
name: "Guest Network", name: "Guest Network",
link: "/basic/guestnetwork", link: "/basic/guestnetwork",
icon: guestNetworkIcon, icon: guestNetworkIcon,
statusColor: statusColors.badStatus, statusColor: statusColors.badStatus,
statusMessage: "Offline", statusMessage: `${guestNetwork}`,
} }
] ];
} catch (error) {
return backendOnline.value = false;
}
};
onMounted(() => {
fetchOverviewItems();
})
</script> </script>
<template> <template>
<div id="overviewComponent"> <div id="overviewComponent">
<h2 class="title">Overview</h2> <h2 class="title">Overview</h2>
<ul> <ul v-if="backendOnline">
<RouterLink :to="overviewItem.link" v-for="overviewItem in overviewItems"> <RouterLink :to="overviewItem.link" v-for="overviewItem in overviewItems">
<li> <li>
<component :is="overviewItem.icon"/> <component :is="overviewItem.icon"/>
@ -84,6 +119,7 @@
</li> </li>
</RouterLink> </RouterLink>
</ul> </ul>
<p class="error" v-else>Backend offline or not available, please try again later.</p>
</div> </div>
</template> </template>

View file

@ -1,3 +1,10 @@
.error {
margin-top: 30px;
width: 100%;
text-align: center;
font-size: 2rem;
}
#basicDashboard { #basicDashboard {
display: flex; display: flex;
margin-top: 20px; margin-top: 20px;