sensor config fix
This commit is contained in:
parent
f1759540ec
commit
2032c8104c
|
@ -1,7 +1,7 @@
|
|||
import InfraOS from './InfraOS';
|
||||
import Infra from './Infra';
|
||||
|
||||
interface InfraHost extends Infra {
|
||||
export interface InfraHost extends Infra {
|
||||
// id?: number;
|
||||
os?: InfraOS;
|
||||
ip?: number;
|
||||
|
|
|
@ -4,9 +4,10 @@ import {
|
|||
List, Icon, Radio, CheckboxProps, InputOnChangeData, Input,
|
||||
Grid,
|
||||
} from 'semantic-ui-react';
|
||||
import {Infra} from '@overflow/infra/api/model/Infra';
|
||||
|
||||
import { Infra } from '@overflow/infra/api/model/Infra';
|
||||
import { InfraHost } from '@overflow/infra/api/model/InfraHost';
|
||||
|
||||
import * as Utils from '@overflow/commons/util/Utils';
|
||||
|
||||
export interface StateProps {
|
||||
}
|
||||
|
@ -160,7 +161,7 @@ export class SensorConfigSettingTargetInfo extends React.Component<TargetInfoPro
|
|||
|
||||
let infraList: Array<Infra> = this.state.testInfraList;
|
||||
|
||||
if(infraList === undefined || infraList.length <= 0) {
|
||||
if (infraList === undefined || infraList.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -168,7 +169,14 @@ export class SensorConfigSettingTargetInfo extends React.Component<TargetInfoPro
|
|||
|
||||
|
||||
infraList.map((infra: Infra, idx: number) => {
|
||||
console.log('');
|
||||
if (infra.infraType.name === 'HOST') {
|
||||
elems.push(
|
||||
<SensorConfigSettingTargetInfoHost infraHost={infra} />,
|
||||
);
|
||||
} else if (infra.infraType.name === 'OS_SERVICE') {
|
||||
// elems.push(
|
||||
// );
|
||||
}
|
||||
});
|
||||
|
||||
return elems;
|
||||
|
@ -186,6 +194,7 @@ export class SensorConfigSettingTargetInfo extends React.Component<TargetInfoPro
|
|||
|
||||
|
||||
export interface TargetInfoHostStateProps {
|
||||
infraHost: InfraHost;
|
||||
}
|
||||
|
||||
export interface TargetInfoHostDispatchProps {
|
||||
|
@ -207,9 +216,62 @@ export class SensorConfigSettingTargetInfoHost extends React.Component<TargetInf
|
|||
};
|
||||
}
|
||||
|
||||
public renderInfraHost(): JSX.Element[] {
|
||||
|
||||
if (this.props.infraHost === undefined || this.props.infraHost === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let ih: InfraHost = this.props.infraHost;
|
||||
|
||||
let elems: Array<JSX.Element> = new Array();
|
||||
|
||||
elems.push(
|
||||
<Table celled={false} >
|
||||
<Table.Body>
|
||||
<Table.Row>
|
||||
<Table.Cell collapsing>
|
||||
<Header size='small'>os vendor</Header>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{ih.os.vendor.name}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell collapsing>
|
||||
<Header size='small'>meta info</Header>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{ih.os.meta}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell collapsing>
|
||||
<Header size='small'>IP</Header>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{Utils.int2ip(ih.ip)}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell collapsing>
|
||||
<Header size='small'>mac</Header>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{Utils.intToMac(ih.mac)}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
</Table.Body>
|
||||
</Table>,
|
||||
);
|
||||
|
||||
return elems;
|
||||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<Container>
|
||||
{this.renderInfraHost()}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
@ -228,7 +290,7 @@ export interface SensorItemInfoDispatchProps {
|
|||
export type SensorItemInfoProps = SensorItemInfoStateProps & SensorItemInfoDispatchProps;
|
||||
|
||||
export interface SensorItemInfoState {
|
||||
|
||||
testSensorItemList: Array<any>;
|
||||
}
|
||||
|
||||
export class SensorConfigSettingSensorItemInfo extends React.Component<SensorItemInfoProps, SensorItemInfoState> {
|
||||
|
@ -237,13 +299,61 @@ export class SensorConfigSettingSensorItemInfo extends React.Component<SensorIte
|
|||
super(props, context);
|
||||
|
||||
this.state = {
|
||||
|
||||
testSensorItemList: new Array(),
|
||||
};
|
||||
|
||||
this.testCreateData();
|
||||
}
|
||||
|
||||
|
||||
public testCreateData(): void {
|
||||
|
||||
this.state.testSensorItemList.push({ key: 'CPU Total Usage', unit: '%', realKey: 'wmi.cpu.usage.total' });
|
||||
this.state.testSensorItemList.push({ key: 'CPU Free Usage', unit: 'kb', realKey: 'wmi.cpu.usage.free' });
|
||||
this.state.testSensorItemList.push({ key: 'Mem Total Usage', unit: '%', realKey: 'wmi.mem.usage.total' });
|
||||
}
|
||||
|
||||
public renderSensorItem(): JSX.Element[] {
|
||||
|
||||
let elems: Array<JSX.Element> = new Array();
|
||||
|
||||
|
||||
this.state.testSensorItemList.map((data: any, idx: number) => {
|
||||
elems.push(
|
||||
<Table.Row key={'sil' + String(idx)}>
|
||||
<Table.Cell collapsing>
|
||||
{data.key} ({data.unit})
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{data.realKey}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
[Add Notification]
|
||||
</Table.Cell>
|
||||
</Table.Row>,
|
||||
<Table.Row key={'siladd' + String(idx)}>
|
||||
<Table.Cell>
|
||||
<input type='text' placeholder='MIN' />
|
||||
<input type='text' placeholder='MAX' />
|
||||
<Checkbox label={{ children: 'local push' }} />
|
||||
<Checkbox label={{ children: 'email' }} />
|
||||
<Checkbox label={{ children: 'sms' }} />
|
||||
</Table.Cell>
|
||||
</Table.Row>,
|
||||
);
|
||||
});
|
||||
|
||||
return elems;
|
||||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<Container>
|
||||
<Table celled={false}>
|
||||
<Table.Body>
|
||||
{this.renderSensorItem()}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
@ -824,4 +934,4 @@ const testInfraDataList: any[] = [
|
|||
'ip': 3232235980,
|
||||
'mac': 8796753988883,
|
||||
},
|
||||
];
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue
Block a user