From 912e1b96bfa7d6c022d854fa744f719b49ca98d0 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 21 Jul 2020 15:33:37 +0200 Subject: Add first plotting attempts for portfolios --- frontend/src/components/app/map/LoadingScreen.js | 2 +- frontend/src/components/app/map/MapConstants.js | 3 +- .../src/components/app/map/MapStageComponent.js | 36 +++------- .../app/map/controls/ExportCanvasComponent.js | 2 +- .../app/map/controls/ScaleIndicatorComponent.js | 5 +- .../app/map/controls/ToolPanelComponent.js | 4 +- .../app/map/controls/ZoomControlComponent.js | 30 ++++---- .../src/components/app/map/elements/Backdrop.js | 10 +-- .../src/components/app/map/elements/RackFillBar.js | 35 ++------- .../components/app/map/elements/TilePlusIcon.js | 8 +-- .../src/components/app/map/elements/WallSegment.js | 9 +-- .../src/components/app/map/groups/GridGroup.js | 8 +-- .../src/components/app/map/groups/RackGroup.js | 18 +---- .../src/components/app/map/groups/RoomGroup.js | 30 +++----- .../src/components/app/map/groups/TileGroup.js | 4 +- .../src/components/app/map/groups/TopologyGroup.js | 20 +++--- .../src/components/app/map/groups/WallGroup.js | 2 +- .../app/map/layers/HoverLayerComponent.js | 34 ++++----- .../components/app/map/layers/MapLayerComponent.js | 13 ++-- .../app/map/layers/ObjectHoverLayerComponent.js | 2 +- .../app/map/layers/RoomHoverLayerComponent.js | 2 +- .../components/app/results/MetricChartComponent.js | 67 +++++++++++++++++ .../app/results/PortfolioResultsComponent.js | 78 ++++++++++++++++++++ frontend/src/components/app/sidebars/Sidebar.js | 17 ++--- frontend/src/components/app/sidebars/Sidebar.sass | 2 +- .../app/sidebars/elements/LoadChartComponent.js | 84 ---------------------- .../app/sidebars/project/PortfolioListComponent.js | 15 ++-- .../sidebars/project/ProjectSidebarComponent.js | 12 ++-- .../app/sidebars/project/ScenarioListComponent.js | 16 +++-- .../app/sidebars/project/TopologyListComponent.js | 11 ++- .../app/sidebars/topology/NameComponent.js | 2 +- .../sidebars/topology/TopologySidebarComponent.js | 8 +-- .../topology/building/BuildingSidebarComponent.js | 5 +- .../building/NewRoomConstructionComponent.js | 13 ++-- .../topology/machine/BackToRackComponent.js | 2 +- .../topology/machine/DeleteMachineComponent.js | 2 +- .../topology/machine/MachineNameComponent.js | 4 +- .../topology/machine/MachineSidebarComponent.js | 8 +-- .../sidebars/topology/machine/UnitAddComponent.js | 13 ++-- .../app/sidebars/topology/machine/UnitComponent.js | 14 +--- .../sidebars/topology/machine/UnitListComponent.js | 7 +- .../sidebars/topology/machine/UnitTabsComponent.js | 37 +++------- .../sidebars/topology/rack/BackToRoomComponent.js | 2 +- .../sidebars/topology/rack/DeleteRackComponent.js | 2 +- .../sidebars/topology/rack/EmptySlotComponent.js | 6 +- .../app/sidebars/topology/rack/MachineComponent.js | 44 +++--------- .../sidebars/topology/rack/MachineListComponent.js | 10 +-- .../sidebars/topology/rack/RackNameComponent.js | 4 +- .../sidebars/topology/rack/RackSidebarComponent.js | 8 +-- .../topology/room/BackToBuildingComponent.js | 2 +- .../sidebars/topology/room/DeleteRoomComponent.js | 2 +- .../sidebars/topology/room/EditRoomComponent.js | 11 +-- .../topology/room/RackConstructionComponent.js | 11 +-- .../sidebars/topology/room/RoomNameComponent.js | 4 +- .../sidebars/topology/room/RoomSidebarComponent.js | 10 +-- 55 files changed, 348 insertions(+), 462 deletions(-) create mode 100644 frontend/src/components/app/results/MetricChartComponent.js create mode 100644 frontend/src/components/app/results/PortfolioResultsComponent.js delete mode 100644 frontend/src/components/app/sidebars/elements/LoadChartComponent.js (limited to 'frontend/src/components/app') diff --git a/frontend/src/components/app/map/LoadingScreen.js b/frontend/src/components/app/map/LoadingScreen.js index 03daa692..7efea9b0 100644 --- a/frontend/src/components/app/map/LoadingScreen.js +++ b/frontend/src/components/app/map/LoadingScreen.js @@ -3,7 +3,7 @@ import FontAwesome from 'react-fontawesome' const LoadingScreen = () => (
- + Loading your project...
) diff --git a/frontend/src/components/app/map/MapConstants.js b/frontend/src/components/app/map/MapConstants.js index 286920e2..0a970701 100644 --- a/frontend/src/components/app/map/MapConstants.js +++ b/frontend/src/components/app/map/MapConstants.js @@ -5,8 +5,7 @@ export const MAP_SIZE_IN_PIXELS = MAP_SIZE * TILE_SIZE_IN_PIXELS export const OBJECT_MARGIN_IN_PIXELS = TILE_SIZE_IN_PIXELS / 5 export const TILE_PLUS_MARGIN_IN_PIXELS = TILE_SIZE_IN_PIXELS / 3 -export const OBJECT_SIZE_IN_PIXELS = - TILE_SIZE_IN_PIXELS - OBJECT_MARGIN_IN_PIXELS * 2 +export const OBJECT_SIZE_IN_PIXELS = TILE_SIZE_IN_PIXELS - OBJECT_MARGIN_IN_PIXELS * 2 export const GRID_LINE_WIDTH_IN_PIXELS = 2 export const WALL_WIDTH_IN_PIXELS = TILE_SIZE_IN_PIXELS / 8 diff --git a/frontend/src/components/app/map/MapStageComponent.js b/frontend/src/components/app/map/MapStageComponent.js index f1c2b211..cecb34de 100644 --- a/frontend/src/components/app/map/MapStageComponent.js +++ b/frontend/src/components/app/map/MapStageComponent.js @@ -43,19 +43,12 @@ class MapStageComponent extends React.Component { } updateDimensions() { - this.props.setMapDimensions( - jQuery(window).width(), - jQuery(window).height() - NAVBAR_HEIGHT, - ) + this.props.setMapDimensions(jQuery(window).width(), jQuery(window).height() - NAVBAR_HEIGHT) } updateScale(e) { e.preventDefault() - this.props.zoomInOnPosition( - e.deltaY < 0, - this.state.mouseX, - this.state.mouseY, - ) + this.props.zoomInOnPosition(e.deltaY < 0, this.state.mouseX, this.state.mouseY) } updateMousePosition() { @@ -83,21 +76,14 @@ class MapStageComponent extends React.Component { } moveWithDelta(deltaX, deltaY) { - this.props.setMapPositionWithBoundsCheck( - this.props.mapPosition.x + deltaX, - this.props.mapPosition.y + deltaY, - ) + this.props.setMapPositionWithBoundsCheck(this.props.mapPosition.x + deltaX, this.props.mapPosition.y + deltaY) } render() { return ( - + { + ref={(stage) => { this.stage = stage }} width={this.props.mapDimensions.width} @@ -105,15 +91,9 @@ class MapStageComponent extends React.Component { onMouseMove={this.updateMousePosition.bind(this)} > - - - + + + diff --git a/frontend/src/components/app/map/controls/ExportCanvasComponent.js b/frontend/src/components/app/map/controls/ExportCanvasComponent.js index d166bcc8..8487f47b 100644 --- a/frontend/src/components/app/map/controls/ExportCanvasComponent.js +++ b/frontend/src/components/app/map/controls/ExportCanvasComponent.js @@ -6,7 +6,7 @@ const ExportCanvasComponent = () => ( title="Export Canvas to PNG Image" onClick={() => window['exportCanvasToImage']()} > - + ) diff --git a/frontend/src/components/app/map/controls/ScaleIndicatorComponent.js b/frontend/src/components/app/map/controls/ScaleIndicatorComponent.js index daaf8ec6..54709482 100644 --- a/frontend/src/components/app/map/controls/ScaleIndicatorComponent.js +++ b/frontend/src/components/app/map/controls/ScaleIndicatorComponent.js @@ -3,10 +3,7 @@ import { TILE_SIZE_IN_METERS, TILE_SIZE_IN_PIXELS } from '../MapConstants' import './ScaleIndicatorComponent.css' const ScaleIndicatorComponent = ({ scale }) => ( -
+
{TILE_SIZE_IN_METERS}m
) diff --git a/frontend/src/components/app/map/controls/ToolPanelComponent.js b/frontend/src/components/app/map/controls/ToolPanelComponent.js index e3bb1dbb..e0e4d554 100644 --- a/frontend/src/components/app/map/controls/ToolPanelComponent.js +++ b/frontend/src/components/app/map/controls/ToolPanelComponent.js @@ -5,8 +5,8 @@ import './ToolPanelComponent.css' const ToolPanelComponent = () => (
- - + +
) diff --git a/frontend/src/components/app/map/controls/ZoomControlComponent.js b/frontend/src/components/app/map/controls/ZoomControlComponent.js index bd6527a6..65944bea 100644 --- a/frontend/src/components/app/map/controls/ZoomControlComponent.js +++ b/frontend/src/components/app/map/controls/ZoomControlComponent.js @@ -3,21 +3,21 @@ import React from 'react' const ZoomControlComponent = ({ zoomInOnCenter }) => { return ( - - - + + + ) } diff --git a/frontend/src/components/app/map/elements/Backdrop.js b/frontend/src/components/app/map/elements/Backdrop.js index 556d6a7b..8ccfe584 100644 --- a/frontend/src/components/app/map/elements/Backdrop.js +++ b/frontend/src/components/app/map/elements/Backdrop.js @@ -3,14 +3,6 @@ import { Rect } from 'react-konva' import { BACKDROP_COLOR } from '../../../../util/colors' import { MAP_SIZE_IN_PIXELS } from '../MapConstants' -const Backdrop = () => ( - -) +const Backdrop = () => export default Backdrop diff --git a/frontend/src/components/app/map/elements/RackFillBar.js b/frontend/src/components/app/map/elements/RackFillBar.js index 6e56e059..8c573a6f 100644 --- a/frontend/src/components/app/map/elements/RackFillBar.js +++ b/frontend/src/components/app/map/elements/RackFillBar.js @@ -21,27 +21,14 @@ const RackFillBar = ({ positionX, positionY, type, fillFraction }) => { const x = positionX * TILE_SIZE_IN_PIXELS + OBJECT_MARGIN_IN_PIXELS + - (type === 'space' - ? halfOfObjectBorderWidth - : 0.5 * (TILE_SIZE_IN_PIXELS - 2 * OBJECT_MARGIN_IN_PIXELS)) - const startY = - positionY * TILE_SIZE_IN_PIXELS + - OBJECT_MARGIN_IN_PIXELS + - halfOfObjectBorderWidth - const width = - 0.5 * (TILE_SIZE_IN_PIXELS - OBJECT_MARGIN_IN_PIXELS * 2) - - halfOfObjectBorderWidth - const fullHeight = - TILE_SIZE_IN_PIXELS - - OBJECT_MARGIN_IN_PIXELS * 2 - - OBJECT_BORDER_WIDTH_IN_PIXELS + (type === 'space' ? halfOfObjectBorderWidth : 0.5 * (TILE_SIZE_IN_PIXELS - 2 * OBJECT_MARGIN_IN_PIXELS)) + const startY = positionY * TILE_SIZE_IN_PIXELS + OBJECT_MARGIN_IN_PIXELS + halfOfObjectBorderWidth + const width = 0.5 * (TILE_SIZE_IN_PIXELS - OBJECT_MARGIN_IN_PIXELS * 2) - halfOfObjectBorderWidth + const fullHeight = TILE_SIZE_IN_PIXELS - OBJECT_MARGIN_IN_PIXELS * 2 - OBJECT_BORDER_WIDTH_IN_PIXELS const fractionHeight = fillFraction * fullHeight const fractionY = - (positionY + 1) * TILE_SIZE_IN_PIXELS - - OBJECT_MARGIN_IN_PIXELS - - halfOfObjectBorderWidth - - fractionHeight + (positionY + 1) * TILE_SIZE_IN_PIXELS - OBJECT_MARGIN_IN_PIXELS - halfOfObjectBorderWidth - fractionHeight return ( @@ -50,22 +37,14 @@ const RackFillBar = ({ positionX, positionY, type, fillFraction }) => { y={startY} width={width} height={fullHeight} - fill={ - type === 'space' - ? RACK_SPACE_BAR_BACKGROUND_COLOR - : RACK_ENERGY_BAR_BACKGROUND_COLOR - } + fill={type === 'space' ? RACK_SPACE_BAR_BACKGROUND_COLOR : RACK_ENERGY_BAR_BACKGROUND_COLOR} /> { pixelX + 0.5 * TILE_SIZE_IN_PIXELS * mapScale, pixelY + TILE_PLUS_MARGIN_IN_PIXELS * mapScale, pixelX + 0.5 * TILE_SIZE_IN_PIXELS * mapScale, - pixelY + - TILE_SIZE_IN_PIXELS * mapScale - - TILE_PLUS_MARGIN_IN_PIXELS * mapScale, + pixelY + TILE_SIZE_IN_PIXELS * mapScale - TILE_PLUS_MARGIN_IN_PIXELS * mapScale, ], [ pixelX + TILE_PLUS_MARGIN_IN_PIXELS * mapScale, pixelY + 0.5 * TILE_SIZE_IN_PIXELS * mapScale, - pixelX + - TILE_SIZE_IN_PIXELS * mapScale - - TILE_PLUS_MARGIN_IN_PIXELS * mapScale, + pixelX + TILE_SIZE_IN_PIXELS * mapScale - TILE_PLUS_MARGIN_IN_PIXELS * mapScale, pixelY + 0.5 * TILE_SIZE_IN_PIXELS * mapScale, ], ] diff --git a/frontend/src/components/app/map/elements/WallSegment.js b/frontend/src/components/app/map/elements/WallSegment.js index d1ba6157..8aa2aebf 100644 --- a/frontend/src/components/app/map/elements/WallSegment.js +++ b/frontend/src/components/app/map/elements/WallSegment.js @@ -22,14 +22,7 @@ const WallSegment = ({ wallSegment }) => { ] } - return ( - - ) + return } WallSegment.propTypes = { diff --git a/frontend/src/components/app/map/groups/GridGroup.js b/frontend/src/components/app/map/groups/GridGroup.js index 10554834..ebc00244 100644 --- a/frontend/src/components/app/map/groups/GridGroup.js +++ b/frontend/src/components/app/map/groups/GridGroup.js @@ -4,13 +4,13 @@ import { GRID_COLOR } from '../../../../util/colors' import { GRID_LINE_WIDTH_IN_PIXELS, MAP_SIZE, MAP_SIZE_IN_PIXELS, TILE_SIZE_IN_PIXELS } from '../MapConstants' const MAP_COORDINATE_ENTRIES = Array.from(new Array(MAP_SIZE), (x, i) => i) -const HORIZONTAL_POINT_PAIRS = MAP_COORDINATE_ENTRIES.map(index => [ +const HORIZONTAL_POINT_PAIRS = MAP_COORDINATE_ENTRIES.map((index) => [ 0, index * TILE_SIZE_IN_PIXELS, MAP_SIZE_IN_PIXELS, index * TILE_SIZE_IN_PIXELS, ]) -const VERTICAL_POINT_PAIRS = MAP_COORDINATE_ENTRIES.map(index => [ +const VERTICAL_POINT_PAIRS = MAP_COORDINATE_ENTRIES.map((index) => [ index * TILE_SIZE_IN_PIXELS, 0, index * TILE_SIZE_IN_PIXELS, @@ -19,9 +19,7 @@ const VERTICAL_POINT_PAIRS = MAP_COORDINATE_ENTRIES.map(index => [ const GridGroup = () => ( - {HORIZONTAL_POINT_PAIRS.concat( - VERTICAL_POINT_PAIRS, - ).map((points, index) => ( + {HORIZONTAL_POINT_PAIRS.concat(VERTICAL_POINT_PAIRS).map((points, index) => ( { return ( - + - - + + ) diff --git a/frontend/src/components/app/map/groups/RoomGroup.js b/frontend/src/components/app/map/groups/RoomGroup.js index 4e3c7410..1fd54687 100644 --- a/frontend/src/components/app/map/groups/RoomGroup.js +++ b/frontend/src/components/app/map/groups/RoomGroup.js @@ -5,17 +5,12 @@ import TileContainer from '../../../../containers/app/map/TileContainer' import WallContainer from '../../../../containers/app/map/WallContainer' import Shapes from '../../../../shapes/index' -const RoomGroup = ({ - room, - interactionLevel, - currentRoomInConstruction, - onClick, - }) => { +const RoomGroup = ({ room, interactionLevel, currentRoomInConstruction, onClick }) => { if (currentRoomInConstruction === room._id) { return ( - {room.tileIds.map(tileId => ( - + {room.tileIds.map((tileId) => ( + ))} ) @@ -25,26 +20,23 @@ const RoomGroup = ({ {(() => { if ( - (interactionLevel.mode === 'RACK' || - interactionLevel.mode === 'MACHINE') && + (interactionLevel.mode === 'RACK' || interactionLevel.mode === 'MACHINE') && interactionLevel.roomId === room._id ) { return [ room.tileIds - .filter(tileId => tileId !== interactionLevel.tileId) - .map(tileId => ), - , + .filter((tileId) => tileId !== interactionLevel.tileId) + .map((tileId) => ), + , room.tileIds - .filter(tileId => tileId === interactionLevel.tileId) - .map(tileId => ), + .filter((tileId) => tileId === interactionLevel.tileId) + .map((tileId) => ), ] } else { - return room.tileIds.map(tileId => ( - - )) + return room.tileIds.map((tileId) => ) } })()} - + ) } diff --git a/frontend/src/components/app/map/groups/TileGroup.js b/frontend/src/components/app/map/groups/TileGroup.js index e984f05b..1e106823 100644 --- a/frontend/src/components/app/map/groups/TileGroup.js +++ b/frontend/src/components/app/map/groups/TileGroup.js @@ -9,7 +9,7 @@ import RoomTile from '../elements/RoomTile' const TileGroup = ({ tile, newTile, roomLoad, onClick }) => { let tileObject if (tile.rackId) { - tileObject = + tileObject = } else { tileObject = null } @@ -21,7 +21,7 @@ const TileGroup = ({ tile, newTile, roomLoad, onClick }) => { return ( onClick(tile)}> - + {tileObject} ) diff --git a/frontend/src/components/app/map/groups/TopologyGroup.js b/frontend/src/components/app/map/groups/TopologyGroup.js index a40a1d41..6096fc8b 100644 --- a/frontend/src/components/app/map/groups/TopologyGroup.js +++ b/frontend/src/components/app/map/groups/TopologyGroup.js @@ -6,14 +6,14 @@ import Shapes from '../../../../shapes/index' const TopologyGroup = ({ topology, interactionLevel }) => { if (!topology) { - return + return } if (interactionLevel.mode === 'BUILDING') { return ( - {topology.roomIds.map(roomId => ( - + {topology.roomIds.map((roomId) => ( + ))} ) @@ -22,12 +22,16 @@ const TopologyGroup = ({ topology, interactionLevel }) => { return ( {topology.roomIds - .filter(roomId => roomId !== interactionLevel.roomId) - .map(roomId => )} - {interactionLevel.mode === 'ROOM' ? : null} + .filter((roomId) => roomId !== interactionLevel.roomId) + .map((roomId) => ( + + ))} + {interactionLevel.mode === 'ROOM' ? : null} {topology.roomIds - .filter(roomId => roomId === interactionLevel.roomId) - .map(roomId => )} + .filter((roomId) => roomId === interactionLevel.roomId) + .map((roomId) => ( + + ))} ) } diff --git a/frontend/src/components/app/map/groups/WallGroup.js b/frontend/src/components/app/map/groups/WallGroup.js index 81c72d94..7b0f5ca0 100644 --- a/frontend/src/components/app/map/groups/WallGroup.js +++ b/frontend/src/components/app/map/groups/WallGroup.js @@ -9,7 +9,7 @@ const WallGroup = ({ tiles }) => { return ( {deriveWallLocations(tiles).map((wallSegment, index) => ( - + ))} ) diff --git a/frontend/src/components/app/map/layers/HoverLayerComponent.js b/frontend/src/components/app/map/layers/HoverLayerComponent.js index 25c9c412..bead87de 100644 --- a/frontend/src/components/app/map/layers/HoverLayerComponent.js +++ b/frontend/src/components/app/map/layers/HoverLayerComponent.js @@ -26,18 +26,13 @@ class HoverLayerComponent extends React.Component { } const positionX = Math.floor( - (this.props.mouseX - this.props.mapPosition.x) / - (this.props.mapScale * TILE_SIZE_IN_PIXELS), + (this.props.mouseX - this.props.mapPosition.x) / (this.props.mapScale * TILE_SIZE_IN_PIXELS) ) const positionY = Math.floor( - (this.props.mouseY - this.props.mapPosition.y) / - (this.props.mapScale * TILE_SIZE_IN_PIXELS), + (this.props.mouseY - this.props.mapPosition.y) / (this.props.mapScale * TILE_SIZE_IN_PIXELS) ) - if ( - positionX !== this.state.positionX || - positionY !== this.state.positionY - ) { + if (positionX !== this.state.positionX || positionY !== this.state.positionY) { this.setState({ positionX, positionY, @@ -48,15 +43,11 @@ class HoverLayerComponent extends React.Component { render() { if (!this.props.isEnabled()) { - return + return } - const pixelX = - this.props.mapScale * this.state.positionX * TILE_SIZE_IN_PIXELS + - this.props.mapPosition.x - const pixelY = - this.props.mapScale * this.state.positionY * TILE_SIZE_IN_PIXELS + - this.props.mapPosition.y + const pixelX = this.props.mapScale * this.state.positionX * TILE_SIZE_IN_PIXELS + this.props.mapPosition.x + const pixelY = this.props.mapScale * this.state.positionY * TILE_SIZE_IN_PIXELS + this.props.mapPosition.y return ( @@ -66,16 +57,15 @@ class HoverLayerComponent extends React.Component { scale={this.props.mapScale} isValid={this.state.validity} onClick={() => - this.state.validity - ? this.props.onClick(this.state.positionX, this.state.positionY) - : undefined} + this.state.validity ? this.props.onClick(this.state.positionX, this.state.positionY) : undefined + } /> {this.props.children ? React.cloneElement(this.props.children, { - pixelX, - pixelY, - scale: this.props.mapScale, - }) + pixelX, + pixelY, + scale: this.props.mapScale, + }) : undefined} ) diff --git a/frontend/src/components/app/map/layers/MapLayerComponent.js b/frontend/src/components/app/map/layers/MapLayerComponent.js index 940057f9..8ee14c9c 100644 --- a/frontend/src/components/app/map/layers/MapLayerComponent.js +++ b/frontend/src/components/app/map/layers/MapLayerComponent.js @@ -6,15 +6,10 @@ import GridGroup from '../groups/GridGroup' const MapLayerComponent = ({ mapPosition, mapScale }) => ( - - - - + + + + ) diff --git a/frontend/src/components/app/map/layers/ObjectHoverLayerComponent.js b/frontend/src/components/app/map/layers/ObjectHoverLayerComponent.js index 31689635..661fc255 100644 --- a/frontend/src/components/app/map/layers/ObjectHoverLayerComponent.js +++ b/frontend/src/components/app/map/layers/ObjectHoverLayerComponent.js @@ -2,7 +2,7 @@ import React from 'react' import TilePlusIcon from '../elements/TilePlusIcon' import HoverLayerComponent from './HoverLayerComponent' -const ObjectHoverLayerComponent = props => ( +const ObjectHoverLayerComponent = (props) => ( diff --git a/frontend/src/components/app/map/layers/RoomHoverLayerComponent.js b/frontend/src/components/app/map/layers/RoomHoverLayerComponent.js index d3d5e9b2..887e2891 100644 --- a/frontend/src/components/app/map/layers/RoomHoverLayerComponent.js +++ b/frontend/src/components/app/map/layers/RoomHoverLayerComponent.js @@ -1,6 +1,6 @@ import React from 'react' import HoverLayerComponent from './HoverLayerComponent' -const RoomHoverLayerComponent = props => +const RoomHoverLayerComponent = (props) => export default RoomHoverLayerComponent diff --git a/frontend/src/components/app/results/MetricChartComponent.js b/frontend/src/components/app/results/MetricChartComponent.js new file mode 100644 index 00000000..29a4676a --- /dev/null +++ b/frontend/src/components/app/results/MetricChartComponent.js @@ -0,0 +1,67 @@ +import React from 'react' +import ReactDOM from 'react-dom/server' +import SvgSaver from 'svgsaver' +import { VictoryAxis, VictoryChart, VictoryLabel, VictoryLine, VictoryScatter } from 'victory' +import { convertSecondsToFormattedTime } from '../../../util/date-time' + +const MetricChartComponent = ({ data, currentTick }) => { + const onExport = () => { + const div = document.createElement('div') + div.innerHTML = ReactDOM.renderToString( + + ) + div.firstChild.style = 'font-family: Roboto, Arial, sans-serif; font-size: 10pt;' + const svgSaver = new SvgSaver() + svgSaver.asSvg(div.firstChild, 'opendc-chart-export-' + Date.now() + '.svg') + } + + return ( +
+ Load over time + + +
+ ) +} + +const VictoryChartComponent = ({ data, currentTick, showCurrentTick }) => ( + + convertSecondsToFormattedTime(tick)} + fixLabelOverlap={true} + label="Simulated Time" + /> + + + + {showCurrentTick ? ( + } + data={[ + { x: currentTick + 1, y: 0 }, + { x: currentTick + 1, y: 1 }, + ]} + labels={(point) => + point.y === 1 ? 'Current tick : ' + convertSecondsToFormattedTime(currentTick) : '' + } + style={{ + data: { stroke: '#00A6D6', strokeWidth: 4 }, + labels: { fill: '#00A6D6' }, + }} + /> + ) : undefined} + +) + +const ExportChartComponent = ({ onExport }) => ( + +) + +export default MetricChartComponent diff --git a/frontend/src/components/app/results/PortfolioResultsComponent.js b/frontend/src/components/app/results/PortfolioResultsComponent.js new file mode 100644 index 00000000..8c778098 --- /dev/null +++ b/frontend/src/components/app/results/PortfolioResultsComponent.js @@ -0,0 +1,78 @@ +import React from 'react' +import PropTypes from 'prop-types' +import { Bar, BarChart, CartesianGrid, ErrorBar, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts' +import { AVAILABLE_METRICS, METRIC_NAMES } from '../../../util/available-metrics' +import { mean, std } from 'mathjs' +import Shapes from '../../../shapes/index' +import approx from 'approximate-number' + +const PortfolioResultsComponent = ({ portfolio, scenarios }) => { + if (!portfolio) { + return
Loading...
+ } + + const nonFinishedScenarios = scenarios.filter((s) => s.simulation.state !== 'FINISHED') + + if (nonFinishedScenarios.length > 0) { + if (nonFinishedScenarios.every((s) => s.simulation.state === 'QUEUED' || s.simulation.state === 'RUNNING')) { + return ( +
+

Simulation running...

+

{nonFinishedScenarios.length} of the scenarios are still being simulated

+
+ ) + } + if (nonFinishedScenarios.some((s) => s.simulation.state === 'FAILED')) { + return ( +
+

Simulation failed.

+

+ Try again by creating a new scenario. Please contact the OpenDC team for support, if issues + persist. +

+
+ ) + } + } + + const dataPerMetric = {} + + AVAILABLE_METRICS.forEach((metric) => { + dataPerMetric[metric] = scenarios.map((scenario) => ({ + name: scenario.name, + value: mean(scenario.results[metric]), + std: std(scenario.results[metric]), + })) + }) + + return ( +
+

Portfolio: {portfolio.name}

+

Repeats per Scenario: {portfolio.targets.repeatsPerScenario}

+
+ {AVAILABLE_METRICS.map(metric => ( +
+

{METRIC_NAMES[metric]}

+ + + + + approx(tick)}/> + + + + + +
+ ))} +
+
+ ) +} + +PortfolioResultsComponent.propTypes = { + portfolio: Shapes.Portfolio, + scenarios: PropTypes.arrayOf(Shapes.Scenario), +} + +export default PortfolioResultsComponent diff --git a/frontend/src/components/app/sidebars/Sidebar.js b/frontend/src/components/app/sidebars/Sidebar.js index a47a67c0..e1760d5e 100644 --- a/frontend/src/components/app/sidebars/Sidebar.js +++ b/frontend/src/components/app/sidebars/Sidebar.js @@ -10,7 +10,7 @@ class Sidebar extends React.Component { } static defaultProps = { - collapsible: true + collapsible: true, } state = { @@ -25,17 +25,10 @@ class Sidebar extends React.Component { })} onClick={() => this.setState({ collapsed: !this.state.collapsed })} > - {(this.state.collapsed && this.props.isRight) || - (!this.state.collapsed && !this.props.isRight) ? ( - + {(this.state.collapsed && this.props.isRight) || (!this.state.collapsed && !this.props.isRight) ? ( + ) : ( - + )}
) @@ -48,7 +41,7 @@ class Sidebar extends React.Component { className={classNames('sidebar p-3 h-100', { 'sidebar-right': this.props.isRight, })} - onWheel={e => e.stopPropagation()} + onWheel={(e) => e.stopPropagation()} > {this.props.children} {this.props.collapsible && collapseButton} diff --git a/frontend/src/components/app/sidebars/Sidebar.sass b/frontend/src/components/app/sidebars/Sidebar.sass index 02e8940d..b8e15716 100644 --- a/frontend/src/components/app/sidebars/Sidebar.sass +++ b/frontend/src/components/app/sidebars/Sidebar.sass @@ -27,7 +27,7 @@ position: absolute top: 0 left: 0 - width: 350px + width: $side-bar-width z-index: 100 background: white diff --git a/frontend/src/components/app/sidebars/elements/LoadChartComponent.js b/frontend/src/components/app/sidebars/elements/LoadChartComponent.js deleted file mode 100644 index ae52891a..00000000 --- a/frontend/src/components/app/sidebars/elements/LoadChartComponent.js +++ /dev/null @@ -1,84 +0,0 @@ -import React from 'react' -import ReactDOM from 'react-dom/server' -import SvgSaver from 'svgsaver' -import { VictoryAxis, VictoryChart, VictoryLabel, VictoryLine, VictoryScatter } from 'victory' -import { convertSecondsToFormattedTime } from '../../../../util/date-time' - -const LoadChartComponent = ({ data, currentTick }) => { - const onExport = () => { - const div = document.createElement('div') - div.innerHTML = ReactDOM.renderToString( - , - ) - div.firstChild.style = - 'font-family: Roboto, Arial, sans-serif; font-size: 10pt;' - const svgSaver = new SvgSaver() - svgSaver.asSvg( - div.firstChild, - 'opendc-chart-export-' + Date.now() + '.svg', - ) - } - - return ( -
- Load over time - - -
- ) -} - -const VictoryChartComponent = ({ data, currentTick, showCurrentTick }) => ( - - convertSecondsToFormattedTime(tick)} - fixLabelOverlap={true} - label="Simulated Time" - /> - - - - {showCurrentTick ? ( - - } - data={[{ x: currentTick + 1, y: 0 }, { x: currentTick + 1, y: 1 }]} - labels={point => - point.y === 1 - ? 'Current tick : ' + convertSecondsToFormattedTime(currentTick) - : ''} - style={{ - data: { stroke: '#00A6D6', strokeWidth: 4 }, - labels: { fill: '#00A6D6' }, - }} - /> - ) : ( - undefined - )} - -) - -const ExportChartComponent = ({ onExport }) => ( - -) - -export default LoadChartComponent diff --git a/frontend/src/components/app/sidebars/project/PortfolioListComponent.js b/frontend/src/components/app/sidebars/project/PortfolioListComponent.js index a31f11cf..837666af 100644 --- a/frontend/src/components/app/sidebars/project/PortfolioListComponent.js +++ b/frontend/src/components/app/sidebars/project/PortfolioListComponent.js @@ -24,8 +24,11 @@ class PortfolioListComponent extends React.Component {

Portfolios -

@@ -33,7 +36,11 @@ class PortfolioListComponent extends React.Component {
+ className={ + 'col-8 align-self-center ' + + (portfolio._id === this.props.currentPortfolioId ? 'font-weight-bold' : '') + } + > {portfolio.name}
@@ -48,7 +55,7 @@ class PortfolioListComponent extends React.Component { />
- +
))}
diff --git a/frontend/src/components/app/sidebars/project/ProjectSidebarComponent.js b/frontend/src/components/app/sidebars/project/ProjectSidebarComponent.js index b21b012b..aadc451e 100644 --- a/frontend/src/components/app/sidebars/project/ProjectSidebarComponent.js +++ b/frontend/src/components/app/sidebars/project/ProjectSidebarComponent.js @@ -3,11 +3,11 @@ import Sidebar from '../Sidebar' import TopologyListContainer from '../../../../containers/app/sidebars/project/TopologyListContainer' import PortfolioListContainer from '../../../../containers/app/sidebars/project/PortfolioListContainer' -const ProjectSidebarComponent = ({collapsible}) => ( - - - - - ) +const ProjectSidebarComponent = ({ collapsible }) => ( + + + + +) export default ProjectSidebarComponent diff --git a/frontend/src/components/app/sidebars/project/ScenarioListComponent.js b/frontend/src/components/app/sidebars/project/ScenarioListComponent.js index 9d2e261e..f44ce77f 100644 --- a/frontend/src/components/app/sidebars/project/ScenarioListComponent.js +++ b/frontend/src/components/app/sidebars/project/ScenarioListComponent.js @@ -24,7 +24,12 @@ class ScenarioListComponent extends React.Component { <> {this.props.scenarios.map((scenario, idx) => (
-
+
{scenario.name}
@@ -35,14 +40,17 @@ class ScenarioListComponent extends React.Component { /> idx !== 0 ? this.onDelete(scenario._id) : undefined} + onClick={() => (idx !== 0 ? this.onDelete(scenario._id) : undefined)} />
))}
-
this.props.onNewScenario(this.props.portfolioId)}> - +
this.props.onNewScenario(this.props.portfolioId)} + > + New scenario
diff --git a/frontend/src/components/app/sidebars/project/TopologyListComponent.js b/frontend/src/components/app/sidebars/project/TopologyListComponent.js index b8b41200..498ee26d 100644 --- a/frontend/src/components/app/sidebars/project/TopologyListComponent.js +++ b/frontend/src/components/app/sidebars/project/TopologyListComponent.js @@ -26,13 +26,18 @@ class TopologyListComponent extends React.Component {

Topologies

{this.props.topologies.map((topology, idx) => (
-
+
{topology.name}
@@ -42,7 +47,7 @@ class TopologyListComponent extends React.Component { /> idx !== 0 ? this.onDelete(topology._id) : undefined} + onClick={() => (idx !== 0 ? this.onDelete(topology._id) : undefined)} />
diff --git a/frontend/src/components/app/sidebars/topology/NameComponent.js b/frontend/src/components/app/sidebars/topology/NameComponent.js index 1f3051d5..5fb0dc55 100644 --- a/frontend/src/components/app/sidebars/topology/NameComponent.js +++ b/frontend/src/components/app/sidebars/topology/NameComponent.js @@ -5,7 +5,7 @@ const NameComponent = ({ name, onEdit }) => (

{name}

) diff --git a/frontend/src/components/app/sidebars/topology/TopologySidebarComponent.js b/frontend/src/components/app/sidebars/topology/TopologySidebarComponent.js index b1def94b..f5eee36b 100644 --- a/frontend/src/components/app/sidebars/topology/TopologySidebarComponent.js +++ b/frontend/src/components/app/sidebars/topology/TopologySidebarComponent.js @@ -10,16 +10,16 @@ const TopologySidebarComponent = ({ interactionLevel }) => { switch (interactionLevel.mode) { case 'BUILDING': - sidebarContent = + sidebarContent = break case 'ROOM': - sidebarContent = + sidebarContent = break case 'RACK': - sidebarContent = + sidebarContent = break case 'MACHINE': - sidebarContent = + sidebarContent = break default: sidebarContent = 'Missing Content' diff --git a/frontend/src/components/app/sidebars/topology/building/BuildingSidebarComponent.js b/frontend/src/components/app/sidebars/topology/building/BuildingSidebarComponent.js index 4cc87798..eea62f84 100644 --- a/frontend/src/components/app/sidebars/topology/building/BuildingSidebarComponent.js +++ b/frontend/src/components/app/sidebars/topology/building/BuildingSidebarComponent.js @@ -1,12 +1,11 @@ import React from 'react' -import NewRoomConstructionContainer - from '../../../../../containers/app/sidebars/topology/building/NewRoomConstructionContainer' +import NewRoomConstructionContainer from '../../../../../containers/app/sidebars/topology/building/NewRoomConstructionContainer' const BuildingSidebarComponent = () => { return (

Building

- +
) } diff --git a/frontend/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js b/frontend/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js index 75b00c54..fd552c1e 100644 --- a/frontend/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js +++ b/frontend/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js @@ -1,15 +1,10 @@ import React from 'react' -const NewRoomConstructionComponent = ({ - onStart, - onFinish, - onCancel, - currentRoomInConstruction, - }) => { +const NewRoomConstructionComponent = ({ onStart, onFinish, onCancel, currentRoomInConstruction }) => { if (currentRoomInConstruction === '-1') { return (
- + Construct a new room
) @@ -17,11 +12,11 @@ const NewRoomConstructionComponent = ({ return (
- + Finalize new room
- + Cancel construction
diff --git a/frontend/src/components/app/sidebars/topology/machine/BackToRackComponent.js b/frontend/src/components/app/sidebars/topology/machine/BackToRackComponent.js index d7ce24bc..70d522b2 100644 --- a/frontend/src/components/app/sidebars/topology/machine/BackToRackComponent.js +++ b/frontend/src/components/app/sidebars/topology/machine/BackToRackComponent.js @@ -2,7 +2,7 @@ import React from 'react' const BackToRackComponent = ({ onClick }) => (
- + Back to rack
) diff --git a/frontend/src/components/app/sidebars/topology/machine/DeleteMachineComponent.js b/frontend/src/components/app/sidebars/topology/machine/DeleteMachineComponent.js index b9aa6251..37820316 100644 --- a/frontend/src/components/app/sidebars/topology/machine/DeleteMachineComponent.js +++ b/frontend/src/components/app/sidebars/topology/machine/DeleteMachineComponent.js @@ -2,7 +2,7 @@ import React from 'react' const DeleteMachineComponent = ({ onClick }) => (
- + Delete this machine
) diff --git a/frontend/src/components/app/sidebars/topology/machine/MachineNameComponent.js b/frontend/src/components/app/sidebars/topology/machine/MachineNameComponent.js index 70be6968..992383c4 100644 --- a/frontend/src/components/app/sidebars/topology/machine/MachineNameComponent.js +++ b/frontend/src/components/app/sidebars/topology/machine/MachineNameComponent.js @@ -1,7 +1,5 @@ import React from 'react' -const MachineNameComponent = ({ position }) => ( -

Machine at slot {position}

-) +const MachineNameComponent = ({ position }) =>

Machine at slot {position}

export default MachineNameComponent diff --git a/frontend/src/components/app/sidebars/topology/machine/MachineSidebarComponent.js b/frontend/src/components/app/sidebars/topology/machine/MachineSidebarComponent.js index d78c20eb..02e7b8d4 100644 --- a/frontend/src/components/app/sidebars/topology/machine/MachineSidebarComponent.js +++ b/frontend/src/components/app/sidebars/topology/machine/MachineSidebarComponent.js @@ -7,10 +7,10 @@ import UnitTabsContainer from '../../../../../containers/app/sidebars/topology/m const MachineSidebarComponent = ({ machineId }) => { return (
- - - - + + + +
) } diff --git a/frontend/src/components/app/sidebars/topology/machine/UnitAddComponent.js b/frontend/src/components/app/sidebars/topology/machine/UnitAddComponent.js index 98238de7..d5ecbce3 100644 --- a/frontend/src/components/app/sidebars/topology/machine/UnitAddComponent.js +++ b/frontend/src/components/app/sidebars/topology/machine/UnitAddComponent.js @@ -11,11 +11,8 @@ class UnitAddComponent extends React.Component { return (
- (this.unitSelect = unitSelect)}> + {this.props.units.map((unit) => ( @@ -24,11 +21,9 @@ class UnitAddComponent extends React.Component {
diff --git a/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js b/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js index 3953347a..4816ca23 100644 --- a/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js +++ b/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js @@ -21,10 +21,7 @@ class UnitComponent extends React.Component { 'Energy Cons.: ' + this.props.unit.energyConsumptionW + ' W' - } else if ( - this.props.unitType === 'memory' || - this.props.unitType === 'storage' - ) { + } else if (this.props.unitType === 'memory' || this.props.unitType === 'storage') { unitInfo = 'Speed: ' + this.props.unit.speedMbPerS + @@ -39,9 +36,7 @@ class UnitComponent extends React.Component { return (
  • - - {this.props.unit.name} - + {this.props.unit.name} - +
  • ) diff --git a/frontend/src/components/app/sidebars/topology/machine/UnitListComponent.js b/frontend/src/components/app/sidebars/topology/machine/UnitListComponent.js index fcd3e03b..2ade0f6a 100644 --- a/frontend/src/components/app/sidebars/topology/machine/UnitListComponent.js +++ b/frontend/src/components/app/sidebars/topology/machine/UnitListComponent.js @@ -5,12 +5,7 @@ const UnitListComponent = ({ unitType, unitIds }) => (
      {unitIds.length !== 0 ? ( unitIds.map((unitId, index) => ( - + )) ) : (
      diff --git a/frontend/src/components/app/sidebars/topology/machine/UnitTabsComponent.js b/frontend/src/components/app/sidebars/topology/machine/UnitTabsComponent.js index c774036f..15c89ed5 100644 --- a/frontend/src/components/app/sidebars/topology/machine/UnitTabsComponent.js +++ b/frontend/src/components/app/sidebars/topology/machine/UnitTabsComponent.js @@ -6,12 +6,7 @@ const UnitTabsComponent = () => (
      - - + +
      - - + +
      - - + +
      - - + +
      diff --git a/frontend/src/components/app/sidebars/topology/rack/BackToRoomComponent.js b/frontend/src/components/app/sidebars/topology/rack/BackToRoomComponent.js index 345674d1..c14775bf 100644 --- a/frontend/src/components/app/sidebars/topology/rack/BackToRoomComponent.js +++ b/frontend/src/components/app/sidebars/topology/rack/BackToRoomComponent.js @@ -2,7 +2,7 @@ import React from 'react' const BackToRoomComponent = ({ onClick }) => (
      - + Back to room
      ) diff --git a/frontend/src/components/app/sidebars/topology/rack/DeleteRackComponent.js b/frontend/src/components/app/sidebars/topology/rack/DeleteRackComponent.js index b1672764..23b0daac 100644 --- a/frontend/src/components/app/sidebars/topology/rack/DeleteRackComponent.js +++ b/frontend/src/components/app/sidebars/topology/rack/DeleteRackComponent.js @@ -2,7 +2,7 @@ import React from 'react' const DeleteRackComponent = ({ onClick }) => (
      - + Delete this rack
      ) diff --git a/frontend/src/components/app/sidebars/topology/rack/EmptySlotComponent.js b/frontend/src/components/app/sidebars/topology/rack/EmptySlotComponent.js index 03b44aa6..d7e30f1d 100644 --- a/frontend/src/components/app/sidebars/topology/rack/EmptySlotComponent.js +++ b/frontend/src/components/app/sidebars/topology/rack/EmptySlotComponent.js @@ -2,11 +2,9 @@ import React from 'react' const EmptySlotComponent = ({ position, onAdd }) => (
    • - - {position} - + {position}
    • diff --git a/frontend/src/components/app/sidebars/topology/rack/MachineComponent.js b/frontend/src/components/app/sidebars/topology/rack/MachineComponent.js index cec3c912..caa3dc04 100644 --- a/frontend/src/components/app/sidebars/topology/rack/MachineComponent.js +++ b/frontend/src/components/app/sidebars/topology/rack/MachineComponent.js @@ -12,17 +12,9 @@ const UnitIcon = ({ id, type }) => (
      ) -const MachineComponent = ({ - position, - machine, - onClick, - }) => { +const MachineComponent = ({ position, machine, onClick }) => { const hasNoUnits = - machine.cpuIds.length + - machine.gpuIds.length + - machine.memoryIds.length + - machine.storageIds.length === - 0 + machine.cpuIds.length + machine.gpuIds.length + machine.memoryIds.length + machine.storageIds.length === 0 return (
    • {position}
      - {machine.cpuIds.length > 0 ? ( - - ) : ( - undefined - )} - {machine.gpuIds.length > 0 ? ( - - ) : ( - undefined - )} - {machine.memoryIds.length > 0 ? ( - - ) : ( - undefined - )} - {machine.storageIds.length > 0 ? ( - - ) : ( - undefined - )} + {machine.cpuIds.length > 0 ? : undefined} + {machine.gpuIds.length > 0 ? : undefined} + {machine.memoryIds.length > 0 ? : undefined} + {machine.storageIds.length > 0 ? : undefined} {hasNoUnits ? ( - - Machine with no units - - ) : ( - undefined - )} + Machine with no units + ) : undefined}
    • ) diff --git a/frontend/src/components/app/sidebars/topology/rack/MachineListComponent.js b/frontend/src/components/app/sidebars/topology/rack/MachineListComponent.js index a381771c..aa7a4f8f 100644 --- a/frontend/src/components/app/sidebars/topology/rack/MachineListComponent.js +++ b/frontend/src/components/app/sidebars/topology/rack/MachineListComponent.js @@ -8,15 +8,9 @@ const MachineListComponent = ({ machineIds }) => {
        {machineIds.map((machineId, index) => { if (machineId === null) { - return + return } else { - return ( - - ) + return } })}
      diff --git a/frontend/src/components/app/sidebars/topology/rack/RackNameComponent.js b/frontend/src/components/app/sidebars/topology/rack/RackNameComponent.js index 1888b69d..b701909a 100644 --- a/frontend/src/components/app/sidebars/topology/rack/RackNameComponent.js +++ b/frontend/src/components/app/sidebars/topology/rack/RackNameComponent.js @@ -1,8 +1,6 @@ import React from 'react' import NameComponent from '../NameComponent' -const RackNameComponent = ({ rackName, onEdit }) => ( - -) +const RackNameComponent = ({ rackName, onEdit }) => export default RackNameComponent diff --git a/frontend/src/components/app/sidebars/topology/rack/RackSidebarComponent.js b/frontend/src/components/app/sidebars/topology/rack/RackSidebarComponent.js index 23e8e743..c04e46d8 100644 --- a/frontend/src/components/app/sidebars/topology/rack/RackSidebarComponent.js +++ b/frontend/src/components/app/sidebars/topology/rack/RackSidebarComponent.js @@ -9,12 +9,12 @@ const RackSidebarComponent = () => { return (
      - - - + + +
      - +
      ) diff --git a/frontend/src/components/app/sidebars/topology/room/BackToBuildingComponent.js b/frontend/src/components/app/sidebars/topology/room/BackToBuildingComponent.js index 7bd8c2f8..64c0a1f6 100644 --- a/frontend/src/components/app/sidebars/topology/room/BackToBuildingComponent.js +++ b/frontend/src/components/app/sidebars/topology/room/BackToBuildingComponent.js @@ -2,7 +2,7 @@ import React from 'react' const BackToBuildingComponent = ({ onClick }) => (
      - + Back to building
      ) diff --git a/frontend/src/components/app/sidebars/topology/room/DeleteRoomComponent.js b/frontend/src/components/app/sidebars/topology/room/DeleteRoomComponent.js index 2be752b5..78417359 100644 --- a/frontend/src/components/app/sidebars/topology/room/DeleteRoomComponent.js +++ b/frontend/src/components/app/sidebars/topology/room/DeleteRoomComponent.js @@ -2,7 +2,7 @@ import React from 'react' const DeleteRoomComponent = ({ onClick }) => (
      - + Delete this room
      ) diff --git a/frontend/src/components/app/sidebars/topology/room/EditRoomComponent.js b/frontend/src/components/app/sidebars/topology/room/EditRoomComponent.js index 672a191f..857a646f 100644 --- a/frontend/src/components/app/sidebars/topology/room/EditRoomComponent.js +++ b/frontend/src/components/app/sidebars/topology/room/EditRoomComponent.js @@ -1,15 +1,10 @@ import classNames from 'classnames' import React from 'react' -const EditRoomComponent = ({ - onEdit, - onFinish, - isEditing, - isInRackConstructionMode, - }) => +const EditRoomComponent = ({ onEdit, onFinish, isEditing, isInRackConstructionMode }) => isEditing ? (
      - + Finish editing room
      ) : ( @@ -19,7 +14,7 @@ const EditRoomComponent = ({ })} onClick={() => (isInRackConstructionMode ? undefined : onEdit())} > - + Edit the tiles of this room
    ) diff --git a/frontend/src/components/app/sidebars/topology/room/RackConstructionComponent.js b/frontend/src/components/app/sidebars/topology/room/RackConstructionComponent.js index 42b7357b..44566f61 100644 --- a/frontend/src/components/app/sidebars/topology/room/RackConstructionComponent.js +++ b/frontend/src/components/app/sidebars/topology/room/RackConstructionComponent.js @@ -1,16 +1,11 @@ import classNames from 'classnames' import React from 'react' -const RackConstructionComponent = ({ - onStart, - onStop, - inRackConstructionMode, - isEditingRoom, - }) => { +const RackConstructionComponent = ({ onStart, onStop, inRackConstructionMode, isEditingRoom }) => { if (inRackConstructionMode) { return (
    - + Stop rack construction
    ) @@ -23,7 +18,7 @@ const RackConstructionComponent = ({ })} onClick={() => (isEditingRoom ? undefined : onStart())} > - + Start rack construction
    ) diff --git a/frontend/src/components/app/sidebars/topology/room/RoomNameComponent.js b/frontend/src/components/app/sidebars/topology/room/RoomNameComponent.js index 409d2eef..d637828e 100644 --- a/frontend/src/components/app/sidebars/topology/room/RoomNameComponent.js +++ b/frontend/src/components/app/sidebars/topology/room/RoomNameComponent.js @@ -1,8 +1,6 @@ import React from 'react' import NameComponent from '../NameComponent' -const RoomNameComponent = ({ roomName, onEdit }) => ( - -) +const RoomNameComponent = ({ roomName, onEdit }) => export default RoomNameComponent diff --git a/frontend/src/components/app/sidebars/topology/room/RoomSidebarComponent.js b/frontend/src/components/app/sidebars/topology/room/RoomSidebarComponent.js index a23ac381..1bc6533e 100644 --- a/frontend/src/components/app/sidebars/topology/room/RoomSidebarComponent.js +++ b/frontend/src/components/app/sidebars/topology/room/RoomSidebarComponent.js @@ -8,11 +8,11 @@ import RoomNameContainer from '../../../../../containers/app/sidebars/topology/r const RoomSidebarComponent = () => { return (
    - - - - - + + + + +
    ) } -- cgit v1.2.3 From 2ed4052162e2fcfa49f55cdd7f77cc2595526169 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 21 Jul 2020 15:50:20 +0200 Subject: Fix overflow and rearrange --- .../components/app/results/PortfolioResultsComponent.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'frontend/src/components/app') diff --git a/frontend/src/components/app/results/PortfolioResultsComponent.js b/frontend/src/components/app/results/PortfolioResultsComponent.js index 8c778098..a5c33f47 100644 --- a/frontend/src/components/app/results/PortfolioResultsComponent.js +++ b/frontend/src/components/app/results/PortfolioResultsComponent.js @@ -46,21 +46,21 @@ const PortfolioResultsComponent = ({ portfolio, scenarios }) => { }) return ( -
    +

    Portfolio: {portfolio.name}

    Repeats per Scenario: {portfolio.targets.repeatsPerScenario}

    - {AVAILABLE_METRICS.map(metric => ( + {AVAILABLE_METRICS.map((metric) => (

    {METRIC_NAMES[metric]}

    - - - approx(tick)}/> - - - + + + approx(tick)} /> + + +
    -- cgit v1.2.3 From 3c03c08f996c1cd2bc26bac7bb72a5e61cad6338 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 22 Jul 2020 11:14:03 +0200 Subject: Add error bars --- .../app/results/PortfolioResultsComponent.js | 31 +++++++++++++--------- .../app/sidebars/project/ScenarioListComponent.js | 2 +- 2 files changed, 19 insertions(+), 14 deletions(-) (limited to 'frontend/src/components/app') diff --git a/frontend/src/components/app/results/PortfolioResultsComponent.js b/frontend/src/components/app/results/PortfolioResultsComponent.js index a5c33f47..e9b33777 100644 --- a/frontend/src/components/app/results/PortfolioResultsComponent.js +++ b/frontend/src/components/app/results/PortfolioResultsComponent.js @@ -1,7 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' -import { Bar, BarChart, CartesianGrid, ErrorBar, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts' -import { AVAILABLE_METRICS, METRIC_NAMES } from '../../../util/available-metrics' +import { Bar, CartesianGrid, ComposedChart, ErrorBar, ResponsiveContainer, Scatter, XAxis, YAxis } from 'recharts' +import { AVAILABLE_METRICS, METRIC_NAMES, METRIC_UNITS } from '../../../util/available-metrics' import { mean, std } from 'mathjs' import Shapes from '../../../shapes/index' import approx from 'approximate-number' @@ -41,27 +41,32 @@ const PortfolioResultsComponent = ({ portfolio, scenarios }) => { dataPerMetric[metric] = scenarios.map((scenario) => ({ name: scenario.name, value: mean(scenario.results[metric]), - std: std(scenario.results[metric]), + errorX: std(scenario.results[metric]), })) }) return (
    -

    Portfolio: {portfolio.name}

    +

    Portfolio: {portfolio.name}

    Repeats per Scenario: {portfolio.targets.repeatsPerScenario}

    {AVAILABLE_METRICS.map((metric) => ( -
    +

    {METRIC_NAMES[metric]}

    - - - - approx(tick)} /> - - - - + + + approx(tick)} + label={{ value: METRIC_UNITS[metric], position: 'bottom', offset: 0 }} + type="number"/> + + + + + + +
    ))} diff --git a/frontend/src/components/app/sidebars/project/ScenarioListComponent.js b/frontend/src/components/app/sidebars/project/ScenarioListComponent.js index f44ce77f..8b50eff0 100644 --- a/frontend/src/components/app/sidebars/project/ScenarioListComponent.js +++ b/frontend/src/components/app/sidebars/project/ScenarioListComponent.js @@ -34,7 +34,7 @@ class ScenarioListComponent extends React.Component {
    this.props.onChooseScenario(scenario.portfolioId, scenario._id)} /> -- cgit v1.2.3 From 0d7889c23d407f6c0cd3db4020989ce8a5f8063a Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 22 Jul 2020 11:40:01 +0200 Subject: Fix polling and upgrade bootstrap --- .../app/results/PortfolioResultsComponent.js | 28 +++++++++++++--------- .../app/sidebars/project/PortfolioListComponent.js | 4 ++-- .../sidebars/project/ProjectSidebarComponent.js | 6 +++-- .../app/sidebars/project/ScenarioListComponent.js | 4 ++-- .../app/sidebars/project/TopologyListComponent.js | 4 ++-- 5 files changed, 27 insertions(+), 19 deletions(-) (limited to 'frontend/src/components/app') diff --git a/frontend/src/components/app/results/PortfolioResultsComponent.js b/frontend/src/components/app/results/PortfolioResultsComponent.js index e9b33777..286dd48c 100644 --- a/frontend/src/components/app/results/PortfolioResultsComponent.js +++ b/frontend/src/components/app/results/PortfolioResultsComponent.js @@ -54,18 +54,24 @@ const PortfolioResultsComponent = ({ portfolio, scenarios }) => {

    {METRIC_NAMES[metric]}

    - - - approx(tick)} - label={{ value: METRIC_UNITS[metric], position: 'bottom', offset: 0 }} - type="number"/> - - - - + + + approx(tick)} + label={{ value: METRIC_UNITS[metric], position: 'bottom', offset: 0 }} + type="number" + /> + + + + -
    diff --git a/frontend/src/components/app/sidebars/project/PortfolioListComponent.js b/frontend/src/components/app/sidebars/project/PortfolioListComponent.js index 837666af..b000b9e2 100644 --- a/frontend/src/components/app/sidebars/project/PortfolioListComponent.js +++ b/frontend/src/components/app/sidebars/project/PortfolioListComponent.js @@ -37,13 +37,13 @@ class PortfolioListComponent extends React.Component {
    {portfolio.name}
    -
    +
    ( - - +
    + + +
    ) diff --git a/frontend/src/components/app/sidebars/project/ScenarioListComponent.js b/frontend/src/components/app/sidebars/project/ScenarioListComponent.js index 8b50eff0..e775a663 100644 --- a/frontend/src/components/app/sidebars/project/ScenarioListComponent.js +++ b/frontend/src/components/app/sidebars/project/ScenarioListComponent.js @@ -26,13 +26,13 @@ class ScenarioListComponent extends React.Component {
    {scenario.name}
    -
    +
    {topology.name}
    -
    +
    this.onChoose(topology._id)} -- cgit v1.2.3 From 8739a156b75ba96e15d1bb19b08ca829c1eb01e8 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 22 Jul 2020 13:25:53 +0200 Subject: Remove old charting library --- .../components/app/results/MetricChartComponent.js | 67 ---------------------- 1 file changed, 67 deletions(-) delete mode 100644 frontend/src/components/app/results/MetricChartComponent.js (limited to 'frontend/src/components/app') diff --git a/frontend/src/components/app/results/MetricChartComponent.js b/frontend/src/components/app/results/MetricChartComponent.js deleted file mode 100644 index 29a4676a..00000000 --- a/frontend/src/components/app/results/MetricChartComponent.js +++ /dev/null @@ -1,67 +0,0 @@ -import React from 'react' -import ReactDOM from 'react-dom/server' -import SvgSaver from 'svgsaver' -import { VictoryAxis, VictoryChart, VictoryLabel, VictoryLine, VictoryScatter } from 'victory' -import { convertSecondsToFormattedTime } from '../../../util/date-time' - -const MetricChartComponent = ({ data, currentTick }) => { - const onExport = () => { - const div = document.createElement('div') - div.innerHTML = ReactDOM.renderToString( - - ) - div.firstChild.style = 'font-family: Roboto, Arial, sans-serif; font-size: 10pt;' - const svgSaver = new SvgSaver() - svgSaver.asSvg(div.firstChild, 'opendc-chart-export-' + Date.now() + '.svg') - } - - return ( -
    - Load over time - - -
    - ) -} - -const VictoryChartComponent = ({ data, currentTick, showCurrentTick }) => ( - - convertSecondsToFormattedTime(tick)} - fixLabelOverlap={true} - label="Simulated Time" - /> - - - - {showCurrentTick ? ( - } - data={[ - { x: currentTick + 1, y: 0 }, - { x: currentTick + 1, y: 1 }, - ]} - labels={(point) => - point.y === 1 ? 'Current tick : ' + convertSecondsToFormattedTime(currentTick) : '' - } - style={{ - data: { stroke: '#00A6D6', strokeWidth: 4 }, - labels: { fill: '#00A6D6' }, - }} - /> - ) : undefined} - -) - -const ExportChartComponent = ({ onExport }) => ( - -) - -export default MetricChartComponent -- cgit v1.2.3