sensor regist vaildate

This commit is contained in:
snoop 2017-08-25 17:30:56 +09:00
parent b310a37a00
commit c218576d44
2 changed files with 63 additions and 2 deletions

View File

@ -150,9 +150,9 @@ export class SensorItemTree extends React.Component<SensorItemTreeProps, SensorI
<List selection>
{this.ViewSensorItemType()}
</List>
<Button primary floated='right' onClick={() => {
{/*<Button primary floated='right' onClick={() => {
console.log(this.selectedItemMap);
}}>Test</Button><br /><br />
}}>Test</Button><br /><br />*/}
</Container>
);
}

View File

@ -96,6 +96,13 @@ export class SensorConfigStepper extends React.Component<SensorConfigStepperProp
}
public handleNext(event: React.SyntheticEvent<HTMLAnchorElement>, data: object): void {
let step: number = this.state.currentStep;
let errorStr: string = this.checkSensorData();
if (errorStr.length > 0) {
alert('Choose ' + errorStr);
return;
}
if (step >= this.props.steps.length + 1) {
step = this.props.steps.length + 1;
} else {
@ -111,6 +118,60 @@ export class SensorConfigStepper extends React.Component<SensorConfigStepperProp
}
}
public checkSensorData(): string {
let sd = this.props.getSensor();
switch (this.state.currentStep) {
case 1:
{
if (sd.infra === undefined || sd.infra === null) {
return 'Target';
}
if (sd.crawler === undefined || sd.crawler === null) {
return 'Crawler';
}
}
break;
case 2:
{
if (sd.sensorItemMap === undefined || sd.sensorItemMap === null || this.checkItemMapSize() === false) {
return 'Sensor Item';
}
}
break;
case 3:
{
if (sd.interval === undefined) {
return 'Interval';
}
}
break;
default:
break;
}
return '';
}
public checkItemMapSize(): boolean {
if (this.props.getSensor().sensorItemMap.size <= 0) {
return false;
}
let result: boolean = false;
this.props.getSensor().sensorItemMap.forEach((value: MetaSensorItem[], key: number) => {
if (value.length > 0) {
result = true;
}
});
return result;
}
public registSensor(): void {
let sensorData = this.props.getSensor();
let sensor: Sensor = {};