Skip to content
Snippets Groups Projects
Commit a11d6a86 authored by Anthony's avatar Anthony
Browse files

Add default value for toolstate and remove useless code

parent cd0ad56a
No related branches found
No related tags found
1 merge request!10Draft: MigratingAnnotationCreation to MUI5.
......@@ -14,6 +14,7 @@ import AnnotationDrawing from './annotationForm/AnnotationDrawing';
import AnnotationFormContent from './annotationForm/AnnotationFormContent';
import AnnotationFormTime from './annotationForm/AnnotationFormTime';
import {
defaultToolState,
geomFromAnnoTarget, timeFromAnnoTarget,
} from './AnnotationCreationUtils';
import AnnotationFormOverlay from './annotationForm/AnnotationFormOverlay/AnnotationFormOverlay';
......@@ -28,15 +29,7 @@ const MANIFEST_LINK_VIEW = 'link';
/** Component for creating annotations.
* Display in companion window when a manifest is open and an annoation created or edited */
function AnnotationCreation(props) {
const [toolState, setToolState] = useState({
activeTool: 'edit',
closedMode: 'closed',
fillColor: 'rgba(255, 0, 0, 0.5)',
image: { id: null },
imageEvent: null,
strokeColor: 'rgba(255, 0, 0, 0.5)',
strokeWidth: 20,
});
const [toolState, setToolState] = useState(defaultToolState);
const [drawingState, setDrawingState] = useState({
currentShape: null,
......
import axios from 'axios';
export const fileUploaderUrl = 'https://scene-uploads.tetras-libre.fr/upload';
export const fileReaderUrl = 'https://scene-uploads.tetras-libre.fr/static/';
/*const fileUploaderUrl = 'http://localhost:3000/upload';
const fileReaderUrl = 'http://localhost:3000/static/';*/
/** Extract time information from annotation target */
export function timeFromAnnoTarget(annotarget) {
console.info('TODO proper time extraction from: ', annotarget);
......@@ -74,34 +67,12 @@ export async function saveAnnotationInEachCanvas(canvases, config, receiveAnnota
});
}
const sendFile = async (fileContent) => {
const blob = new Blob([fileContent], { type: 'image/svg+xml'});
const formData = new FormData();
formData.append('file', blob);
try {
const response = await axios.post(fileUploaderUrl, formData, {
headers: {
'Access-Control-Allow-Origin': '*',
'Cache-Control': 'no-cache',
'Content-Type': 'multipart/form-data',
},
});
console.log('File Uploaded', response.data);
return response.data.file.filename;
} catch (error) {
return '';
console.error('Error uploading file:', error);
}
};
function dataURLtoBlob(dataurl) {
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
while(n--){
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], {type:mime});
export const defaultToolState = {
activeTool: OVERLAY_TOOL.EDIT,
closedMode: 'closed',
fillColor: 'rgba(83,162, 235, 50)',
image: { id: null },
imageEvent: null,
strokeColor: 'rgba(20,82,168,100)',
strokeWidth: 2,
}
......@@ -19,6 +19,7 @@ import AddPhotoAlternateIcon from '@mui/icons-material/AddPhotoAlternate';
import { v4 as uuidv4 } from 'uuid';
import ImageFormField from './ImageFormField';
import { isShapesTool, OVERLAY_TOOL } from '../../AnnotationCreationUtils';
import { defaultLineWeightChoices } from './KonvaDrawing/KonvaUtils';
const StyledDivider = styled(Divider)(({ theme }) => ({
margin: theme.spacing(1, 0.5),
......@@ -228,7 +229,7 @@ function AnnotationFormOverlayToolOptions({ updateToolState, toolState }) {
<Paper>
<ClickAwayListener onClickAway={handleCloseLineWeight}>
<MenuList autoFocus role="listbox">
{[5, 10, 20, 50].map((option, index) => (
{defaultLineWeightChoices.map((option, index) => (
<MenuItem
key={option}
onClick={handleLineWeightSelect}
......
......@@ -21,3 +21,5 @@ export async function getKonvaAsDataURL(windowId) {
console.log('dataURL:', dataURL);
return dataURL;
}
export const defaultLineWeightChoices = [0, 2, 5, 10, 20, 50];
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment