Commit 94cd91af authored by Sonja Happ's avatar Sonja Happ

Merge branch 'develop' of git.rwth-aachen.de:acs/public/villas/web into develop

parents d76d6a4d bb08991e
...@@ -69,7 +69,7 @@ class NewDashboardDialog extends React.Component { ...@@ -69,7 +69,7 @@ class NewDashboardDialog extends React.Component {
return ( return (
<Dialog show={this.props.show} title="New Dashboard" buttonTitle="Add" onClose={(c) => this.onClose(c)} onReset={() => this.resetState()} valid={this.valid}> <Dialog show={this.props.show} title="New Dashboard" buttonTitle="Add" onClose={(c) => this.onClose(c)} onReset={() => this.resetState()} valid={this.valid}>
<form> <form>
<FormGroup controlId="name" validationState={this.validateForm('name')}> <FormGroup controlId="name" validationstate={this.validateForm('name')}>
<FormLabel>Name</FormLabel> <FormLabel>Name</FormLabel>
<FormControl type="text" placeholder="Enter name" value={this.state.name} onChange={(e) => this.handleChange(e)} /> <FormControl type="text" placeholder="Enter name" value={this.state.name} onChange={(e) => this.handleChange(e)} />
<FormControl.Feedback /> <FormControl.Feedback />
......
...@@ -292,12 +292,12 @@ class Scenario extends React.Component { ...@@ -292,12 +292,12 @@ class Scenario extends React.Component {
closeNewDashboardModal(data) { closeNewDashboardModal(data) {
this.setState({ newDashboardModal : false }); this.setState({ newDashboardModal : false });
let newDashboard = data;
// add default grid value and scenarioID
newDashboard["grid"] = 15;
newDashboard["scenarioID"] = this.state.scenario.id;
if (data) { if (data) {
let newDashboard = data;
// add default grid value and scenarioID
newDashboard["grid"] = 15;
newDashboard["scenarioID"] = this.state.scenario.id;
AppDispatcher.dispatch({ AppDispatcher.dispatch({
type: 'dashboards/start-add', type: 'dashboards/start-add',
data, data,
......
...@@ -65,12 +65,24 @@ class EditWidgetDialog extends React.Component { ...@@ -65,12 +65,24 @@ class EditWidgetDialog extends React.Component {
return changeObject; return changeObject;
} }
getTextWidth(text, fontSize) {
let font = fontSize + "px ariel";
let canvas = this.getTextWidth.canvas || (this.getTextWidth.canvas = document.createElement("canvas"));
let context = canvas.getContext("2d");
context.font = font;
let metrics = context.measureText(text);
return metrics.width;
}
setMaxWidth(changeObject){ setMaxWidth(changeObject){
if(changeObject.type === 'Label'){ if(changeObject.type === 'Label'){
changeObject.customProperties.maxWidth = (changeObject.customProperties.textSize* 0.34) * changeObject.name.length; changeObject.customProperties.maxWidth = Math.ceil(this.getTextWidth(changeObject.name, changeObject.customProperties.textSize));
} }
else if (changeObject.type === 'Value'){ /*else if (changeObject.type === 'Value'){
// changeObject.customProperties.maxWidth = (changeObject.customProperties.textSize* 0.5) * (changeObject.name.length+13); changeObject.customProperties.maxWidth = Math.ceil(this.getTextWidth(changeObject.name, changeObject.customProperties.textSize));
}*/
if(this.state.temporal.width > changeObject.customProperties.maxWidth){
changeObject.width = changeObject.customProperties.maxWidth;
} }
return changeObject; return changeObject;
} }
......
...@@ -70,7 +70,7 @@ class WidgetFactory { ...@@ -70,7 +70,7 @@ class WidgetFactory {
case 'Value': case 'Value':
widget.minWidth = 70; widget.minWidth = 70;
widget.minHeight = 20; widget.minHeight = 20;
widget.width = 150; widget.width = 110;
widget.height = 30; widget.height = 30;
widget.customProperties.textSize = 16; widget.customProperties.textSize = 16;
widget.name = 'Value'; widget.name = 'Value';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment