From d241b62ecd5bcf2841235847351e46b4603f8576 Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 9 Nov 2017 17:41:21 +0900 Subject: [PATCH] model's arranging --- .../react/components/chart/LoadChartLinux.tsx | 4 +- src/ts/@overflow/probe/api/model/Probe.ts | 4 +- .../probe/react/components/ProbeList.tsx | 15 +- src/ts/@overflow/sensor/api/model/Sensor.ts | 1 + .../react/components/SensorConfigStepper.tsx | 6 +- .../react/components/SensorDetailInfo.tsx | 2 +- .../react/components/SensorDetailItems.tsx | 172 ++++++------------ .../sensor/react/components/SensorList.tsx | 2 +- src/ts/@overflow/target/api/model/Target.ts | 2 + .../target/react/components/TargetDetail.tsx | 15 +- .../target/react/components/TargetList.tsx | 17 +- 11 files changed, 102 insertions(+), 138 deletions(-) diff --git a/src/ts/@overflow/metric/react/components/chart/LoadChartLinux.tsx b/src/ts/@overflow/metric/react/components/chart/LoadChartLinux.tsx index d3eeac1..e491494 100644 --- a/src/ts/@overflow/metric/react/components/chart/LoadChartLinux.tsx +++ b/src/ts/@overflow/metric/react/components/chart/LoadChartLinux.tsx @@ -34,8 +34,8 @@ export class LoadChartLinux extends React.Component { public render(): JSX.Element { return ( - - + diff --git a/src/ts/@overflow/probe/api/model/Probe.ts b/src/ts/@overflow/probe/api/model/Probe.ts index 1a42e0d..770350e 100644 --- a/src/ts/@overflow/probe/api/model/Probe.ts +++ b/src/ts/@overflow/probe/api/model/Probe.ts @@ -1,6 +1,7 @@ import MetaProbeStatus from '@overflow/meta/api/model/MetaProbeStatus'; import Domain from '@overflow/domain/api/model/Domain'; import Member from '@overflow/member/api/model/Member'; +import Target from '@overflow/target/api/model/Target'; import InfraHost from '@overflow/infra/api/model/InfraHost'; interface Probe { @@ -11,13 +12,12 @@ interface Probe { domain?: Domain; probeKey?: string; encryptionKey?: string; - targetCount?: number; - sensorCount?: number; displayName?: string; cidr?: string; authorizeDate?: Date; authorizeMember?: Member; host?: InfraHost; + targets?: Target[]; } export default Probe; diff --git a/src/ts/@overflow/probe/react/components/ProbeList.tsx b/src/ts/@overflow/probe/react/components/ProbeList.tsx index 9164177..41c2f4d 100644 --- a/src/ts/@overflow/probe/react/components/ProbeList.tsx +++ b/src/ts/@overflow/probe/react/components/ProbeList.tsx @@ -3,6 +3,7 @@ import { Table, Header, Container, Form, Checkbox, Button } from 'semantic-ui-re import { ListContainer } from '@overflow/commons/react/component/ListContainer'; import Probe from '@overflow/probe/api/model/Probe'; import Domain from '@overflow/domain/api/model/Domain'; +import Infra from '@overflow/infra/api/model/Infra'; export interface StateProps { probeList?: Probe[]; @@ -85,8 +86,7 @@ export class ProbeList extends React.Component { CIDR IP Status - Target Count - Sensor Count + Targets @@ -121,11 +121,18 @@ export class ProbeList extends React.Component { {probe.cidr} todo {probe.status.name} - {probe.targetCount} - {probe.sensorCount} + {this.listTargets(probe)} )); } + private listTargets(probe: Probe): JSX.Element[] { + if(probe.targets === null || probe.targets.length === 0) { + return null; + } + return probe.targets.map((infra: Infra, index: number) => ( +
{infra.target.displayName}
+ )); + } } export class ProbeFilter extends React.Component { diff --git a/src/ts/@overflow/sensor/api/model/Sensor.ts b/src/ts/@overflow/sensor/api/model/Sensor.ts index 04fe7f9..fb530ee 100644 --- a/src/ts/@overflow/sensor/api/model/Sensor.ts +++ b/src/ts/@overflow/sensor/api/model/Sensor.ts @@ -10,6 +10,7 @@ interface Sensor { target?: Target; crawler?: MetaCrawler; crawlerInputItems?: string; + itemCount?: number; } export default Sensor; diff --git a/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx b/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx index 4199a95..463f1a8 100644 --- a/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorConfigStepper.tsx @@ -188,7 +188,6 @@ export class SensorConfigStepper extends React.Component = new Array; @@ -200,6 +199,7 @@ export class SensorConfigStepper extends React.Component - + - + diff --git a/src/ts/@overflow/sensor/react/components/SensorDetailInfo.tsx b/src/ts/@overflow/sensor/react/components/SensorDetailInfo.tsx index 8ec70c5..761fba7 100644 --- a/src/ts/@overflow/sensor/react/components/SensorDetailInfo.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorDetailInfo.tsx @@ -101,7 +101,7 @@ export class SensorDetailInfo extends React.Component
Item Count
- {44} + {this.props.sensor.itemCount} diff --git a/src/ts/@overflow/sensor/react/components/SensorDetailItems.tsx b/src/ts/@overflow/sensor/react/components/SensorDetailItems.tsx index 4e061ed..cfd9b56 100644 --- a/src/ts/@overflow/sensor/react/components/SensorDetailItems.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorDetailItems.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Table, Button, Header, Container } from 'semantic-ui-react'; +import { Table, Button, Header, Container, Card, Image, Icon } from 'semantic-ui-react'; import Sensor from '@overflow/sensor/api/model/Sensor'; import SensorItem from '@overflow/sensor/api/model/SensorItem'; @@ -7,6 +7,7 @@ import Page from '@overflow/commons/api/model/Page'; import { Pager } from '@overflow/commons/react/component/Pager'; import PageParams from '@overflow/commons/api/model/PageParams'; import { SortTableHeaderRow } from '@overflow/commons/react/component/SortTableHeaderRow'; +import { LoadChartLinux } from '@overflow/metric/react/components/chart/LoadChartLinux'; export interface StateProps { sensorId?: number; @@ -26,9 +27,9 @@ export interface State { export class SensorDetailItems extends React.Component { - private countPerPage: number = 10; + private countPerPage: number = 100000; private sortCol: string = 'id'; - private sortDirection: string = 'descending'; + private sortDirection: string = 'ascending'; private pageNo: number = 0; constructor(props: Props, context: State) { @@ -50,42 +51,24 @@ export class SensorDetailItems extends React.Component { this.props.onReadAllBySensor({ id: this.props.sensorId }, pageParams); } - public componentWillMount(): void { - console.log(''); - } - - private handlePaging = (pageNo: number) => { - this.pageNo = pageNo; - const pageParams: PageParams = { - pageNo: String(this.pageNo), - countPerPage: String(this.countPerPage), - sortCol: this.sortCol, - sortDirection: this.sortDirection, - }; - this.props.onReadAllBySensor({ id: this.props.sensorId }, pageParams); - } public render(): JSX.Element { if (this.props.sensorItemList === undefined) { return null; } - let colsmap: Map = new Map(); - colsmap.set('No.', 'id'); - colsmap.set('Type', 'item.itemType.name'); - colsmap.set('Name', 'item.name'); - colsmap.set('Key', 'item.key'); + // let colsmap: Map = new Map(); + // colsmap.set('Type', 'item.itemType.name'); + // colsmap.set('Name', 'item.displayName'); + // colsmap.set('Unit', 'item.unit.mark'); + // colsmap.set('Description', 'item.description'); return ( - + {this.renderSensorItemInfo()} + + {/*
- {/* - No. - Type - Name - Key - */} @@ -93,10 +76,10 @@ export class SensorDetailItems extends React.Component { this.props.sensorItemList.content ? this.props.sensorItemList.content.map((sensorItem: SensorItem, idx: number) => { return ( - {idx} - {sensorItem.item.itemType.name} - {sensorItem.item.name} - {sensorItem.item.key} + {sensorItem.item.itemType.name} + {sensorItem.item.displayName} + {sensorItem.item.unit.mark} + {sensorItem.item.description} ); }) : '' @@ -109,94 +92,45 @@ export class SensorDetailItems extends React.Component { -
+ */}
); } - private handleSort = (col: string, direction: string): void => { - console.log(col + ' || direction:' + direction); - this.sortCol = col; - this.sortDirection = direction; - this.getData(); + private renderSensorItemInfo(): JSX.Element { + return this.props.sensorItemList.content.map((sensorItem: SensorItem, index: number) => ( + + + {sensorItem.item.displayName} + + {sensorItem.item.description} + + {sensorItem.sensor.crawler.name} + + + {this.getChart(sensorItem)} + + + )); } + private getChart(sensorItem: SensorItem): JSX.Element { + return ; + } + + // private handleSort = (col: string, direction: string): void => { + // console.log(col + ' || direction:' + direction); + // this.sortCol = col; + // this.sortDirection = direction; + // this.getData(); + // } + // private handlePaging = (pageNo: number) => { + // this.pageNo = pageNo; + // const pageParams: PageParams = { + // pageNo: String(this.pageNo), + // countPerPage: String(this.countPerPage), + // sortCol: this.sortCol, + // sortDirection: this.sortDirection, + // }; + // this.props.onReadAllBySensor({ id: this.props.sensorId }, pageParams); + // } + } - - - -// const SensorItemJson: any = [{ -// 'id': 1, -// 'sensor': { -// 'id': 1, -// 'createDate': 1498475947009, -// 'description': 'My sensor', -// 'status': { -// 'id': 1, -// 'name': 'RUNNING', -// }, -// 'target': { -// 'id': 1, -// 'createDate': 1501154289555, -// 'displayName': 'ghost target', -// 'description': 'i am target', -// }, -// 'crawler': { -// 'id': 1, -// 'createDate': 1498794968791, -// 'name': 'ACTIVEDIRECTORY_CRAWLER', -// 'description': 'ACTIVEDIRECTORY', -// }, -// 'crawlerInputItems': null, -// }, -// 'item': { -// 'id': 1, -// 'itemType': { -// 'id': 1, -// 'name': 'CPU', -// 'description': 'CPU blah blah blah', -// 'createDate': 1498474179690, -// }, -// 'key': 'cpu.usage', -// 'name': 'CPU USAGE', -// 'createDate': 1498475408269, -// }, -// 'createDate': 1498476076626, -// }, -// { -// 'id': 2, -// 'sensor': { -// 'id': 1, -// 'createDate': 1498475947074, -// 'description': 'My sensor', -// 'status': { -// 'id': 1, -// 'name': 'RUNNING', -// }, -// 'target': { -// 'id': 1, -// 'createDate': 1501154289555, -// 'displayName': 'ghost target', -// 'description': 'i am target', -// }, -// 'crawler': { -// 'id': 1, -// 'createDate': 1498794968791, -// 'name': 'ACTIVEDIRECTORY_CRAWLER', -// 'description': 'ACTIVEDIRECTORY', -// }, -// 'crawlerInputItems': null, -// }, -// 'item': { -// 'id': 2, -// 'itemType': { -// 'id': 1, -// 'name': 'CPU', -// 'description': 'CPU blah blah blah', -// 'createDate': 1498474179690, -// }, -// 'key': 'cpu.free', -// 'name': 'CPU FREE', -// 'createDate': 1498475408361, -// }, -// 'createDate': 1498476110988, -// }, -// ]; diff --git a/src/ts/@overflow/sensor/react/components/SensorList.tsx b/src/ts/@overflow/sensor/react/components/SensorList.tsx index cc74cb3..edcd134 100644 --- a/src/ts/@overflow/sensor/react/components/SensorList.tsx +++ b/src/ts/@overflow/sensor/react/components/SensorList.tsx @@ -132,7 +132,7 @@ export class SensorList extends React.Component
{sensor.crawler.name}
{sensor.description} - to do + {sensor.itemCount} {/* {this.showStartStopBtn(sensor.metaSensorStatus)} */}
)) : ''} diff --git a/src/ts/@overflow/target/api/model/Target.ts b/src/ts/@overflow/target/api/model/Target.ts index f48f388..245ef57 100644 --- a/src/ts/@overflow/target/api/model/Target.ts +++ b/src/ts/@overflow/target/api/model/Target.ts @@ -1,11 +1,13 @@ import Probe from '@overflow/probe/api/model/Probe'; import Infra from '@overflow/infra/api/model/Infra'; +import Sensor from '@overflow/sensor/api/model/Sensor'; interface Target { id?: number; createDate?: Date; displayName?: string; description?: string; + sensors?: Sensor[]; } export default Target; diff --git a/src/ts/@overflow/target/react/components/TargetDetail.tsx b/src/ts/@overflow/target/react/components/TargetDetail.tsx index b8e2748..19e4da7 100644 --- a/src/ts/@overflow/target/react/components/TargetDetail.tsx +++ b/src/ts/@overflow/target/react/components/TargetDetail.tsx @@ -11,7 +11,7 @@ import InfraOSApplication from '@overflow/infra/api/model/InfraOSApplication'; import InfraOSDaemon from '@overflow/infra/api/model/InfraOSDaemon'; import InfraOSPort from '@overflow/infra/api/model/InfraOSPort'; import InfraService from '@overflow/infra/api/model/InfraService'; - +import Sensor from '@overflow/sensor/api/model/Sensor'; import * as Utils from '@overflow/commons/util/Utils'; @@ -113,10 +113,10 @@ export class TargetBasicInfo extends React.Component -
Sensor Count
+
Sensors
- TODO + {this.listSensors()} @@ -142,4 +142,13 @@ export class TargetBasicInfo extends React.Component ); } + + private listSensors = (): any => { + if (this.props.infra.target.sensors === null || this.props.infra.target.sensors.length === 0) { + return
-
; + } + return this.props.infra.target.sensors.map((sensor: Sensor, index: number) => ( +
{sensor.crawler.name}
+ )); + } } diff --git a/src/ts/@overflow/target/react/components/TargetList.tsx b/src/ts/@overflow/target/react/components/TargetList.tsx index 521b32d..a652b89 100644 --- a/src/ts/@overflow/target/react/components/TargetList.tsx +++ b/src/ts/@overflow/target/react/components/TargetList.tsx @@ -12,7 +12,7 @@ import { Pager } from '@overflow/commons/react/component/Pager'; import * as Utils from '@overflow/commons/util/Utils'; import PageParams from '@overflow/commons/api/model/PageParams'; import { SortTableHeaderRow } from '@overflow/commons/react/component/SortTableHeaderRow'; - +import Sensor from '@overflow/sensor/api/model/Sensor'; export interface StateProps { probeId?: string; @@ -134,7 +134,7 @@ export class TargetList extends React.Component { colsmap.set('No.', 'id'); colsmap.set('Type', 'infraType.name'); colsmap.set('Name', 'target.displayName'); - colsmap.set('Sensor Count', 'sensorCount'); + colsmap.set('Sensors', 'target.sensors'); colsmap.set('Created at', 'createDate'); if (this.props.infraList === undefined) { @@ -162,7 +162,9 @@ export class TargetList extends React.Component { {index + 1} {infra.infraType.name} {infra.target.displayName} - TODO + + {this.listSensors(infra)} + {Utils.date2date(infra.target.createDate)} ))} @@ -190,6 +192,15 @@ export class TargetList extends React.Component { ); } + private listSensors = (infra: Infra): any => { + if (infra.target.sensors.length === 0) { + return
-
; + } + return infra.target.sensors.map((sensor: Sensor, index: number) => ( +
{sensor.crawler.name}
+ )); + } + private handleSelectedTarget = (infra: Infra): void => { console.log('handleSelectedTarget '); this.setState({ selected: infra });