Feat: gseps 화면 작업 완료

This commit is contained in:
hyojin 2023-09-11 17:40:47 +09:00
parent 3a639e9a38
commit c3fe093f5f
20 changed files with 530 additions and 112 deletions

1
.env Normal file
View File

@ -0,0 +1 @@
NEXT_PUBLIC_BASE_API_URL="http://13.209.39.139:32171"

View File

@ -1,5 +1,17 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
domains: ['13.209.39.139'],
// remotePatterns: [
// {
// protocol: 'http',
// hostname: '13.209.39.139',
// port: '31192',
// pathname: '/api/v1/buckets/gseps-test-a/objects/**',
// },
// ],
},
compiler: {
styledComponents: true,
},

74
package-lock.json generated
View File

@ -8,11 +8,19 @@
"name": "front-boilerplate",
"version": "0.0.1",
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-regular-svg-icons": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@nivo/bar": "^0.83.0",
"@nivo/core": "^0.83.0",
"@nivo/line": "^0.83.0",
"@sdt/sdt-ui-kit": "^0.1.20",
"@tanstack/react-query": "^4.33.0",
"autoprefixer": "10.4.15",
"axios": "^1.4.0",
"cookies-next": "^3.0.0",
"date-fns": "^2.30.0",
"eslint": "8.47.0",
"eslint-config-next": "13.4.19",
"lodash": "^4.17.21",
@ -2817,6 +2825,29 @@
"react": ">= 16.14.0 < 19.0.0"
}
},
"node_modules/@nivo/bar": {
"version": "0.83.0",
"resolved": "https://registry.npmjs.org/@nivo/bar/-/bar-0.83.0.tgz",
"integrity": "sha512-QXN6BcT1PiT/YViyoDU4G5mytbOUP1jYbuQmJhDDxKPMLNcZ/pHfThedRGVfDoD1poHBRJtV6mbgeCpAVmlTtw==",
"dependencies": {
"@nivo/annotations": "0.83.0",
"@nivo/axes": "0.83.0",
"@nivo/colors": "0.83.0",
"@nivo/core": "0.83.0",
"@nivo/legends": "0.83.0",
"@nivo/scales": "0.83.0",
"@nivo/tooltip": "0.83.0",
"@react-spring/web": "9.4.5 || ^9.7.2",
"@types/d3-scale": "^3.2.3",
"@types/d3-shape": "^2.0.0",
"d3-scale": "^3.2.3",
"d3-shape": "^1.3.5",
"lodash": "^4.17.21"
},
"peerDependencies": {
"react": ">= 16.14.0 < 19.0.0"
}
},
"node_modules/@nivo/colors": {
"version": "0.83.0",
"resolved": "https://registry.npmjs.org/@nivo/colors/-/colors-0.83.0.tgz",
@ -4503,6 +4534,21 @@
"integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==",
"dev": true
},
"node_modules/date-fns": {
"version": "2.30.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz",
"integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==",
"dependencies": {
"@babel/runtime": "^7.21.0"
},
"engines": {
"node": ">=0.11"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/date-fns"
}
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@ -10500,6 +10546,26 @@
"prop-types": "^15.7.2"
}
},
"@nivo/bar": {
"version": "0.83.0",
"resolved": "https://registry.npmjs.org/@nivo/bar/-/bar-0.83.0.tgz",
"integrity": "sha512-QXN6BcT1PiT/YViyoDU4G5mytbOUP1jYbuQmJhDDxKPMLNcZ/pHfThedRGVfDoD1poHBRJtV6mbgeCpAVmlTtw==",
"requires": {
"@nivo/annotations": "0.83.0",
"@nivo/axes": "0.83.0",
"@nivo/colors": "0.83.0",
"@nivo/core": "0.83.0",
"@nivo/legends": "0.83.0",
"@nivo/scales": "0.83.0",
"@nivo/tooltip": "0.83.0",
"@react-spring/web": "9.4.5 || ^9.7.2",
"@types/d3-scale": "^3.2.3",
"@types/d3-shape": "^2.0.0",
"d3-scale": "^3.2.3",
"d3-shape": "^1.3.5",
"lodash": "^4.17.21"
}
},
"@nivo/colors": {
"version": "0.83.0",
"resolved": "https://registry.npmjs.org/@nivo/colors/-/colors-0.83.0.tgz",
@ -11761,6 +11827,14 @@
"integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==",
"dev": true
},
"date-fns": {
"version": "2.30.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz",
"integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==",
"requires": {
"@babel/runtime": "^7.21.0"
}
},
"debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",

