mirror of
https://github.com/DeveloLongScript/MHSF.git
synced 2026-05-07 15:05:02 -05:00
This ain't history class + clean-ups
This commit is contained in:
parent
3a16258c0d
commit
473332cf69
@ -14,7 +14,6 @@ import { IconDisplayClient } from "@/components/IconDisplay";
|
||||
import { banner } from "@/banner";
|
||||
import Link from "next/link";
|
||||
import TabServer from "@/components/misc/TabServer";
|
||||
import { ChartComponent } from "@/components/Chart";
|
||||
import { NewChart } from "@/components/NewChart";
|
||||
|
||||
type Props = {
|
||||
@ -1,104 +0,0 @@
|
||||
"use client";
|
||||
import { TrendingUp } from "lucide-react";
|
||||
import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import {
|
||||
ChartConfig,
|
||||
ChartContainer,
|
||||
ChartTooltip,
|
||||
ChartTooltipContent,
|
||||
} from "@/components/ui/chart";
|
||||
import { useState } from "react";
|
||||
import { useEffectOnce } from "@/lib/useEffectOnce";
|
||||
|
||||
const chartConfig = {
|
||||
player_count: {
|
||||
label: "Player Count ",
|
||||
color: "hsl(var(--chart-1))",
|
||||
},
|
||||
favorites: {
|
||||
label: "Favorites",
|
||||
color: "hsl(var(--chart-2))",
|
||||
},
|
||||
} satisfies ChartConfig;
|
||||
|
||||
export function ChartComponent({
|
||||
chart,
|
||||
server,
|
||||
}: {
|
||||
chart: string;
|
||||
server: string;
|
||||
}) {
|
||||
const [data, setData] = useState([]);
|
||||
|
||||
useEffectOnce(() => {
|
||||
fetch("/api/history/getShortTermData", {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
scopes: ["player_count", "favorites", "time"],
|
||||
server: server,
|
||||
}),
|
||||
method: "POST",
|
||||
}).then((c) =>
|
||||
c.json().then((b) => {
|
||||
setData(b.data.slice(-30));
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>
|
||||
{chart == "player_count" ? "Joins" : "Favorites"} for {server}
|
||||
</CardTitle>
|
||||
<CardDescription>Information from the last day</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<ChartContainer config={chartConfig}>
|
||||
<LineChart
|
||||
accessibilityLayer
|
||||
data={data}
|
||||
margin={{
|
||||
left: 12,
|
||||
right: 12,
|
||||
}}
|
||||
>
|
||||
<CartesianGrid />
|
||||
<XAxis
|
||||
dataKey="time"
|
||||
tickLine={false}
|
||||
axisLine={false}
|
||||
tickMargin={8}
|
||||
minTickGap={32}
|
||||
tickFormatter={(value) => {
|
||||
const date = new Date(value);
|
||||
return date.toLocaleTimeString("en-US", {
|
||||
timeStyle: "short",
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<ChartTooltip content={<ChartTooltipContent />} />
|
||||
<YAxis
|
||||
dataKey="player_count"
|
||||
tickLine={false}
|
||||
axisLine={false}
|
||||
tickMargin={8}
|
||||
minTickGap={32}
|
||||
/>
|
||||
|
||||
<Line dataKey={chart} strokeWidth={2} dot={false} />
|
||||
</LineChart>
|
||||
</ChartContainer>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@ -22,14 +22,14 @@ export default function TabServer({
|
||||
setTab(tac);
|
||||
setTabLoading(true);
|
||||
if (tac == "historical")
|
||||
window.location.replace(`/server/${server}/historical-data`);
|
||||
window.location.replace(`/server/${server}/short-term`);
|
||||
if (tac == "general") window.location.replace(`/server/${server}`);
|
||||
}}
|
||||
className="w-[300px]"
|
||||
>
|
||||
<TabsList className="grid w-full grid-cols-2">
|
||||
<TabsTrigger value="general"> General Information</TabsTrigger>
|
||||
<TabsTrigger value="historical">Historical Data</TabsTrigger>
|
||||
<TabsTrigger value="historical">Short Term</TabsTrigger>
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
@ -20,12 +20,15 @@ export const Changelog = () => (
|
||||
<br />
|
||||
<div>
|
||||
<strong className="flex items-center">
|
||||
Version b-0.4 (July 24th 2024):
|
||||
Version b-0.4 (July 25th 2024):
|
||||
</strong>
|
||||
<ul>
|
||||
<li>• Added Info button</li>
|
||||
<li>• Fixed Clerk in production</li>
|
||||
<li>• Added Turbo for faster builds</li>
|
||||
<li>
|
||||
• <strong>Added historical data</strong>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user