mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Add token to all API calls
This commit is contained in:
parent
4df0e7a5fb
commit
723e2df3d1
7 changed files with 90 additions and 38 deletions
|
@ -104,11 +104,13 @@ class App extends Component {
|
|||
|
||||
// load all simulators and simulations to fetch simulation data
|
||||
AppDispatcher.dispatch({
|
||||
type: 'nodes/start-load'
|
||||
type: 'nodes/start-load',
|
||||
token
|
||||
});
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulations/start-load'
|
||||
type: 'simulations/start-load',
|
||||
token
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import { Button, Modal, Glyphicon } from 'react-bootstrap';
|
|||
|
||||
import AppDispatcher from '../app-dispatcher';
|
||||
import ProjectStore from '../stores/project-store';
|
||||
import UserStore from '../stores/user-store';
|
||||
import VisualizationStore from '../stores/visualization-store';
|
||||
|
||||
import CustomTable from '../components/table';
|
||||
|
@ -34,7 +35,7 @@ import EditVisualizationDialog from '../components/dialog/edit-visualization';
|
|||
|
||||
class Visualizations extends Component {
|
||||
static getStores() {
|
||||
return [ ProjectStore, VisualizationStore ];
|
||||
return [ ProjectStore, VisualizationStore, UserStore ];
|
||||
}
|
||||
|
||||
static calculateState(prevState, props) {
|
||||
|
@ -59,6 +60,7 @@ class Visualizations extends Component {
|
|||
return {
|
||||
projects: currentProjects,
|
||||
visualizations: currentVisualizations,
|
||||
sessionToken: UserStore.getState().token,
|
||||
|
||||
newModal: prevState.newModal,
|
||||
deleteModal: prevState.deleteModal,
|
||||
|
@ -78,6 +80,7 @@ class Visualizations extends Component {
|
|||
return {
|
||||
projects: currentProjects,
|
||||
visualizations: currentVisualizations,
|
||||
sessionToken: UserStore.getState().token,
|
||||
|
||||
newModal: false,
|
||||
deleteModal: false,
|
||||
|
@ -95,14 +98,16 @@ class Visualizations extends Component {
|
|||
|
||||
static loadProjects() {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'projects/start-load'
|
||||
type: 'projects/start-load',
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
static loadVisualizations(visualizations) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'visualizations/start-load',
|
||||
data: visualizations
|
||||
data: visualizations,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -117,7 +122,8 @@ class Visualizations extends Component {
|
|||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'visualizations/start-add',
|
||||
data: data
|
||||
data: data,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -129,7 +135,8 @@ class Visualizations extends Component {
|
|||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'visualizations/start-remove',
|
||||
data: this.state.modalData
|
||||
data: this.state.modalData,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -139,7 +146,8 @@ class Visualizations extends Component {
|
|||
if (data) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'visualizations/start-edit',
|
||||
data: data
|
||||
data: data,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import { Button, Modal, Glyphicon } from 'react-bootstrap';
|
|||
|
||||
import AppDispatcher from '../app-dispatcher';
|
||||
import ProjectStore from '../stores/project-store';
|
||||
import UserStore from '../stores/user-store';
|
||||
import SimulationStore from '../stores/simulation-store';
|
||||
|
||||
import Table from '../components/table';
|
||||
|
@ -34,13 +35,14 @@ import EditProjectDialog from '../components/dialog/edit-project';
|
|||
|
||||
class Projects extends Component {
|
||||
static getStores() {
|
||||
return [ ProjectStore, SimulationStore ];
|
||||
return [ ProjectStore, SimulationStore, UserStore ];
|
||||
}
|
||||
|
||||
static calculateState() {
|
||||
return {
|
||||
projects: ProjectStore.getState(),
|
||||
simulations: SimulationStore.getState(),
|
||||
sessionToken: UserStore.getState().token,
|
||||
|
||||
newModal: false,
|
||||
editModal: false,
|
||||
|
@ -51,11 +53,13 @@ class Projects extends Component {
|
|||
|
||||
componentWillMount() {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'projects/start-load'
|
||||
type: 'projects/start-load',
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulations/start-load'
|
||||
type: 'simulations/start-load',
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -65,7 +69,8 @@ class Projects extends Component {
|
|||
if (data) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'projects/start-add',
|
||||
data: data
|
||||
data: data,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +80,8 @@ class Projects extends Component {
|
|||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'projects/start-remove',
|
||||
data: this.state.modalData
|
||||
data: this.state.modalData,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -85,7 +91,8 @@ class Projects extends Component {
|
|||
if (data) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'projects/start-edit',
|
||||
data: data
|
||||
data: data,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import { Button, Modal, Glyphicon } from 'react-bootstrap';
|
|||
|
||||
import SimulationStore from '../stores/simulation-store';
|
||||
import NodeStore from '../stores/node-store';
|
||||
import UserStore from '../stores/user-store';
|
||||
import AppDispatcher from '../app-dispatcher';
|
||||
|
||||
import Table from '../components/table';
|
||||
|
@ -34,13 +35,14 @@ import EditSimulationModelDialog from '../components/dialog/edit-simulation-mode
|
|||
|
||||
class Simulation extends Component {
|
||||
static getStores() {
|
||||
return [ SimulationStore, NodeStore ];
|
||||
return [ SimulationStore, NodeStore, UserStore ];
|
||||
}
|
||||
|
||||
static calculateState() {
|
||||
return {
|
||||
simulations: SimulationStore.getState(),
|
||||
nodes: NodeStore.getState(),
|
||||
sessionToken: UserStore.getState().token,
|
||||
|
||||
newModal: false,
|
||||
deleteModal: false,
|
||||
|
@ -54,11 +56,13 @@ class Simulation extends Component {
|
|||
|
||||
componentWillMount() {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulations/start-load'
|
||||
type: 'simulations/start-load',
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'nodes/start-load'
|
||||
type: 'nodes/start-load',
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -86,7 +90,8 @@ class Simulation extends Component {
|
|||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulations/start-edit',
|
||||
data: this.state.simulation
|
||||
data: this.state.simulation,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +105,8 @@ class Simulation extends Component {
|
|||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulations/start-edit',
|
||||
data: simulation
|
||||
data: simulation,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -114,7 +120,8 @@ class Simulation extends Component {
|
|||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulations/start-edit',
|
||||
data: simulation
|
||||
data: simulation,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import { Button, Modal, Glyphicon } from 'react-bootstrap';
|
|||
|
||||
import AppDispatcher from '../app-dispatcher';
|
||||
import SimulationStore from '../stores/simulation-store';
|
||||
import UserStore from '../stores/user-store';
|
||||
|
||||
import Table from '../components/table';
|
||||
import TableColumn from '../components/table-column';
|
||||
|
@ -33,12 +34,13 @@ import EditSimulationDialog from '../components/dialog/edit-simulation';
|
|||
|
||||
class Simulations extends Component {
|
||||
static getStores() {
|
||||
return [ SimulationStore ];
|
||||
return [ SimulationStore, UserStore ];
|
||||
}
|
||||
|
||||
static calculateState() {
|
||||
return {
|
||||
simulations: SimulationStore.getState(),
|
||||
sessionToken: UserStore.getState().token,
|
||||
|
||||
newModal: false,
|
||||
deleteModal: false,
|
||||
|
@ -49,7 +51,8 @@ class Simulations extends Component {
|
|||
|
||||
componentWillMount() {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulations/start-load'
|
||||
type: 'simulations/start-load',
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -59,7 +62,8 @@ class Simulations extends Component {
|
|||
if (data) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulations/start-add',
|
||||
data: data
|
||||
data: data,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +86,8 @@ class Simulations extends Component {
|
|||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulations/start-remove',
|
||||
data: this.state.modalSimulation
|
||||
data: this.state.modalSimulation,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -105,7 +110,8 @@ class Simulations extends Component {
|
|||
if (data) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulations/start-edit',
|
||||
data: data
|
||||
data: data,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import { Button, Modal, Glyphicon } from 'react-bootstrap';
|
|||
|
||||
import AppDispatcher from '../app-dispatcher';
|
||||
import NodeStore from '../stores/node-store';
|
||||
import UserStore from '../stores/user-store';
|
||||
|
||||
import NewNodeDialog from '../components/dialog/new-node';
|
||||
import EditNodeDialog from '../components/dialog/edit-node';
|
||||
|
@ -34,12 +35,13 @@ import NodeTree from '../components/node-tree';
|
|||
|
||||
class Simulators extends Component {
|
||||
static getStores() {
|
||||
return [ NodeStore ];
|
||||
return [ NodeStore, UserStore ];
|
||||
}
|
||||
|
||||
static calculateState() {
|
||||
return {
|
||||
nodes: NodeStore.getState(),
|
||||
sessionToken: UserStore.getState().token,
|
||||
|
||||
newNodeModal: false,
|
||||
deleteNodeModal: false,
|
||||
|
@ -57,7 +59,8 @@ class Simulators extends Component {
|
|||
|
||||
componentWillMount() {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'nodes/start-load'
|
||||
type: 'nodes/start-load',
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -67,7 +70,8 @@ class Simulators extends Component {
|
|||
if (data) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'nodes/start-add',
|
||||
data: data
|
||||
data: data,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +91,8 @@ class Simulators extends Component {
|
|||
if (data) {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'nodes/start-edit',
|
||||
data: data
|
||||
data: data,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +111,8 @@ class Simulators extends Component {
|
|||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'nodes/start-remove',
|
||||
data: this.state.modalData
|
||||
data: this.state.modalData,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -128,7 +134,8 @@ class Simulators extends Component {
|
|||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'nodes/start-edit',
|
||||
data: node
|
||||
data: node,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +158,8 @@ class Simulators extends Component {
|
|||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'nodes/start-edit',
|
||||
data: node
|
||||
data: node,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +182,8 @@ class Simulators extends Component {
|
|||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'nodes/start-edit',
|
||||
data: node
|
||||
data: node,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -183,7 +192,8 @@ class Simulators extends Component {
|
|||
nodes.forEach((node) => {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'nodes/start-edit',
|
||||
data: node
|
||||
data: node,
|
||||
token: this.state.sessionToken
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -73,8 +73,11 @@ class Visualization extends Component {
|
|||
}
|
||||
|
||||
componentWillMount() {
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'visualizations/start-load'
|
||||
type: 'visualizations/start-load',
|
||||
token
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -89,9 +92,12 @@ class Visualization extends Component {
|
|||
if (project._id === this.state.visualization.project) {
|
||||
this.setState({ project: project, simulation: null });
|
||||
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'simulations/start-load',
|
||||
data: project.simulation
|
||||
data: project.simulation,
|
||||
token
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -137,9 +143,12 @@ class Visualization extends Component {
|
|||
|
||||
this.setState({ visualization: visualization, project: null });
|
||||
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'projects/start-load',
|
||||
data: visualization.project
|
||||
data: visualization.project,
|
||||
token
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -268,9 +277,12 @@ class Visualization extends Component {
|
|||
widgets: this.transformToWidgetsList(this.state.visualization.widgets)
|
||||
});
|
||||
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'visualizations/start-edit',
|
||||
data: visualization
|
||||
data: visualization,
|
||||
token
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue