Skip to content

Commit

Permalink
Fix geosolutions-it#1115. Display upload error
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz committed Oct 10, 2016
1 parent 436b19e commit 67d0ed6
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
15 changes: 11 additions & 4 deletions web/client/components/file/FileUploader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const React = require('react');

const {Message, DateFormat} = require('../I18N/I18N');
const Spinner = require('react-spinkit');
const {Glyphicon, ProgressBar, Table} = require('react-bootstrap');
const {Glyphicon, ProgressBar, Table, Alert} = require('react-bootstrap');

const Dropzone = require('react-dropzone');

Expand All @@ -25,7 +25,8 @@ const FileUploader = React.createClass({
onUpload: React.PropTypes.func,
uploadAdditionalParams: React.PropTypes.oneOfType([React.PropTypes.array, React.PropTypes.object]),
// if exists do not run before upload and start directly the upload after drag
allowUpload: React.PropTypes.object
allowUpload: React.PropTypes.object,
error: React.PropTypes.object
},
getDefaultProps() {
return {
Expand Down Expand Up @@ -82,6 +83,11 @@ const FileUploader = React.createClass({
</tr>) )
}</tbody></Table>);
},
renderError() {
if (this.props.error) {
return (<Alert bsStyle="danger">There was an error during the upload: {this.props.error.statusText}<div>{this.props.error.data}</div></Alert>);
}
},
render() {
if (this.state && this.state.files) {
return (<div> <Spinner spinnerName="circle" />{this.props.beforeUploadMessage}{this.renderPreview()}</div>);
Expand All @@ -93,7 +99,8 @@ const FileUploader = React.createClass({
</div>);
}

return (<Dropzone
return (<div><Dropzone
key="dropzone"
rejectClassName="alert-danger"
className="alert alert-info"
onDrop={this.uploadFiles}
Expand All @@ -115,7 +122,7 @@ const FileUploader = React.createClass({
{this.props.dropMessage}
</span>
</div>
</Dropzone>);
</Dropzone>{this.renderError()}</div>);

},
humanFileSize(size) {
Expand Down
4 changes: 1 addition & 3 deletions web/client/components/manager/importer/Import.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ const Task = React.createClass({
componentDidMount() {
if (this.props.import.state === "RUNNING") {
// Check if some task is running the update is not needed
if ( this.props.import.tasks && !(this.props.import.tasks.findIndex((task) => task.state === "RUNNING") >= 0)) {
this.interval = setInterval(this.props.loadImport.bind(null, this.props.import.id), this.props.timeout);
}
this.interval = setInterval(this.props.loadImport.bind(null, this.props.import.id), this.props.timeout);

}
},
Expand Down
3 changes: 3 additions & 0 deletions web/client/components/manager/importer/Importer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const BreadCrumb = require('./BreadCrumb');
const Importer = React.createClass({
propTypes: {
loading: React.PropTypes.bool,
taskCreationError: React.PropTypes.object,
error: React.PropTypes.object,
defaultPresets: React.PropTypes.string,
/**
Expand Down Expand Up @@ -179,6 +180,7 @@ const Importer = React.createClass({
return (<div>
{breadcrumb}
<ImportsGrid
loadImports={this.props.loadImports}
deleteImport={this.props.deleteImport}
loadImport={this.props.loadImport}
imports={this.props.imports} />
Expand All @@ -204,6 +206,7 @@ const Importer = React.createClass({
boxShadow: "0px 0px 25px 14px #d9edf7"

}}
error={this.props.taskCreationError}
beforeUploadMessage={<Message msgId="importer.creatingImportProcess" />}
dropMessage={<Message msgId={message} />}
uploading={this.props.uploading}
Expand Down
4 changes: 4 additions & 0 deletions web/client/components/manager/importer/ImportsGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const {Table, Glyphicon, Button, Label, OverlayTrigger, Tooltip} = require('reac
const ImportsGrid = React.createClass({
propTypes: {
loading: React.PropTypes.bool,
timeout: React.PropTypes.number,
loadImports: React.PropTypes.func,
loadImport: React.PropTypes.func,
deleteImport: React.PropTypes.func,
imports: React.PropTypes.array,
Expand All @@ -25,6 +27,8 @@ const ImportsGrid = React.createClass({
},
getDefaultProps() {
return {
timeout: 5000,
loadImports: () => {},
placement: "bottom",
deleteAction: <Message msgId="importer.import.deleteImport" />,
loadImport: () => {},
Expand Down
3 changes: 0 additions & 3 deletions web/client/components/manager/importer/Task.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ const Task = React.createClass({

};
},
componentDidMount() {
// setTimeout(() => {this.props.loadLayer(); }, 500);
},
getbsStyleForState(state) {
return ImporterUtils.getbsStyleForState(state);
},
Expand Down
1 change: 1 addition & 0 deletions web/client/plugins/manager/Importer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const ImporterPlugin = connect(
selectedTask: state.importer && state.importer.selectedTask,
selectedTransform: state.importer && state.importer.selectedTransform,
error: state.importer && state.importer.loadingError,
taskCreationError: state.importer && state.importer.taskCreationError,
workspaces: state.importer && state.importer.workspaces,
selectedWorkSpace: state.importer && state.importer.selectedWorkSpace,
workspaceCreationStatus: state.importer && state.importer.workspaceCreationStatus
Expand Down
4 changes: 2 additions & 2 deletions web/client/reducers/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function importer(state = {}, action) {
let selectedImport = assign({}, state.selectedImport, {
tasks: [...(state.selectedImport.tasks || []), ...action.tasks]
});
return assign({}, state, {selectedImport});
return assign({}, state, {taskCreationError: null, selectedImport});
}
return state;
case IMPORTS_TASK_UPDATED: {
Expand All @@ -187,7 +187,7 @@ function importer(state = {}, action) {
case IMPORTS_TASK_CREATION_ERROR: {
return assign({}, state, {
uploading: false,
error: action.error
taskCreationError: action.error
});
}
case TASK_PROGRESS_UPDATED: {
Expand Down

0 comments on commit 67d0ed6

Please sign in to comment.