NodePanel render input & output
This commit is contained in:
1 parent
a891fc7122
commit
aa6460ff32
3 files changed
+58
-12
No files matched your search
@@ -11,7 +11,7 @@ export interface BehaviorNodeTypeModel {
|
|||||||
desc?: string;
|
desc?: string;
|
||||||
args?: ArgsDefType[];
|
args?: ArgsDefType[];
|
||||||
input?: string[];
|
input?: string[];
|
||||||
output?: string;
|
output?: string[];
|
||||||
doc?: string;
|
doc?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ export interface BehaviorNodeModel {
|
|||||||
desc?: string;
|
desc?: string;
|
||||||
args?: {[key: string]: any};
|
args?: {[key: string]: any};
|
||||||
input?: string[];
|
input?: string[];
|
||||||
output?: string;
|
output?: string[];
|
||||||
children?: BehaviorNodeModel[];
|
children?: BehaviorNodeModel[];
|
||||||
debug?: boolean;
|
debug?: boolean;
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ export interface GraphNodeModel extends TreeGraphData {
|
|||||||
desc?: string;
|
desc?: string;
|
||||||
args?: {[key: string]: any};
|
args?: {[key: string]: any};
|
||||||
input?: string[];
|
input?: string[];
|
||||||
output?: string;
|
output?: string[];
|
||||||
children?: GraphNodeModel[];
|
children?: GraphNodeModel[];
|
||||||
|
|
||||||
size?: number[];
|
size?: number[];
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export default class NodePanel extends React.Component<NodePanelProps> {
|
|||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
const { model, settings } = this.props;
|
const { model, settings } = this.props;
|
||||||
|
this.formRef.current.resetFields();
|
||||||
this.formRef.current.setFieldsValue(this.getInitialValues());
|
this.formRef.current.setFieldsValue(this.getInitialValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,9 +37,19 @@ export default class NodePanel extends React.Component<NodePanelProps> {
|
|||||||
};
|
};
|
||||||
if (model.args) {
|
if (model.args) {
|
||||||
for (let k in model.args) {
|
for (let k in model.args) {
|
||||||
initialValues[`args.${k}`] = model.args[k]
|
initialValues[`args.${k}`] = model.args[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (model.input) {
|
||||||
|
model.input.forEach((v, i) => {
|
||||||
|
initialValues[`input.${i}`] = v;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (model.output) {
|
||||||
|
model.output.forEach((v, i) => {
|
||||||
|
initialValues[`output.${i}`] = v;
|
||||||
|
})
|
||||||
|
}
|
||||||
return initialValues;
|
return initialValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,15 +124,15 @@ export default class NodePanel extends React.Component<NodePanelProps> {
|
|||||||
<Switch onChange={this.handleSubmit} />
|
<Switch onChange={this.handleSubmit} />
|
||||||
</Item>
|
</Item>
|
||||||
<Markdown source={conf.doc} />
|
<Markdown source={conf.doc} />
|
||||||
{this.renderInputs(model, conf)}
|
{this.renderInputs(conf)}
|
||||||
{this.renderArgs(model, conf)}
|
{this.renderArgs(conf)}
|
||||||
{this.renderOutputs(model, conf)}
|
{this.renderOutputs(conf)}
|
||||||
</Form>
|
</Form>
|
||||||
</Card >
|
</Card >
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
renderArgs(model: BehaviorNodeModel, conf: BehaviorNodeTypeModel) {
|
renderArgs(conf: BehaviorNodeTypeModel) {
|
||||||
if (!conf || !conf.args || conf.args.length == 0) {
|
if (!conf || !conf.args || conf.args.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -158,12 +169,16 @@ export default class NodePanel extends React.Component<NodePanelProps> {
|
|||||||
<div>
|
<div>
|
||||||
<Divider orientation="left"><h3>常量参数</h3></Divider>
|
<Divider orientation="left"><h3>常量参数</h3></Divider>
|
||||||
{conf && conf.args && conf.args.map((e, i: number) => {
|
{conf && conf.args && conf.args.map((e, i: number) => {
|
||||||
|
const required = e.type.indexOf("?") == -1;
|
||||||
return (
|
return (
|
||||||
<Item
|
<Item
|
||||||
name={`args.${e.name}`}
|
name={`args.${e.name}`}
|
||||||
label={e.desc}
|
label={e.desc}
|
||||||
key={i}
|
key={i}
|
||||||
valuePropName={e.type.indexOf("boolean") >= 0 ? 'checked' : undefined}
|
valuePropName={e.type.indexOf("boolean") >= 0 ? 'checked' : undefined}
|
||||||
|
rules={[
|
||||||
|
{ required, message: `${e.desc}(${e.name})为必填字段` }
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
{normalArgs(e)}
|
{normalArgs(e)}
|
||||||
</Item>
|
</Item>
|
||||||
@@ -175,18 +190,49 @@ export default class NodePanel extends React.Component<NodePanelProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
renderInputs(model: BehaviorNodeModel, conf: BehaviorNodeTypeModel) {
|
renderInputs(conf: BehaviorNodeTypeModel) {
|
||||||
|
if (!conf.input || !conf.input || conf.input.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Divider orientation="left"><h3>输入变量</h3></Divider>
|
<Divider orientation="left"><h3>输入变量</h3></Divider>
|
||||||
|
{
|
||||||
|
conf.input.map((e, i) => {
|
||||||
|
return (
|
||||||
|
<Item
|
||||||
|
label={e}
|
||||||
|
name={`input.${i}`}
|
||||||
|
>
|
||||||
|
<Input onBlur={this.handleSubmit} />
|
||||||
|
</Item>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
renderOutputs(model: BehaviorNodeModel, conf: BehaviorNodeTypeModel) {
|
renderOutputs(conf: BehaviorNodeTypeModel) {
|
||||||
|
if (!conf.output || !conf.output || conf.output.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Divider orientation="left"><h3>输出变量</h3></Divider>
|
<Divider orientation="left"><h3>输出变量</h3></Divider>
|
||||||
|
{
|
||||||
|
conf.output.map((e, i) => {
|
||||||
|
return (
|
||||||
|
<Item
|
||||||
|
label={e}
|
||||||
|
name={`output.${i}`}
|
||||||
|
>
|
||||||
|
<Input onBlur={this.handleSubmit} />
|
||||||
|
</Item>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ export default function (settings: Settings) {
|
|||||||
stateStyles: {
|
stateStyles: {
|
||||||
selected: {
|
selected: {
|
||||||
'main-box': {
|
'main-box': {
|
||||||
stroke: 'black',
|
stroke: 'yellow',
|
||||||
lineWidth: 3,
|
lineWidth: 5,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
hover: {
|
hover: {
|
||||||
|
|||||||
Reference in new issue
Block a user