mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Add notification system and data managers
Add notification on simulator running state
This commit is contained in:
parent
4c795701b4
commit
3a87013f9b
4 changed files with 46 additions and 2 deletions
|
@ -8,6 +8,7 @@
|
|||
"es6-promise": "^4.0.5",
|
||||
"flux": "^3.1.2",
|
||||
"immutable": "^3.8.1",
|
||||
"rd3": "^0.7.4",
|
||||
"react": "^15.4.2",
|
||||
"react-bootstrap": "^0.30.7",
|
||||
"react-contextmenu": "^2.3.0",
|
||||
|
@ -15,10 +16,10 @@
|
|||
"react-dnd": "^2.2.4",
|
||||
"react-dnd-html5-backend": "^2.2.4",
|
||||
"react-dom": "^15.4.2",
|
||||
"react-notification-system": "^0.2.13",
|
||||
"react-rnd": "^4.2.2",
|
||||
"react-router": "^3.0.2",
|
||||
"superagent": "^3.5.0",
|
||||
"rd3": "^0.7.4"
|
||||
"superagent": "^3.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"react-scripts": "0.9.3"
|
||||
|
|
|
@ -11,11 +11,13 @@ import React, { Component } from 'react';
|
|||
import { Container } from 'flux/utils';
|
||||
import { DragDropContext } from 'react-dnd';
|
||||
import HTML5Backend from 'react-dnd-html5-backend';
|
||||
import NotificationSystem from 'react-notification-system';
|
||||
|
||||
import AppDispatcher from '../app-dispatcher';
|
||||
import SimulationStore from '../stores/simulation-store';
|
||||
import SimulatorStore from '../stores/simulator-store';
|
||||
import UserStore from '../stores/user-store';
|
||||
import NotificationsDataManager from '../data-managers/notifications-data-manager';
|
||||
|
||||
import Header from '../components/header';
|
||||
import Footer from '../components/footer';
|
||||
|
@ -95,6 +97,10 @@ class App extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
NotificationsDataManager.setSystem(this.refs.notificationSystem);
|
||||
}
|
||||
|
||||
componentWillUpdate(nextProps, nextState) {
|
||||
// check if user is still logged in
|
||||
if (nextState.token == null) {
|
||||
|
@ -160,6 +166,8 @@ class App extends Component {
|
|||
|
||||
return (
|
||||
<div className="app">
|
||||
<NotificationSystem ref="notificationSystem" />
|
||||
|
||||
<Header />
|
||||
<SidebarMenu />
|
||||
|
||||
|
|
22
src/data-managers/notifications-data-manager.js
Normal file
22
src/data-managers/notifications-data-manager.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* File: notifications-data-manager.js
|
||||
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
|
||||
* Date: 21.03.2017
|
||||
* Copyright: 2017, Institute for Automation of Complex Power Systems, EONERC
|
||||
* This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
**********************************************************************************/
|
||||
|
||||
class NotificationsDataManager {
|
||||
_notificationSystem = null;
|
||||
|
||||
setSystem(notificationSystem) {
|
||||
this._notificationSystem = notificationSystem;
|
||||
}
|
||||
|
||||
addNotification(notification) {
|
||||
this._notificationSystem.addNotification(notification);
|
||||
}
|
||||
}
|
||||
|
||||
export default new NotificationsDataManager();
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
import ArrayStore from './array-store';
|
||||
import SimulatorsDataManager from '../data-managers/simulators-data-manager';
|
||||
import NotificationsDataManager from '../data-managers/notifications-data-manager';
|
||||
|
||||
class SimulatorStore extends ArrayStore {
|
||||
constructor() {
|
||||
|
@ -51,6 +52,12 @@ class SimulatorStore extends ArrayStore {
|
|||
return element._id === action.identifier;
|
||||
});
|
||||
|
||||
NotificationsDataManager.addNotification({
|
||||
title: 'Simulator online',
|
||||
message: 'Simulator \'' + simulator.name + '\' went online.',
|
||||
level: 'info'
|
||||
});
|
||||
|
||||
// restart requesting again
|
||||
SimulatorsDataManager.stopRunningDetection(simulator);
|
||||
|
||||
|
@ -65,6 +72,12 @@ class SimulatorStore extends ArrayStore {
|
|||
// update running state
|
||||
simulator.running = false;
|
||||
|
||||
NotificationsDataManager.addNotification({
|
||||
title: 'Simulator offline',
|
||||
message: 'Simulator \'' + simulator.name + '\' went offline.',
|
||||
level: 'info'
|
||||
});
|
||||
|
||||
// restart requesting again
|
||||
SimulatorsDataManager.startRunningDetection(simulator);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue