mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Add backend offline notification
This commit is contained in:
parent
4a317708b3
commit
b2bd914752
2 changed files with 15 additions and 1 deletions
|
@ -10,10 +10,12 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Container } from 'flux/utils';
|
||||
import { PageHeader } from 'react-bootstrap';
|
||||
import NotificationSystem from 'react-notification-system';
|
||||
|
||||
import LoginForm from '../components/login-form';
|
||||
import Header from '../components/header';
|
||||
import Footer from '../components/footer';
|
||||
import NotificationsDataManager from '../data-managers/notifications-data-manager';
|
||||
|
||||
import AppDispatcher from '../app-dispatcher';
|
||||
import UserStore from '../stores/user-store';
|
||||
|
@ -30,6 +32,10 @@ class Login extends Component {
|
|||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
NotificationsDataManager.setSystem(this.refs.notificationSystem);
|
||||
}
|
||||
|
||||
componentWillUpdate(nextProps, nextState) {
|
||||
// if token stored locally, request user
|
||||
if (nextState.token == null) {
|
||||
|
@ -56,6 +62,8 @@ class Login extends Component {
|
|||
render() {
|
||||
return (
|
||||
<div>
|
||||
<NotificationSystem ref="notificationSystem" />
|
||||
|
||||
<Header />
|
||||
|
||||
<div className="login-container">
|
||||
|
|
|
@ -11,6 +11,7 @@ import { ReduceStore } from 'flux/utils';
|
|||
|
||||
import AppDispatcher from '../app-dispatcher';
|
||||
import UsersDataManager from '../data-managers/users-data-manager';
|
||||
import NotificationsDataManager from '../data-managers/notifications-data-manager';
|
||||
|
||||
class UserStore extends ReduceStore {
|
||||
constructor() {
|
||||
|
@ -50,7 +51,12 @@ class UserStore extends ReduceStore {
|
|||
return Object.assign({}, state, { currentUser: null, token: null });
|
||||
|
||||
case 'users/login-error':
|
||||
console.log(action);
|
||||
// server offline
|
||||
NotificationsDataManager.addNotification({
|
||||
title: 'Server offline',
|
||||
message: 'The server is offline. Please try again later.',
|
||||
level: 'error'
|
||||
});
|
||||
return state;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Add table
Reference in a new issue