View File

@ -9,11 +9,19 @@
"lint": "next lint"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-regular-svg-icons": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@nivo/bar": "^0.83.0",
"@nivo/core": "^0.83.0",
"@nivo/line": "^0.83.0",
"@sdt/sdt-ui-kit": "^0.1.20",
"@tanstack/react-query": "^4.33.0",
"autoprefixer": "10.4.15",
"axios": "^1.4.0",
"cookies-next": "^3.0.0",
"date-fns": "^2.30.0",
"eslint": "8.47.0",
"eslint-config-next": "13.4.19",
"lodash": "^4.17.21",

BIN
public/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,12 @@
import { ResultDataType } from '@/app/dashboard/types';
import { afterAxios, fetchApi } from '../config';
export interface GetResultApiRequestType {}
export type GetResultApiResponseType = ResultDataType;
export const getResultApi = (): Promise<GetResultApiResponseType> =>
fetchApi({
url: 'blokworks/v1/transport/inference/results',
method: 'GET',
}).then(afterAxios);

View File

@ -0,0 +1,49 @@
import React from 'react';
import { ResponsiveBar } from '@nivo/bar';
function BarChart({ data }: any) {
return (
<div className="w-full h-[calc(100vh-300px)]">
<ResponsiveBar
data={data}
keys={['count']}
indexBy="range"
margin={{ top: 50, right: 20, bottom: 50, left: 60 }}
padding={0.3}
valueScale={{ type: 'linear' }}
indexScale={{ type: 'band', round: true }}
colors={{ scheme: 'nivo' }}
borderColor={{
from: 'color',
modifiers: [['darker', 1.6]],
}}
// maxValue={10}
axisTop={null}
axisRight={null}
axisBottom={{
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
}}
axisLeft={{
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
}}
enableLabel={false}
labelTextColor={{
from: 'color',
modifiers: [['darker', 1.6]],
}}
legends={[]}
role="application"
ariaLabel="Nivo bar chart demo"
barAriaLabel={(e) =>
e.id + ': ' + e.formattedValue + ' in country: ' + e.indexValue
}
/>
</div>
);
}
export default BarChart;

View File

@ -0,0 +1,80 @@
'use client';
import React from 'react';
import BarChart from './BarChart';
import { format } from 'date-fns';
import Image from 'next/image';
import useDashboard from '../hooks/useDashboard';
import { Button } from '@sdt/sdt-ui-kit';
import { useQueryClient } from '@tanstack/react-query';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faArrowsRotate } from '@fortawesome/free-solid-svg-icons';
function Dashboard() {
const { getResult, convertChartData } = useDashboard();
const queryClient = useQueryClient();
return (
<div>
<div className=" flex items-center h-[80px] px-12 bg-white border-b border-gray-300">
<Image src={'/logo.png'} alt="logo" width={100} height={50} />
</div>
<div className="grid grid-cols-8 p-12 h-[calc(100vh-150px)]">
{getResult.data && (
<>
<div className="mt-12 col-span-2">
<h2 className="text-lg font-semibold text-center">Input Image</h2>
<div className="relative w-full h-[calc(50vh-250px)] mt-2 mb-20 ">
<Image
src={getResult.data?.origin.imageUrl}
alt="origin image"
fill
sizes="100vw, 100vh"
priority
/>
</div>
<h2 className="text-lg font-semibold text-center">
Inference Result Image
</h2>
<div className="relative w-full h-[calc(50vh-250px)] mt-2">
<Image
src={getResult.data?.latest.imageUrl}
alt="inference image"
fill
sizes="100vw, 100vh"
priority
/>
</div>
</div>
<div className="col-span-6">
<div className="text-right text-lg font-semibold">
:{' '}
{format(
getResult.data?.latest.timestamp,
'yyyy-MM-dd HH:mm:ss',
)}
<Button
onClick={() => queryClient.invalidateQueries(['result'])}
backgroundColor="#fafafa"
className="ml-2"
>
<FontAwesomeIcon
icon={faArrowsRotate}
style={{ color: '#7a7a7a' }}
/>
</Button>
</div>
<BarChart data={convertChartData} />
</div>
</>
)}
</div>
<div className="text-center text-[#7a7a7a]">
Copyright 2023 SDT Inc. All rights reserved.
</div>
</div>
);
}
export default Dashboard;

