mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
notify if no topology model has been selected.
This commit is contained in:
parent
2b0d69f03a
commit
bf1f4513fd
1 changed files with 22 additions and 5 deletions
|
@ -49,7 +49,7 @@ const msgContainerStyle = Object.assign({
|
|||
backgroundColor: '#ececec'
|
||||
},spinnerContainerStyle)
|
||||
|
||||
const failedMsgStyle = {
|
||||
const msgStyle = {
|
||||
fontWeight: 'bold'
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,11 @@ class WidgetTopology extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
attachComponentEvents() {
|
||||
window.onMouseOver = (e) => console.log(e);
|
||||
window.onMouseLeave = (e) => console.log(e);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const file = nextProps.files.find(file => file._id === nextProps.widget.file);
|
||||
// Ensure model is requested only once or a different was selected
|
||||
|
@ -90,15 +95,27 @@ class WidgetTopology extends React.Component {
|
|||
this.setState({'visualizationState': 'ready' });
|
||||
window.cimxml.clearXmlData()
|
||||
window.cimsvg.setFileCount(1);
|
||||
response.text().then( contents => window.cimsvg.loadFile(contents));
|
||||
response.text().then( contents => {
|
||||
window.cimsvg.loadFile(contents);
|
||||
this.attachComponentEvents();
|
||||
});
|
||||
} else {
|
||||
throw new Error('Request failed');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.setState({'visualizationState': 'failed' });
|
||||
this.setState({
|
||||
'visualizationState': 'show_message',
|
||||
'message': 'Topology could not be loaded.'});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// No file has been selected
|
||||
if (!nextProps.widget.file) {
|
||||
this.setState({
|
||||
'visualizationState': 'show_message',
|
||||
'message': 'Select a topology model first.'});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,8 +125,8 @@ class WidgetTopology extends React.Component {
|
|||
switch(this.state.visualizationState) {
|
||||
case 'loading':
|
||||
markup = <div style={spinnerContainerStyle}><div className="loader" /></div>; break;
|
||||
case 'failed':
|
||||
markup = <div style={msgContainerStyle}><div style={failedMsgStyle}>Topology could not be loaded</div></div>; break;
|
||||
case 'show_message':
|
||||
markup = <div style={msgContainerStyle}><div style={msgStyle}>{ this.state.message }</div></div>; break;
|
||||
default:
|
||||
markup = (<div>
|
||||
<ReactSVGPanZoom
|
||||
|
|
Loading…
Add table
Reference in a new issue