Skip to content

Commit

Permalink
Fix #1168. AutoRefresh and error handling imporved
Browse files Browse the repository at this point in the history
 - AutoRefresh of the main page when one process is running
 - Delete errors notified and explain how to fix them
  • Loading branch information
offtherailz committed Oct 18, 2016
1 parent 1ffcfb3 commit ce0137a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
8 changes: 5 additions & 3 deletions web/client/actions/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@ function importDeleted(id) {
};
}

function importDeleteError(e) {
function importDeleteError(id, e) {
return {
type: IMPORT_DELETE_ERROR,
"error": e
error: e,
id
};
}

Expand Down Expand Up @@ -395,7 +396,7 @@ function deleteImport(geoserverRestURL, importId) {
dispatch(importDeleted(importId));
dispatch(loading({importId: importId, message: "deleting"}, false));
}).catch((e) => {
dispatch(importDeleteError(e));
dispatch(importDeleteError(importId, e));
dispatch(loading({importId: importId, message: "deleting"}, false));
});
};
Expand Down Expand Up @@ -738,6 +739,7 @@ module.exports = {
IMPORT_RUN_SUCCESS,
IMPORT_RUN_ERROR,
IMPORT_DELETE,
IMPORT_DELETE_ERROR,
IMPORTS_TASK_CREATED,
IMPORTS_TASK_CREATION_ERROR,
IMPORTS_TASK_LOADED,
Expand Down
24 changes: 23 additions & 1 deletion web/client/components/manager/importer/ImportsGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const ImportsGrid = React.createClass({
imports: []
};
},
componentDidMount() {
this.interval = setInterval(() => {this.update(); }, this.props.timeout);
},
componentWillUnmount() {
clearInterval(this.interval);
},
getbsStyleForState(state) {
return ImporterUtils.getbsStyleForState(state);
},
Expand All @@ -53,11 +59,19 @@ const ImportsGrid = React.createClass({
}
return null;
},
renderImportErrorMessage(imp) {
if (imp && imp.error) {
return <Label bsStyle="danger">{"Could not delete import, please try to delete all its content first"}</Label>;
}
},
renderImport(importObj) {
let tooltip = <Tooltip id="import-delete-action">{this.props.deleteAction}</Tooltip>;
return (<tr key={importObj && importObj.id}>
<td key="id"><a onClick={(e) => {e.preventDefault(); this.props.loadImport(importObj.id); }} >{importObj.id}</a></td>
<td key="state"><Label bsStyle={this.getbsStyleForState(importObj.state)}>{importObj.state}</Label>{this.renderLoadingImport(importObj)}</td>
<td key="state"><Label bsStyle={this.getbsStyleForState(importObj.state)}>{importObj.state}</Label>
{this.renderLoadingImport(importObj)}
{this.renderImportErrorMessage(importObj)}
</td>
<td key="actions">
<OverlayTrigger overlay={tooltip} placement={this.props.placement}>
<Button bsSize="xsmall" onClick={(e) => {e.preventDefault(); this.props.deleteImport(importObj.id); }}><Glyphicon glyph="remove"/></Button>
Expand All @@ -83,6 +97,14 @@ const ImportsGrid = React.createClass({
</tbody>
</Table>
);
},
update() {
if (this.props.imports) {
let i = this.props.imports.findIndex((importObj) => importObj.state === "RUNNING");
if ( i >= 0 ) {
this.props.loadImports();
}
}
}
});
module.exports = ImportsGrid;
2 changes: 1 addition & 1 deletion web/client/components/manager/importer/TaskProgress.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const TaskProgress = React.createClass({
<ProgressBar bsStyle="warning" key="progressbar" striped now={percent} label={`${percent}%`}/>
);
}
return <Spinner noFadeIn />;
return <Spinner noFadeIn spinnerName="circle"/>;
},
update() {
if (this.props.state === "RUNNING") {
Expand Down
13 changes: 13 additions & 0 deletions web/client/reducers/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const {
IMPORT_RUN_SUCCESS,
IMPORT_RUN_ERROR,
IMPORT_DELETE,
IMPORT_DELETE_ERROR,
IMPORTS_TASK_CREATED,
IMPORTS_TASK_CREATION_ERROR,
IMPORTS_TASK_LOADED,
Expand Down Expand Up @@ -345,6 +346,18 @@ function importer(state = {}, action) {
imports
});
}
case IMPORT_DELETE_ERROR: {
let imports = state && state.imports;
imports = imports && imports.map((imp) => {
if (imp.id === action.id) {
return {...imp, error: action.error};
}
return imp;
});
return assign({}, state, {
imports
});
}
case IMPORTS_FILE_UPLOADED: {
return assign({}, state, {
uploading: false
Expand Down

0 comments on commit ce0137a

Please sign in to comment.