mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-16 00:00:03 +01:00
infrastructure components (ics) show in table
This commit is contained in:
parent
dfc538113f
commit
37af564975
5 changed files with 19 additions and 21 deletions
|
@ -23,16 +23,15 @@ import ICDataDataManager from './ic-data-data-manager';
|
|||
|
||||
class InfrastructureComponentStore extends ArrayStore {
|
||||
constructor() {
|
||||
super('ic', ICsDataManager);
|
||||
super('ics', ICsDataManager);
|
||||
}
|
||||
|
||||
reduce(state, action) {
|
||||
switch(action.type) {
|
||||
case 'ic/loaded':
|
||||
case 'ics/loaded':
|
||||
// connect to each infrastructure component
|
||||
for (let ic of action.data) {
|
||||
const endpoint = _.get(ic, 'properties.endpoint') || _.get(ic, 'rawProperties.endpoint');
|
||||
|
||||
if (endpoint != null && endpoint !== '') {
|
||||
ICDataDataManager.open(endpoint, ic.id);
|
||||
} else {
|
||||
|
@ -43,32 +42,31 @@ class InfrastructureComponentStore extends ArrayStore {
|
|||
|
||||
return super.reduce(state, action);
|
||||
|
||||
case 'ic/edited':
|
||||
case 'ics/edited':
|
||||
// connect to each infrastructure component
|
||||
const ic = action.data;
|
||||
const endpoint = _.get(ic, 'properties.endpoint') || _.get(ic, 'rawProperties.endpoint');
|
||||
|
||||
if (endpoint != null && endpoint !== '') {
|
||||
console.log("Updating IC id " + ic.id);
|
||||
ICDataDataManager.update(endpoint, ic.id);
|
||||
}
|
||||
|
||||
return super.reduce(state, action);
|
||||
|
||||
case 'ic/fetched':
|
||||
case 'ics/fetched':
|
||||
return this.updateElements(state, [action.data]);
|
||||
|
||||
case 'ic/fetch-error':
|
||||
case 'ics/fetch-error':
|
||||
return state;
|
||||
|
||||
case 'ic/start-action':
|
||||
case 'ics/start-action':
|
||||
if (!Array.isArray(action.data))
|
||||
action.data = [ action.data ]
|
||||
|
||||
ICsDataManager.doActions(action.ic, action.data, action.token);
|
||||
return state;
|
||||
|
||||
case 'ic/action-error':
|
||||
case 'ics/action-error':
|
||||
console.log(action.error);
|
||||
return state;
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ class IcsDataManager extends RestDataManager {
|
|||
// TODO: Make only infrastructure component id dependent
|
||||
RestAPI.post(this.makeURL(this.url + '/' + ic.id), action, token).then(response => {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/action-started',
|
||||
type: 'ics/action-started',
|
||||
data: response
|
||||
});
|
||||
}).catch(error => {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/action-error',
|
||||
type: 'ics/action-error',
|
||||
error
|
||||
});
|
||||
});
|
||||
|
|
|
@ -85,7 +85,7 @@ class InfrastructureComponents extends Component {
|
|||
|
||||
componentDidMount() {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/start-load',
|
||||
type: 'ics/start-load',
|
||||
token: this.state.sessionToken,
|
||||
});
|
||||
|
||||
|
@ -104,7 +104,7 @@ class InfrastructureComponents extends Component {
|
|||
}
|
||||
else {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/start-load',
|
||||
type: 'ics/start-load',
|
||||
token: this.state.sessionToken,
|
||||
});
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ class InfrastructureComponents extends Component {
|
|||
|
||||
if (data) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/start-add',
|
||||
type: 'ics/start-add',
|
||||
data,
|
||||
token: this.state.sessionToken,
|
||||
});
|
||||
|
@ -132,7 +132,7 @@ class InfrastructureComponents extends Component {
|
|||
this.setState({ ic: ic });
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/start-edit',
|
||||
type: 'ics/start-edit',
|
||||
data: ic,
|
||||
token: this.state.sessionToken,
|
||||
});
|
||||
|
@ -147,7 +147,7 @@ class InfrastructureComponents extends Component {
|
|||
}
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/start-remove',
|
||||
type: 'ics/start-remove',
|
||||
data: this.state.modalIC,
|
||||
token: this.state.sessionToken,
|
||||
});
|
||||
|
@ -168,7 +168,7 @@ class InfrastructureComponents extends Component {
|
|||
|
||||
if (data) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/start-add',
|
||||
type: 'ics/start-add',
|
||||
data,
|
||||
token: this.state.sessionToken,
|
||||
});
|
||||
|
@ -203,7 +203,7 @@ class InfrastructureComponents extends Component {
|
|||
runAction = action => {
|
||||
for (let index of this.state.selectedICs) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/start-action',
|
||||
type: 'ics/start-action',
|
||||
ic: this.state.ics[index],
|
||||
data: action.data,
|
||||
token: this.state.sessionToken,
|
||||
|
|
|
@ -121,7 +121,7 @@ class Scenario extends React.Component {
|
|||
|
||||
// load ICs to enable that simulation models work with them
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/start-load',
|
||||
type: 'ics/start-load',
|
||||
token: this.state.sessionToken,
|
||||
});
|
||||
|
||||
|
@ -258,7 +258,7 @@ class Scenario extends React.Component {
|
|||
}
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/start-action',
|
||||
type: 'ics/start-action',
|
||||
ic: ic,
|
||||
data: action.data,
|
||||
token: this.state.sessionToken
|
||||
|
|
|
@ -48,7 +48,7 @@ class WidgetCustomAction extends Component {
|
|||
|
||||
onClick() {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic/start-action',
|
||||
type: 'ics/start-action',
|
||||
ic: this.state.ic,
|
||||
data: this.props.widget.customProperties.actions,
|
||||
token: this.state.sessionToken
|
||||
|
|
Loading…
Add table
Reference in a new issue