mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
moved action handling to LoginStore as it's derived directly from ReduceStore
This commit is contained in:
parent
fdeab76fe6
commit
93ca536f40
3 changed files with 11 additions and 45 deletions
|
@ -19,37 +19,14 @@
|
|||
import ScenariosDataManager from './scenarios-data-manager';
|
||||
import ArrayStore from '../common/array-store';
|
||||
|
||||
//export default new ArrayStore('scenarios', ScenariosDataManager);
|
||||
|
||||
class ScenarioStore extends ArrayStore {
|
||||
constructor() {
|
||||
super('scenarios', ScenariosDataManager);
|
||||
}
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
state: super.getInitialState(),
|
||||
users: null
|
||||
};
|
||||
super('scenarios', ScenariosDataManager);
|
||||
}
|
||||
|
||||
getUsers(token, id) {
|
||||
ScenariosDataManager.getUsers(token, id);
|
||||
}
|
||||
|
||||
reduce(state, action) {
|
||||
switch (action.type) {
|
||||
case 'scenarios/users':
|
||||
state.users = action.users;
|
||||
return state;
|
||||
case 'scenarios/users-error':
|
||||
return state;
|
||||
|
||||
default:
|
||||
return super.reduce(state, action);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new ScenarioStore();
|
|
@ -43,11 +43,8 @@ import EditSignalMapping from "../signal/edit-signal-mapping";
|
|||
import FileStore from "../file/file-store"
|
||||
import WidgetStore from "../widget/widget-store";
|
||||
|
||||
|
||||
class Scenario extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.getUsers = true;
|
||||
}
|
||||
|
||||
static getStores() {
|
||||
return [ ScenarioStore, ConfigStore, DashboardStore, ICStore, LoginStore, SignalStore, FileStore, WidgetStore];
|
||||
|
@ -65,22 +62,8 @@ class Scenario extends React.Component {
|
|||
token: sessionToken
|
||||
});
|
||||
}
|
||||
let users = null;
|
||||
let sc = ScenarioStore.getState().users;
|
||||
/*
|
||||
if (sc) {
|
||||
users = sc.users;
|
||||
if (users == null && this.getUsers ) {
|
||||
ScenarioStore.getUsers(sessionToken, props.match.params.scenario);
|
||||
this.getUsers = false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// ScenariosDataManager.getUsers(sessionToken, props.match.params.scenario);
|
||||
|
||||
let users = LoginStore.getState().scenarioUsers;
|
||||
// obtain all dashboards of a scenario
|
||||
let dashboards = DashboardStore.getState().filter(dashb => dashb.scenarioID === parseInt(props.match.params.scenario, 10));
|
||||
|
||||
|
@ -132,7 +115,6 @@ class Scenario extends React.Component {
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
// get users of scenario
|
||||
ScenarioStore.getUsers(this.state.sessionToken, this.state.scenario.id);
|
||||
|
||||
//load selected scenario
|
||||
|
|
|
@ -30,7 +30,8 @@ class LoginStore extends ReduceStore {
|
|||
return {
|
||||
currentUser: null,
|
||||
token: null,
|
||||
loginMessage: null
|
||||
loginMessage: null,
|
||||
scenarioUsers: null
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,13 @@ class LoginStore extends ReduceStore {
|
|||
// If it was an error and hasn't been handled, the credentials must have been wrong.
|
||||
state = Object.assign({}, state, { loginMessage: 'Wrong credentials! Please try again.' });
|
||||
}
|
||||
return state;
|
||||
|
||||
case 'scenarios/users':
|
||||
state.scenarioUsers = action.users;
|
||||
return state;
|
||||
|
||||
case 'scenarios/users-error':
|
||||
return state;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Add table
Reference in a new issue