From d59e6c50e0a401fd37c561f8597571d707cd86ae Mon Sep 17 00:00:00 2001 From: NlightN22 Date: Thu, 29 Feb 2024 23:41:25 +0700 Subject: [PATCH] fix lint warnings --- Dockerfile | 19 +++++++++ package.json | 3 +- src/pages/MainPage.tsx | 55 ++++++++++++++++----------- src/pages/TestPage.tsx | 38 +++++++++--------- src/widgets/header/HeaderAction.tsx | 9 ++--- src/widgets/header/header.links.ts | 2 +- src/widgets/hosts.table/StateCell.tsx | 7 ++-- yarn.lock | 5 --- 8 files changed, 77 insertions(+), 61 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..47a2a01 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# syntax=docker/dockerfile:1 +# Build commands: +# - rm dist -r -Force ; yarn build +# - $VERSION=0.1 +# - docker build --pull --rm -t oncharterliz/frigate-proxy:latest -t oncharterliz/frigate-proxy:$VERSION "." +# - docker image push --all-tags oncharterliz/frigate-proxy + +FROM node:18-alpine AS frigate-proxy +ENV NODE_ENV=production +WORKDIR /app + +COPY package.json yarn.lock ./ + +RUN yarn install --production + +COPY ./dist ./dist + +CMD yarn prod +EXPOSE 4000 \ No newline at end of file diff --git a/package.json b/package.json index 03fe94e..611085a 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@types/strftime": "^0.9.8", "@types/uuid": "^9.0.2", - "@types/video.js": "^7.3.56", - "uuid": "^9.0.0" + "@types/video.js": "^7.3.56" } } diff --git a/src/pages/MainPage.tsx b/src/pages/MainPage.tsx index 5473ac0..01c4a0d 100644 --- a/src/pages/MainPage.tsx +++ b/src/pages/MainPage.tsx @@ -1,17 +1,17 @@ -import { Flex, Grid, Group, TextInput } from '@mantine/core'; -import { useContext, useState, useEffect, useMemo } from 'react'; -import { Context } from '..'; -import { observer } from 'mobx-react-lite' -import CenterLoader from '../shared/components/loaders/CenterLoader'; -import { useQuery } from '@tanstack/react-query'; -import { frigateApi, frigateQueryKeys } from '../services/frigate.proxy/frigate.api'; -import RetryErrorPage from './RetryErrorPage'; -import CameraCard from '../widgets/CameraCard'; +import { Flex, Grid, TextInput } from '@mantine/core'; import { IconSearch } from '@tabler/icons-react'; -import React from 'react'; +import { useQuery } from '@tanstack/react-query'; +import { observer } from 'mobx-react-lite'; +import { useContext, useEffect, useMemo, useRef, useState } from 'react'; +import { Context } from '..'; +import { frigateApi, frigateQueryKeys } from '../services/frigate.proxy/frigate.api'; import { GetCameraWHostWConfig } from '../services/frigate.proxy/frigate.schema'; +import CenterLoader from '../shared/components/loaders/CenterLoader'; +import CameraCard from '../widgets/CameraCard'; +import RetryErrorPage from './RetryErrorPage'; const MainPage = () => { + const executed = useRef(false) const { sideBarsStore } = useContext(Context) const [searchQuery, setSearchQuery] = useState() const [filteredCameras, setFilteredCameras] = useState() @@ -30,28 +30,37 @@ const MainPage = () => { }, [searchQuery, cameras]) useEffect(() => { - sideBarsStore.rightVisible = false - sideBarsStore.setLeftChildren(null) - sideBarsStore.setRightChildren(null) - }, []) + if (!executed.current) { + sideBarsStore.rightVisible = false + sideBarsStore.setLeftChildren(null) + sideBarsStore.setRightChildren(null) + executed.current = true + } + }, [sideBarsStore]) const cards = useMemo(() => { if (filteredCameras) - return filteredCameras.map(camera => ( + return filteredCameras.filter(camera => { + if (camera.frigateHost && !camera.frigateHost.enabled) return false + return true + }).map(camera => ( ) ) - else - return cameras?.map( - camera => ( - ) + else if (cameras) + return cameras.filter(camera => { + if (camera.frigateHost && !camera.frigateHost.enabled) return false + return true + }).map(camera => ( + ) ) - }, [cameras, filteredCameras, searchQuery]) + else return [] + }, [cameras, filteredCameras]) if (isPending) return diff --git a/src/pages/TestPage.tsx b/src/pages/TestPage.tsx index da6c384..876e78e 100644 --- a/src/pages/TestPage.tsx +++ b/src/pages/TestPage.tsx @@ -1,35 +1,31 @@ -import React, { Fragment, useContext, useEffect, useRef, useState } from 'react'; +import { Flex, Grid, Group } from '@mantine/core'; import { observer } from 'mobx-react-lite'; -import { Button, Flex, Grid, Group, Indicator, Paper, Skeleton } from '@mantine/core'; -import RetryError from '../shared/components/RetryError'; -import { DatePickerInput } from '@mantine/dates'; -import HeadSearch from '../shared/components/inputs/HeadSearch'; -import ViewSelector from '../shared/components/TableGridViewSelector'; -import { useIntersection } from '@mantine/hooks'; -import TestItem from './TestItem'; +import { useContext, useEffect, useRef } from 'react'; import { Context } from '..'; +import HeadSearch from '../shared/components/inputs/HeadSearch'; +import TestItem from './TestItem'; const Test = () => { - const [value, setValue] = useState<[Date | null, Date | null]>([null, null]) + const executed = useRef(false) + const { sideBarsStore } = useContext(Context) sideBarsStore.rightVisible = true useEffect(() => { - sideBarsStore.rightVisible = true - return () => { - sideBarsStore.rightVisible = false + if (!executed.current) { + sideBarsStore.rightVisible = false + sideBarsStore.setLeftChildren(null) + sideBarsStore.setRightChildren(null) + executed.current = true } - }, []) +}, [sideBarsStore]) - useEffect(() => { - console.log('value', value) - }, [value]) - const handleClick = () => { - const startOfDay = new Date(); - startOfDay.setHours(0, 0, 0, 0); - setValue([startOfDay, startOfDay]) - } + // const handleClick = () => { + // const startOfDay = new Date(); + // startOfDay.setHours(0, 0, 0, 0); + // setValue([startOfDay, startOfDay]) + // } const cards = (qty: number) => { let items = [] diff --git a/src/widgets/header/HeaderAction.tsx b/src/widgets/header/HeaderAction.tsx index da1e8f8..6200db7 100644 --- a/src/widgets/header/HeaderAction.tsx +++ b/src/widgets/header/HeaderAction.tsx @@ -1,13 +1,12 @@ -import { Burger, createStyles, Header, rem, Menu, Container, Group, Button, Flex } from "@mantine/core"; -import { useDisclosure, useMediaQuery } from "@mantine/hooks"; -import UserMenu from '../../shared/components/UserMenu'; +import { Button, Container, Flex, Group, Header, Menu, createStyles, rem } from "@mantine/core"; import { useAuth } from 'react-oidc-context'; import { useNavigate } from 'react-router-dom'; +import { useAdminRole } from "../../hooks/useAdminRole"; +import { routesPath } from "../../router/routes.path"; +import UserMenu from '../../shared/components/UserMenu'; import ColorSchemeToggle from "../../shared/components/buttons/ColorSchemeToggle"; import Logo from "../../shared/components/images/LogoImage"; -import { routesPath } from "../../router/routes.path"; import DrawerMenu from "../../shared/components/menu/DrawerMenu"; -import { useAdminRole } from "../../hooks/useAdminRole"; const HEADER_HEIGHT = rem(60) diff --git a/src/widgets/header/header.links.ts b/src/widgets/header/header.links.ts index 3f06e59..d81faf9 100644 --- a/src/widgets/header/header.links.ts +++ b/src/widgets/header/header.links.ts @@ -1,6 +1,6 @@ import { routesPath } from "../../router/routes.path"; import { headerMenu } from "../../shared/strings/header.menu.strings"; -import { HeaderActionProps, LinkItem } from "./HeaderAction"; +import { LinkItem } from "./HeaderAction"; export const headerLinks: LinkItem[] = [ { link: routesPath.MAIN_PATH, label: headerMenu.home }, diff --git a/src/widgets/hosts.table/StateCell.tsx b/src/widgets/hosts.table/StateCell.tsx index 155f6b0..a2c8381 100644 --- a/src/widgets/hosts.table/StateCell.tsx +++ b/src/widgets/hosts.table/StateCell.tsx @@ -1,8 +1,7 @@ -import { Flex, Paper } from '@mantine/core'; +import { Flex } from '@mantine/core'; import { IconPower } from '@tabler/icons-react'; -import React from 'react'; -import { frigateApi, frigateQueryKeys } from '../../services/frigate.proxy/frigate.api'; import { useQuery } from '@tanstack/react-query'; +import { frigateApi, frigateQueryKeys } from '../../services/frigate.proxy/frigate.api'; interface StateCellProps { id?: string @@ -12,7 +11,7 @@ const StateCell = ({ id, width, }: StateCellProps) => { - const { isPending, isError, data } = useQuery({ + const { data } = useQuery({ queryKey: [frigateQueryKeys.getFrigateHosts, id], queryFn: frigateApi.getHosts, staleTime: 60 * 1000, diff --git a/yarn.lock b/yarn.lock index e7a0368..8adc20c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9825,11 +9825,6 @@ uuid@^8.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== -uuid@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" - integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== - v8-to-istanbul@^8.1.0: version "8.1.1" resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-8.1.1.tgz#77b752fd3975e31bbcef938f85e9bd1c7a8d60ed"