From fdae12fc880a5a9c9be72977f6c0c64622ee060c Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 22 Aug 2023 00:12:26 +0000 Subject: [PATCH] equipment documentation --- public/locales/de/translation.json | 3 +- public/locales/en/translation.json | 3 +- src/Components/AppRoutes/index.js | 2 +- src/Components/MyModal/index.js | 26 ++ .../CreateEquipmentDocumentationModal.js | 343 ++++++++++++------ src/Pages/EquipmentDocumentation/index.js | 74 +++- src/utils.js | 41 ++- 7 files changed, 374 insertions(+), 118 deletions(-) diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index e3590dd..e11748d 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -11,7 +11,8 @@ "close": "Schließen", "save": "Speichern", "delete": "Löschen", - "confirm": "Bestätigen" + "confirm": "Bestätigen", + "create": "Erstellen" }, "contactAdmin": "Bitte kontaktieren Sie einen Administrator" }, diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index c839372..305803a 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -11,7 +11,8 @@ "close": "Close", "save": "Save", "delete": "Delete", - "confirm": "Confirm" + "confirm": "Confirm", + "create": "Create" }, "contactAdmin": "Please contact an administrator" }, diff --git a/src/Components/AppRoutes/index.js b/src/Components/AppRoutes/index.js index 8d5b924..f6bf0d0 100644 --- a/src/Components/AppRoutes/index.js +++ b/src/Components/AppRoutes/index.js @@ -54,7 +54,7 @@ export default function AppRoutes() { } /> diff --git a/src/Components/MyModal/index.js b/src/Components/MyModal/index.js index e24504f..9d80c1d 100644 --- a/src/Components/MyModal/index.js +++ b/src/Components/MyModal/index.js @@ -103,3 +103,29 @@ export function MyModalOnlyCloseButtonFooter({ onCancel }) { return ; } + +export function MyModalCloseSaveButtonFooter({ onCancel, onSave }) { + const { t } = useTranslation(); + + return ( + <> + + + + ); +} + +export function MyModalCloseCreateButtonFooter({ onCancel, onCreate }) { + const { t } = useTranslation(); + + return ( + <> + + + + ); +} diff --git a/src/Pages/EquipmentDocumentation/CreateEquipmentDocumentationModal.js b/src/Pages/EquipmentDocumentation/CreateEquipmentDocumentationModal.js index f994dce..8bf95a9 100644 --- a/src/Pages/EquipmentDocumentation/CreateEquipmentDocumentationModal.js +++ b/src/Pages/EquipmentDocumentation/CreateEquipmentDocumentationModal.js @@ -1,95 +1,241 @@ import { useNavigate, useParams } from "react-router-dom"; -import MyModal from "../../Components/MyModal"; -import { AppStyle, Constants } from "../../utils"; -import { - Button, - Card, - Col, - Divider, - Modal, - Row, - Typography, - Upload, - message, -} from "antd"; -import { useRef, useState } from "react"; +import MyModal, { + MyModalCloseCreateButtonFooter, + MyModalCloseSaveButtonFooter, +} from "../../Components/MyModal"; +import { AppStyle, Constants, myFetch, myFetchContentType } from "../../utils"; +import { Button, Card, Col, Row, Select, Typography } from "antd"; +import { createRef, useRef, useState } from "react"; import TextArea from "antd/es/input/TextArea"; import Webcam from "react-webcam"; -import { CameraOutlined, PlusOutlined } from "@ant-design/icons"; +import { + CameraOutlined, + DeleteOutlined, + FullscreenOutlined, + PlusOutlined, +} from "@ant-design/icons"; +import { DocumentationImage } from "."; -const CameraComponent = () => { - const [visible, setVisible] = useState(false); - const [imageData, setImageData] = useState(null); - const webcamRef = useRef(); +function UploadComponent({ index, setImagePreview }) { + const handleFileChange = (event) => { + const file = event.target.files[0]; + console.log("file", event.target.files); + if (file) { + const reader = new FileReader(); + reader.onload = () => { + //setImagePreview(URL.createObjectURL(file)); + setImagePreview(reader.result); - const handleCapture = () => { - const imageSrc = webcamRef.current.getScreenshot(); - setImageData(imageSrc); - }; - - const handleClear = () => { - setImageData(null); - }; - - const handleSave = () => { - // Hier könntest du die Logik zum Speichern des Bildes implementieren. - message.success("Bild gespeichert!"); - setVisible(false); + // base 64 string + // console.log(reader.result); + }; + reader.readAsDataURL(file); + } }; return (
- + + +
+ ); +} + +function CameraComponent({ setImagePreview }) { + const [modalVisible, setModalVisible] = useState(false); + const [cameraVisible, setCameraVisible] = useState(false); + const webcamRef = useRef(null); + + const handleCapture = () => { + const imageSrc = webcamRef.current.getScreenshot(); + setImagePreview(imageSrc); + + handleCancel(); + }; + + const handleCancel = () => { + setCameraVisible(false); + // this is needed to close the camera correctly + setTimeout(() => setModalVisible(false), 100); + }; + + return ( + <> +
{ + setModalVisible(true); + setCameraVisible(true); + }} + > + +
+ setVisible(false)} + isOpen={modalVisible} + onCancel={handleCancel} footer={[ - , - , - , ]} > - - {imageData && ( -
- Vorschau -
+ {cameraVisible && ( + )}
- + ); -}; +} + +export function NoteComponent({ + viewMode, + index, + image, + onImageChange, + description, + onDescriptionChange, + onDeleteImage, +}) { + return ( + + + ] + : [ + , + , + , + , + ] + } + > + + + + + + {viewMode ? ( + {description} + ) : ( +