1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

fixing issue with dashboard state and svgElem reference; fixing issue with data blob parsing #217

This commit is contained in:
Sonja Happ 2020-05-14 16:47:11 +02:00
parent afb8d1add8
commit 12b1df8e9e

View file

@ -114,7 +114,6 @@ class WidgetTopology extends React.Component {
// Query the file referenced by the widget
let widgetFile = parseInt(this.props.widget.customProperties.file, 10);
console.log("Topology, componenDidMount, file:", widgetFile)
if (widgetFile !== -1 && this.state.file === undefined) {
this.dashboardState = 'loading';
AppDispatcher.dispatch({
@ -131,8 +130,6 @@ class WidgetTopology extends React.Component {
componentDidUpdate(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot: SS): void {
console.log("Topology, componendDidUpdate, prevState:", prevState, "State", this.state)
if(this.state.file === undefined) {
// No file has been selected
this.dashboardState = 'show_message';
@ -152,19 +149,22 @@ class WidgetTopology extends React.Component {
} else if (this.state.file.hasOwnProperty("data") && this.dashboardState === 'loading') {
// data of file has been newly downloaded (did not exist in previous state)
this.dashboardState = 'ready';
console.log("Topology file data: ", this.state.file.data.text());
} else if(this.state.file.hasOwnProperty("data") && this.dashboardState === 'ready'){
if (this.svgElem) {
let cimsvgInstance = new cimsvg(this.svgElem.current);
cimsvg.setCimsvg(cimsvgInstance);
cimsvgInstance.setFileCount(1);
cimsvgInstance.loadFile(this.state.file.data.text());
//cimsvgInstance.fit();
attachComponentEvents();
// transform data blob into string format
this.state.file.data.text().then(function(content) {
cimsvgInstance.loadFile(content);
cimsvgInstance.fit();
attachComponentEvents();
});
}
else {
console.error("The svgElem variable is not initialized before the attempt to create the cimsvg instance.");
}
}
}