diff --git a/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js b/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js index 7a8e5d1f..038bc0c5 100644 --- a/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js +++ b/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js @@ -1040,6 +1040,7 @@ export function SelectLibrariesModal ({ open, close }) { const allLibraries = useSelector(state => state.schematicEditorReducer.allLibraries) const libraries = useSelector(state => state.schematicEditorReducer.libraries) const uploadSuccess = useSelector(state => state.schematicEditorReducer.uploadSuccess) + const uploadError = useSelector(state => state.schematicEditorReducer.uploadError) const auth = useSelector(state => state.authReducer) const dispatch = useDispatch() const classes = useStyles() @@ -1061,11 +1062,21 @@ export function SelectLibrariesModal ({ open, close }) { dispatch(fetchAllLibraries()) } if (uploadSuccess === false) { - setMessage('An Error Occured') + if (uploadError === 400) { + setMessage('Upload Failed: Invalid file format. Please upload valid .lib and .dcm files.') + } else if (uploadError === 401 || uploadError === 403) { + setMessage('Upload Failed: You are not authorized to upload libraries.') + } else if (uploadError === 413) { + setMessage('Upload Failed: File size too large.') + } else if (uploadError === 500) { + setMessage('Upload Failed: Server error. Please try again.') + } else { + setMessage('Upload Failed: An unexpected error occurred.') + } setsnacOpen(true) dispatch(resetUploadSuccess()) } - }, [dispatch, uploadSuccess]) + }, [dispatch, uploadSuccess, uploadError]) useEffect(() => { const updateActive = () => { diff --git a/eda-frontend/src/redux/reducers/schematicEditorReducer.js b/eda-frontend/src/redux/reducers/schematicEditorReducer.js index f4d17c47..f760070c 100644 --- a/eda-frontend/src/redux/reducers/schematicEditorReducer.js +++ b/eda-frontend/src/redux/reducers/schematicEditorReducer.js @@ -97,8 +97,8 @@ export default function (state = InitialState, action) { case actions.UPLOAD_LIBRARIES: { if (action.payload === 201) { - return { ...state, uploadSuccess: true } - } else { return { ...state, uploadSuccess: false } } + return { ...state, uploadSuccess: true, uploadError: null } + } else { return { ...state, uploadSuccess: false, uploadError: action.payload } } } case actions.RESET_UPLOAD_SUCCESS: { diff --git a/esim-cloud-backend/libAPI/lib_utils.py b/esim-cloud-backend/libAPI/lib_utils.py index e0808fec..d93b4d7a 100644 --- a/esim-cloud-backend/libAPI/lib_utils.py +++ b/esim-cloud-backend/libAPI/lib_utils.py @@ -63,9 +63,9 @@ def save_libs(files, path, out_path, library_set): # Get Component name component_svg = os.path.split(component_svg)[-1] - # Get Corresponding Details + if component_svg[:-4] not in component_details: + continue svg_desc = component_details[component_svg[:-4]] - # Seed DB component = LibraryComponent.objects.filter( name=svg_desc['name'],