diff --git a/src/ts/containers/test/Probes.tsx b/src/ts/containers/test/Probes.tsx index dba2358..2e92ad2 100644 --- a/src/ts/containers/test/Probes.tsx +++ b/src/ts/containers/test/Probes.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Table, Header, Container } from 'semantic-ui-react'; +import { Table, Header, Container, Form, Checkbox, Button } from 'semantic-ui-react'; import { ProbeDetails } from './ProbeDetails'; import { ListContainer } from './commons/ListContainer'; @@ -12,6 +12,7 @@ export class Probes extends React.Component { this.state = { selected: null, isDetail: false, + list: [], }; } @@ -23,7 +24,7 @@ export class Probes extends React.Component { "name": "STARTED" }, "domain": { - "name": "overFlow's domain111" + "name": "asus" }, "probeKey": "AGBLKDFJ2452ASDGFL2KWJLKSDJ", "description": "description1111111111", @@ -34,7 +35,7 @@ export class Probes extends React.Component { "name": "STOPPED" }, "domain": { - "name": "overFlow's domain222" + "name": "ottugi" }, "probeKey": "AGBLKDFJ2452ASDGFL2KWJLKSDJ", "description": "description22222222", @@ -45,7 +46,7 @@ export class Probes extends React.Component { "name": "STOPPED" }, "domain": { - "name": "overFlow's domain333" + "name": "lg" }, "probeKey": "AGBLKDFJ2452ASDGFL2KWJLKSDJ", "description": "description33333", @@ -56,12 +57,15 @@ export class Probes extends React.Component { "name": "STARTED" }, "domain": { - "name": "overFlow's domain444" + "name": "apple" }, "probeKey": "AGBLKDFJ2452ASDGFL2KWJLKSDJ", "description": "description4444", }, ]; + this.setState({ + list: this.data, + }); } checkCellStatus(status: any): boolean { @@ -78,6 +82,39 @@ export class Probes extends React.Component { }); } + handleSearch(searchWord: string) { + console.log(searchWord); + let founds = new Array(); + for (let probe of this.data) { + if (probe.domain.name.toLowerCase().indexOf(searchWord) !== -1 + || probe.description.toLowerCase().indexOf(searchWord) !== -1 + || probe.metaProbeStatus.name.toLowerCase().indexOf(searchWord) !== -1) { + founds.push(probe); + } + } + this.setState({ + list: founds, + }); + } + + handleFilter(filterStr: string) { + if (filterStr === null) { + this.setState({ + list: this.data, + }); + return; + } + let founds = new Array(); + for (let probe of this.data) { + if (probe.metaProbeStatus.name.indexOf(filterStr) !== -1) { + founds.push(probe); + } + } + this.setState({ + list: founds, + }); + } + render() { if (this.state.isDetail) { return this.setState({ isDetail: false })} />; @@ -96,10 +133,10 @@ export class Probes extends React.Component { - {this.data.map((probe: any, index: number) => ( + {this.state.list.map((probe: any, index: number) => ( - todo. {probe.name} - todo. {probe.cidr} + {probe.domain.name} + {index} {probe.metaProbeStatus.name} todo. {probe.targetCnt} todo. {probe.sensorCnt} @@ -110,7 +147,71 @@ export class Probes extends React.Component { ; return ( - + } + onSearch={this.handleSearch.bind(this)} + /> + ); + } +} + +export class ProbeFilter extends React.Component { + + constructor(props: any, context: any) { + super(props, context); + this.state = { + status: null, + }; + } + + handleChange(e: any, data: any) { + this.setState({ + status: data.value, + }); + this.props.onFilter(data.value); + } + handleReset(e: any, data: any) { + this.setState({ + status: null, + }); + this.props.onFilter(null); + } + + render() { + //todo. getting MetaProbeStatus + let metaProbeStatus = [ + { + "id": "1", + "name": "STARTED", + }, + { + "id": "2", + "name": "STOPPED", + }, + ]; + return ( +
+ +