Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return 201 when upload finish (and not before) and 500 if upload fail #844

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36,128 changes: 17,440 additions & 18,688 deletions src/frontend/boilerplates/archipelago/package-lock.json

Large diffs are not rendered by default.

220 changes: 95 additions & 125 deletions src/frontend/boilerplates/dms/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const AvatarField = ({ record, label, defaultLabel, image, fallback, variant, la
classes = useStyles(classes);
if (!record) return null;

const computedLabel = ( typeof label === 'function' ? label(record) : record[label] ) || defaultLabel;
const computedLabel = (typeof label === 'function' ? label(record) : record[label]) || defaultLabel;
const computedImage = typeof image === 'function' ? image(record) : record[image];
const computedFallback = typeof fallback === 'function' ? fallback(record) : fallback;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ const SeparatedListField = props => {
const { ids, data, loaded, resource, basePath } = useListContext(props);

if (linkType !== undefined) {
console.warn(
"The 'linkType' prop is deprecated and should be named to 'link' in <SeparatedListField />"
);
console.warn("The 'linkType' prop is deprecated and should be named to 'link' in <SeparatedListField />");
link = linkType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ const LocalLoginPage = props => {
const redirectTo = searchParams.get('redirect');
const { identity } = useGetIdentity();

if( identity?.id ) {
if (identity?.id) {
// Do not show login page if user is already connected
return( <Redirect to={redirectTo || '/'} /> );
return <Redirect to={redirectTo || '/'} />;
} else {
return (
<ThemeProvider theme={muiTheme}>
Expand All @@ -61,7 +61,11 @@ const LocalLoginPage = props => {
<LockIcon />
</Avatar>
</div>
{isSignup ? <SignupForm redirectTo={redirectTo} delayBeforeRedirect={3000} /> : <LoginForm redirectTo={redirectTo} />}
{isSignup ? (
<SignupForm redirectTo={redirectTo} delayBeforeRedirect={3000} />
) : (
<LoginForm redirectTo={redirectTo} />
)}
<div className={classes.switch}>
{isSignup ? (
<Link to="/login">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const SignupForm = ({ redirectTo, delayBeforeRedirect }) => {
setLoading(true);
signup(values)
.then(webId => {
if(delayBeforeRedirect) {
if (delayBeforeRedirect) {
setTimeout(() => {
history.push(redirectTo || '/Person/' + encodeURIComponent(webId) + '/edit');
setLoading(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const useStyles = makeStyles(theme => ({
text: {
maxWidth: 300,
textAlign: 'center',
padding: '4px 8px 8px',
padding: '4px 8px 8px'
},
card: {
minWidth: 300,
Expand Down Expand Up @@ -90,7 +90,11 @@ const SsoLoginPage = ({ theme, history, location, buttons, userResource, text })
<LockIcon />
</Avatar>
</div>
{text && <Typography variant="body2" className={classes.text}>{text}</Typography>}
{text && (
<Typography variant="body2" className={classes.text}>
{text}
</Typography>
)}
{buttons &&
buttons.map((button, i) => (
<CardActions key={i}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import { usePermissionsOptimized, useRedirect, useNotify, useGetIdentity } from 'react-admin';
import { rights, forbiddenErrors } from '../constants';
import useCheckAuthenticated from "./useCheckAuthenticated";
import useCheckAuthenticated from './useCheckAuthenticated';

const useCheckPermissions = (resourceId, mode, redirectUrl = '/') => {
const { identity } = useCheckAuthenticated();
Expand Down
8 changes: 2 additions & 6 deletions src/frontend/packages/auth-provider/src/hooks/useSignup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { useAuthProvider } from 'react-admin';
const useSignup = () => {
const authProvider = useAuthProvider();

return useCallback(
(params = {}) =>
authProvider.signup(params),
[authProvider]
);
return useCallback((params = {}) => authProvider.signup(params), [authProvider]);
};

export default useSignup;
export default useSignup;
12 changes: 10 additions & 2 deletions src/frontend/packages/semantic-data-provider/src/dataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ const isType = (type, resource) => {
return Array.isArray(resourceType) ? resourceType.includes(type) : resourceType === type;
};

const dataProvider = ({ sparqlEndpoint, httpClient, resources, ontologies, jsonContext, uploadsContainerUri, returnFailedResources = false }) => {
const dataProvider = ({
sparqlEndpoint,
httpClient,
resources,
ontologies,
jsonContext,
uploadsContainerUri,
returnFailedResources = false
}) => {
const uploadFile = async rawFile => {
if (!uploadsContainerUri) throw new Error('No uploadsContainerUri defined for the data provider');

Expand Down Expand Up @@ -258,7 +266,7 @@ const dataProvider = ({ sparqlEndpoint, httpClient, resources, ontologies, jsonC
// Catch if one resource fails to load
// Otherwise no references will be show if only one is missing
// See https://github.com/marmelab/react-admin/issues/5190
if( returnFailedResources ) {
if (returnFailedResources) {
// Return only the ID of the resource
returnData.push({ id });
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/packages/auth/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module.exports = {
resource['semapps:fileName'] = filename;

try {
fileStream.pipe(fs.createWriteStream(resource['semapps:localPath']));
await this.streamToFile(fileStream, resource['semapps:localPath']);
} catch (e) {
throw new MoleculerError(e, 500, 'Server Error');
}
Expand Down
12 changes: 12 additions & 0 deletions src/middleware/packages/ldp/services/resource/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ const rdfParser = require('rdf-parse').default;
const streamifyString = require('streamify-string');
const { variable } = require('rdf-data-model');
const { MIME_TYPES } = require('@semapps/mime-types');
const fs = require('fs');

const { defaultToArray } = require('../../utils');

// TODO put each method in a different file (problems with "this" not working)
module.exports = {
async streamToFile(inputStream, filePath) {
return new Promise((resolve, reject) => {
const fileWriteStream = fs.createWriteStream(filePath);
inputStream
.pipe(fileWriteStream)
.on('finish', resolve)
.on('error', reject);
});
},

async bodyToTriples(body, contentType) {
return new Promise((resolve, reject) => {
if (contentType === 'application/ld+json' && typeof body === 'object') body = JSON.stringify(body);
Expand Down
4 changes: 3 additions & 1 deletion src/middleware/packages/ldp/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ const buildFiltersQuery = filters => {
Object.keys(filters).forEach((predicate, i) => {
if (filters[predicate]) {
where += `
FILTER EXISTS { ?s1 ${predicate.startsWith('http') ? `<${predicate}>` : predicate} ${filters[predicate].startsWith('http') ? `<${filters[predicate]}>` : `"${filters[predicate]}"`} } .
FILTER EXISTS { ?s1 ${predicate.startsWith('http') ? `<${predicate}>` : predicate} ${
filters[predicate].startsWith('http') ? `<${filters[predicate]}>` : `"${filters[predicate]}"`
} } .
`;
} else {
where += `
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/packages/middlewares/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const parseJson = async (req, res, next) => {
};

const parseFile = (req, res, next) => {
if (!req.$ctx.meta.parser) {
if (!req.$ctx.meta.parser && (req.method == 'POST' || req.method == 'PUT')) {
if (req.headers['content-type'] && req.headers['content-type'].includes('multipart/form-data')) {
const busboy = new Busboy({ headers: req.headers });
let files = [];
Expand Down