From 71aaef7acb1ff41f36570795cc9d7cc4107cf1f9 Mon Sep 17 00:00:00 2001 From: dohyeons Date: Thu, 16 Oct 2025 14:19:08 +0900 Subject: [PATCH 01/10] =?UTF-8?q?=EB=A9=94=EB=89=B4=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=EC=8B=9C=EB=B3=B4=EB=93=9C=20=ED=95=A0?= =?UTF-8?q?=EB=8B=B9=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/components/admin/MenuFormModal.tsx | 287 ++++++++++++++------ 1 file changed, 211 insertions(+), 76 deletions(-) diff --git a/frontend/components/admin/MenuFormModal.tsx b/frontend/components/admin/MenuFormModal.tsx index f8d80592..ad9edfc4 100644 --- a/frontend/components/admin/MenuFormModal.tsx +++ b/frontend/components/admin/MenuFormModal.tsx @@ -47,12 +47,12 @@ export const MenuFormModal: React.FC = ({ uiTexts, }) => { // console.log("๐ŸŽฏ MenuFormModal ๋ Œ๋”๋ง - Props:", { - // isOpen, - // menuId, - // parentId, - // menuType, - // level, - // parentCompanyCode, + // isOpen, + // menuId, + // parentId, + // menuType, + // level, + // parentCompanyCode, // }); // ๋‹ค๊ตญ์–ด ํ…์ŠคํŠธ ๊ฐ€์ ธ์˜ค๊ธฐ ํ•จ์ˆ˜ @@ -75,12 +75,18 @@ export const MenuFormModal: React.FC = ({ }); // ํ™”๋ฉด ํ• ๋‹น ๊ด€๋ จ ์ƒํƒœ - const [urlType, setUrlType] = useState<"direct" | "screen">("screen"); // URL ์ง์ ‘ ์ž…๋ ฅ or ํ™”๋ฉด ํ• ๋‹น (๊ธฐ๋ณธ๊ฐ’: ํ™”๋ฉด ํ• ๋‹น) + const [urlType, setUrlType] = useState<"direct" | "screen" | "dashboard">("screen"); // URL ์ง์ ‘ ์ž…๋ ฅ or ํ™”๋ฉด ํ• ๋‹น or ๋Œ€์‹œ๋ณด๋“œ ํ• ๋‹น (๊ธฐ๋ณธ๊ฐ’: ํ™”๋ฉด ํ• ๋‹น) const [selectedScreen, setSelectedScreen] = useState(null); const [screens, setScreens] = useState([]); const [screenSearchText, setScreenSearchText] = useState(""); const [isScreenDropdownOpen, setIsScreenDropdownOpen] = useState(false); + // ๋Œ€์‹œ๋ณด๋“œ ํ• ๋‹น ๊ด€๋ จ ์ƒํƒœ + const [selectedDashboard, setSelectedDashboard] = useState(null); + const [dashboards, setDashboards] = useState([]); + const [dashboardSearchText, setDashboardSearchText] = useState(""); + const [isDashboardDropdownOpen, setIsDashboardDropdownOpen] = useState(false); + const [loading, setLoading] = useState(false); const [isEdit, setIsEdit] = useState(false); const [companies, setCompanies] = useState([]); @@ -93,21 +99,6 @@ export const MenuFormModal: React.FC = ({ try { const response = await screenApi.getScreens({ size: 1000 }); // ๋ชจ๋“  ํ™”๋ฉด ๊ฐ€์ ธ์˜ค๊ธฐ - // console.log("๐Ÿ” ํ™”๋ฉด ๋ชฉ๋ก ๋กœ๋“œ ๋””๋ฒ„๊น…:", { - // totalScreens: response.data.length, - // firstScreen: response.data[0], - // firstScreenFields: response.data[0] ? Object.keys(response.data[0]) : [], - // firstScreenValues: response.data[0] ? Object.values(response.data[0]) : [], - // allScreenIds: response.data - // .map((s) => ({ - // screenId: s.screenId, - // legacyId: s.id, - // name: s.screenName, - // code: s.screenCode, - // })) - // .slice(0, 5), // ์ฒ˜์Œ 5๊ฐœ๋งŒ ์ถœ๋ ฅ - // }); - setScreens(response.data); console.log("โœ… ํ™”๋ฉด ๋ชฉ๋ก ๋กœ๋“œ ์™„๋ฃŒ:", response.data.length); } catch (error) { @@ -116,15 +107,28 @@ export const MenuFormModal: React.FC = ({ } }; + // ๋Œ€์‹œ๋ณด๋“œ ๋ชฉ๋ก ๋กœ๋“œ + const loadDashboards = async () => { + try { + const { dashboardApi } = await import("@/lib/api/dashboard"); + const response = await dashboardApi.getMyDashboards(); + setDashboards(response.dashboards || []); + console.log("โœ… ๋Œ€์‹œ๋ณด๋“œ ๋ชฉ๋ก ๋กœ๋“œ ์™„๋ฃŒ:", response.dashboards?.length || 0); + } catch (error) { + console.error("โŒ ๋Œ€์‹œ๋ณด๋“œ ๋ชฉ๋ก ๋กœ๋“œ ์‹คํŒจ:", error); + toast.error("๋Œ€์‹œ๋ณด๋“œ ๋ชฉ๋ก์„ ๋ถˆ๋Ÿฌ์˜ค๋Š”๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."); + } + }; + // ํ™”๋ฉด ์„ ํƒ ์‹œ URL ์ž๋™ ์„ค์ • const handleScreenSelect = (screen: ScreenDefinition) => { // console.log("๐Ÿ–ฅ๏ธ ํ™”๋ฉด ์„ ํƒ ๋””๋ฒ„๊น…:", { - // screen, - // screenId: screen.screenId, - // screenIdType: typeof screen.screenId, - // legacyId: screen.id, - // allFields: Object.keys(screen), - // screenValues: Object.values(screen), + // screen, + // screenId: screen.screenId, + // screenIdType: typeof screen.screenId, + // legacyId: screen.id, + // allFields: Object.keys(screen), + // screenValues: Object.values(screen), // }); // ScreenDefinition์—์„œ๋Š” screenId ํ•„๋“œ๋ฅผ ์‚ฌ์šฉ @@ -155,24 +159,42 @@ export const MenuFormModal: React.FC = ({ })); // console.log("๐Ÿ–ฅ๏ธ ํ™”๋ฉด ์„ ํƒ ์™„๋ฃŒ:", { - // screenId: screen.screenId, - // legacyId: screen.id, - // actualScreenId, - // screenName: screen.screenName, - // menuType: menuType, - // formDataMenuType: formData.menuType, - // isAdminMenu, - // generatedUrl: screenUrl, + // screenId: screen.screenId, + // legacyId: screen.id, + // actualScreenId, + // screenName: screen.screenName, + // menuType: menuType, + // formDataMenuType: formData.menuType, + // isAdminMenu, + // generatedUrl: screenUrl, // }); }; + // ๋Œ€์‹œ๋ณด๋“œ ์„ ํƒ ์‹œ URL ์ž๋™ ์„ค์ • + const handleDashboardSelect = (dashboard: any) => { + setSelectedDashboard(dashboard); + setIsDashboardDropdownOpen(false); + + // ๋Œ€์‹œ๋ณด๋“œ URL ์ƒ์„ฑ + let dashboardUrl = `/dashboard/${dashboard.id}`; + + // ํ˜„์žฌ ๋ฉ”๋‰ด ํƒ€์ž…์ด ๊ด€๋ฆฌ์ž์ธ์ง€ ํ™•์ธ (0 ๋˜๋Š” "admin") + const isAdminMenu = menuType === "0" || menuType === "admin" || formData.menuType === "0"; + if (isAdminMenu) { + dashboardUrl += "?mode=admin"; + } + + setFormData((prev) => ({ ...prev, menuUrl: dashboardUrl })); + toast.success(`๋Œ€์‹œ๋ณด๋“œ๊ฐ€ ์„ ํƒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค: ${dashboard.title}`); + }; + // URL ํƒ€์ž… ๋ณ€๊ฒฝ ์‹œ ์ฒ˜๋ฆฌ - const handleUrlTypeChange = (type: "direct" | "screen") => { + const handleUrlTypeChange = (type: "direct" | "screen" | "dashboard") => { // console.log("๐Ÿ”„ URL ํƒ€์ž… ๋ณ€๊ฒฝ:", { - // from: urlType, - // to: type, - // currentSelectedScreen: selectedScreen?.screenName, - // currentUrl: formData.menuUrl, + // from: urlType, + // to: type, + // currentSelectedScreen: selectedScreen?.screenName, + // currentUrl: formData.menuUrl, // }); setUrlType(type); @@ -286,10 +308,10 @@ export const MenuFormModal: React.FC = ({ const screenId = menuUrl.match(/\/screens\/(\d+)/)?.[1]; if (screenId) { // console.log("๐Ÿ” ๊ธฐ์กด ๋ฉ”๋‰ด์—์„œ ํ™”๋ฉด ID ์ถ”์ถœ:", { - // menuUrl, - // screenId, - // hasAdminParam: menuUrl.includes("mode=admin"), - // currentScreensCount: screens.length, + // menuUrl, + // screenId, + // hasAdminParam: menuUrl.includes("mode=admin"), + // currentScreensCount: screens.length, // }); // ํ™”๋ฉด ์„ค์ • ํ•จ์ˆ˜ @@ -298,15 +320,15 @@ export const MenuFormModal: React.FC = ({ if (screen) { setSelectedScreen(screen); // console.log("๐Ÿ–ฅ๏ธ ๊ธฐ์กด ๋ฉ”๋‰ด์˜ ํ• ๋‹น๋œ ํ™”๋ฉด ์„ค์ •:", { - // screen, - // originalUrl: menuUrl, - // hasAdminParam: menuUrl.includes("mode=admin"), + // screen, + // originalUrl: menuUrl, + // hasAdminParam: menuUrl.includes("mode=admin"), // }); return true; } else { // console.warn("โš ๏ธ ํ•ด๋‹น ID์˜ ํ™”๋ฉด์„ ์ฐพ์„ ์ˆ˜ ์—†์Œ:", { - // screenId, - // availableScreens: screens.map((s) => ({ screenId: s.screenId, id: s.id, name: s.screenName })), + // screenId, + // availableScreens: screens.map((s) => ({ screenId: s.screenId, id: s.id, name: s.screenName })), // }); return false; } @@ -325,30 +347,34 @@ export const MenuFormModal: React.FC = ({ }, 500); } } + } else if (menuUrl.startsWith("/dashboard/")) { + setUrlType("dashboard"); + setSelectedScreen(null); + // ๋Œ€์‹œ๋ณด๋“œ ID ์ถ”์ถœ ๋ฐ ์„ ํƒ์€ useEffect์—์„œ ์ฒ˜๋ฆฌ๋จ } else { setUrlType("direct"); setSelectedScreen(null); } // console.log("์„ค์ •๋œ ํผ ๋ฐ์ดํ„ฐ:", { - // objid: menu.objid || menu.OBJID, - // parentObjId: menu.parent_obj_id || menu.PARENT_OBJ_ID || "0", - // menuNameKor: menu.menu_name_kor || menu.MENU_NAME_KOR || "", - // menuUrl: menu.menu_url || menu.MENU_URL || "", - // menuDesc: menu.menu_desc || menu.MENU_DESC || "", - // seq: menu.seq || menu.SEQ || 1, - // menuType: convertedMenuType, - // status: convertedStatus, - // companyCode: companyCode, - // langKey: langKey, + // objid: menu.objid || menu.OBJID, + // parentObjId: menu.parent_obj_id || menu.PARENT_OBJ_ID || "0", + // menuNameKor: menu.menu_name_kor || menu.MENU_NAME_KOR || "", + // menuUrl: menu.menu_url || menu.MENU_URL || "", + // menuDesc: menu.menu_desc || menu.MENU_DESC || "", + // seq: menu.seq || menu.SEQ || 1, + // menuType: convertedMenuType, + // status: convertedStatus, + // companyCode: companyCode, + // langKey: langKey, // }); } } catch (error: any) { console.error("๋ฉ”๋‰ด ์ •๋ณด ๋กœ๋”ฉ ์˜ค๋ฅ˜:", error); // console.error("์˜ค๋ฅ˜ ์ƒ์„ธ ์ •๋ณด:", { - // message: error?.message, - // stack: error?.stack, - // response: error?.response, + // message: error?.message, + // stack: error?.stack, + // response: error?.response, // }); toast.error(getText(MENU_MANAGEMENT_KEYS.MESSAGE_ERROR_LOAD_MENU_INFO)); } finally { @@ -391,11 +417,11 @@ export const MenuFormModal: React.FC = ({ }); // console.log("๋ฉ”๋‰ด ๋“ฑ๋ก ๊ธฐ๋ณธ๊ฐ’ ์„ค์ •:", { - // parentObjId: parentId || "0", - // menuType: defaultMenuType, - // status: "ACTIVE", - // companyCode: "", - // langKey: "", + // parentObjId: parentId || "0", + // menuType: defaultMenuType, + // status: "ACTIVE", + // companyCode: "", + // langKey: "", // }); } }, [menuId, parentId, menuType]); @@ -430,10 +456,11 @@ export const MenuFormModal: React.FC = ({ } }, [isOpen, formData.companyCode]); - // ํ™”๋ฉด ๋ชฉ๋ก ๋กœ๋“œ + // ํ™”๋ฉด ๋ชฉ๋ก ๋ฐ ๋Œ€์‹œ๋ณด๋“œ ๋ชฉ๋ก ๋กœ๋“œ useEffect(() => { if (isOpen) { loadScreens(); + loadDashboards(); } }, [isOpen]); @@ -449,9 +476,9 @@ export const MenuFormModal: React.FC = ({ if (screen) { setSelectedScreen(screen); // console.log("โœ… ๊ธฐ์กด ๋ฉ”๋‰ด์˜ ํ• ๋‹น๋œ ํ™”๋ฉด ์ž๋™ ์„ค์ • ์™„๋ฃŒ:", { - // screenId, - // screenName: screen.screenName, - // menuUrl, + // screenId, + // screenName: screen.screenName, + // menuUrl, // }); } } @@ -459,6 +486,23 @@ export const MenuFormModal: React.FC = ({ } }, [screens, isEdit, formData.menuUrl, urlType, selectedScreen]); + // ๋Œ€์‹œ๋ณด๋“œ ๋ชฉ๋ก ๋กœ๋“œ ์™„๋ฃŒ ํ›„ ๊ธฐ์กด ๋ฉ”๋‰ด์˜ ํ• ๋‹น๋œ ๋Œ€์‹œ๋ณด๋“œ ์„ค์ • + useEffect(() => { + if (dashboards.length > 0 && isEdit && formData.menuUrl && urlType === "dashboard") { + const menuUrl = formData.menuUrl; + if (menuUrl.startsWith("/dashboard/")) { + const dashboardId = menuUrl.replace("/dashboard/", ""); + if (dashboardId && !selectedDashboard) { + console.log("๐Ÿ”„ ๋Œ€์‹œ๋ณด๋“œ ๋ชฉ๋ก ๋กœ๋“œ ์™„๋ฃŒ - ๊ธฐ์กด ํ• ๋‹น ๋Œ€์‹œ๋ณด๋“œ ์ž๋™ ์„ค์ •"); + const dashboard = dashboards.find((d) => d.id === dashboardId); + if (dashboard) { + setSelectedDashboard(dashboard); + } + } + } + } + }, [dashboards, isEdit, formData.menuUrl, urlType, selectedDashboard]); + // ๋“œ๋กญ๋‹ค์šด ์™ธ๋ถ€ ํด๋ฆญ ์‹œ ๋‹ซ๊ธฐ useEffect(() => { const handleClickOutside = (event: MouseEvent) => { @@ -471,9 +515,13 @@ export const MenuFormModal: React.FC = ({ setIsScreenDropdownOpen(false); setScreenSearchText(""); } + if (!target.closest(".dashboard-dropdown")) { + setIsDashboardDropdownOpen(false); + setDashboardSearchText(""); + } }; - if (isLangKeyDropdownOpen || isScreenDropdownOpen) { + if (isLangKeyDropdownOpen || isScreenDropdownOpen || isDashboardDropdownOpen) { document.addEventListener("mousedown", handleClickOutside); } @@ -751,6 +799,12 @@ export const MenuFormModal: React.FC = ({ ํ™”๋ฉด ํ• ๋‹น +
+ + +
); } diff --git a/frontend/components/admin/dashboard/MenuAssignmentModal.tsx b/frontend/components/admin/dashboard/MenuAssignmentModal.tsx new file mode 100644 index 00000000..9220a0c8 --- /dev/null +++ b/frontend/components/admin/dashboard/MenuAssignmentModal.tsx @@ -0,0 +1,210 @@ +"use client"; + +import React, { useState, useEffect } from "react"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; +import { Label } from "@/components/ui/label"; +import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { toast } from "sonner"; +import { menuApi, MenuItem } from "@/lib/api/menu"; +import { Loader2 } from "lucide-react"; + +interface MenuAssignmentModalProps { + isOpen: boolean; + onClose: () => void; + onConfirm: (assignToMenu: boolean, menuId?: string, menuType?: "0" | "1") => void; + dashboardId: string; + dashboardTitle: string; +} + +export const MenuAssignmentModal: React.FC = ({ + isOpen, + onClose, + onConfirm, + dashboardId, + dashboardTitle, +}) => { + const [assignToMenu, setAssignToMenu] = useState(false); + const [selectedMenuId, setSelectedMenuId] = useState(""); + const [selectedMenuType, setSelectedMenuType] = useState<"0" | "1">("0"); + const [adminMenus, setAdminMenus] = useState([]); + const [userMenus, setUserMenus] = useState([]); + const [loading, setLoading] = useState(false); + + // ๋ฉ”๋‰ด ๋ชฉ๋ก ๋กœ๋“œ + useEffect(() => { + if (isOpen && assignToMenu) { + loadMenus(); + } + }, [isOpen, assignToMenu]); + + const loadMenus = async () => { + try { + setLoading(true); + const [adminResponse, userResponse] = await Promise.all([ + menuApi.getAdminMenus(), // ๊ด€๋ฆฌ์ž ๋ฉ”๋‰ด + menuApi.getUserMenus(), // ์‚ฌ์šฉ์ž ๋ฉ”๋‰ด + ]); + + if (adminResponse.success) { + setAdminMenus(adminResponse.data || []); + } + if (userResponse.success) { + setUserMenus(userResponse.data || []); + } + } catch (error) { + console.error("๋ฉ”๋‰ด ๋ชฉ๋ก ๋กœ๋“œ ์‹คํŒจ:", error); + toast.error("๋ฉ”๋‰ด ๋ชฉ๋ก์„ ๋ถˆ๋Ÿฌ์˜ค๋Š”๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."); + } finally { + setLoading(false); + } + }; + + // ๋ฉ”๋‰ด ํŠธ๋ฆฌ๋ฅผ ํ‰ํƒ„ํ™”ํ•˜์—ฌ Select ์˜ต์…˜์œผ๋กœ ๋ณ€ํ™˜ + const flattenMenus = (menus: MenuItem[], level: number = 0): Array<{ id: string; name: string; level: number }> => { + const result: Array<{ id: string; name: string; level: number }> = []; + + menus.forEach((menu) => { + const menuId = menu.objid || menu.OBJID || ""; + const menuName = menu.menu_name_kor || menu.MENU_NAME_KOR || ""; + const parentId = menu.parent_obj_id || menu.PARENT_OBJ_ID || "0"; + + // ๋ฉ”๋‰ด ์ด๋ฆ„์ด ์žˆ๊ณ , ์ตœ์ƒ์œ„๊ฐ€ ์•„๋‹Œ ๊ฒฝ์šฐ์—๋งŒ ์ถ”๊ฐ€ + if (menuName && parentId !== "0") { + result.push({ + id: menuId, + name: " ".repeat(level) + menuName, + level, + }); + + // ํ•˜์œ„ ๋ฉ”๋‰ด๊ฐ€ ์žˆ์œผ๋ฉด ์žฌ๊ท€ ํ˜ธ์ถœ + const children = menus.filter((m) => (m.parent_obj_id || m.PARENT_OBJ_ID) === menuId); + if (children.length > 0) { + result.push(...flattenMenus(children, level + 1)); + } + } + }); + + return result; + }; + + const currentMenus = selectedMenuType === "0" ? adminMenus : userMenus; + const flatMenus = flattenMenus(currentMenus); + + const handleConfirm = () => { + if (assignToMenu && !selectedMenuId) { + toast.error("๋ฉ”๋‰ด๋ฅผ ์„ ํƒํ•ด์ฃผ์„ธ์š”."); + return; + } + + onConfirm(assignToMenu, selectedMenuId, selectedMenuType); + }; + + const handleClose = () => { + setAssignToMenu(false); + setSelectedMenuId(""); + setSelectedMenuType("0"); + onClose(); + }; + + return ( + + + + ๋Œ€์‹œ๋ณด๋“œ ์ €์žฅ ์™„๋ฃŒ + '{dashboardTitle}' ๋Œ€์‹œ๋ณด๋“œ๊ฐ€ ์ €์žฅ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. + + +
+
+ + setAssignToMenu(value === "yes")} + className="flex space-x-4" + > +
+ + +
+
+ + +
+
+
+ + {assignToMenu && ( + <> +
+ + { + setSelectedMenuType(value as "0" | "1"); + setSelectedMenuId(""); // ๋ฉ”๋‰ด ํƒ€์ž… ๋ณ€๊ฒฝ ์‹œ ์„ ํƒ ์ดˆ๊ธฐํ™” + }} + className="flex space-x-4" + > +
+ + +
+
+ + +
+
+
+ +
+ + {loading ? ( +
+ +
+ ) : ( + + )} +
+ + )} +
+ + + + + +
+
+ ); +}; From 8e2c66e2a46c94f945e9d867251501965bbdb156 Mon Sep 17 00:00:00 2001 From: dohyeons Date: Thu, 16 Oct 2025 15:39:54 +0900 Subject: [PATCH 03/10] =?UTF-8?q?3d=20=EC=A4=91=EA=B0=84=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend-node/src/app.ts | 6 +- .../src/controllers/WarehouseController.ts | 97 +++ backend-node/src/routes/warehouseRoutes.ts | 22 + backend-node/src/services/WarehouseService.ts | 170 +++++ .../admin/dashboard/DashboardDesigner.tsx | 4 + .../admin/dashboard/DashboardTopMenu.tsx | 1 + frontend/components/admin/dashboard/types.ts | 5 +- .../dashboard/widgets/Warehouse3DWidget.tsx | 418 ++++++++++++ .../components/dashboard/DashboardViewer.tsx | 11 + frontend/package-lock.json | 610 +++++++++++++++++- frontend/package.json | 4 + 11 files changed, 1339 insertions(+), 9 deletions(-) create mode 100644 backend-node/src/controllers/WarehouseController.ts create mode 100644 backend-node/src/routes/warehouseRoutes.ts create mode 100644 backend-node/src/services/WarehouseService.ts create mode 100644 frontend/components/admin/dashboard/widgets/Warehouse3DWidget.tsx diff --git a/backend-node/src/app.ts b/backend-node/src/app.ts index ae10a6fe..9483726a 100644 --- a/backend-node/src/app.ts +++ b/backend-node/src/app.ts @@ -55,6 +55,7 @@ import riskAlertRoutes from "./routes/riskAlertRoutes"; // ๋ฆฌ์Šคํฌ/์•Œ๋ฆผ ๊ด€ import todoRoutes from "./routes/todoRoutes"; // To-Do ๊ด€๋ฆฌ import bookingRoutes from "./routes/bookingRoutes"; // ์˜ˆ์•ฝ ์š”์ฒญ ๊ด€๋ฆฌ import mapDataRoutes from "./routes/mapDataRoutes"; // ์ง€๋„ ๋ฐ์ดํ„ฐ ๊ด€๋ฆฌ +import warehouseRoutes from "./routes/warehouseRoutes"; // ์ฐฝ๊ณ  ๊ด€๋ฆฌ import { BatchSchedulerService } from "./services/batchSchedulerService"; // import collectionRoutes from "./routes/collectionRoutes"; // ์ž„์‹œ ์ฃผ์„ // import batchRoutes from "./routes/batchRoutes"; // ์ž„์‹œ ์ฃผ์„ @@ -204,6 +205,7 @@ app.use("/api/risk-alerts", riskAlertRoutes); // ๋ฆฌ์Šคํฌ/์•Œ๋ฆผ ๊ด€๋ฆฌ app.use("/api/todos", todoRoutes); // To-Do ๊ด€๋ฆฌ app.use("/api/bookings", bookingRoutes); // ์˜ˆ์•ฝ ์š”์ฒญ ๊ด€๋ฆฌ app.use("/api/map-data", mapDataRoutes); // ์ง€๋„ ๋ฐ์ดํ„ฐ ์กฐํšŒ +app.use("/api/warehouse", warehouseRoutes); // ์ฐฝ๊ณ  ๊ด€๋ฆฌ // app.use("/api/collections", collectionRoutes); // ์ž„์‹œ ์ฃผ์„ // app.use("/api/batch", batchRoutes); // ์ž„์‹œ ์ฃผ์„ // app.use('/api/users', userRoutes); @@ -241,7 +243,9 @@ app.listen(PORT, HOST, async () => { // ๋ฆฌ์Šคํฌ/์•Œ๋ฆผ ์ž๋™ ๊ฐฑ์‹  ์‹œ์ž‘ try { - const { RiskAlertCacheService } = await import('./services/riskAlertCacheService'); + const { RiskAlertCacheService } = await import( + "./services/riskAlertCacheService" + ); const cacheService = RiskAlertCacheService.getInstance(); cacheService.startAutoRefresh(); logger.info(`โฐ ๋ฆฌ์Šคํฌ/์•Œ๋ฆผ ์ž๋™ ๊ฐฑ์‹ ์ด ์‹œ์ž‘๋˜์—ˆ์Šต๋‹ˆ๋‹ค. (10๋ถ„ ๊ฐ„๊ฒฉ)`); diff --git a/backend-node/src/controllers/WarehouseController.ts b/backend-node/src/controllers/WarehouseController.ts new file mode 100644 index 00000000..1fe140e8 --- /dev/null +++ b/backend-node/src/controllers/WarehouseController.ts @@ -0,0 +1,97 @@ +import { Request, Response } from "express"; +import { WarehouseService } from "../services/WarehouseService"; + +export class WarehouseController { + private warehouseService: WarehouseService; + + constructor() { + this.warehouseService = new WarehouseService(); + } + + // ์ฐฝ๊ณ  ๋ฐ ์ž์žฌ ๋ฐ์ดํ„ฐ ์กฐํšŒ + getWarehouseData = async (req: Request, res: Response) => { + try { + const data = await this.warehouseService.getWarehouseData(); + + return res.json({ + success: true, + warehouses: data.warehouses, + materials: data.materials, + }); + } catch (error: any) { + console.error("์ฐฝ๊ณ  ๋ฐ์ดํ„ฐ ์กฐํšŒ ์˜ค๋ฅ˜:", error); + return res.status(500).json({ + success: false, + message: "์ฐฝ๊ณ  ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋Š”๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.", + error: error.message, + }); + } + }; + + // ํŠน์ • ์ฐฝ๊ณ  ์ •๋ณด ์กฐํšŒ + getWarehouseById = async (req: Request, res: Response) => { + try { + const { id } = req.params; + const warehouse = await this.warehouseService.getWarehouseById(id); + + if (!warehouse) { + return res.status(404).json({ + success: false, + message: "์ฐฝ๊ณ ๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.", + }); + } + + return res.json({ + success: true, + data: warehouse, + }); + } catch (error: any) { + console.error("์ฐฝ๊ณ  ์กฐํšŒ ์˜ค๋ฅ˜:", error); + return res.status(500).json({ + success: false, + message: "์ฐฝ๊ณ  ์ •๋ณด๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋Š”๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.", + error: error.message, + }); + } + }; + + // ์ฐฝ๊ณ ๋ณ„ ์ž์žฌ ๋ชฉ๋ก ์กฐํšŒ + getMaterialsByWarehouse = async (req: Request, res: Response) => { + try { + const { warehouseId } = req.params; + const materials = + await this.warehouseService.getMaterialsByWarehouse(warehouseId); + + return res.json({ + success: true, + data: materials, + }); + } catch (error: any) { + console.error("์ž์žฌ ๋ชฉ๋ก ์กฐํšŒ ์˜ค๋ฅ˜:", error); + return res.status(500).json({ + success: false, + message: "์ž์žฌ ๋ชฉ๋ก์„ ๋ถˆ๋Ÿฌ์˜ค๋Š”๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.", + error: error.message, + }); + } + }; + + // ์ฐฝ๊ณ  ํ†ต๊ณ„ ์กฐํšŒ + getWarehouseStats = async (req: Request, res: Response) => { + try { + const stats = await this.warehouseService.getWarehouseStats(); + + return res.json({ + success: true, + data: stats, + }); + } catch (error: any) { + console.error("์ฐฝ๊ณ  ํ†ต๊ณ„ ์กฐํšŒ ์˜ค๋ฅ˜:", error); + return res.status(500).json({ + success: false, + message: "์ฐฝ๊ณ  ํ†ต๊ณ„๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋Š”๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.", + error: error.message, + }); + } + }; +} diff --git a/backend-node/src/routes/warehouseRoutes.ts b/backend-node/src/routes/warehouseRoutes.ts new file mode 100644 index 00000000..15625a35 --- /dev/null +++ b/backend-node/src/routes/warehouseRoutes.ts @@ -0,0 +1,22 @@ +import { Router } from "express"; +import { WarehouseController } from "../controllers/WarehouseController"; + +const router = Router(); +const warehouseController = new WarehouseController(); + +// ์ฐฝ๊ณ  ๋ฐ ์ž์žฌ ๋ฐ์ดํ„ฐ ์กฐํšŒ +router.get("/data", warehouseController.getWarehouseData); + +// ํŠน์ • ์ฐฝ๊ณ  ์ •๋ณด ์กฐํšŒ +router.get("/:id", warehouseController.getWarehouseById); + +// ์ฐฝ๊ณ ๋ณ„ ์ž์žฌ ๋ชฉ๋ก ์กฐํšŒ +router.get( + "/:warehouseId/materials", + warehouseController.getMaterialsByWarehouse +); + +// ์ฐฝ๊ณ  ํ†ต๊ณ„ ์กฐํšŒ +router.get("/stats/summary", warehouseController.getWarehouseStats); + +export default router; diff --git a/backend-node/src/services/WarehouseService.ts b/backend-node/src/services/WarehouseService.ts new file mode 100644 index 00000000..fe0433c7 --- /dev/null +++ b/backend-node/src/services/WarehouseService.ts @@ -0,0 +1,170 @@ +import pool from "../database/db"; + +export class WarehouseService { + // ์ฐฝ๊ณ  ๋ฐ ์ž์žฌ ๋ฐ์ดํ„ฐ ์กฐํšŒ + async getWarehouseData() { + try { + // ์ฐฝ๊ณ  ๋ชฉ๋ก ์กฐํšŒ + const warehousesResult = await pool.query(` + SELECT + id, + name, + position_x, + position_y, + position_z, + size_x, + size_y, + size_z, + color, + capacity, + current_usage, + status, + description, + created_at, + updated_at + FROM warehouse + WHERE status = 'active' + ORDER BY id + `); + + // ์ž์žฌ ๋ชฉ๋ก ์กฐํšŒ + const materialsResult = await pool.query(` + SELECT + id, + warehouse_id, + name, + material_code, + quantity, + unit, + position_x, + position_y, + position_z, + size_x, + size_y, + size_z, + color, + status, + last_updated, + created_at + FROM warehouse_material + ORDER BY warehouse_id, id + `); + + return { + warehouses: warehousesResult, + materials: materialsResult, + }; + } catch (error) { + throw error; + } + } + + // ํŠน์ • ์ฐฝ๊ณ  ์ •๋ณด ์กฐํšŒ + async getWarehouseById(id: string) { + try { + const result = await pool.query( + ` + SELECT + id, + name, + position_x, + position_y, + position_z, + size_x, + size_y, + size_z, + color, + capacity, + current_usage, + status, + description, + created_at, + updated_at + FROM warehouse + WHERE id = $1 + `, + [id] + ); + + return result[0] || null; + } catch (error) { + throw error; + } + } + + // ์ฐฝ๊ณ ๋ณ„ ์ž์žฌ ๋ชฉ๋ก ์กฐํšŒ + async getMaterialsByWarehouse(warehouseId: string) { + try { + const result = await pool.query( + ` + SELECT + id, + warehouse_id, + name, + material_code, + quantity, + unit, + position_x, + position_y, + position_z, + size_x, + size_y, + size_z, + color, + status, + last_updated, + created_at + FROM warehouse_material + WHERE warehouse_id = $1 + ORDER BY id + `, + [warehouseId] + ); + + return result; + } catch (error) { + throw error; + } + } + + // ์ฐฝ๊ณ  ํ†ต๊ณ„ ์กฐํšŒ + async getWarehouseStats() { + try { + const result = await pool.query(` + SELECT + COUNT(DISTINCT w.id) as total_warehouses, + COUNT(m.id) as total_materials, + SUM(w.capacity) as total_capacity, + SUM(w.current_usage) as total_usage, + ROUND(AVG((w.current_usage::numeric / NULLIF(w.capacity, 0)) * 100), 2) as avg_usage_percent + FROM warehouse w + LEFT JOIN warehouse_material m ON w.id = m.warehouse_id + WHERE w.status = 'active' + `); + + // ์ƒํƒœ๋ณ„ ์ž์žฌ ์ˆ˜ + const statusResult = await pool.query(` + SELECT + status, + COUNT(*) as count + FROM warehouse_material + GROUP BY status + `); + + const statusCounts = statusResult.reduce( + (acc: Record, row: any) => { + acc[row.status] = parseInt(row.count); + return acc; + }, + {} as Record + ); + + return { + ...result[0], + materialsByStatus: statusCounts, + }; + } catch (error) { + throw error; + } + } +} diff --git a/frontend/components/admin/dashboard/DashboardDesigner.tsx b/frontend/components/admin/dashboard/DashboardDesigner.tsx index 0c41ff7c..95eea2f2 100644 --- a/frontend/components/admin/dashboard/DashboardDesigner.tsx +++ b/frontend/components/admin/dashboard/DashboardDesigner.tsx @@ -575,6 +575,8 @@ function getElementTitle(type: ElementType, subtype: ElementSubtype): string { return "๐Ÿšš ๊ธฐ์‚ฌ ๊ด€๋ฆฌ ์œ„์ ฏ"; case "list": return "๐Ÿ“‹ ๋ฆฌ์ŠคํŠธ ์œ„์ ฏ"; + case "warehouse-3d": + return "๐Ÿญ ์ฐฝ๊ณ  ํ˜„ํ™ฉ (3D)"; default: return "๐Ÿ”ง ์œ„์ ฏ"; } @@ -615,6 +617,8 @@ function getElementContent(type: ElementType, subtype: ElementSubtype): string { return "driver-management"; case "list": return "list-widget"; + case "warehouse-3d": + return "warehouse-3d"; default: return "์œ„์ ฏ ๋‚ด์šฉ์ด ์—ฌ๊ธฐ์— ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค"; } diff --git a/frontend/components/admin/dashboard/DashboardTopMenu.tsx b/frontend/components/admin/dashboard/DashboardTopMenu.tsx index 1d58988f..446830a8 100644 --- a/frontend/components/admin/dashboard/DashboardTopMenu.tsx +++ b/frontend/components/admin/dashboard/DashboardTopMenu.tsx @@ -184,6 +184,7 @@ export function DashboardTopMenu({ ๋ฐ์ดํ„ฐ ์œ„์ ฏ ๋ฆฌ์ŠคํŠธ ์œ„์ ฏ ์ง€๋„ + ์ฐฝ๊ณ  ํ˜„ํ™ฉ (3D) ์ผ๋ฐ˜ ์œ„์ ฏ diff --git a/frontend/components/admin/dashboard/types.ts b/frontend/components/admin/dashboard/types.ts index cdf70550..90668874 100644 --- a/frontend/components/admin/dashboard/types.ts +++ b/frontend/components/admin/dashboard/types.ts @@ -35,7 +35,8 @@ export type ElementSubtype = | "booking-alert" | "maintenance" | "document" - | "list"; // ์œ„์ ฏ ํƒ€์ž… + | "list" + | "warehouse-3d"; // ์œ„์ ฏ ํƒ€์ž… export interface Position { x: number; @@ -139,7 +140,7 @@ export interface ChartConfig { // ์• ๋‹ˆ๋ฉ”์ด์…˜ enableAnimation?: boolean; // ์• ๋‹ˆ๋ฉ”์ด์…˜ ํ™œ์„ฑํ™” - + // ์ƒํƒœ ํ•„ํ„ฐ๋ง (์ปค์Šคํ…€ ์ƒํƒœ ์นด๋“œ์šฉ) statusFilter?: string[]; // ํ‘œ์‹œํ•  ์ƒํƒœ ๋ชฉ๋ก (์˜ˆ: ["driving", "parked"]) animationDuration?: number; // ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹œ๊ฐ„ (ms) diff --git a/frontend/components/admin/dashboard/widgets/Warehouse3DWidget.tsx b/frontend/components/admin/dashboard/widgets/Warehouse3DWidget.tsx new file mode 100644 index 00000000..71d2df0e --- /dev/null +++ b/frontend/components/admin/dashboard/widgets/Warehouse3DWidget.tsx @@ -0,0 +1,418 @@ +"use client"; + +import React, { useRef, useState, useEffect, Suspense } from "react"; +import { Canvas, useFrame } from "@react-three/fiber"; +import { OrbitControls, Text, Box, Html } from "@react-three/drei"; +import * as THREE from "three"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Badge } from "@/components/ui/badge"; +import { Loader2, Maximize2, Info } from "lucide-react"; + +interface WarehouseData { + id: string; + name: string; + position_x: number; + position_y: number; + position_z: number; + size_x: number; + size_y: number; + size_z: number; + color: string; + capacity: number; + current_usage: number; + status: string; + description?: string; +} + +interface MaterialData { + id: string; + warehouse_id: string; + name: string; + material_code: string; + quantity: number; + unit: string; + position_x: number; + position_y: number; + position_z: number; + size_x: number; + size_y: number; + size_z: number; + color: string; + status: string; +} + +interface Warehouse3DWidgetProps { + element?: any; +} + +// ์ฐฝ๊ณ  3D ๋ฐ•์Šค ์ปดํฌ๋„ŒํŠธ +function WarehouseBox({ + warehouse, + onClick, + isSelected, +}: { + warehouse: WarehouseData; + onClick: () => void; + isSelected: boolean; +}) { + const meshRef = useRef(null); + const [hovered, setHovered] = useState(false); + + useFrame(() => { + if (meshRef.current) { + if (isSelected) { + meshRef.current.scale.lerp(new THREE.Vector3(1.05, 1.05, 1.05), 0.1); + } else if (hovered) { + meshRef.current.scale.lerp(new THREE.Vector3(1.02, 1.02, 1.02), 0.1); + } else { + meshRef.current.scale.lerp(new THREE.Vector3(1, 1, 1), 0.1); + } + } + }); + + const usagePercentage = (warehouse.current_usage / warehouse.capacity) * 100; + + return ( + + { + e.stopPropagation(); + onClick(); + }} + onPointerOver={() => setHovered(true)} + onPointerOut={() => setHovered(false)} + > + + + + + {/* ์ฐฝ๊ณ  ํ…Œ๋‘๋ฆฌ */} + + + + + + {/* ์ฐฝ๊ณ  ์ด๋ฆ„ ๋ผ๋ฒจ */} + + {warehouse.name} + + + {/* ์‚ฌ์šฉ๋ฅ  ํ‘œ์‹œ */} + +
+ {usagePercentage.toFixed(0)}% ์‚ฌ์šฉ์ค‘ +
+ +
+ ); +} + +// ์ž์žฌ 3D ๋ฐ•์Šค ์ปดํฌ๋„ŒํŠธ +function MaterialBox({ + material, + onClick, + isSelected, +}: { + material: MaterialData; + onClick: () => void; + isSelected: boolean; +}) { + const meshRef = useRef(null); + const [hovered, setHovered] = useState(false); + + useFrame(() => { + if (meshRef.current && (isSelected || hovered)) { + meshRef.current.rotation.y += 0.01; + } + }); + + const statusColor = + { + stocked: material.color, + reserved: "#FFA500", + urgent: "#FF0000", + out_of_stock: "#808080", + }[material.status] || material.color; + + return ( + + { + e.stopPropagation(); + onClick(); + }} + onPointerOver={() => setHovered(true)} + onPointerOut={() => setHovered(false)} + > + + + + + {(hovered || isSelected) && ( + +
+
{material.name}
+
+ {material.quantity} {material.unit} +
+
+ + )} +
+ ); +} + +// 3D ์”ฌ ์ปดํฌ๋„ŒํŠธ +function Scene({ + warehouses, + materials, + onSelectWarehouse, + onSelectMaterial, + selectedWarehouse, + selectedMaterial, +}: { + warehouses: WarehouseData[]; + materials: MaterialData[]; + onSelectWarehouse: (warehouse: WarehouseData | null) => void; + onSelectMaterial: (material: MaterialData | null) => void; + selectedWarehouse: WarehouseData | null; + selectedMaterial: MaterialData | null; +}) { + return ( + <> + {/* ์กฐ๋ช… */} + + + + + {/* ๋ฐ”๋‹ฅ ๊ทธ๋ฆฌ๋“œ */} + + + {/* ์ฐฝ๊ณ ๋“ค */} + {warehouses.map((warehouse) => ( + { + if (selectedWarehouse?.id === warehouse.id) { + onSelectWarehouse(null); + } else { + onSelectWarehouse(warehouse); + onSelectMaterial(null); + } + }} + isSelected={selectedWarehouse?.id === warehouse.id} + /> + ))} + + {/* ์ž์žฌ๋“ค */} + {materials.map((material) => ( + { + if (selectedMaterial?.id === material.id) { + onSelectMaterial(null); + } else { + onSelectMaterial(material); + } + }} + isSelected={selectedMaterial?.id === material.id} + /> + ))} + + {/* ์นด๋ฉ”๋ผ ์ปจํŠธ๋กค */} + + + ); +} + +export function Warehouse3DWidget({ element }: Warehouse3DWidgetProps) { + const [warehouses, setWarehouses] = useState([]); + const [materials, setMaterials] = useState([]); + const [loading, setLoading] = useState(true); + const [selectedWarehouse, setSelectedWarehouse] = useState(null); + const [selectedMaterial, setSelectedMaterial] = useState(null); + const [isFullscreen, setIsFullscreen] = useState(false); + + useEffect(() => { + loadData(); + }, []); + + const loadData = async () => { + try { + setLoading(true); + // API ํ˜ธ์ถœ (๋ฐฑ์—”๋“œ API ๊ตฌํ˜„ ํ•„์š”) + const response = await fetch("/api/warehouse/data"); + if (response.ok) { + const data = await response.json(); + setWarehouses(data.warehouses || []); + setMaterials(data.materials || []); + } else { + // ์ž„์‹œ ๋”๋ฏธ ๋ฐ์ดํ„ฐ (๊ฐœ๋ฐœ์šฉ) + console.log("API ์‹คํŒจ, ๋”๋ฏธ ๋ฐ์ดํ„ฐ ์‚ฌ์šฉ"); + } + } catch (error) { + console.error("์ฐฝ๊ณ  ๋ฐ์ดํ„ฐ ๋กœ๋“œ ์‹คํŒจ:", error); + } finally { + setLoading(false); + } + }; + + if (loading) { + return ( + + + + + + ); + } + + return ( + + + ๐Ÿญ ์ฐฝ๊ณ  ํ˜„ํ™ฉ (3D) +
+ + {warehouses.length}๊ฐœ ์ฐฝ๊ณ  | {materials.length}๊ฐœ ์ž์žฌ + + +
+
+ + {/* 3D ๋ทฐ */} +
+ + + + + +
+ + {/* ์ •๋ณด ํŒจ๋„ */} +
+ {/* ์„ ํƒ๋œ ์ฐฝ๊ณ  ์ •๋ณด */} + {selectedWarehouse && ( + + + + + ์ฐฝ๊ณ  ์ •๋ณด + + + +
+ ์ด๋ฆ„: {selectedWarehouse.name} +
+
+ ID: {selectedWarehouse.id} +
+
+ ์šฉ๋Ÿ‰: {selectedWarehouse.current_usage} /{" "} + {selectedWarehouse.capacity} +
+
+ ์‚ฌ์šฉ๋ฅ :{" "} + {((selectedWarehouse.current_usage / selectedWarehouse.capacity) * 100).toFixed(1)}% +
+
+ ์ƒํƒœ:{" "} + + {selectedWarehouse.status} + +
+ {selectedWarehouse.description && ( +
+ ์„ค๋ช…: {selectedWarehouse.description} +
+ )} +
+
+ )} + + {/* ์„ ํƒ๋œ ์ž์žฌ ์ •๋ณด */} + {selectedMaterial && ( + + + + + ์ž์žฌ ์ •๋ณด + + + +
+ ์ด๋ฆ„: {selectedMaterial.name} +
+
+ ์ฝ”๋“œ: {selectedMaterial.material_code} +
+
+ ์ˆ˜๋Ÿ‰: {selectedMaterial.quantity} {selectedMaterial.unit} +
+
+ ์œ„์น˜:{" "} + {warehouses.find((w) => w.id === selectedMaterial.warehouse_id)?.name} +
+
+ ์ƒํƒœ:{" "} + + {selectedMaterial.status} + +
+
+
+ )} + + {/* ์ฐฝ๊ณ  ๋ชฉ๋ก */} + {!selectedWarehouse && !selectedMaterial && ( + + + ์ฐฝ๊ณ  ๋ชฉ๋ก + + + {warehouses.map((warehouse) => { + const warehouseMaterials = materials.filter((m) => m.warehouse_id === warehouse.id); + return ( + + ); + })} + + + )} +
+
+
+ ); +} diff --git a/frontend/components/dashboard/DashboardViewer.tsx b/frontend/components/dashboard/DashboardViewer.tsx index f4f8caea..d0c12ccf 100644 --- a/frontend/components/dashboard/DashboardViewer.tsx +++ b/frontend/components/dashboard/DashboardViewer.tsx @@ -38,6 +38,14 @@ const ListWidget = dynamic( { ssr: false }, ); +const Warehouse3DWidget = dynamic( + () => + import("@/components/admin/dashboard/widgets/Warehouse3DWidget").then((mod) => ({ + default: mod.Warehouse3DWidget, + })), + { ssr: false }, +); + /** * ์œ„์ ฏ ๋ Œ๋”๋ง ํ•จ์ˆ˜ - DashboardSidebar์˜ ๋ชจ๋“  subtype ์ฒ˜๋ฆฌ * ViewerElement์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์ปดํฌ๋„ŒํŠธ ์™ธ๋ถ€์— ์ •์˜ @@ -78,6 +86,9 @@ function renderWidget(element: DashboardElement) { case "list": return ; + case "warehouse-3d": + return ; + // === ์ฐจ๋Ÿ‰ ๊ด€๋ จ (์ถ”๊ฐ€ ์œ„์ ฏ) === case "vehicle-status": return ; diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 99c48de4..9dbf4f10 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -30,11 +30,14 @@ "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-switch": "^1.2.6", "@radix-ui/react-tabs": "^1.1.13", + "@react-three/drei": "^10.7.6", + "@react-three/fiber": "^9.4.0", "@tanstack/react-query": "^5.86.0", "@tanstack/react-table": "^8.21.3", "@types/d3": "^7.4.3", "@types/leaflet": "^1.9.21", "@types/react-window": "^1.8.8", + "@types/three": "^0.180.0", "@xyflow/react": "^12.8.4", "axios": "^1.11.0", "class-variance-authority": "^0.7.1", @@ -64,6 +67,7 @@ "sheetjs-style": "^0.15.8", "sonner": "^2.0.7", "tailwind-merge": "^3.3.1", + "three": "^0.180.0", "uuid": "^13.0.0", "xlsx": "^0.18.5", "zod": "^4.1.5" @@ -280,6 +284,12 @@ "integrity": "sha512-P5LUNhtbj6YfI3iJjw5EL9eUAG6OitD0W3fWQcpQjDRc/QIsL0tRNuO1PcDvPccWL1fSTXXdE1ds+l95DV/OFA==", "license": "MIT" }, + "node_modules/@dimforge/rapier3d-compat": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@dimforge/rapier3d-compat/-/rapier3d-compat-0.12.0.tgz", + "integrity": "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow==", + "license": "Apache-2.0" + }, "node_modules/@dnd-kit/accessibility": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/@dnd-kit/accessibility/-/accessibility-3.1.1.tgz", @@ -1100,6 +1110,24 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@mediapipe/tasks-vision": { + "version": "0.10.17", + "resolved": "https://registry.npmjs.org/@mediapipe/tasks-vision/-/tasks-vision-0.10.17.tgz", + "integrity": "sha512-CZWV/q6TTe8ta61cZXjfnnHsfWIdFhms03M9T7Cnd5y2mdpylJM0rF1qRq+wsQVRMLz1OYPVEBU9ph2Bx8cxrg==", + "license": "Apache-2.0" + }, + "node_modules/@monogrid/gainmap-js": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@monogrid/gainmap-js/-/gainmap-js-3.1.0.tgz", + "integrity": "sha512-Obb0/gEd/HReTlg8ttaYk+0m62gQJmCblMOjHSMHRrBP2zdfKMHLCRbh/6ex9fSUJMKdjjIEiohwkbGD3wj2Nw==", + "license": "MIT", + "dependencies": { + "promise-worker-transferable": "^1.0.4" + }, + "peerDependencies": { + "three": ">= 0.159.0" + } + }, "node_modules/@napi-rs/wasm-runtime": { "version": "0.2.12", "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.12.tgz", @@ -2495,6 +2523,160 @@ "react-dom": "^19.0.0" } }, + "node_modules/@react-three/drei": { + "version": "10.7.6", + "resolved": "https://registry.npmjs.org/@react-three/drei/-/drei-10.7.6.tgz", + "integrity": "sha512-ZSFwRlRaa4zjtB7yHO6Q9xQGuyDCzE7whXBhum92JslcMRC3aouivp0rAzszcVymIoJx6PXmibyP+xr+zKdwLg==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.26.0", + "@mediapipe/tasks-vision": "0.10.17", + "@monogrid/gainmap-js": "^3.0.6", + "@use-gesture/react": "^10.3.1", + "camera-controls": "^3.1.0", + "cross-env": "^7.0.3", + "detect-gpu": "^5.0.56", + "glsl-noise": "^0.0.0", + "hls.js": "^1.5.17", + "maath": "^0.10.8", + "meshline": "^3.3.1", + "stats-gl": "^2.2.8", + "stats.js": "^0.17.0", + "suspend-react": "^0.1.3", + "three-mesh-bvh": "^0.8.3", + "three-stdlib": "^2.35.6", + "troika-three-text": "^0.52.4", + "tunnel-rat": "^0.1.2", + "use-sync-external-store": "^1.4.0", + "utility-types": "^3.11.0", + "zustand": "^5.0.1" + }, + "peerDependencies": { + "@react-three/fiber": "^9.0.0", + "react": "^19", + "react-dom": "^19", + "three": ">=0.159" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } + } + }, + "node_modules/@react-three/drei/node_modules/zustand": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.8.tgz", + "integrity": "sha512-gyPKpIaxY9XcO2vSMrLbiER7QMAMGOQZVRdJ6Zi782jkbzZygq5GI9nG8g+sMgitRtndwaBSl7uiqC49o1SSiw==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + }, + "peerDependencies": { + "@types/react": ">=18.0.0", + "immer": ">=9.0.6", + "react": ">=18.0.0", + "use-sync-external-store": ">=1.2.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + }, + "use-sync-external-store": { + "optional": true + } + } + }, + "node_modules/@react-three/fiber": { + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/@react-three/fiber/-/fiber-9.4.0.tgz", + "integrity": "sha512-k4iu1R6e5D54918V4sqmISUkI5OgTw3v7/sDRKEC632Wd5g2WBtUS5gyG63X0GJO/HZUj1tsjSXfyzwrUHZl1g==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@types/react-reconciler": "^0.32.0", + "@types/webxr": "*", + "base64-js": "^1.5.1", + "buffer": "^6.0.3", + "its-fine": "^2.0.0", + "react-reconciler": "^0.31.0", + "react-use-measure": "^2.1.7", + "scheduler": "^0.25.0", + "suspend-react": "^0.1.3", + "use-sync-external-store": "^1.4.0", + "zustand": "^5.0.3" + }, + "peerDependencies": { + "expo": ">=43.0", + "expo-asset": ">=8.4", + "expo-file-system": ">=11.0", + "expo-gl": ">=11.0", + "react": "^19.0.0", + "react-dom": "^19.0.0", + "react-native": ">=0.78", + "three": ">=0.156" + }, + "peerDependenciesMeta": { + "expo": { + "optional": true + }, + "expo-asset": { + "optional": true + }, + "expo-file-system": { + "optional": true + }, + "expo-gl": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "react-native": { + "optional": true + } + } + }, + "node_modules/@react-three/fiber/node_modules/scheduler": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.25.0.tgz", + "integrity": "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA==", + "license": "MIT" + }, + "node_modules/@react-three/fiber/node_modules/zustand": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.8.tgz", + "integrity": "sha512-gyPKpIaxY9XcO2vSMrLbiER7QMAMGOQZVRdJ6Zi782jkbzZygq5GI9nG8g+sMgitRtndwaBSl7uiqC49o1SSiw==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + }, + "peerDependencies": { + "@types/react": ">=18.0.0", + "immer": ">=9.0.6", + "react": ">=18.0.0", + "use-sync-external-store": ">=1.2.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + }, + "use-sync-external-store": { + "optional": true + } + } + }, "node_modules/@reactflow/background": { "version": "11.3.9", "resolved": "https://registry.npmjs.org/@reactflow/background/-/background-11.3.9.tgz", @@ -3022,6 +3204,12 @@ "url": "https://github.com/sponsors/tannerlinsley" } }, + "node_modules/@tweenjs/tween.js": { + "version": "23.1.3", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz", + "integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==", + "license": "MIT" + }, "node_modules/@tybys/wasm-util": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", @@ -3286,6 +3474,12 @@ "@types/d3-selection": "*" } }, + "node_modules/@types/draco3d": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/@types/draco3d/-/draco3d-1.4.10.tgz", + "integrity": "sha512-AX22jp8Y7wwaBgAixaSvkoG4M/+PlAcm3Qs4OW8yT9DM4xUpWKeFhLueTAyZF39pviAdcDdeJoACapiAceqNcw==", + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", @@ -3332,6 +3526,12 @@ "undici-types": "~6.21.0" } }, + "node_modules/@types/offscreencanvas": { + "version": "2019.7.3", + "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.3.tgz", + "integrity": "sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==", + "license": "MIT" + }, "node_modules/@types/react": { "version": "19.1.13", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.13.tgz", @@ -3351,6 +3551,15 @@ "@types/react": "^19.0.0" } }, + "node_modules/@types/react-reconciler": { + "version": "0.32.2", + "resolved": "https://registry.npmjs.org/@types/react-reconciler/-/react-reconciler-0.32.2.tgz", + "integrity": "sha512-gjcm6O0aUknhYaogEl8t5pecPfiOTD8VQkbjOhgbZas/E6qGY+veW9iuJU/7p4Y1E0EuQ0mArga7VEOUWSlVRA==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*" + } + }, "node_modules/@types/react-window": { "version": "1.8.8", "resolved": "https://registry.npmjs.org/@types/react-window/-/react-window-1.8.8.tgz", @@ -3360,6 +3569,27 @@ "@types/react": "*" } }, + "node_modules/@types/stats.js": { + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/@types/stats.js/-/stats.js-0.17.4.tgz", + "integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==", + "license": "MIT" + }, + "node_modules/@types/three": { + "version": "0.180.0", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.180.0.tgz", + "integrity": "sha512-ykFtgCqNnY0IPvDro7h+9ZeLY+qjgUWv+qEvUt84grhenO60Hqd4hScHE7VTB9nOQ/3QM8lkbNE+4vKjEpUxKg==", + "license": "MIT", + "dependencies": { + "@dimforge/rapier3d-compat": "~0.12.0", + "@tweenjs/tween.js": "~23.1.3", + "@types/stats.js": "*", + "@types/webxr": "*", + "@webgpu/types": "*", + "fflate": "~0.8.2", + "meshoptimizer": "~0.22.0" + } + }, "node_modules/@types/trusted-types": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", @@ -3380,6 +3610,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/webxr": { + "version": "0.5.24", + "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz", + "integrity": "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==", + "license": "MIT" + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.44.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.44.1.tgz", @@ -3937,6 +4173,30 @@ "win32" ] }, + "node_modules/@use-gesture/core": { + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/@use-gesture/core/-/core-10.3.1.tgz", + "integrity": "sha512-WcINiDt8WjqBdUXye25anHiNxPc0VOrlT8F6LLkU6cycrOGUDyY/yyFmsg3k8i5OLvv25llc0QC45GhR/C8llw==", + "license": "MIT" + }, + "node_modules/@use-gesture/react": { + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/@use-gesture/react/-/react-10.3.1.tgz", + "integrity": "sha512-Yy19y6O2GJq8f7CHf7L0nxL8bf4PZCPaVOCgJrusOeFHY1LvHgYXnmnXg6N5iwAnbgbZCDjo60SiM6IPJi9C5g==", + "license": "MIT", + "dependencies": { + "@use-gesture/core": "10.3.1" + }, + "peerDependencies": { + "react": ">= 16.8.0" + } + }, + "node_modules/@webgpu/types": { + "version": "0.1.66", + "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.66.tgz", + "integrity": "sha512-YA2hLrwLpDsRueNDXIMqN9NTzD6bCDkuXbOSe0heS+f8YE8usA6Gbv1prj81pzVHrbaAma7zObnIC+I6/sXJgA==", + "license": "BSD-3-Clause" + }, "node_modules/@xmldom/xmldom": { "version": "0.8.11", "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.11.tgz", @@ -4384,6 +4644,30 @@ "node": ">=8" } }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "node_modules/c12": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/c12/-/c12-3.1.0.tgz", @@ -4472,6 +4756,19 @@ "node": ">=6" } }, + "node_modules/camera-controls": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/camera-controls/-/camera-controls-3.1.0.tgz", + "integrity": "sha512-w5oULNpijgTRH0ARFJJ0R5ct1nUM3R3WP7/b8A6j9uTGpRfnsypc/RBMPQV8JQDPayUe37p/TZZY1PcUr4czOQ==", + "license": "MIT", + "engines": { + "node": ">=20.11.0", + "npm": ">=10.8.2" + }, + "peerDependencies": { + "three": ">=0.126.1" + } + }, "node_modules/caniuse-lite": { "version": "1.0.30001745", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001745.tgz", @@ -4718,11 +5015,28 @@ "node": ">=0.8" } }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "dev": true, "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -5380,6 +5694,15 @@ "dev": true, "license": "MIT" }, + "node_modules/detect-gpu": { + "version": "5.0.70", + "resolved": "https://registry.npmjs.org/detect-gpu/-/detect-gpu-5.0.70.tgz", + "integrity": "sha512-bqerEP1Ese6nt3rFkwPnGbsUF9a4q+gMmpTVVOEzoCyeCc+y7/RvJnQZJx1JwhgQI5Ntg0Kgat8Uu7XpBqnz1w==", + "license": "MIT", + "dependencies": { + "webgl-constants": "^1.1.1" + } + }, "node_modules/detect-libc": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.1.tgz", @@ -5516,6 +5839,12 @@ "url": "https://dotenvx.com" } }, + "node_modules/draco3d": { + "version": "1.5.7", + "resolved": "https://registry.npmjs.org/draco3d/-/draco3d-1.5.7.tgz", + "integrity": "sha512-m6WCKt/erDXcw+70IJXnG7M3awwQPAsZvJGX5zY7beBqpELw6RDGkYVU0W43AFxye4pDZ5i2Lbyc/NNGqwjUVQ==", + "license": "Apache-2.0" + }, "node_modules/duck": { "version": "0.1.12", "resolved": "https://registry.npmjs.org/duck/-/duck-0.1.12.tgz", @@ -6374,6 +6703,12 @@ "reusify": "^1.0.4" } }, + "node_modules/fflate": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", + "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==", + "license": "MIT" + }, "node_modules/file-entry-cache": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", @@ -6677,6 +7012,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/glsl-noise": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/glsl-noise/-/glsl-noise-0.0.0.tgz", + "integrity": "sha512-b/ZCF6amfAUb7dJM/MxRs7AetQEahYzJ8PtgfrmEdtw6uyGOr+ZSGtgjFm6mfsBkxJ4d2W7kg+Nlqzqvn3Bc0w==", + "license": "MIT" + }, "node_modules/goober": { "version": "2.1.16", "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.16.tgz", @@ -6813,6 +7154,12 @@ "node": ">= 0.4" } }, + "node_modules/hls.js": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.6.13.tgz", + "integrity": "sha512-hNEzjZNHf5bFrUNvdS4/1RjIanuJ6szpWNfTaX5I6WfGynWXGT7K/YQLYtemSvFExzeMdgdE4SsyVLJbd5PcZA==", + "license": "Apache-2.0" + }, "node_modules/hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", @@ -6872,6 +7219,26 @@ "node": ">=0.10.0" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -7217,6 +7584,12 @@ "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", "license": "MIT" }, + "node_modules/is-promise": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==", + "license": "MIT" + }, "node_modules/is-regex": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", @@ -7373,7 +7746,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true, "license": "ISC" }, "node_modules/isomorphic-dompurify": { @@ -7407,6 +7779,27 @@ "node": ">= 0.4" } }, + "node_modules/its-fine": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/its-fine/-/its-fine-2.0.0.tgz", + "integrity": "sha512-KLViCmWx94zOvpLwSlsx6yOCeMhZYaxrJV87Po5k/FoZzcPSahvK5qJ7fYhS61sZi5ikmh2S3Hz55A2l3U69ng==", + "license": "MIT", + "dependencies": { + "@types/react-reconciler": "^0.28.9" + }, + "peerDependencies": { + "react": "^19.0.0" + } + }, + "node_modules/its-fine/node_modules/@types/react-reconciler": { + "version": "0.28.9", + "resolved": "https://registry.npmjs.org/@types/react-reconciler/-/react-reconciler-0.28.9.tgz", + "integrity": "sha512-HHM3nxyUZ3zAylX8ZEyrDNd2XZOnQ0D5XfunJF5FLQnZbHHYq4UWvW1QfelQNXv1ICNkwYhfxjwfnqivYB6bFg==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*" + } + }, "node_modules/jiti": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.6.0.tgz", @@ -7901,6 +8294,16 @@ "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, + "node_modules/maath": { + "version": "0.10.8", + "resolved": "https://registry.npmjs.org/maath/-/maath-0.10.8.tgz", + "integrity": "sha512-tRvbDF0Pgqz+9XUa4jjfgAQ8/aPKmQdWXilFu2tMy4GWj4NOsx99HlULO4IeREfbO3a0sA145DZYyvXPkybm0g==", + "license": "MIT", + "peerDependencies": { + "@types/three": ">=0.134.0", + "three": ">=0.134.0" + } + }, "node_modules/magic-string": { "version": "0.30.19", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.19.tgz", @@ -7969,6 +8372,21 @@ "node": ">= 8" } }, + "node_modules/meshline": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/meshline/-/meshline-3.3.1.tgz", + "integrity": "sha512-/TQj+JdZkeSUOl5Mk2J7eLcYTLiQm2IDzmlSvYm7ov15anEcDJ92GHqqazxTSreeNgfnYu24kiEvvv0WlbCdFQ==", + "license": "MIT", + "peerDependencies": { + "three": ">=0.137" + } + }, + "node_modules/meshoptimizer": { + "version": "0.22.0", + "resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-0.22.0.tgz", + "integrity": "sha512-IebiK79sqIy+E4EgOr+CAw+Ke8hAspXKzBd0JdgEmPHiAwmvEj2S4h1rfvo+o/BnfEYd/jAOg5IeeIjzlzSnDg==", + "license": "MIT" + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", @@ -8468,7 +8886,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -8564,6 +8981,12 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/potpack": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/potpack/-/potpack-1.0.2.tgz", + "integrity": "sha512-choctRBIV9EMT9WGAZHn3V7t0Z2pMQyl0EZE6pFc/6ml3ssw7Dlf/oAOvFwjm1HVsqfQN8GfeFyJ+d8tRzqueQ==", + "license": "ISC" + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -8734,6 +9157,16 @@ "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "license": "MIT" }, + "node_modules/promise-worker-transferable": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/promise-worker-transferable/-/promise-worker-transferable-1.0.4.tgz", + "integrity": "sha512-bN+0ehEnrXfxV2ZQvU2PetO0n4gqBD4ulq3MI1WOPLgr7/Mg9yRQkX5+0v1vagr74ZTsl7XtzlaYDo2EuCeYJw==", + "license": "Apache-2.0", + "dependencies": { + "is-promise": "^2.1.0", + "lie": "^3.0.2" + } + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -8944,6 +9377,27 @@ "react-dom": "^19.0.0" } }, + "node_modules/react-reconciler": { + "version": "0.31.0", + "resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.31.0.tgz", + "integrity": "sha512-7Ob7Z+URmesIsIVRjnLoDGwBEG/tVitidU0nMsqX/eeJaLY89RISO/10ERe0MqmzuKUUB1rmY+h1itMbUHg9BQ==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.25.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "peerDependencies": { + "react": "^19.0.0" + } + }, + "node_modules/react-reconciler/node_modules/scheduler": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.25.0.tgz", + "integrity": "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA==", + "license": "MIT" + }, "node_modules/react-redux": { "version": "9.2.0", "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz", @@ -9046,6 +9500,21 @@ } } }, + "node_modules/react-use-measure": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/react-use-measure/-/react-use-measure-2.1.7.tgz", + "integrity": "sha512-KrvcAo13I/60HpwGO5jpW7E9DfusKyLPLvuHlUyP5zqnmAPhNc6qTRjUQrdTADl0lpPpDVU2/Gg51UlOGHXbdg==", + "license": "MIT", + "peerDependencies": { + "react": ">=16.13", + "react-dom": ">=16.13" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } + } + }, "node_modules/react-window": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/react-window/-/react-window-2.1.1.tgz", @@ -9510,7 +9979,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" @@ -9523,7 +9991,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -9674,6 +10141,32 @@ "dev": true, "license": "MIT" }, + "node_modules/stats-gl": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/stats-gl/-/stats-gl-2.4.2.tgz", + "integrity": "sha512-g5O9B0hm9CvnM36+v7SFl39T7hmAlv541tU81ME8YeSb3i1CIP5/QdDeSB3A0la0bKNHpxpwxOVRo2wFTYEosQ==", + "license": "MIT", + "dependencies": { + "@types/three": "*", + "three": "^0.170.0" + }, + "peerDependencies": { + "@types/three": "*", + "three": "*" + } + }, + "node_modules/stats-gl/node_modules/three": { + "version": "0.170.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.170.0.tgz", + "integrity": "sha512-FQK+LEpYc0fBD+J8g6oSEyyNzjp+Q7Ks1C568WWaoMRLW+TkNNWmenWeGgJjV105Gd+p/2ql1ZcjYvNiPZBhuQ==", + "license": "MIT" + }, + "node_modules/stats.js": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/stats.js/-/stats.js-0.17.0.tgz", + "integrity": "sha512-hNKz8phvYLPEcRkeG1rsGmV5ChMjKDAWU7/OJJdDErPBNChQXxCo3WZurGpnWc6gZhAzEPFad1aVgyOANH1sMw==", + "license": "MIT" + }, "node_modules/stop-iteration-iterator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", @@ -9882,6 +10375,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/suspend-react": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/suspend-react/-/suspend-react-0.1.3.tgz", + "integrity": "sha512-aqldKgX9aZqpoDp3e8/BZ8Dm7x1pJl+qI3ZKxDN0i/IQTWUwBx/ManmlVJ3wowqbno6c2bmiIfs+Um6LbsjJyQ==", + "license": "MIT", + "peerDependencies": { + "react": ">=17.0" + } + }, "node_modules/symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", @@ -9952,6 +10454,44 @@ "node": ">=18" } }, + "node_modules/three": { + "version": "0.180.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.180.0.tgz", + "integrity": "sha512-o+qycAMZrh+TsE01GqWUxUIKR1AL0S8pq7zDkYOQw8GqfX8b8VoCKYUoHbhiX5j+7hr8XsuHDVU6+gkQJQKg9w==", + "license": "MIT" + }, + "node_modules/three-mesh-bvh": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/three-mesh-bvh/-/three-mesh-bvh-0.8.3.tgz", + "integrity": "sha512-4G5lBaF+g2auKX3P0yqx+MJC6oVt6sB5k+CchS6Ob0qvH0YIhuUk1eYr7ktsIpY+albCqE80/FVQGV190PmiAg==", + "license": "MIT", + "peerDependencies": { + "three": ">= 0.159.0" + } + }, + "node_modules/three-stdlib": { + "version": "2.36.0", + "resolved": "https://registry.npmjs.org/three-stdlib/-/three-stdlib-2.36.0.tgz", + "integrity": "sha512-kv0Byb++AXztEGsULgMAs8U2jgUdz6HPpAB/wDJnLiLlaWQX2APHhiTJIN7rqW+Of0eRgcp7jn05U1BsCP3xBA==", + "license": "MIT", + "dependencies": { + "@types/draco3d": "^1.4.0", + "@types/offscreencanvas": "^2019.6.4", + "@types/webxr": "^0.5.2", + "draco3d": "^1.4.1", + "fflate": "^0.6.9", + "potpack": "^1.0.1" + }, + "peerDependencies": { + "three": ">=0.128.0" + } + }, + "node_modules/three-stdlib/node_modules/fflate": { + "version": "0.6.10", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.6.10.tgz", + "integrity": "sha512-IQrh3lEPM93wVCEczc9SaAOvkmcoQn/G8Bo1e8ZPlY3X3bnAxWaBdvTdvM1hP62iZp0BXWDy4vTAy4fF0+Dlpg==", + "license": "MIT" + }, "node_modules/tiny-invariant": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", @@ -10068,6 +10608,36 @@ "node": ">=20" } }, + "node_modules/troika-three-text": { + "version": "0.52.4", + "resolved": "https://registry.npmjs.org/troika-three-text/-/troika-three-text-0.52.4.tgz", + "integrity": "sha512-V50EwcYGruV5rUZ9F4aNsrytGdKcXKALjEtQXIOBfhVoZU9VAqZNIoGQ3TMiooVqFAbR1w15T+f+8gkzoFzawg==", + "license": "MIT", + "dependencies": { + "bidi-js": "^1.0.2", + "troika-three-utils": "^0.52.4", + "troika-worker-utils": "^0.52.0", + "webgl-sdf-generator": "1.1.1" + }, + "peerDependencies": { + "three": ">=0.125.0" + } + }, + "node_modules/troika-three-utils": { + "version": "0.52.4", + "resolved": "https://registry.npmjs.org/troika-three-utils/-/troika-three-utils-0.52.4.tgz", + "integrity": "sha512-NORAStSVa/BDiG52Mfudk4j1FG4jC4ILutB3foPnfGbOeIs9+G5vZLa0pnmnaftZUGm4UwSoqEpWdqvC7zms3A==", + "license": "MIT", + "peerDependencies": { + "three": ">=0.125.0" + } + }, + "node_modules/troika-worker-utils": { + "version": "0.52.0", + "resolved": "https://registry.npmjs.org/troika-worker-utils/-/troika-worker-utils-0.52.0.tgz", + "integrity": "sha512-W1CpvTHykaPH5brv5VHLfQo9D1OYuo0cSBEUQFFT/nBUzM8iD6Lq2/tgG/f1OelbAS1WtaTPQzE5uM49egnngw==", + "license": "MIT" + }, "node_modules/ts-api-utils": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", @@ -10100,6 +10670,15 @@ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "license": "0BSD" }, + "node_modules/tunnel-rat": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/tunnel-rat/-/tunnel-rat-0.1.2.tgz", + "integrity": "sha512-lR5VHmkPhzdhrM092lI2nACsLO4QubF0/yoOhzX7c+wIpbN1GjHNzCc91QlpxBi+cnx8vVJ+Ur6vL5cEoQPFpQ==", + "license": "MIT", + "dependencies": { + "zustand": "^4.3.2" + } + }, "node_modules/tw-animate-css": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/tw-animate-css/-/tw-animate-css-1.4.0.tgz", @@ -10350,6 +10929,15 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "license": "MIT" }, + "node_modules/utility-types": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.11.0.tgz", + "integrity": "sha512-6Z7Ma2aVEWisaL6TvBCy7P8rm2LQoPv6dJ7ecIaIixHcwfbJ0x7mWdbcwlIM5IGQxPZSFYeqRCqlOOeKoJYMkw==", + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, "node_modules/uuid": { "version": "13.0.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-13.0.0.tgz", @@ -10397,6 +10985,17 @@ "node": ">=18" } }, + "node_modules/webgl-constants": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/webgl-constants/-/webgl-constants-1.1.1.tgz", + "integrity": "sha512-LkBXKjU5r9vAW7Gcu3T5u+5cvSvh5WwINdr0C+9jpzVB41cjQAP5ePArDtk/WHYdVj0GefCgM73BA7FlIiNtdg==" + }, + "node_modules/webgl-sdf-generator": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/webgl-sdf-generator/-/webgl-sdf-generator-1.1.1.tgz", + "integrity": "sha512-9Z0JcMTFxeE+b2x1LJTdnaT8rT8aEp7MVxkNwoycNmJWwPdzoXzMh0BjJSh/AEFP+KPYZUli814h8bJZFIZ2jA==", + "license": "MIT" + }, "node_modules/webidl-conversions": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.0.tgz", @@ -10444,7 +11043,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, "license": "ISC", "dependencies": { "isexe": "^2.0.0" diff --git a/frontend/package.json b/frontend/package.json index bc9e8d1d..522ccd29 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -38,11 +38,14 @@ "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-switch": "^1.2.6", "@radix-ui/react-tabs": "^1.1.13", + "@react-three/drei": "^10.7.6", + "@react-three/fiber": "^9.4.0", "@tanstack/react-query": "^5.86.0", "@tanstack/react-table": "^8.21.3", "@types/d3": "^7.4.3", "@types/leaflet": "^1.9.21", "@types/react-window": "^1.8.8", + "@types/three": "^0.180.0", "@xyflow/react": "^12.8.4", "axios": "^1.11.0", "class-variance-authority": "^0.7.1", @@ -72,6 +75,7 @@ "sheetjs-style": "^0.15.8", "sonner": "^2.0.7", "tailwind-merge": "^3.3.1", + "three": "^0.180.0", "uuid": "^13.0.0", "xlsx": "^0.18.5", "zod": "^4.1.5" From 5093d336c0f54b7b6f68b33f1d60d30d129166a9 Mon Sep 17 00:00:00 2001 From: dohyeons Date: Thu, 16 Oct 2025 16:43:04 +0900 Subject: [PATCH 04/10] =?UTF-8?q?=EB=8C=80=EC=8B=9C=EB=B3=B4=EB=93=9C?= =?UTF-8?q?=EC=97=90=20=ED=99=94=EB=A9=B4=20=ED=95=A0=EB=8B=B9=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/dashboard/DashboardDesigner.tsx | 254 +++++++------- .../admin/dashboard/DashboardSaveModal.tsx | 321 ++++++++++++++++++ .../admin/dashboard/ElementConfigModal.tsx | 13 +- 3 files changed, 457 insertions(+), 131 deletions(-) create mode 100644 frontend/components/admin/dashboard/DashboardSaveModal.tsx diff --git a/frontend/components/admin/dashboard/DashboardDesigner.tsx b/frontend/components/admin/dashboard/DashboardDesigner.tsx index 95eea2f2..7f19bbc4 100644 --- a/frontend/components/admin/dashboard/DashboardDesigner.tsx +++ b/frontend/components/admin/dashboard/DashboardDesigner.tsx @@ -6,10 +6,14 @@ import { DashboardCanvas } from "./DashboardCanvas"; import { DashboardTopMenu } from "./DashboardTopMenu"; import { ElementConfigModal } from "./ElementConfigModal"; import { ListWidgetConfigModal } from "./widgets/ListWidgetConfigModal"; -import { MenuAssignmentModal } from "./MenuAssignmentModal"; +import { DashboardSaveModal } from "./DashboardSaveModal"; import { DashboardElement, ElementType, ElementSubtype } from "./types"; import { GRID_CONFIG, snapToGrid, snapSizeToGrid, calculateCellSize } from "./gridUtils"; import { Resolution, RESOLUTIONS, detectScreenResolution } from "./ResolutionSelector"; +import { useMenu } from "@/contexts/MenuContext"; +import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; +import { CheckCircle2 } from "lucide-react"; interface DashboardDesignerProps { dashboardId?: string; @@ -24,6 +28,7 @@ interface DashboardDesignerProps { */ export default function DashboardDesigner({ dashboardId: initialDashboardId }: DashboardDesignerProps = {}) { const router = useRouter(); + const { refreshMenus } = useMenu(); const [elements, setElements] = useState([]); const [selectedElement, setSelectedElement] = useState(null); const [elementCounter, setElementCounter] = useState(0); @@ -34,9 +39,10 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D const [canvasBackgroundColor, setCanvasBackgroundColor] = useState("#f9fafb"); const canvasRef = useRef(null); - // ๋ฉ”๋‰ด ํ• ๋‹น ๋ชจ๋‹ฌ ์ƒํƒœ - const [menuAssignmentModalOpen, setMenuAssignmentModalOpen] = useState(false); - const [savedDashboardInfo, setSavedDashboardInfo] = useState<{ id: string; title: string } | null>(null); + // ์ €์žฅ ๋ชจ๋‹ฌ ์ƒํƒœ + const [saveModalOpen, setSaveModalOpen] = useState(false); + const [dashboardDescription, setDashboardDescription] = useState(""); + const [successModalOpen, setSuccessModalOpen] = useState(false); // ํ™”๋ฉด ํ•ด์ƒ๋„ ์ž๋™ ๊ฐ์ง€ const [screenResolution] = useState(() => detectScreenResolution()); @@ -308,117 +314,93 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D ); // ๋ ˆ์ด์•„์›ƒ ์ €์žฅ - const saveLayout = useCallback(async () => { + const saveLayout = useCallback(() => { if (elements.length === 0) { alert("์ €์žฅํ•  ์š”์†Œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ์ฐจํŠธ๋‚˜ ์œ„์ ฏ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”."); return; } - try { - // ์‹ค์ œ API ํ˜ธ์ถœ - const { dashboardApi } = await import("@/lib/api/dashboard"); - - const elementsData = elements.map((el) => ({ - id: el.id, - type: el.type, - subtype: el.subtype, - position: el.position, - size: el.size, - title: el.title, - content: el.content, - dataSource: el.dataSource, - chartConfig: el.chartConfig, - })); - - let savedDashboard; - - if (dashboardId) { - // ๊ธฐ์กด ๋Œ€์‹œ๋ณด๋“œ ์—…๋ฐ์ดํŠธ - console.log("๐Ÿ’พ ์ €์žฅ ์‹œ์ž‘ - ํ˜„์žฌ resolution ์ƒํƒœ:", resolution); - console.log("๐Ÿ’พ ์ €์žฅ ์‹œ์ž‘ - ํ˜„์žฌ ๋ฐฐ๊ฒฝ์ƒ‰ ์ƒํƒœ:", canvasBackgroundColor); - - const updateData = { - elements: elementsData, - settings: { - resolution, - backgroundColor: canvasBackgroundColor, - }, - }; - - console.log("๐Ÿ’พ ์ €์žฅํ•  ๋ฐ์ดํ„ฐ:", updateData); - console.log("๐Ÿ’พ ์ €์žฅํ•  settings:", updateData.settings); - - savedDashboard = await dashboardApi.updateDashboard(dashboardId, updateData); - - console.log("โœ… ์ €์žฅ๋œ ๋Œ€์‹œ๋ณด๋“œ:", savedDashboard); - console.log("โœ… ์ €์žฅ๋œ settings:", (savedDashboard as any).settings); - - // ๋ฉ”๋‰ด ํ• ๋‹น ๋ชจ๋‹ฌ ๋„์šฐ๊ธฐ (๊ธฐ์กด ๋Œ€์‹œ๋ณด๋“œ ์—…๋ฐ์ดํŠธ ์‹œ์—๋„) - setSavedDashboardInfo({ - id: savedDashboard.id, - title: savedDashboard.title, - }); - setMenuAssignmentModalOpen(true); - } else { - // ์ƒˆ ๋Œ€์‹œ๋ณด๋“œ ์ƒ์„ฑ - const title = prompt("๋Œ€์‹œ๋ณด๋“œ ์ œ๋ชฉ์„ ์ž…๋ ฅํ•˜์„ธ์š”:", "์ƒˆ ๋Œ€์‹œ๋ณด๋“œ"); - if (!title) return; - - const description = prompt("๋Œ€์‹œ๋ณด๋“œ ์„ค๋ช…์„ ์ž…๋ ฅํ•˜์„ธ์š” (์„ ํƒ์‚ฌํ•ญ):", ""); - - const dashboardData = { - title, - description: description || undefined, - isPublic: false, - elements: elementsData, - settings: { - resolution, - backgroundColor: canvasBackgroundColor, - }, - }; - - savedDashboard = await dashboardApi.createDashboard(dashboardData); - - // ๋Œ€์‹œ๋ณด๋“œ ID ์„ค์ • (๋‹ค์Œ ์ €์žฅ ์‹œ ์—…๋ฐ์ดํŠธ ๋ชจ๋“œ๋กœ ์ „ํ™˜) - setDashboardId(savedDashboard.id); - setDashboardTitle(savedDashboard.title); - - // ๋ฉ”๋‰ด ํ• ๋‹น ๋ชจ๋‹ฌ ๋„์šฐ๊ธฐ - setSavedDashboardInfo({ - id: savedDashboard.id, - title: savedDashboard.title, - }); - setMenuAssignmentModalOpen(true); - } - } catch (error) { - const errorMessage = error instanceof Error ? error.message : "์•Œ ์ˆ˜ ์—†๋Š” ์˜ค๋ฅ˜"; - alert(`๋Œ€์‹œ๋ณด๋“œ ์ €์žฅ ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n์˜ค๋ฅ˜: ${errorMessage}\n\n๊ด€๋ฆฌ์ž์—๊ฒŒ ๋ฌธ์˜ํ•˜์„ธ์š”.`); - } - }, [elements, dashboardId, router, resolution, canvasBackgroundColor]); - - // ๋ฉ”๋‰ด ํ• ๋‹น ์ฒ˜๋ฆฌ - const handleMenuAssignment = useCallback( - async (assignToMenu: boolean, menuId?: string, menuType?: "0" | "1") => { - if (!savedDashboardInfo) return; + // ์ €์žฅ ๋ชจ๋‹ฌ ์—ด๊ธฐ + setSaveModalOpen(true); + }, [elements]); + // ์ €์žฅ ์ฒ˜๋ฆฌ + const handleSave = useCallback( + async (data: { + title: string; + description: string; + assignToMenu: boolean; + menuType?: "admin" | "user"; + menuId?: string; + }) => { try { - if (assignToMenu && menuId) { - // ๋ฉ”๋‰ด API๋ฅผ ํ†ตํ•ด ๋Œ€์‹œ๋ณด๋“œ URL ํ• ๋‹น + const { dashboardApi } = await import("@/lib/api/dashboard"); + + const elementsData = elements.map((el) => ({ + id: el.id, + type: el.type, + subtype: el.subtype, + position: el.position, + size: el.size, + title: el.title, + content: el.content, + dataSource: el.dataSource, + chartConfig: el.chartConfig, + listConfig: el.listConfig, + })); + + let savedDashboard; + + if (dashboardId) { + // ๊ธฐ์กด ๋Œ€์‹œ๋ณด๋“œ ์—…๋ฐ์ดํŠธ + const updateData = { + title: data.title, + description: data.description || undefined, + elements: elementsData, + settings: { + resolution, + backgroundColor: canvasBackgroundColor, + }, + }; + + savedDashboard = await dashboardApi.updateDashboard(dashboardId, updateData); + } else { + // ์ƒˆ ๋Œ€์‹œ๋ณด๋“œ ์ƒ์„ฑ + const dashboardData = { + title: data.title, + description: data.description || undefined, + isPublic: false, + elements: elementsData, + settings: { + resolution, + backgroundColor: canvasBackgroundColor, + }, + }; + + savedDashboard = await dashboardApi.createDashboard(dashboardData); + setDashboardId(savedDashboard.id); + } + + setDashboardTitle(savedDashboard.title); + setDashboardDescription(data.description); + + // ๋ฉ”๋‰ด ํ• ๋‹น ์ฒ˜๋ฆฌ + if (data.assignToMenu && data.menuId) { const { menuApi } = await import("@/lib/api/menu"); // ๋Œ€์‹œ๋ณด๋“œ URL ์ƒ์„ฑ (๊ด€๋ฆฌ์ž ๋ฉ”๋‰ด๋ฉด mode=admin ์ถ”๊ฐ€) - let dashboardUrl = `/dashboard/${savedDashboardInfo.id}`; - if (menuType === "0") { + let dashboardUrl = `/dashboard/${savedDashboard.id}`; + if (data.menuType === "admin") { dashboardUrl += "?mode=admin"; } // ๋ฉ”๋‰ด ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ - const menuResponse = await menuApi.getMenuInfo(menuId); + const menuResponse = await menuApi.getMenuInfo(data.menuId); + if (menuResponse.success && menuResponse.data) { const menu = menuResponse.data; - // ๋ฉ”๋‰ด URL ์—…๋ฐ์ดํŠธ - await menuApi.updateMenu(menuId, { + const updateData = { menuUrl: dashboardUrl, parentObjId: menu.parent_obj_id || menu.PARENT_OBJ_ID || "0", menuNameKor: menu.menu_name_kor || menu.MENU_NAME_KOR || "", @@ -428,24 +410,25 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D status: menu.status || menu.STATUS || "active", companyCode: menu.company_code || menu.COMPANY_CODE || "", langKey: menu.lang_key || menu.LANG_KEY || "", - }); + }; - alert(`๋ฉ”๋‰ด "${menu.menu_name_kor || menu.MENU_NAME_KOR}"์— ๋Œ€์‹œ๋ณด๋“œ๊ฐ€ ํ• ๋‹น๋˜์—ˆ์Šต๋‹ˆ๋‹ค!`); + // ๋ฉ”๋‰ด URL ์—…๋ฐ์ดํŠธ + await menuApi.updateMenu(data.menuId, updateData); + + // ๋ฉ”๋‰ด ๋ชฉ๋ก ์ƒˆ๋กœ๊ณ ์นจ + await refreshMenus(); } } - // ๋ชจ๋‹ฌ ๋‹ซ๊ธฐ - setMenuAssignmentModalOpen(false); - setSavedDashboardInfo(null); - - // ๋Œ€์‹œ๋ณด๋“œ ๋ทฐ์–ด๋กœ ์ด๋™ - router.push(`/dashboard/${savedDashboardInfo.id}`); + // ์„ฑ๊ณต ๋ชจ๋‹ฌ ํ‘œ์‹œ + setSuccessModalOpen(true); } catch (error) { - console.error("๋ฉ”๋‰ด ํ• ๋‹น ์˜ค๋ฅ˜:", error); - alert("๋ฉ”๋‰ด ํ• ๋‹น ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค."); + const errorMessage = error instanceof Error ? error.message : "์•Œ ์ˆ˜ ์—†๋Š” ์˜ค๋ฅ˜"; + alert(`๋Œ€์‹œ๋ณด๋“œ ์ €์žฅ ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.\n\n์˜ค๋ฅ˜: ${errorMessage}`); + throw error; } }, - [savedDashboardInfo, router], + [elements, dashboardId, resolution, canvasBackgroundColor, router], ); // ๋กœ๋”ฉ ์ค‘์ด๋ฉด ๋กœ๋”ฉ ํ™”๋ฉด ํ‘œ์‹œ @@ -523,21 +506,44 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D )} - {/* ๋ฉ”๋‰ด ํ• ๋‹น ๋ชจ๋‹ฌ */} - {savedDashboardInfo && ( - { - setMenuAssignmentModalOpen(false); - setSavedDashboardInfo(null); - // ๋ชจ๋‹ฌ์„ ๊ทธ๋ƒฅ ๋‹ซ์œผ๋ฉด ๋Œ€์‹œ๋ณด๋“œ ๋ทฐ์–ด๋กœ ์ด๋™ - router.push(`/dashboard/${savedDashboardInfo.id}`); - }} - onConfirm={handleMenuAssignment} - dashboardId={savedDashboardInfo.id} - dashboardTitle={savedDashboardInfo.title} - /> - )} + {/* ์ €์žฅ ๋ชจ๋‹ฌ */} + setSaveModalOpen(false)} + onSave={handleSave} + initialTitle={dashboardTitle} + initialDescription={dashboardDescription} + isEditing={!!dashboardId} + /> + + {/* ์ €์žฅ ์„ฑ๊ณต ๋ชจ๋‹ฌ */} + { + setSuccessModalOpen(false); + router.push("/admin/dashboard"); + }} + > + + +
+ +
+ ์ €์žฅ ์™„๋ฃŒ + ๋Œ€์‹œ๋ณด๋“œ๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ์ €์žฅ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. +
+
+ +
+
+
); } diff --git a/frontend/components/admin/dashboard/DashboardSaveModal.tsx b/frontend/components/admin/dashboard/DashboardSaveModal.tsx new file mode 100644 index 00000000..34837384 --- /dev/null +++ b/frontend/components/admin/dashboard/DashboardSaveModal.tsx @@ -0,0 +1,321 @@ +"use client"; + +import { useState, useEffect } from "react"; +import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Textarea } from "@/components/ui/textarea"; +import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, + SelectGroup, + SelectLabel, +} from "@/components/ui/select"; +import { Loader2, Save } from "lucide-react"; +import { menuApi } from "@/lib/api/menu"; + +interface MenuItem { + id: string; + name: string; + url?: string; + parent_id?: string; + children?: MenuItem[]; +} + +interface DashboardSaveModalProps { + isOpen: boolean; + onClose: () => void; + onSave: (data: { + title: string; + description: string; + assignToMenu: boolean; + menuType?: "admin" | "user"; + menuId?: string; + }) => Promise; + initialTitle?: string; + initialDescription?: string; + isEditing?: boolean; +} + +export function DashboardSaveModal({ + isOpen, + onClose, + onSave, + initialTitle = "", + initialDescription = "", + isEditing = false, +}: DashboardSaveModalProps) { + const [title, setTitle] = useState(initialTitle); + const [description, setDescription] = useState(initialDescription); + const [assignToMenu, setAssignToMenu] = useState(false); + const [menuType, setMenuType] = useState<"admin" | "user">("admin"); + const [selectedMenuId, setSelectedMenuId] = useState(""); + const [adminMenus, setAdminMenus] = useState([]); + const [userMenus, setUserMenus] = useState([]); + const [loading, setLoading] = useState(false); + const [loadingMenus, setLoadingMenus] = useState(false); + + useEffect(() => { + if (isOpen) { + setTitle(initialTitle); + setDescription(initialDescription); + setAssignToMenu(false); + setMenuType("admin"); + setSelectedMenuId(""); + loadMenus(); + } + }, [isOpen, initialTitle, initialDescription]); + + const loadMenus = async () => { + setLoadingMenus(true); + try { + const [adminData, userData] = await Promise.all([menuApi.getAdminMenus(), menuApi.getUserMenus()]); + + // API ์‘๋‹ต์ด ๋ฐฐ์—ด์ธ์ง€ ํ™•์ธํ•˜๊ณ  ์ฒ˜๋ฆฌ + const adminMenuList = Array.isArray(adminData) ? adminData : adminData?.data || []; + const userMenuList = Array.isArray(userData) ? userData : userData?.data || []; + + setAdminMenus(adminMenuList); + setUserMenus(userMenuList); + } catch (error) { + console.error("๋ฉ”๋‰ด ๋ชฉ๋ก ๋กœ๋“œ ์‹คํŒจ:", error); + setAdminMenus([]); + setUserMenus([]); + } finally { + setLoadingMenus(false); + } + }; + + const flattenMenus = ( + menus: MenuItem[], + prefix = "", + parentPath = "", + ): { id: string; label: string; uniqueKey: string }[] => { + if (!Array.isArray(menus)) { + return []; + } + + const result: { id: string; label: string; uniqueKey: string }[] = []; + menus.forEach((menu, index) => { + // ๋ฉ”๋‰ด ID ์ถ”์ถœ (objid ๋˜๋Š” id) + const menuId = (menu as any).objid || menu.id || ""; + const uniqueKey = `${parentPath}-${menuId}-${index}`; + + // ๋ฉ”๋‰ด ์ด๋ฆ„ ์ถ”์ถœ + const menuName = + menu.name || + (menu as any).menu_name_kor || + (menu as any).MENU_NAME_KOR || + (menu as any).menuNameKor || + (menu as any).title || + "์ด๋ฆ„์—†์Œ"; + + // lev ํ•„๋“œ๋กœ ๋ ˆ๋ฒจ ํ™•์ธ (lev > 1์ธ ๋ฉ”๋‰ด๋งŒ ์ถ”๊ฐ€) + const menuLevel = (menu as any).lev || 0; + + if (menuLevel > 1) { + result.push({ + id: menuId, + label: prefix + menuName, + uniqueKey, + }); + } + + // ํ•˜์œ„ ๋ฉ”๋‰ด๊ฐ€ ์žˆ์œผ๋ฉด ์žฌ๊ท€ ํ˜ธ์ถœ + if (menu.children && Array.isArray(menu.children) && menu.children.length > 0) { + result.push(...flattenMenus(menu.children, prefix + menuName + " > ", uniqueKey)); + } + }); + + return result; + }; + + const handleSave = async () => { + if (!title.trim()) { + alert("๋Œ€์‹œ๋ณด๋“œ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”."); + return; + } + + if (assignToMenu && !selectedMenuId) { + alert("๋ฉ”๋‰ด๋ฅผ ์„ ํƒํ•ด์ฃผ์„ธ์š”."); + return; + } + + setLoading(true); + try { + await onSave({ + title: title.trim(), + description: description.trim(), + assignToMenu, + menuType: assignToMenu ? menuType : undefined, + menuId: assignToMenu ? selectedMenuId : undefined, + }); + onClose(); + } catch (error) { + console.error("์ €์žฅ ์‹คํŒจ:", error); + } finally { + setLoading(false); + } + }; + + const currentMenus = menuType === "admin" ? adminMenus : userMenus; + const flatMenus = flattenMenus(currentMenus); + + return ( + + + + {isEditing ? "๋Œ€์‹œ๋ณด๋“œ ์ˆ˜์ •" : "๋Œ€์‹œ๋ณด๋“œ ์ €์žฅ"} + + +
+ {/* ๋Œ€์‹œ๋ณด๋“œ ์ด๋ฆ„ */} +
+ + setTitle(e.target.value)} + placeholder="์˜ˆ: ์ƒ์‚ฐ ํ˜„ํ™ฉ ๋Œ€์‹œ๋ณด๋“œ" + className="w-full" + /> +
+ + {/* ๋Œ€์‹œ๋ณด๋“œ ์„ค๋ช… */} +
+ +