target
This commit is contained in:
parent
f7f66116ff
commit
d5be7681dc
|
@ -1,9 +1,9 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Table, Button, Modal, Input, Header, Container, InputOnChangeData, ButtonProps } from 'semantic-ui-react';
|
import { Table, Button, Modal, Input, Header, Container, InputOnChangeData, ButtonProps } from 'semantic-ui-react';
|
||||||
import { TargetDetails } from './TargetDetail';
|
import { TargetDetails } from './TargetDetail';
|
||||||
|
|
||||||
import Target from '@overflow/target/api/model/Target';
|
import Target from '@overflow/target/api/model/Target';
|
||||||
import Probe from '@overflow/probe/api/model/Probe';
|
import Probe from '@overflow/probe/api/model/Probe';
|
||||||
|
import { ListContainer } from '@overflow/commons/react/component/ListContainer';
|
||||||
|
|
||||||
export interface StateProps {
|
export interface StateProps {
|
||||||
|
|
||||||
|
@ -18,34 +18,59 @@ export type Props = StateProps & DispatchProps;
|
||||||
export interface State {
|
export interface State {
|
||||||
selected: Target;
|
selected: Target;
|
||||||
openAddTarget: boolean;
|
openAddTarget: boolean;
|
||||||
|
list: Target[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TargetList extends React.Component<Props, State> {
|
export class TargetList extends React.Component<Props, State> {
|
||||||
|
|
||||||
|
private data: any;
|
||||||
constructor(props: Props, context: State) {
|
constructor(props: Props, context: State) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
this.state = {
|
this.state = {
|
||||||
selected: null,
|
selected: null,
|
||||||
openAddTarget: false,
|
openAddTarget: false,
|
||||||
|
list: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public handleAddTarget(event: React.MouseEvent<HTMLButtonElement>, data: ButtonProps): void {
|
public handleAddTarget(event: React.MouseEvent<HTMLButtonElement>, data: ButtonProps): void {
|
||||||
|
alert('test');
|
||||||
this.setState({
|
this.setState({
|
||||||
openAddTarget: true,
|
openAddTarget: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public handleSearch(result: Target[]): void {
|
||||||
|
this.setState({
|
||||||
|
list: result,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
public handleFilter(filterStr: string): void {
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public render(): JSX.Element {
|
||||||
|
let targetList =
|
||||||
<Container fluid>
|
<Container fluid>
|
||||||
{/*search bar */}
|
{/*search bar */}
|
||||||
|
<Button content='Add' icon='add' labelPosition='left' floated='right' positive onClick={this.handleAddTarget.bind(this)} />
|
||||||
<TargetTable />
|
<TargetTable />
|
||||||
<br />
|
<br />
|
||||||
<Button content='Add' icon='add' labelPosition='left' floated='right' positive onClick={this.handleAddTarget.bind(this)} />
|
|
||||||
<br /><br /><br /><br /><br /><br /><br /><br /><br />
|
|
||||||
<TargetDetails target={this.state.selected} />
|
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
open={this.state.openAddTarget}
|
open={this.state.openAddTarget}
|
||||||
|
@ -61,7 +86,14 @@ export class TargetList extends React.Component<Props, State> {
|
||||||
<Button positive labelPosition='right' icon='checkmark' content='Done' />
|
<Button positive labelPosition='right' icon='checkmark' content='Done' />
|
||||||
</Modal.Actions>
|
</Modal.Actions>
|
||||||
</Modal>
|
</Modal>
|
||||||
</Container>
|
</Container>;
|
||||||
|
return (
|
||||||
|
<ListContainer
|
||||||
|
contents={targetList}
|
||||||
|
data={this.data}
|
||||||
|
onSearch={this.handleSearch.bind(this)}
|
||||||
|
filter={null}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user