This commit is contained in:
snoop 2017-07-28 18:37:19 +09:00
parent 0acc9791dc
commit 821effa2ad
2 changed files with 0 additions and 222 deletions

View File

@ -1,28 +0,0 @@
import { connect, Dispatch } from 'react-redux';
import {
SensorDetail,
SensorDetailStateProps,
SensorDetailDispatchProps,
} from './components/SensorDetail';
import State from '../redux/state/Read';
import * as ReadActions from '../redux/action/read';
import Target from '@overflow/target/api/model/Target';
import Sensor from '@overflow/sensor/api/model/Sensor';
export function mapStateToProps(state: any): SensorDetailStateProps {
return {
sensor:state.sensor,
};
}
export function mapDispatchToProps(dispatch: Dispatch<any>): SensorDetailDispatchProps {
return {
onRead: (id: number) => {
dispatch(ReadActions.request(id));
},
};
}
export default connect(mapStateToProps, mapDispatchToProps)(SensorDetail);

View File

@ -1,194 +0,0 @@
import * as React from 'react';
import { Button, Table, Label, Segment, Header, Container } from 'semantic-ui-react';
import { DetailContainer } from '@overflow/commons/react/component/DetailContainer';
import { SensorDetailItems } from './SensorDetailItems';
import Sensor from '@overflow/sensor/api/model/Sensor';
import Probe from '@overflow/probe/api/model/Probe';
export interface SensorDetailStateProps {
sensor?: Sensor;
probe?: Probe;
}
export interface SensorDetailDispatchProps {
onRead?(id: number): void;
}
export type SensorDetailProps = SensorDetailStateProps & SensorDetailDispatchProps;
export interface SensorDetailsState {
}
export class SensorDetail extends React.Component<SensorDetailProps, SensorDetailsState> {
constructor(props: SensorDetailProps, context: SensorDetailsState) {
super(props, context);
this.state = {
};
}
public componentWillMount(): void {
console.log('');
}
public render(): JSX.Element {
const items = [
{ name: 'Info', child: <SensorBasicInfo sensor={this.props.sensor} /> },
{ name: 'Sensor Items', child: <SensorDetailItems sensor={this.props.sensor} /> },
];
const data = { 'probe': this.props.probe };
return (
<DetailContainer panes={items} data={data} />
);
}
}
export interface SensorBasicInfoProps {
sensor?: Sensor;
probe?: Probe;
onBack?(): void;
}
export interface SensorBasicInfoState {
sensor: Sensor;
}
export class SensorBasicInfo extends React.Component<SensorBasicInfoProps, SensorBasicInfoState> {
constructor(props: SensorBasicInfoProps, context: SensorBasicInfoState) {
super(props, context);
this.state = {
sensor: SensorDetailJson,
};
}
public handleStartStop(event: any, data: any): void {
console.log(event);
}
public handleDiscovery(event: any, data: any): void {
alert('Discovery');
}
public handleBack(event: any, data: any): void {
this.props.onBack();
}
public componentWillMount(): void {
console.log('');
}
public showStartStopBtn(): JSX.Element {
if (this.state.sensor.status.name === 'STARTED') {
return <Button content='Stop' icon='stop' labelPosition='left' color={'blue'} floated={'right'} onClick={this.handleStartStop} />;
} else {
return <Button content='Start' icon='play' labelPosition='left' color={'blue'} floated={'right'} onClick={this.handleStartStop} />;
}
}
public render(): JSX.Element {
return (
<Container fluid>
<Table celled>
<Table.Body>
<Table.Row>
<Table.Cell>
<Header size='small'>Name</Header>
</Table.Cell>
<Table.Cell>{this.state.sensor.target.displayName}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
<Header size='small'>Status</Header>
</Table.Cell>
<Table.Cell>{this.state.sensor.status.name}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
<Header size='small'>Crawler</Header>
</Table.Cell>
<Table.Cell>{this.state.sensor.crawler.name}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
<Header size='small'>Item Count</Header>
</Table.Cell>
<Table.Cell>{44}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
<Header size='small'>Created at</Header>
</Table.Cell>
<Table.Cell>{this.state.sensor.createDate}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
<Header size='small'>Created by</Header>
</Table.Cell>
<Table.Cell>test Snoop</Table.Cell>
</Table.Row>
</Table.Body>
</Table>
<Button content='Back' icon='left arrow' labelPosition='left' onClick={this.handleBack.bind(this)} />
<Button content='Discovery' icon='search' labelPosition='left' floated={'right'} positive onClick={this.handleDiscovery} />
{/*{this.showStartStopBtn()}*/}
</Container>
);
}
}
const SensorDetailJson: any = {
'id': 1,
'createDate': 1498475947009,
'description': 'My sensor',
'status': {
'id': 1,
'name': 'RUNNING',
},
'target': {
'id': 1,
'createDate': 1498448242854,
'probe': {
'id': 1,
'status': {
'id': 1,
'name': 'INITIAL',
},
'description': 'snoop probe',
'createDate': 1498448699813,
'lastPollingDate': null,
'nextPollingDate': null,
'domain': {
'id': 1,
'name': 'overFlow\'s domain',
'createDate': 1498443944866,
},
'probeKey': 'a1e1710557de11e78799080027658d13',
'encryptionKey': '9c8d41ab57de11e7a2c9080027658d13',
},
'infra': {
'id': 1,
'type': {
'id': 1,
'name': 'MACHINE',
'createDate': 1498379502770,
},
'childId': 0,
'createDate': 1498446731809,
},
},
'crawler': {
'id': 1,
'createDate': 1498794968791,
'name': 'ACTIVEDIRECTORY_CRAWLER',
'description': 'ACTIVEDIRECTORY',
},
'crawlerInputItems': null,
};