mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 02:30:45 +00:00
* better state visibility * pure state changes * state debug panel (show: crtl-h, move: ctrl-w)
55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
import React from 'react';
|
|
import { connect } from 'react-redux';
|
|
|
|
class Status extends React.Component {
|
|
render() {
|
|
const {errorUrl, topologiesLoaded, topology, websocketClosed} = this.props;
|
|
|
|
let title = '';
|
|
let text = 'Trying to reconnect...';
|
|
let showWarningIcon = false;
|
|
let classNames = 'status sidebar-item';
|
|
|
|
if (errorUrl) {
|
|
title = `Cannot reach Scope. Make sure the following URL is reachable: ${errorUrl}`;
|
|
classNames += ' status-loading';
|
|
showWarningIcon = true;
|
|
} else if (!topologiesLoaded) {
|
|
text = 'Connecting to Scope...';
|
|
classNames += ' status-loading';
|
|
showWarningIcon = true;
|
|
} else if (websocketClosed) {
|
|
classNames += ' status-loading';
|
|
showWarningIcon = true;
|
|
} else if (topology) {
|
|
const stats = topology.get('stats');
|
|
text = `${stats.get('node_count')} nodes`;
|
|
if (stats.get('filtered_nodes')) {
|
|
text = `${text} (${stats.get('filtered_nodes')} filtered)`;
|
|
}
|
|
classNames += ' status-stats';
|
|
showWarningIcon = false;
|
|
}
|
|
|
|
return (
|
|
<div className={classNames}>
|
|
{showWarningIcon && <span className="status-icon fa fa-exclamation-circle" />}
|
|
<span className="status-label" title={title}>{text}</span>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
function mapStateToProps(state) {
|
|
return {
|
|
errorUrl: state.get('errorUrl'),
|
|
topologiesLoaded: state.get('topologiesLoaded'),
|
|
topology: state.get('currentTopology'),
|
|
websocketClosed: state.get('websocketClosed')
|
|
};
|
|
}
|
|
|
|
export default connect(
|
|
mapStateToProps
|
|
)(Status);
|