diff --git a/react/src/components/dashboard/notifications.js b/react/src/components/dashboard/notifications.js index c7cc783..1acf7f4 100755 --- a/react/src/components/dashboard/notifications.js +++ b/react/src/components/dashboard/notifications.js @@ -12,10 +12,12 @@ class Notifications extends React.Component { super(props); this.state = { displayModal: false, - totalCalls: 0, - totalErrorCalls: 0, - totalSuccessCalls: 0, - totalPendingCalls: 0, + calls: { + total: 0, + error: 0, + success: 0, + pending: 0, + }, activeTab: 2, guiLog: null, }; @@ -33,31 +35,27 @@ class Notifications extends React.Component { if (this.props.Dashboard && this.props.Dashboard.guiLog) { const _guiLog = this.props.Dashboard.guiLog; - let totalCalls = Object.keys(_guiLog).length; - let totalErrorCalls = 0; - let totalSuccessCalls = 0; - let totalPendingCalls = 0; + let _callsLength = { + total: Object.keys(_guiLog).length, + error: 0, + success: 0, + pending: 0, + } + let guiLogToArray = []; for (let timestamp in _guiLog) { guiLogToArray.push(_guiLog[timestamp]); - - if (_guiLog[timestamp].status === 'error') { - totalErrorCalls++; - } - if (_guiLog[timestamp].status === 'success') { - totalSuccessCalls++; - } - if (_guiLog[timestamp].status === 'pending') { - totalPendingCalls++; - } + _callsLength[_guiLog[timestamp].status]++; } this.setState(Object.assign({}, this.state, { - totalCalls, - totalErrorCalls, - totalSuccessCalls, - totalPendingCalls, + calls: { + total: _callsLength.total, + error: _callsLength.error, + success: _callsLength.success, + pending: _callsLength.pending, + }, guiLog: guiLogToArray, })); } @@ -70,7 +68,6 @@ class Notifications extends React.Component { let _guiLog = this.state.guiLog; _guiLog = sortByDate(_guiLog); let items = []; - let index = 0; for (let i = 0; i < _guiLog.length; i++) { if (_guiLog[i].status === type) { @@ -78,7 +75,7 @@ class Notifications extends React.Component { items.push(