From 45c7295f45837a06723e6b22aa604f76246c4d2b Mon Sep 17 00:00:00 2001 From: Jade McGough Date: Mon, 26 Sep 2016 14:53:59 -0700 Subject: [PATCH] remove reactable, do sorting by hand --- ui/package.json | 1 - ui/src/hosts/components/HostsTable.js | 75 ++++++++++++------- .../style/enterprise_style/application.scss | 3 +- ui/src/style/enterprise_style/hosts.scss | 3 + 4 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 ui/src/style/enterprise_style/hosts.scss diff --git a/ui/package.json b/ui/package.json index a2eb1fe740..b2c55a86e9 100644 --- a/ui/package.json +++ b/ui/package.json @@ -97,7 +97,6 @@ "react-redux": "^4.4.0", "react-router": "^2.4.1", "react-sparklines": "^1.4.2", - "reactable": "^0.14.0", "redux": "^3.3.1", "redux-thunk": "^1.0.3", "updeep": "^0.13.0" diff --git a/ui/src/hosts/components/HostsTable.js b/ui/src/hosts/components/HostsTable.js index 3cdc700685..c546fafd3f 100644 --- a/ui/src/hosts/components/HostsTable.js +++ b/ui/src/hosts/components/HostsTable.js @@ -1,5 +1,5 @@ import React, {PropTypes} from 'react'; -import Reactable from 'reactable'; +import _ from 'lodash'; const HostsTable = React.createClass({ propTypes: { @@ -9,42 +9,67 @@ const HostsTable = React.createClass({ getInitialState() { return { filteredHosts: this.props.hosts, + sortDirection: null, }; }, filterHosts(searchTerm) { - const hosts = this.props.hosts.filter((h) => h.name.search(searchTerm) !== -1); + const unfiltered = this.props.hosts; + const hosts = unfiltered.filter((h) => h.name.search(searchTerm) !== -1); this.setState({filteredHosts: hosts}); }, + changeSort() { + if (this.state.sortDirection === 'asc') { + this.setState({sortDirection: 'desc'}); + } else { + this.setState({sortDirection: 'asc'}); + } + }, + + sort(hosts) { + switch (this.state.sortDirection) { + case 'asc': + return _.sortBy(hosts, (e) => e.name); + case 'desc': + return _.sortBy(hosts, (e) => e.name).reverse(); + default: + return hosts; + } + }, + render() { - const {Table, Thead, Tr, Td, Th} = Reactable; + const hosts = this.sort(this.state.filteredHosts); return (
- - - - - - - - - { - this.state.filteredHosts.map(({name, id}) => { - return ( - - - - - - - - ); - }) - } -
HostnameStatusCPULoadApps
{name}UP98%1.12influxdb, ntp, system
+ + + + + + + + + + + + { + hosts.map(({name, id}) => { + return ( + + + + + + + + ); + }) + } + +
HostnameStatusCPULoadApps
{name}UP98%1.12influxdb, ntp, system
); }, diff --git a/ui/src/style/enterprise_style/application.scss b/ui/src/style/enterprise_style/application.scss index 45e48c5ebd..c1c68c2309 100644 --- a/ui/src/style/enterprise_style/application.scss +++ b/ui/src/style/enterprise_style/application.scss @@ -12,10 +12,11 @@ @import 'signup'; @import 'modals'; @import 'enterprise-custom'; +@import 'hosts'; // Because of some issues with sharing styles across multiple webpack bundles, // we have to import other scss files here instead of in their corresponding // components. There's likely a better fix, but this does for now. @import '../_OverviewPage'; @import '../chronograf/main'; -@import '../_SideNav'; \ No newline at end of file +@import '../_SideNav'; diff --git a/ui/src/style/enterprise_style/hosts.scss b/ui/src/style/enterprise_style/hosts.scss new file mode 100644 index 0000000000..6489c2baf7 --- /dev/null +++ b/ui/src/style/enterprise_style/hosts.scss @@ -0,0 +1,3 @@ +.sortable-header { + cursor: pointer; +}