X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fframework%2Fwidgets%2Fskyquake_container%2FeventCenter.jsx;h=471efd1beadd59bd6e23d6efacd01577f06736ce;hp=7df4e3ec20896f864fa9c607e232c7892c51b2cb;hb=refs%2Ftags%2Fv3.0.0rc2;hpb=f2dc2462571800e62cba969964de621dca09299c diff --git a/skyquake/framework/widgets/skyquake_container/eventCenter.jsx b/skyquake/framework/widgets/skyquake_container/eventCenter.jsx index 7df4e3ec2..471efd1be 100644 --- a/skyquake/framework/widgets/skyquake_container/eventCenter.jsx +++ b/skyquake/framework/widgets/skyquake_container/eventCenter.jsx @@ -16,12 +16,12 @@ * */ - /** - * EventCenter module to display a list of events from the system - * @module framework/widgets/skyquake_container/EventCenter - * @author Kiran Kashalkar - * - */ +/** + * EventCenter module to display a list of events from the system + * @module framework/widgets/skyquake_container/EventCenter + * @author Kiran Kashalkar + * + */ import React from 'react'; import { Link } from 'react-router'; @@ -31,6 +31,8 @@ import TreeView from 'react-treeview'; import _isEqual from 'lodash/isEqual'; import _merge from 'lodash/merge'; import _indexOf from 'lodash/indexOf'; +import _isArray from 'lodash/isArray'; +import _sortBy from 'lodash/sortBy'; import '../../../node_modules/react-treeview/react-treeview.css'; import './eventCenter.scss'; @@ -44,7 +46,6 @@ export default class EventCenter extends React.Component { componentWillReceiveProps(props) { let stateObject = {}; - let notificationList = sessionStorage.getItem('notificationList'); let latestNotification = sessionStorage.getItem('latestNotification'); if (props.newNotificationEvent && props.newNotificationMsg) { @@ -67,21 +68,16 @@ export default class EventCenter extends React.Component { stateObject.newNotificationEvent = false; stateObject.newNotificationMsg = null; } + stateObject.notifications = props.notifications; - if (notificationList) { - stateObject.notifications = _merge(notificationList, props.notifications); - } else { - stateObject.notifications = props.notifications; - } - sessionStorage.setItem('notifications', JSON.stringify(stateObject.notifications)); this.setState(stateObject); } newNotificationReset = () => { - this.setState({ - newNotificationEvent: false - }); - } + this.setState({ + newNotificationEvent: false + }); + } onClickToggleOpenClose(event) { this.props.onToggle(); @@ -92,13 +88,13 @@ export default class EventCenter extends React.Component { constructTree(details) { let markup = []; for (let key in details) { - if (typeof(details[key]) == "object") { - let html = ( - - {this.constructTree(details[key])} - - ); - markup.push(html); + if (typeof (details[key]) == "object") { + let html = ( + + {this.constructTree(details[key])} + + ); + markup.push(html); } else { markup.push((
{key} = {details[key].toString()}
)); } @@ -142,40 +138,42 @@ export default class EventCenter extends React.Component { ); } - this.state.notifications && this.state.notifications.map((notification, notifIndex) => { - let notificationFields = {}; - - notificationFields = this.getNotificationFields(notification); - - displayNotifications.push( - - {notificationFields.source} - {notificationFields.eventTime} - {notificationFields.eventKey} - - - {this.constructTree(notificationFields.details)} - - - - ); - }); + this.state.notifications && + _isArray(this.state.notifications) && + this.state.notifications.map((notification, notifIndex) => { + let notificationFields = {}; + + notificationFields = this.getNotificationFields(notification); + + displayNotifications.push( + + {notificationFields.source} + {notificationFields.eventTime} + {notificationFields.eventKey} + + + {this.constructTree(notificationFields.details)} + + + + ); + }); let openedClassName = this.state.isOpen ? 'open' : 'closed'; html = (
-
-
+
+

EVENT CENTER