Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"!.next",
"!dist",
"!build",
"!lib/graphql-types.ts"
"!src/lib/graphql-types.ts"
]
},
"formatter": {
Expand Down
4 changes: 2 additions & 2 deletions codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const config: CodegenConfig = {
},
},
},
documents: "pages/**/*.graphql",
documents: "src/**/*.graphql",
ignoreNoDocuments: true,
generates: {
"./lib/graphql-types.ts": {
"./src/lib/graphql-types.ts": {
plugins: [
"typescript",
"typescript-operations",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@emotion/styled": "11.14.1",
"@mui/icons-material": "7.3.6",
"@mui/material": "7.3.6",
"@mui/material-nextjs": "7.3.6",
"@types/node": "24.10.1",
"@types/react": "19.2.7",
"@types/react-dom": "19.2.3",
Expand Down
85 changes: 0 additions & 85 deletions pages/_app.tsx

This file was deleted.

31 changes: 31 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions public/vercel.svg

This file was deleted.

45 changes: 45 additions & 0 deletions src/app/apollo-provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"use client"

import {
ApolloClient,
ApolloProvider,
createHttpLink,
InMemoryCache,
} from "@apollo/client"
import { setContext } from "@apollo/client/link/context"

import { type ReactNode, useMemo } from "react"
import { getToken } from "../lib/auth"

function createApolloClient() {
const httpLink = createHttpLink({
uri: `${process.env.NEXT_PUBLIC_HASURA_URL}/v1/graphql`,
})

const authLink = setContext((_, { headers }) => {
const token = getToken()
return {
headers: {
...headers,
authorization: token ? `Bearer ${token}` : "",
},
}
})

return new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache(),
})
}

export interface ApolloProviderClientProps {
children: ReactNode
}

export default function ApolloProviderClient({
children,
}: ApolloProviderClientProps) {
const client = useMemo(() => createApolloClient(), [])

return <ApolloProvider client={client}>{children}</ApolloProvider>
}
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import CssBaseline from "@mui/material/CssBaseline"
import { ThemeProvider } from "@mui/material/styles"
import { AppRouterCacheProvider } from "@mui/material-nextjs/v15-appRouter"
import type { Metadata } from "next"
import { Noto_Sans_JP } from "next/font/google"
import "./globals.css"

import { InitColorSchemeScript } from "@mui/material"
import theme from "../theme"
import ApolloProviderClient from "./apollo-provider"

const notoSansJp = Noto_Sans_JP({
weight: ["300", "400", "500", "700"],
preload: false,
display: "swap",
variable: "--font-noto-sans-jp",
})

export const metadata: Metadata = {
title: "Harmonica",
description: "Harmonica Web Dashboard",
}

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode
}>) {
return (
<html lang="ja" className={notoSansJp.variable} suppressHydrationWarning>
<body>
<AppRouterCacheProvider>
<ThemeProvider theme={theme}>
<InitColorSchemeScript attribute="class" />
<CssBaseline />
<ApolloProviderClient>{children}</ApolloProviderClient>
</ThemeProvider>
</AppRouterCacheProvider>
</body>
</html>
)
}
5 changes: 5 additions & 0 deletions src/app/login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LoginForm from "../components/login-form"

export default function LoginPage() {
return <LoginForm />
}
5 changes: 5 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Monitor from "../components/monitor"

export default function Home() {
return <Monitor />
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useApolloClient } from "@apollo/client"
import AccountCircleIcon from "@mui/icons-material/AccountCircle"
import { Box, IconButton, Menu, MenuItem } from "@mui/material"
import { useRouter } from "next/router"
import { useRouter } from "next/navigation"
import { useState } from "react"
import { setToken } from "../../auth"
import { setToken } from "../../lib/auth"

export default function AccountMenuIcon() {
const apolloClient = useApolloClient()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Box } from "@mui/material"
import "@/lib/chartjs"

import type { ChartOptions } from "chart.js"
import { type ChartProps, Line } from "react-chartjs-2"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Box } from "@mui/material"
import "@/lib/chartjs"

import type { ChartOptions } from "chart.js"
import { type ChartProps, Line } from "react-chartjs-2"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Box } from "@mui/material"
import "@/lib/chartjs"

import type { ChartOptions } from "chart.js"
import { type ChartProps, Line } from "react-chartjs-2"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Box } from "@mui/material"
import "@/lib/chartjs"

import type { ChartOptions } from "chart.js"
import { type ChartProps, Line } from "react-chartjs-2"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Box } from "@mui/material"
import "@/lib/chartjs"

import type { ChartOptions } from "chart.js"
import { type ChartProps, Line } from "react-chartjs-2"

Expand Down
10 changes: 6 additions & 4 deletions pages/login.tsx → src/components/login-form.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
"use client"

import { Box, Button, Container, TextField } from "@mui/material"
import Head from "next/head"
import { useRouter } from "next/router"
import { useRouter } from "next/navigation"
import { useEffect } from "react"
import { Controller, useForm } from "react-hook-form"
import { hasToken, setToken } from "../lib/auth"
import AnonymousAppBar from "../lib/components/app_bar/anonymous_app_bar"
import AnonymousAppBar from "./app_bar/anonymous_app_bar"

interface LoginValues {
export interface LoginValues {
token: string
}

export default function LoginPage() {
export default function LoginForm() {
const router = useRouter()
const { control, handleSubmit } = useForm<LoginValues>({
defaultValues: {
Expand Down
26 changes: 11 additions & 15 deletions pages/index.tsx → src/components/monitor.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client"

import assert from "node:assert"
import {
Box,
Expand All @@ -7,20 +9,19 @@ import {
Toolbar,
Typography,
} from "@mui/material"
import dayjs from "dayjs"
import Head from "next/head"
import { useRouter } from "next/router"
import { useRouter } from "next/navigation"
import { useEffect, useState } from "react"
import dayjs from "@/lib/dayjs"
import MainAppBar from "../components/app_bar/main_app_bar"
import Co2Chart from "../components/chart/co2_chart"
import HumidityChart from "../components/chart/humidity_chart"
import LightChart from "../components/chart/light_chart"
import TemperatureChart from "../components/chart/temperature_chart"
import SmokePingChartImage from "../components/smoke_ping_chart_image"
import { hasToken } from "../lib/auth"
import MainAppBar from "../lib/components/app_bar/main_app_bar"
import Co2Chart from "../lib/components/chart/co2_chart"
import HumidityChart from "../lib/components/chart/humidity_chart"
import LightChart from "../lib/components/chart/light_chart"
import TemperatureChart from "../lib/components/chart/temperature_chart"
import SmokePingChartImage from "../lib/components/smoke_ping_chart_image"
import { useGetMonitorQuery } from "../lib/graphql-types"

export default function HomePage() {
export default function Monitor() {
const router = useRouter()

const smokePingNames =
Expand Down Expand Up @@ -141,11 +142,6 @@ export default function HomePage() {

return (
<div>
<Head>
<title>Harmonica</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<Box sx={{ display: "flex" }}>
<CssBaseline />
<MainAppBar
Expand Down
Loading