/** * This file is part of VILLASweb. * * VILLASweb is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VILLASweb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VILLASweb. If not, see . ******************************************************************************/ import React from 'react'; import PropTypes from 'prop-types'; import Slider from 'rc-slider'; import { Button, OverlayTrigger, Tooltip } from 'react-bootstrap'; import Icon from "../common/icon"; import {Collapse} from 'react-collapse'; import ToolboxItem from './toolbox-item'; class WidgetToolbox extends React.Component { constructor(props) { super(props); this.state = { showCosmeticWidgets: false, showDisplayingWidgets: false, showManipulationWidgets: false }; } onGridChange = value => { // value 0 would block all widgets, set 1 as 'grid disabled' if (value === 0) { value = 1; } if (this.props.onGridChange != null) { this.props.onGridChange(value); } }; disableDecrease(){ const maxHeight = Object.values(this.props.widgets).reduce((currentHeight, widget) => { const absolutHeight = widget.y + widget.height; return absolutHeight > currentHeight ? absolutHeight : currentHeight; }, 0); if(this.props.dashboard.height <= 400 || this.props.dashboard.height <= maxHeight + 80){ return true; } return false; } showWidgets(value){ let tempValue = false; switch(value){ case 'cosmetic': tempValue = !this.state.showCosmeticWidgets; this.setState({showCosmeticWidgets: tempValue}); break; case 'displaying': tempValue = !this.state.showDisplayingWidgets; this.setState({showDisplayingWidgets: tempValue}); break; case 'manipulation': tempValue = !this.state.showManipulationWidgets; this.setState({showManipulationWidgets: tempValue}); break; default: break; } } render() { let cosmeticIcon = 'chevron-up'; let displayingIcon = 'chevron-up'; let manipulationIcon = 'chevron-up'; if(this.state.showCosmeticWidgets){ cosmeticIcon = 'chevron-down'; } if(this.state.showDisplayingWidgets){ displayingIcon = 'chevron-down'; } if(this.state.showManipulationWidgets){ manipulationIcon = 'chevron-down'; } const disableDecrease = this.disableDecrease(); // Only one topology widget at the time is supported const iconStyle = { color: '#527984', height: '25px', width : '25px' } const buttonStyle = { marginRight: '3px', height: '40px', borderColor: '#527984', backgroundColor: '#527984' } const altButtonStyle = { marginRight: '3px', height: '40px', borderColor: '#ffffff', backgroundColor: '#ffffff' } const thereIsTopologyWidget = this.props.widgets != null && Object.values(this.props.widgets).filter(w => w.type === 'Topology').length > 0; const topologyItemMsg = thereIsTopologyWidget? 'Currently only one is supported' : ''; return (
Show/ hide available Cosmetic Widgets } > Show/ hide available Displaying Widgets } > Show/ hide available Manipulation Widgets } >
Grid: { this.props.grid > 1 ? this.props.grid : 'Disabled' } Increase dashboard height } > Decrease dashboard height } >






Drag and drop widgets onto the dashboard } > Drag and drop widgets onto the dashboard } > Drag and drop widgets onto the dashboard } >
) }; } WidgetToolbox.propTypes = { widgets: PropTypes.array, grid: PropTypes.number, onGridChange: PropTypes.func, onDashboardSizeChange: PropTypes.func }; export default WidgetToolbox;