Commit 9d46d5f3 authored by hh1966's avatar hh1966
Browse files

Add front-end notification for export

parent 508f3c29
......@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
import UIStore from './../stores/UIStore';
import UserStore from './../stores/UserStore';
import NotificationActions from '../actions/NotificationActions';
export default class ModalCollectionExport extends React.Component {
constructor(props) {
super(props);
......@@ -40,6 +42,18 @@ export default class ModalCollectionExport extends React.Component {
action(params);
onHide();
let notification = {
title: "Exporting",
message: "The export file is created on the server. This might take a while. The download will start automatically. Please don't close the window.",
level: "warning",
dismissible: false,
uid: "export_collections",
position: "bl",
autoDismiss: null
}
NotificationActions.add(notification);
}
render() {
......
import 'whatwg-fetch';
import NotificationActions from '../actions/NotificationActions';
export default class ExportCollectionsFetcher {
......@@ -15,11 +16,12 @@ export default class ExportCollectionsFetcher {
}).then((response) => {
return response.json()
}).then((json) => {
console.log(json.export_id);
// after a short delay, start polling
setTimeout(() => {
ExportCollectionsFetcher.pollJob(json.export_id)
}, 1000);
return json;
}).catch((errorMessage) => {
console.log(errorMessage);
});
......@@ -45,6 +47,9 @@ export default class ExportCollectionsFetcher {
ExportCollectionsFetcher.pollJob(exportId);
}, 4000);
} else if (json.status == 'COMPLETED') {
// remove the notification
NotificationActions.removeByUid('export_collections')
// download the file, headers will prevent the browser from reloading the page
window.location.href = json.url;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment