From cdc3ce122386e632f6b4350bc3dd4bdf4c17e0ed Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 24 Sep 2024 23:51:36 +0800 Subject: [PATCH] chore: clear unused code --- src/client/assets/react.svg | 1 - src/client/store/dashboard.ts | 98 ----------------------------------- 2 files changed, 99 deletions(-) delete mode 100644 src/client/assets/react.svg delete mode 100644 src/client/store/dashboard.ts diff --git a/src/client/assets/react.svg b/src/client/assets/react.svg deleted file mode 100644 index 6c87de9..0000000 --- a/src/client/assets/react.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/client/store/dashboard.ts b/src/client/store/dashboard.ts deleted file mode 100644 index 2614413..0000000 --- a/src/client/store/dashboard.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { create } from 'zustand'; -import { Layouts, Layout } from 'react-grid-layout'; -import { mapValues } from 'lodash-es'; -import { v1 as uuid } from 'uuid'; - -export type DashboardItemType = - | 'websiteOverview' - | 'websiteEvents' - | 'monitorHealthBar' - | 'monitorMetrics' - | 'monitorChart' - | 'monitorEvents'; - -export interface DashboardItem { - key: string; // match with layout, not equal - id: string; - title: string; - type: DashboardItemType; -} - -interface DashboardState { - isEditMode: boolean; - switchEditMode: () => void; - layouts: Layouts; - items: DashboardItem[]; - addItem: (type: DashboardItemType, id: string, title: string) => void; - removeItem: (key: string) => void; - changeItemTitle: (key: string, title: string) => void; -} - -export const defaultBlankLayouts = { - lg: [], -}; - -export const useDashboardStore = create((set, get) => ({ - isEditMode: false, - layouts: defaultBlankLayouts, - items: [], - switchEditMode: () => { - set({ isEditMode: !get().isEditMode }); - }, - addItem: (type: DashboardItemType, id: string, title: string) => { - const key = uuid(); - - set((state) => { - return { - layouts: mapValues(state.layouts, (layout) => [ - ...layout, - { ...defaultItemLayout[type], i: key }, - ]), - items: [ - ...state.items, - { - key, - id, - title, - type, - }, - ], - }; - }); - }, - removeItem: (key: string) => { - set((state) => { - return { - layouts: mapValues(state.layouts, (layout) => - layout.filter((l) => l.i !== key) - ), - items: state.items.filter((item) => item.key !== key), - }; - }); - }, - changeItemTitle: (key: string, title: string) => { - set((state) => { - return { - items: state.items.map((item) => { - if (item.key === key) { - return { - ...item, - title, - }; - } else { - return item; - } - }), - }; - }); - }, -})); - -export const defaultItemLayout: Record> = { - websiteOverview: { x: 0, y: Infinity, w: 4, h: 12 }, - websiteEvents: { x: 0, y: Infinity, w: 2, h: 5 }, - monitorHealthBar: { x: 0, y: Infinity, w: 2, h: 2 }, - monitorMetrics: { x: 0, y: Infinity, w: 2, h: 3 }, - monitorChart: { x: 0, y: Infinity, w: 2, h: 6 }, - monitorEvents: { x: 0, y: Infinity, w: 2, h: 10 }, -};