From ed828d9417bb5c742692e833037131bf57e4df65 Mon Sep 17 00:00:00 2001 From: Gomathi9520 Date: Fri, 23 May 2025 09:33:06 +0530 Subject: [PATCH 1/7] refactor: remove console log from TotalCardComponent --- .../IotInputCards/InputSelecterComponent.tsx | 312 +++++++++++------- .../floating/cards/TotalCardComponent.tsx | 2 +- 2 files changed, 186 insertions(+), 128 deletions(-) diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/InputSelecterComponent.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/InputSelecterComponent.tsx index 2d82225..210e2b4 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/InputSelecterComponent.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/InputSelecterComponent.tsx @@ -12,140 +12,198 @@ import Widget4InputCard3D from './Widget4InputCard3D' import WarehouseThroughputInputComponent from './WarehouseThroughputInputComponent' import { useWidgetStore } from '../../../../../store/useWidgetStore' +// const InputSelecterComponent = () => { +// const { selectedChartId } = useWidgetStore(); + +// if (selectedChartId && selectedChartId.type && selectedChartId.type === 'bar' ) { +// return ( +// <> +//
2D Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'line' ) { +// return ( +// <> +//
2D Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'pie' ) { +// return ( +// <> +//
2D Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'doughnut' ) { +// return ( +// <> +//
2D Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'polarArea' ) { +// return ( +// <> +//
2D Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'progress 1' ) { +// return ( +// <> +//
2D Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'progress 2' ) { +// return ( +// <> +//
2D Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.className && selectedChartId.className === 'warehouseThroughput floating' ) { +// return ( +// <> +//
Floting Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.className && selectedChartId.className === 'fleetEfficiency floating' ) { +// return ( +// <> +//
Floting Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.className && selectedChartId.className === 'floating total-card' ) { +// return ( +// <> +//
Floting Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'ui-Widget 1' ) { +// return ( +// <> +//
3D Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'ui-Widget 2' ) { +// return ( +// <> +//
3D Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'ui-Widget 3' ) { +// return ( +// <> +//
3D Widget Input
+// +// +// ) +// } + +// else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'ui-Widget 4' ) { +// return ( +// <> +//
3D Widget Input
+// +// +// ) +// } + +// else { +// return ( +//
No chart selected
+// ) +// } +// } + +const chartTypeMap: Record<| 'bar'| 'line'| 'pie' | 'doughnut' | 'polarArea'| 'progress 1' | 'progress 2' + | 'ui-Widget 1'| 'ui-Widget 2'| 'ui-Widget 3'| 'ui-Widget 4',JSX.Element> = { + bar: , + line: , + pie: , + doughnut: , + polarArea: , + 'progress 1': , + 'progress 2': , + 'ui-Widget 1': , + 'ui-Widget 2': , + 'ui-Widget 3': , + 'ui-Widget 4': , +}; + +const classNameMap: Record< + | 'warehouseThroughput floating' + | 'fleetEfficiency floating' + | 'floating total-card', + JSX.Element +> = { + 'warehouseThroughput floating': , + 'fleetEfficiency floating': , + 'floating total-card': , +}; + const InputSelecterComponent = () => { - const { selectedChartId } = useWidgetStore(); + const { selectedChartId } = useWidgetStore(); - if (selectedChartId && selectedChartId.type && selectedChartId.type === 'bar' ) { - return ( + if (selectedChartId) { + const { type, className } = selectedChartId; + + if (type && chartTypeMap[type as keyof typeof chartTypeMap]) { + const label = ['ui-Widget 1', 'ui-Widget 2', 'ui-Widget 3', 'ui-Widget 4'].includes(type) + ? '3D Widget Input' + : '2D Widget Input'; + + return ( <> -
2D Widget Input
- +
{label}
+ {chartTypeMap[type as keyof typeof chartTypeMap]} - ) - } + ); + } - else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'line' ) { - return ( + if (className && classNameMap[className as keyof typeof classNameMap]) { + return ( <> -
2D Widget Input
- +
Floting Widget Input
+ {classNameMap[className as keyof typeof classNameMap]} - ) + ); + } } - else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'pie' ) { - return ( - <> -
2D Widget Input
- - - ) - } + return
No chart selected
; +}; - else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'doughnut' ) { - return ( - <> -
2D Widget Input
- - - ) - } - - else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'polarArea' ) { - return ( - <> -
2D Widget Input
- - - ) - } - - else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'progress 1' ) { - return ( - <> -
2D Widget Input
- - - ) - } - - else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'progress 2' ) { - return ( - <> -
2D Widget Input
- - - ) - } - - else if (selectedChartId && selectedChartId.className && selectedChartId.className === 'warehouseThroughput floating' ) { - return ( - <> -
Floting Widget Input
- - - ) - } - - else if (selectedChartId && selectedChartId.className && selectedChartId.className === 'fleetEfficiency floating' ) { - return ( - <> -
Floting Widget Input
- - - ) - } - - else if (selectedChartId && selectedChartId.className && selectedChartId.className === 'floating total-card' ) { - return ( - <> -
Floting Widget Input
- - - ) - } - - else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'ui-Widget 1' ) { - return ( - <> -
3D Widget Input
- - - ) - } - - else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'ui-Widget 2' ) { - return ( - <> -
3D Widget Input
- - - ) - } - - else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'ui-Widget 3' ) { - return ( - <> -
3D Widget Input
- - - ) - } - - else if (selectedChartId && selectedChartId.type && selectedChartId.type === 'ui-Widget 4' ) { - return ( - <> -
3D Widget Input
- - - ) - } - - else { - return ( -
No chart selected
- ) - } -} - -export default InputSelecterComponent \ No newline at end of file +export default InputSelecterComponent; \ No newline at end of file diff --git a/app/src/modules/visualization/widgets/floating/cards/TotalCardComponent.tsx b/app/src/modules/visualization/widgets/floating/cards/TotalCardComponent.tsx index edc19e6..2e6886c 100644 --- a/app/src/modules/visualization/widgets/floating/cards/TotalCardComponent.tsx +++ b/app/src/modules/visualization/widgets/floating/cards/TotalCardComponent.tsx @@ -12,7 +12,7 @@ import { } from "../../../../../components/icons/3dChartIcons"; const TotalCardComponent = ({ object }: any) => { - console.log('object: ', object); + const [progress, setProgress] = useState(0); const [measurements, setmeasurements] = useState({}); const [duration, setDuration] = useState("1h"); From 3ad1cb3c58616e4dfb28ed4c737f0008a878ec4f Mon Sep 17 00:00:00 2001 From: Vishnu Date: Fri, 23 May 2025 12:07:58 +0530 Subject: [PATCH 2/7] feat: enhance Messages and ThreadChat components with improved textarea handling and styling --- .../components/ui/collaboration/Messages.tsx | 55 ++++++++- .../ui/collaboration/ThreadChat.tsx | 44 ++++++-- .../function/textAreaHeightAdjust.ts | 17 +++ app/src/modules/scene/setup/setup.tsx | 3 +- app/src/pages/Project.tsx | 2 +- app/src/styles/components/input.scss | 3 +- app/src/styles/scene/comments.scss | 105 ++++++++++++++++-- 7 files changed, 201 insertions(+), 28 deletions(-) create mode 100644 app/src/components/ui/collaboration/function/textAreaHeightAdjust.ts diff --git a/app/src/components/ui/collaboration/Messages.tsx b/app/src/components/ui/collaboration/Messages.tsx index 3440204..3fffb4b 100644 --- a/app/src/components/ui/collaboration/Messages.tsx +++ b/app/src/components/ui/collaboration/Messages.tsx @@ -1,30 +1,71 @@ -import React, { useState } from "react"; +import React, { useEffect, useRef, useState } from "react"; import { getAvatarColor } from "../../../modules/collaboration/functions/getAvatarColor"; import { KebabIcon } from "../../icons/ExportCommonIcons"; +import { adjustHeight } from "./function/textAreaHeightAdjust"; interface MessageProps { - val: Reply; + val: Reply | CommentSchema; i: number; } const Messages: React.FC = ({ val, i }) => { const [isEditing, setIsEditing] = useState(false); const [openOptions, setOpenOptions] = useState(false); + + // input + const [value, setValue] = useState( + "reply" in val ? val.reply : val.comment + ); + const textareaRef = useRef(null); const currentUser = "1"; const UserName = "username"; + useEffect(() => { + if (textareaRef.current) adjustHeight(textareaRef.current); + }, [value]); + + function handleCancelAction() { + setIsEditing(false); + } + + function handleSaveAction() { + setIsEditing(false); + } + return ( <> {isEditing ? (
-