Skip to content

Commit 944db7f

Browse files
authored
Merge pull request #166 from Lodestone-Team/homeHotfix
2 parents 0fa1d01 + fd0fe31 commit 944db7f

File tree

5 files changed

+59
-23
lines changed

5 files changed

+59
-23
lines changed

src/components/DashboardCard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function DashboardCard({
99
}) {
1010
return (
1111
<div
12-
className={`flex h-fit w-full flex-col justify-evenly gap-8 rounded-2xl bg-gray-800 px-10 pt-8 pb-10 ${className} border-gray-faded/30 border`}
12+
className={`flex h-fit w-full flex-col justify-evenly gap-8 rounded-2xl bg-gray-850 p-4 ${className} border border-gray-faded/30`}
1313
>
1414
{children}
1515
</div>

src/components/DashboardLayout/InstanceViewLayout.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const InstanceViewLayout = () => {
2828
if (queryInstanceId && instances && queryInstanceId in instances) {
2929
setInstanceState(instances[queryInstanceId]);
3030
if (!location.pathname.startsWith('/dashboard'))
31-
setPathname('/dashboard/overview');
31+
setPathname('/dashboard/console');
3232
} else {
3333
setInstanceState(undefined);
3434
if (location.pathname.startsWith('/dashboard')) setPathname('/');
@@ -44,7 +44,7 @@ export const InstanceViewLayout = () => {
4444
} else {
4545
setInstanceState(instance);
4646
setQueryInstanceId(instance.uuid);
47-
setPathname('/dashboard/overview');
47+
setPathname('/dashboard/console');
4848
}
4949
}
5050
/* End Instances */
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
3+
const Spinner = () => {
4+
return (
5+
<div className="fixed inset-0 z-50 flex items-center justify-center bg-gray-900 bg-opacity-75">
6+
<div className="relative h-24 w-24">
7+
<div
8+
className="absolute top-0 left-0 h-full w-full animate-spin rounded-full border-4 border-t-4 border-blue-400"
9+
style={{
10+
borderBottomColor: 'transparent',
11+
}}
12+
></div>
13+
</div>
14+
</div>
15+
);
16+
};
17+
18+
export default Spinner;

src/pages/InstanceTabs/InstanceTabs.tsx

+3-13
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useLocation } from 'react-router-dom';
55
import InstanceTabListMap from '../../data/InstanceTabListMap';
66
import Label from 'components/Atoms/Label';
77
import { stateToLabelColor } from 'utils/util';
8+
import Spinner from 'components/DashboardLayout/Spinner';
89
const InstanceTabs = () => {
910
useDocumentTitle('Dashboard - Lodestone');
1011
const location = useLocation();
@@ -25,18 +26,7 @@ const InstanceTabs = () => {
2526

2627
if (!instance || !uuid) {
2728
if (loading) {
28-
return (
29-
<div className="fixed inset-0 z-50 flex items-center justify-center bg-gray-900 bg-opacity-75">
30-
<div className="relative h-24 w-24">
31-
<div
32-
className="absolute top-0 left-0 h-full w-full animate-spin rounded-full border-4 border-t-4 border-blue-400"
33-
style={{
34-
borderBottomColor: 'transparent',
35-
}}
36-
></div>
37-
</div>
38-
</div>
39-
);
29+
return <Spinner />;
4030
} else {
4131
return (
4232
<div
@@ -63,7 +53,7 @@ const InstanceTabs = () => {
6353
(tab) =>
6454
tab.path === path && (
6555
<div
66-
className="gutter-stable -mx-4 flex grow flex-row items-stretch overflow-y-auto pl-4 pr-2"
56+
className="gutter-stable -mx-3 flex grow flex-row items-stretch overflow-y-auto pl-4 pr-2"
6757
key={`${instance.name}-${tab.title}`}
6858
>
6959
<div className="flex h-fit min-h-full w-full flex-col gap-16 pt-6 pb-10 focus:outline-none">

src/pages/home.tsx

+35-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import axios from 'axios';
2+
import { useEffect, useState } from 'react';
23
import DashboardCard from 'components/DashboardCard';
34
import PerformanceGraph from 'components/Graphs/PerformanceGraph';
45
import { useDocumentTitle } from 'usehooks-ts';
56
import { round } from 'utils/util';
7+
import { useUserInfo } from 'data/UserInfo';
8+
import { LodestoneContext } from 'data/LodestoneContext';
9+
import { useContext } from 'react';
10+
import Spinner from 'components/DashboardLayout/Spinner';
611

712
type CpuUsageReply = {
813
cpu_speed: number;
@@ -32,22 +37,45 @@ const getRamUsage = async (): Promise<[number, number]> => {
3237
};
3338

3439
const Home = () => {
40+
const { token } = useContext(LodestoneContext);
41+
const { isLoading, isError, data: user } = useUserInfo();
42+
3543
useDocumentTitle('Home - Lodestone');
44+
45+
const [loading, setLoading] = useState(true);
46+
47+
useEffect(() => {
48+
//give time for user to load
49+
setTimeout(() => {
50+
setLoading(false);
51+
}, 1000);
52+
}, []);
53+
54+
if (loading && isLoading) {
55+
return <Spinner />;
56+
}
57+
3658
return (
3759
// used to possibly center the content
38-
<div className="relative flex h-full w-full flex-row justify-center overflow-y-scroll px-4 pt-8 pb-10 @container">
60+
<div className="relative mx-auto flex h-full w-full max-w-4xl flex-row justify-center overflow-y-scroll pt-8 pb-10 @container">
3961
{/* main content container */}
4062
<div className="flex h-fit min-h-full w-full grow flex-col items-start gap-2">
4163
<h1 className="font-title text-2xlarge font-bold tracking-tight text-gray-300">
42-
Home
64+
{`Welcome, ${
65+
token && !isLoading && !isError && user
66+
? `${user.username}`
67+
: 'Guest'
68+
}!`}
4369
</h1>
44-
<p>Display some general information here maybe</p>
70+
<h3 className="mb-4 text-h3 font-medium italic tracking-medium text-white/50">
71+
{' '}
72+
Select or create an instance to continue.
73+
</h3>
4574
<DashboardCard>
46-
<h1 className="text-h3 font-bold"> Performance </h1>
47-
<div className="mb-10 grid grid-cols-2 gap-10">
75+
<div className="my-8 grid grid-cols-2 gap-10">
4876
<div>
4977
<PerformanceGraph
50-
title="CPU Usage"
78+
title="CPU load"
5179
color="#62DD76"
5280
backgroundColor="#61AE3240"
5381
getter={getCpuUsage}
@@ -56,7 +84,7 @@ const Home = () => {
5684
</div>
5785
<div>
5886
<PerformanceGraph
59-
title="Memory Usage"
87+
title="Memory load"
6088
color="#62DD76"
6189
backgroundColor="#61AE3240"
6290
getter={getRamUsage}

0 commit comments

Comments
 (0)