View File

@ -0,0 +1,99 @@
import React from 'react';
import { ResponsiveLine } from '@nivo/line';
function LineChart({ data }: any) {
return (
<div>
<div className="h-[500px]">
<ResponsiveLine
data={data}
margin={{ top: 50, right: 30, bottom: 50, left: 60 }}
xScale={{ type: 'linear' }}
yScale={{
type: 'linear',
// stacked: true,
min: 0,
max: 100,
}}
yFormat=" >-.2f"
curve="monotoneX"
axisTop={null}
axisRight={null}
axisBottom={{
// tickValues: [0, 20, 40, 60, 80, 100, 120],
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
// format: '.2f',
// legend: 'price',
// legendOffset: 36,
// legendPosition: 'middle',
}}
axisLeft={{
// tickValues: [0, 500, 1000, 1500, 2000, 2500],
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
// format: '.2s',
// legend: 'volume',
// legendOffset: -40,
// legendPosition: 'middle',
}}
enableGridX={false}
colors={{ scheme: 'spectral' }}
lineWidth={1}
pointSize={0}
pointColor={{ theme: 'background' }}
pointBorderWidth={1}
pointBorderColor={{ from: 'serieColor' }}
pointLabelYOffset={-12}
useMesh={true}
// gridXValues={[0, 20, 40, 60, 80, 100, 120]}
// gridYValues={[0, 500, 1000, 1500, 2000, 2500]}
legends={[]}
/>
{/* <ResponsiveLine
data={data}
margin={{ top: 50, right: 20, bottom: 50, left: 60 }}
xScale={{ type: 'point' }}
yScale={{
type: 'linear',
min: 'auto',
max: 'auto',
stacked: true,
reverse: false,
}}
yFormat=" >-.2f"
axisTop={null}
axisRight={null}
axisBottom={{
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
// legend: 'transportation',
// legendOffset: 36,
// legendPosition: 'middle',
}}
axisLeft={{
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
// legend: 'count',
// legendOffset: -40,
// legendPosition: 'middle',
}}
pointSize={1}
pointColor={{ theme: 'background' }}
pointBorderWidth={2}
pointBorderColor={{ from: 'serieColor' }}
pointLabelYOffset={-12}
useMesh={true}
legends={[]}
/> */}
</div>
</div>
);
}
export default LineChart;

View File

@ -0,0 +1,26 @@
'use client';
import React from 'react';
import BarChart from './BarChart';
import { DUMMY_DATA } from '../constants';
import { format } from 'date-fns';
function RecentResult() {
return (
<div className="grid grid-cols-3 gap-4">
<div className="border border-gray-500">image</div>
<BarChart data={DUMMY_DATA.latest.particleSizeRatio} />
<div className="flex justify-center items-center text-center text-xl font-semibold">
<div>
<div></div>
<div>
{format(DUMMY_DATA.latest.timestamp, 'yyyy-MM-dd HH:mm:ss')}
</div>
</div>
</div>
</div>
);
}
export default RecentResult;

View File

@ -0,0 +1,41 @@
'use client';
import React, { useEffect, useState } from 'react';
import LineChart from './LineChart';
import { Button, TextInput } from '@sdt/sdt-ui-kit';
function Result() {
const [line, setLine] = useState([]);
const chartData = [...Array(1000)].map((v, i) => ({
x: i,
y: Math.floor(Math.random() * 100),
}));
const data = [
{
id: 'korea',
color: 'rgb(217, 38, 107)',
data: chartData,
},
];
// useEffect(() => {
// setTimeout(() => {
// setLine(chartData);
// }, 3000);
// }, [chartData]);
return (
<div className="mb-10">
<div className="flex items-center">
<span> </span>
<TextInput size="medium" className="px-4" />
<Button></Button>
</div>
<LineChart data={data} />
</div>
);
}
export default Result;

View File

@ -0,0 +1,29 @@
export const DUMMY_DATA = {
latest: {
imageUrl:
'http://13.209.39.139:31192/api/v1/buckets/gseps-test-a/objects/download?prefix=MjAyMzA5MDctMTEyNzU2LmpwZw==&version_id=null',
timestamp: 1694073245526,
particleSizeRatio: [
{
range: 186,
count: 1,
},
{
range: 102.5,
count: 1,
},
{
range: 79.5,
count: 8,
},
{
range: 313.5,
count: 1,
},
{
range: 146.5,
count: 1,
},
],
},
};

