Skip to content

Commit 788993d

Browse files
committed
Tweaks to rendering
1 parent 1eddda0 commit 788993d

File tree

17 files changed

+447
-216
lines changed

17 files changed

+447
-216
lines changed

app/components/EonDetail/StateList/StateListToolbar.js

Lines changed: 0 additions & 131 deletions
This file was deleted.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import * as UiActions from '../../../../actions/ui_actions';
4+
import { bindActionCreators } from 'redux';
5+
import { connect } from 'react-redux';
6+
import { Dropdown, DropdownItem, DropdownToggle, DropdownMenu } from 'reactstrap';
7+
import { getDepthState } from '../../../../selectors/selectors';
8+
9+
const propTypes = {
10+
paused: PropTypes.bool,
11+
depth: PropTypes.number,
12+
messageCount: PropTypes.number
13+
};
14+
15+
class StateTypeDropdown extends Component {
16+
constructor(props) {
17+
super(props);
18+
19+
this.state = {
20+
servicelistOpen: false,
21+
dropdownOpen: false
22+
};
23+
}
24+
toggleServiceList = () => {
25+
this.setState({
26+
servicelistOpen: !this.state.servicelistOpen
27+
});
28+
}
29+
toggle = () => {
30+
this.setState({
31+
dropdownOpen: !this.state.dropdownOpen
32+
});
33+
}
34+
setService = (serviceKey) => {
35+
this.props.DISCONNECT(this.props.type);
36+
this.props.CHANGE_TAB(serviceKey);
37+
this.props.CONNECT(serviceKey);
38+
}
39+
setDepth = (depth) => {
40+
this.props.SET_STATE_LIST_DEPTH(depth);
41+
}
42+
togglePause = () => {
43+
this.props.TOGGLE_PAUSE();
44+
}
45+
46+
render() {
47+
const { depth } = this.props;
48+
return (
49+
<Dropdown nav isOpen={this.state.dropdownOpen} toggle={this.toggle}>
50+
<DropdownToggle nav caret>
51+
Depth: {depth + ""}
52+
</DropdownToggle>
53+
<DropdownMenu>
54+
<DropdownItem onClick={() => { this.setDepth(0); }}>0</DropdownItem>
55+
<DropdownItem onClick={() => { this.setDepth(1); }}>1</DropdownItem>
56+
<DropdownItem onClick={() => { this.setDepth(2); }}>2</DropdownItem>
57+
<DropdownItem onClick={() => { this.setDepth(3); }}>3</DropdownItem>
58+
</DropdownMenu>
59+
</Dropdown>
60+
);
61+
}
62+
}
63+
64+
StateDepthDropdown.propTypes = propTypes;
65+
66+
function mapDispatchToProps(dispatch) {
67+
return bindActionCreators(...UiActions, dispatch);
68+
}
69+
70+
const mapStateToProps = (state, props) => {
71+
return {
72+
depth: getDepthState(state)
73+
};
74+
};
75+
76+
export default connect(
77+
mapStateToProps,
78+
mapDispatchToProps
79+
)(StateDepthDropdown);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { connect } from 'react-redux';
4+
import { NavItem, NavLink } from 'reactstrap';
5+
import { getMessageCountState } from '../../../../selectors/selectors';
6+
const propTypes = {
7+
messageCount: PropTypes.number
8+
};
9+
10+
class StateMessages extends Component {
11+
render() {
12+
const { messageCount } = this.props;
13+
return (
14+
<NavItem>
15+
<NavLink disabled href="#">Messages: {messageCount}</NavLink>
16+
</NavItem>
17+
)
18+
}
19+
}
20+
21+
StateMessages.propTypes = propTypes;
22+
23+
24+
const mapStateToProps = (state) => {
25+
return {
26+
messageCount: getMessageCountState(state)
27+
};
28+
};
29+
30+
export default connect(
31+
mapStateToProps
32+
)(StateMessages);
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import * as ZmqActions from '../../../../actions/zmq_actions';
4+
import * as UiActions from '../../../../actions/ui_actions';
5+
import * as EonActions from '../../../../actions/eon_detail_actions';
6+
import { bindActionCreators } from 'redux';
7+
import { connect } from 'react-redux';
8+
import { Nav, NavItem, Dropdown, DropdownItem, DropdownToggle, DropdownMenu, NavLink } from 'reactstrap';
9+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
10+
import { getZmqServicesState, getZmqServicesIdsSortedState, getActiveTabState} from '../../../../selectors/selectors';
11+
const propTypes = {
12+
services: PropTypes.object,
13+
activeTab: PropTypes.object,
14+
serviceIds: PropTypes.array
15+
};
16+
17+
class StateTypeDropdown extends Component {
18+
constructor(props) {
19+
super(props);
20+
21+
this.state = {
22+
servicelistOpen: false,
23+
dropdownOpen: false
24+
};
25+
}
26+
toggleServiceList = () => {
27+
this.setState({
28+
servicelistOpen: !this.state.servicelistOpen
29+
});
30+
}
31+
toggle = () => {
32+
this.setState({
33+
dropdownOpen: !this.state.dropdownOpen
34+
});
35+
}
36+
setService = (serviceKey) => {
37+
this.props.DISCONNECT(this.props.type);
38+
this.props.CHANGE_TAB(serviceKey);
39+
this.props.CONNECT(serviceKey);
40+
}
41+
setDepth = (depth) => {
42+
this.props.SET_STATE_LIST_DEPTH(depth);
43+
}
44+
togglePause = () => {
45+
this.props.TOGGLE_PAUSE();
46+
}
47+
48+
render() {
49+
const { serviceIds, services, activeService } = this.props;
50+
const stateTabs = serviceIds.map((key) => {
51+
const service = services[key];
52+
return (
53+
<DropdownItem onClick={() => { this.setService(key); }} id={key + "-tab-link"} key={key + "-tab-link"}>{service.label}</DropdownItem>
54+
);
55+
});
56+
return (<Dropdown nav isOpen={this.state.servicelistOpen} toggle={this.toggleServiceList}>
57+
<DropdownToggle nav caret>
58+
{activeService.label}
59+
{!activeService.id && "Inactive"}
60+
</DropdownToggle>
61+
<DropdownMenu className="service-list-dropdown">
62+
{stateTabs}
63+
</DropdownMenu>
64+
</Dropdown>
65+
);
66+
}
67+
}
68+
69+
StateTypeDropdown.propTypes = propTypes;
70+
71+
function mapDispatchToProps(dispatch) {
72+
return bindActionCreators({...ZmqActions,...EonActions,...UiActions}, dispatch);
73+
}
74+
75+
const mapStateToProps = (state) => {
76+
return {
77+
serviceIds: getZmqServicesIdsSortedState(state),
78+
services: getZmqServicesState(state),
79+
activeService: getActiveTabState(state)
80+
};
81+
};
82+
83+
export default connect(
84+
mapStateToProps,
85+
mapDispatchToProps
86+
)(StateTypeDropdown);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React, { Component } from 'react';
2+
import { Nav } from 'reactstrap';
3+
import StateMessages from './StateMessages';
4+
import StateTypeDropdown from './StateTypeDropdown';
5+
const propTypes = {};
6+
7+
class StateListToolbar extends Component {
8+
render() {
9+
return (
10+
<Nav className="events-toolbar">
11+
<StateTypeDropdown />
12+
<StateMessages />
13+
</Nav>
14+
)
15+
}
16+
}
17+
// <NavItem>
18+
// <NavLink href="#" onClick={this.togglePause}>
19+
// {paused && <FontAwesomeIcon icon={"play"} />}
20+
// {!paused && <FontAwesomeIcon icon={"pause"} />}
21+
// </NavLink>
22+
// </NavItem>
23+
StateListToolbar.propTypes = propTypes;
24+
25+
// function mapDispatchToProps(dispatch) {
26+
// return bindActionCreators({}, dispatch);
27+
// }
28+
29+
const mapStateToProps = (state, props) => {
30+
return {};
31+
};
32+
33+
export default StateListToolbar;

0 commit comments

Comments
 (0)