From f8c963c7d668fc57680f25413f20bc207d4bf64a Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Tue, 23 Jul 2024 13:18:54 +0100 Subject: feat(gui): clean up home page, fix a few bugs (#2304) * wip home screen changes * more * adjust * fixes and things * patch runbook pty check --- ui/src/pages/Home.tsx | 255 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 188 insertions(+), 67 deletions(-) (limited to 'ui/src/pages') diff --git a/ui/src/pages/Home.tsx b/ui/src/pages/Home.tsx index 0f0b5dcf..2e93a893 100644 --- a/ui/src/pages/Home.tsx +++ b/ui/src/pages/Home.tsx @@ -2,32 +2,94 @@ import React, { useEffect } from "react"; import { formatRelative } from "date-fns"; import { Tooltip as ReactTooltip } from "react-tooltip"; -import { useStore } from "@/state/store"; +import { AtuinState, useStore } from "@/state/store"; import { useToast } from "@/components/ui/use-toast"; import { ToastAction } from "@/components/ui/toast"; import { invoke } from "@tauri-apps/api/core"; +import { + Card, + CardHeader, + CardBody, + Listbox, + ListboxItem, +} from "@nextui-org/react"; + +import { + Bar, + BarChart, + CartesianGrid, + LabelList, + XAxis, + YAxis, +} from "recharts"; +import { ChartConfig, ChartContainer } from "@/components/ui/chart"; + +import { Clock, Terminal } from "lucide-react"; import ActivityCalendar from "react-activity-calendar"; +import HistoryRow from "@/components/history/HistoryRow"; +import { ShellHistory } from "@/state/models"; -function Stats({ stats }: any) { +function StatCard({ name, stat }: any) { return ( -
-
- {stats.map((item: any) => ( -
-
- {item.name} -
-
- {item.stat} -
-
- ))} -
-
+ + +

{name}

+
+ +

{stat}

+
+
+ ); +} + +function TopChart({ chartData }: any) { + const chartConfig = { + command: { + label: "Command", + color: "#c4edde", + }, + } satisfies ChartConfig; + + return ( + + + + value.slice(0, 3)} + hide + /> + + + + + + + ); } @@ -62,14 +124,22 @@ const explicitTheme = { }; export default function Home() { - const homeInfo = useStore((state) => state.homeInfo); - const user = useStore((state) => state.user); - const calendar = useStore((state) => state.calendar); - const weekStart = useStore((state) => state.weekStart); + const homeInfo = useStore((state: AtuinState) => state.homeInfo); + const user = useStore((state: AtuinState) => state.user); + const calendar = useStore((state: AtuinState) => state.calendar); + const runbooks = useStore((state: AtuinState) => state.runbooks); + const weekStart = useStore((state: AtuinState) => state.weekStart); - const refreshHomeInfo = useStore((state) => state.refreshHomeInfo); - const refreshUser = useStore((state) => state.refreshUser); - const refreshCalendar = useStore((state) => state.refreshCalendar); + const refreshHomeInfo = useStore( + (state: AtuinState) => state.refreshHomeInfo, + ); + const refreshUser = useStore((state: AtuinState) => state.refreshUser); + const refreshCalendar = useStore( + (state: AtuinState) => state.refreshCalendar, + ); + const refreshRunbooks = useStore( + (state: AtuinState) => state.refreshRunbooks, + ); const { toast } = useToast(); @@ -77,6 +147,9 @@ export default function Home() { refreshHomeInfo(); refreshUser(); refreshCalendar(); + refreshRunbooks(); + + console.log(homeInfo); let setup = async () => { let installed = await invoke("is_cli_installed"); @@ -125,49 +198,97 @@ export default function Home() { } return ( -
-
+
+
+
+
+ + + + -
- -
- -
- - React.cloneElement(block, { - "data-tooltip-id": "react-tooltip", - "data-tooltip-html": `${activity.count} commands on ${activity.date}`, - }) - } - labels={{ - totalCount: "{{count}} history records in the last year", - }} - /> - -
+ + +

Activity graph

+
+ + + React.cloneElement(block, { + "data-tooltip-id": "react-tooltip", + "data-tooltip-html": `${activity.count} commands on ${activity.date}`, + }) + } + /> + + +
+ + + +

Quick actions

+
+ + + + } + > + New runbook + + } + > + Shell History + + + +
+ + + +

Recent commands

+
+ + {homeInfo.recentCommands?.map((i: ShellHistory) => { + return ; + })} + +
+ + + +

Top commands

+
+ + + +
); -- cgit v1.3.1