View File

@ -0,0 +1,31 @@
import { useMemo } from 'react';
import { getResultApi } from '@/api/dashboard/resultApi';
import { useQuery } from '@tanstack/react-query';
export function useDashboard() {
const getResult = useQuery(['result'], () => getResultApi());
const [resultData, setPieData] = useState<any>([]);
useEffect(() => {
setTimeout(() => {
setPieData(PIECHART_DUMMY);
}, 10);
}, []);
/**
* bar chart convert data
*/
const convertChartData = useMemo(() => {
const data = getResult.data?.latest.particleSizeRatio?.map((result, i) => {
return {
range: Number(result.range).toFixed(2),
count: result.count,
};
});
return data;
}, [getResult.data]);
return { getResult, convertChartData };
}

View File

@ -0,0 +1,27 @@
import React, { useMemo } from 'react';
import { getResultApi } from '@/api/dashboard/resultApi';
import { useQuery } from '@tanstack/react-query';
function useDashboard() {
const getResult = useQuery(['result'], () => getResultApi(), {
refetchOnWindowFocus: false,
});
/**
* bar chart convert data
*/
const convertChartData = useMemo(() => {
const data = getResult.data?.latest.particleSizeRatio?.map((result, i) => {
return {
range: Number(result.range).toFixed(2),
count: result.count,
};
});
return data;
}, [getResult.data]);
return { getResult, convertChartData };
}
export default useDashboard;

View File

@ -0,0 +1,7 @@
export default function LoginLayout({
children,
}: {
children: React.ReactNode;
}) {
return <>{children}</>;
}

View File

@ -0,0 +1,8 @@
import React from 'react';
import Dashboard from './components/Dashboard';
function LoginPage() {
return <Dashboard />;
}
export default LoginPage;

View File

@ -0,0 +1,12 @@
import { StaticImageData } from 'next/image';
export interface ResultDataType {
origin: {
imageUrl: StaticImageData;
};
latest: {
imageUrl: StaticImageData;
timestamp: number;
particleSizeRatio: { range: string; count: number }[];
};
}

View File

@ -1,113 +1,15 @@
import Image from 'next/image';
'use client';
import React, { useEffect } from 'react';
import { useRouter } from 'next/navigation';
export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
Get started by editing&nbsp;
<code className="font-mono font-bold">src/app/page.tsx</code>
</p>
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By{' '}
<Image
src="/vercel.svg"
alt="Vercel Logo"
className="dark:invert"
width={100}
height={24}
priority
/>
</a>
</div>
</div>
const router = useRouter();
const targetRoutePath = '/dashboard';
<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-[480px] before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-[240px] after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 before:lg:h-[360px] z-[-1]">
<Image
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>
useEffect(() => {
router.push(targetRoutePath);
}, [router]);
<div className="mb-32 grid text-center lg:max-w-5xl lg:w-full lg:mb-0 lg:grid-cols-4 lg:text-left">
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Docs{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Find in-depth information about Next.js features and API.
</p>
</a>
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Learn{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Learn about Next.js in an interactive course with&nbsp;quizzes!
</p>
</a>
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Templates{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Explore the Next.js 13 playground.
</p>
</a>
<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Deploy{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Instantly deploy your Next.js site to a shareable URL with Vercel.
</p>
</a>
</div>
</main>
);
return <main></main>;
}

View File

@ -9,9 +9,9 @@ export default function Layout({ children }: { children: React.ReactNode }) {
useSilentAuth();
return (
<div className="w-full overflow-hidden">
<div className="flex pt-14">
<main className={`w-full p-12`}>{children}</main>
<div className="w-full overflow-hidden bg-[#fafafa]">
<div className="flex">
<main className={`w-full h-screen`}>{children}</main>
</div>
<Alert

View File

@ -35,7 +35,7 @@ function useSilentAuth() {
!SDT_AT &&
!(pathname.includes('login') || pathname.includes('reset-password'))
) {
router.push(`/login`);
// router.push(`/login`);
handleLogout();
}
}, [SDT_AT, handleLogout, loggedIn, pathname, router, setSignOut]);