Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
hh1966
chemotion_eln_server
Commits
c3e85d0c
Commit
c3e85d0c
authored
Mar 20, 2019
by
hh1966
Browse files
Add error handling to export/import front-end code
parent
0d21734f
Pipeline
#43998
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/api/chemotion/collection_api.rb
View file @
c3e85d0c
...
...
@@ -358,7 +358,6 @@ module Chemotion
format
=
params
[
:format
]
nested
=
params
[
:nested
]
==
true
# check if the user is allowed to export these collections
collection_ids
.
each
do
|
collection_id
|
begin
...
...
@@ -410,7 +409,7 @@ module Chemotion
namespace
:imports
do
desc
"Create
ex
port job"
desc
"Create
im
port job"
params
do
requires
:file
,
type:
File
end
...
...
app/assets/javascripts/components/fetchers/CollectionsFetcher.js
View file @
c3e85d0c
...
...
@@ -294,16 +294,28 @@ export default class CollectionsFetcher {
},
body
:
JSON
.
stringify
(
params
)
}).
then
((
response
)
=>
{
return
response
.
json
()
if
(
response
.
ok
)
{
return
response
.
json
();
}
else
{
throw
new
Error
(
response
.
status
);
}
}).
then
((
json
)
=>
{
// after a short delay, start polling
setTimeout
(()
=>
{
CollectionsFetcher
.
pollExportJob
(
json
.
export_id
)
},
1000
);
return
json
;
}).
catch
((
errorMessage
)
=>
{
console
.
log
(
errorMessage
);
// remove the export notification and add an error notififation
NotificationActions
.
removeByUid
(
'
export_collections
'
)
NotificationActions
.
add
({
title
:
"
Error
"
,
message
:
"
An error occured with your export, please contact the administrators of the site if the problem persists.
"
,
level
:
"
error
"
,
dismissible
:
true
,
uid
:
"
export_collections_error
"
,
position
:
"
bl
"
,
autoDismiss
:
null
});
});
return
promise
;
...
...
@@ -319,7 +331,11 @@ export default class CollectionsFetcher {
'
Content-Type
'
:
'
application/json
'
}
}).
then
((
response
)
=>
{
return
response
.
json
()
if
(
response
.
ok
)
{
return
response
.
json
();
}
else
{
throw
new
Error
(
response
.
status
);
}
}).
then
((
json
)
=>
{
if
(
json
.
status
==
'
EXECUTING
'
)
{
// continue polling
...
...
@@ -334,7 +350,17 @@ export default class CollectionsFetcher {
window
.
location
.
href
=
json
.
url
;
}
}).
catch
((
errorMessage
)
=>
{
console
.
log
(
errorMessage
);
// create an error notififation
NotificationActions
.
removeByUid
(
'
export_collections
'
)
NotificationActions
.
add
({
title
:
"
Error
"
,
message
:
"
An error occured with your export, please contact the administrators of the site if the problem persists.
"
,
level
:
"
error
"
,
dismissible
:
true
,
uid
:
"
export_collections_error
"
,
position
:
"
bl
"
,
autoDismiss
:
null
});
});
return
promise
;
...
...
@@ -350,7 +376,11 @@ export default class CollectionsFetcher {
method
:
'
POST
'
,
body
:
data
}).
then
((
response
)
=>
{
return
response
.
json
()
if
(
response
.
ok
)
{
return
response
.
json
();
}
else
{
throw
new
Error
(
response
.
status
);
}
}).
then
((
json
)
=>
{
// after a short delay, start polling
setTimeout
(()
=>
{
...
...
@@ -359,7 +389,17 @@ export default class CollectionsFetcher {
return
json
;
}).
catch
((
errorMessage
)
=>
{
console
.
log
(
errorMessage
);
// remove the export notification and add an error notififation
NotificationActions
.
removeByUid
(
'
import_collections
'
)
NotificationActions
.
add
({
title
:
"
Error
"
,
message
:
"
An error occured with your export, please contact the administrators of the site if the problem persists.
"
,
level
:
"
error
"
,
dismissible
:
true
,
uid
:
"
import_collections_error
"
,
position
:
"
bl
"
,
autoDismiss
:
null
});
});
return
promise
;
...
...
@@ -375,7 +415,11 @@ export default class CollectionsFetcher {
'
Content-Type
'
:
'
application/json
'
}
}).
then
((
response
)
=>
{
return
response
.
json
()
if
(
response
.
ok
)
{
return
response
.
json
();
}
else
{
throw
new
Error
(
response
.
status
);
}
}).
then
((
json
)
=>
{
if
(
json
.
status
==
'
EXECUTING
'
)
{
// continue polling
...
...
@@ -390,7 +434,17 @@ export default class CollectionsFetcher {
CollectionActions
.
fetchUnsharedCollectionRoots
()
}
}).
catch
((
errorMessage
)
=>
{
console
.
log
(
errorMessage
);
// remove the export notification and add an error notififation
NotificationActions
.
removeByUid
(
'
import_collections
'
)
NotificationActions
.
add
({
title
:
"
Error
"
,
message
:
"
An error occured with your export, please contact the administrators of the site if the problem persists.
"
,
level
:
"
error
"
,
dismissible
:
true
,
uid
:
"
import_collections_error
"
,
position
:
"
bl
"
,
autoDismiss
:
null
});
});
return
promise
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment