mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Merge branch 'example-dashboard' into develop
# Conflicts: # src/dashboard/dashboard.js
This commit is contained in:
commit
42ffff2d2d
5 changed files with 30 additions and 28 deletions
|
@ -54,6 +54,7 @@ class Dashboard extends Component {
|
|||
if (prevState == null) {
|
||||
prevState = {};
|
||||
}
|
||||
|
||||
const sessionToken = LoginStore.getState().token;
|
||||
|
||||
let dashboard = DashboardStore.getState().find(d => d.id === parseInt(props.match.params.dashboard, 10));
|
||||
|
@ -96,7 +97,7 @@ class Dashboard extends Component {
|
|||
modalData: null,
|
||||
modalIndex: null,
|
||||
widgetChangeData: [],
|
||||
widgetAddData:[],
|
||||
widgetAddData:prevState.widgetAddData || [],
|
||||
|
||||
maxWidgetHeight: maxHeight || null,
|
||||
dropZoneHeight: maxHeight +80 || null,
|
||||
|
@ -167,6 +168,10 @@ class Dashboard extends Component {
|
|||
|
||||
handleDrop(widget) {
|
||||
widget.dashboardID = this.state.dashboard.id;
|
||||
let tempChanges = this.state.widgetAddData;
|
||||
tempChanges.push(widget);
|
||||
|
||||
this.setState({ widgetAddData: tempChanges})
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'widgets/start-add',
|
||||
|
@ -174,10 +179,7 @@ class Dashboard extends Component {
|
|||
data: widget
|
||||
});
|
||||
|
||||
let tempChanges = this.state.widgetAddData;
|
||||
tempChanges.push(widget);
|
||||
|
||||
this.setState({ widgetAddData: tempChanges})
|
||||
/*let widgets = [];
|
||||
widgets = this.state.dashboard.get('widgets');
|
||||
|
||||
|
@ -297,15 +299,17 @@ class Dashboard extends Component {
|
|||
}
|
||||
|
||||
cancelEditing() {
|
||||
console.log("cancelEditing the add data: ");
|
||||
console.log(this.state.widgetAddData);
|
||||
//raw widget has no id -> cannot be deleted in its original form
|
||||
/*
|
||||
this.state.widgetAddData.forEach( widget => {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'widgets/start-remove',
|
||||
data: widget,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
});
|
||||
}); */
|
||||
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'widgets/start-load',
|
||||
token: this.state.sessionToken,
|
||||
|
|
|
@ -113,7 +113,7 @@ class WidgetContextMenu extends React.Component {
|
|||
);
|
||||
|
||||
return <div>
|
||||
<MenuProvider id={'widgetMenu'+ this.props.index} style={{ border: '1px solid purple', display: 'inline-block' }}>
|
||||
<MenuProvider id={'widgetMenu'+ this.props.index}>
|
||||
<Widget
|
||||
data={this.props.widget}
|
||||
onWidgetChange={this.props.onWidgetChange}
|
||||
|
|
|
@ -44,7 +44,7 @@ class EditWidgetColorControl extends Component {
|
|||
|
||||
this.state = {
|
||||
widget: {
|
||||
customProperties:{}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ class EditImageWidgetControl extends React.Component {
|
|||
return <div>
|
||||
<FormGroup controlId="file">
|
||||
<FormLabel>Image</FormLabel>
|
||||
<FormControl componentClass="select" value={this.state.widget.customProperties.file} onChange={(e) => this.props.handleChange(e)}>
|
||||
<FormControl className="select" value={this.state.widget.customProperties.file} onChange={(e) => this.props.handleChange(e)}>
|
||||
{this.props.files.length === 0 ? (
|
||||
<option disabled value style={{ display: 'none' }}>No images found, please upload one first.</option>
|
||||
) : (
|
||||
|
@ -96,8 +96,8 @@ class EditImageWidgetControl extends React.Component {
|
|||
<FormControl type="file" onChange={(e) => this.setState({ fileList: e.target.files }) } />
|
||||
</FormGroup>
|
||||
|
||||
<ProgressBar striped active now={this.state.progress} label={`${this.state.progress}%`} />
|
||||
<Button bsSize="small" onClick={this.startFileUpload}>Upload</Button>
|
||||
<ProgressBar striped active={'true'} now={this.state.progress} label={`${this.state.progress}%`} />
|
||||
<Button size='sm' onClick={this.startFileUpload}>Upload</Button>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,22 +28,23 @@ import CreateControls from './edit-widget-control-creator';
|
|||
|
||||
class EditWidgetDialog extends React.Component {
|
||||
valid = true;
|
||||
|
||||
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
temporal: {
|
||||
name: '',
|
||||
simulationModel: '',
|
||||
signal: 0
|
||||
|
||||
}
|
||||
temporal: {},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
static getDerivedStateFromProps(props, state){
|
||||
return {
|
||||
temporal: props.widget
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
onClose(canceled) {
|
||||
if (canceled === false) {
|
||||
|
@ -67,7 +68,7 @@ class EditWidgetDialog extends React.Component {
|
|||
}
|
||||
|
||||
handleChange(e) {
|
||||
|
||||
// TODO: check what we really need in this function. Can we reduce its complexity?
|
||||
if (e.constructor === Array) {
|
||||
// Every property in the array will be updated
|
||||
let changes = e.reduce( (changesObject, event) => {
|
||||
|
@ -78,7 +79,7 @@ class EditWidgetDialog extends React.Component {
|
|||
|
||||
this.setState({ temporal: Object.assign({}, this.state.temporal, changes ) });
|
||||
}
|
||||
|
||||
|
||||
if(e.target.type !== 'text'){
|
||||
let changeObject = {};
|
||||
if (e.target.id === 'lockAspect') {
|
||||
|
@ -100,28 +101,25 @@ class EditWidgetDialog extends React.Component {
|
|||
} else if (e.target.type === 'number') {
|
||||
changeObject[e.target.id] = Number(e.target.value);
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
changeObject[e.target.id] = e.target.value;
|
||||
}
|
||||
|
||||
|
||||
let finalChange = this.state.temporal;
|
||||
|
||||
|
||||
finalChange.customProperties[e.target.id] = changeObject[e.target.id];
|
||||
this.setState({ temporal: finalChange});
|
||||
}
|
||||
else{
|
||||
if(this.state.temporal[e.target.id]){
|
||||
let finalChange = this.state.temporal;
|
||||
|
||||
|
||||
finalChange[e.target.id] = e.target.value;
|
||||
this.setState({ temporal: finalChange});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
resetState() {
|
||||
|
|
Loading…
Add table
Reference in a new issue