diff --git a/src/dashboard/dashboard.js b/src/dashboard/dashboard.js index f35eb67..a6b277f 100644 --- a/src/dashboard/dashboard.js +++ b/src/dashboard/dashboard.js @@ -57,14 +57,14 @@ class Dashboard extends Component { prevState = {}; } const sessionToken = LoginStore.getState().token; - + let maxHeight = null; let dashboard = Map(); let dashboards = DashboardStore.getState() let rawDashboard = dashboards[props.match.params.dashboard - 1]; - if (rawDashboard != null) { + if (rawDashboard) { dashboard = Map(rawDashboard); // convert widgets list to a dictionary to be able to reference widgets @@ -95,7 +95,7 @@ class Dashboard extends Component { - //ist das überhaupt nötiG?? + /* if (this.state.dashboard.has('id') === false) { AppDispatcher.dispatch({ type: 'dashboards/start-load', @@ -121,7 +121,7 @@ class Dashboard extends Component { token: this.state.sessionToken }); */ - } + let widgets = {}; @@ -129,13 +129,14 @@ class Dashboard extends Component { widgets[Dashboard.lastWidgetKey] = widget; Dashboard.lastWidgetKey++; } - let maxHeight = Object.keys(widgets).reduce( (maxHeightSoFar, widgetKey) => { + maxHeight = Object.keys(widgets).reduce( (maxHeightSoFar, widgetKey) => { let thisWidget = widgets[widgetKey]; let thisWidgetHeight = thisWidget.y + thisWidget.height; return thisWidgetHeight > maxHeightSoFar? thisWidgetHeight : maxHeightSoFar; }, 0); + } let simulationModels = []; //if (prevState.simulation != null) { @@ -162,8 +163,8 @@ class Dashboard extends Component { modalData: null, modalIndex: null, - maxWidgetHeight: maxHeight, - dropZoneHeight: maxHeight +80, + maxWidgetHeight: maxHeight || null, + dropZoneHeight: maxHeight +80 || null, }; } @@ -176,7 +177,7 @@ class Dashboard extends Component { } //!!!won't work anymore - componentWillMount() { + componentDidMount() { //document.addEventListener('keydown', this.handleKeydown.bind(this)); if (this.state.dashboard.has('id') === false) { AppDispatcher.dispatch({ @@ -355,7 +356,6 @@ class Dashboard extends Component { editWidget(widget, index){ - console.log("dashboard editWidget was called widget: " + widget +" index: " + index); this.setState({ editModal: true, modalData: widget, modalIndex: index }); }; @@ -442,7 +442,7 @@ class Dashboard extends Component { const widgets = this.state.dashboard.get('widgets'); const grid = this.state.dashboard.get('grid'); const boxClasses = classNames('section', 'box', { 'fullscreen-padding': this.props.isFullscreen }); - + let draggable = this.state.editing; return