Skip to content

Commit f404d9e

Browse files
committed
feat: Node execute
1 parent 0231168 commit f404d9e

File tree

5 files changed

+34
-25
lines changed

5 files changed

+34
-25
lines changed

apps/application/flow/step_node/variable_aggregation_node/impl/base_variable_aggregation_node.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#coding=utf-8
1+
# coding=utf-8
22
"""
33
@project: MaxKB
44
@Author:虎²
@@ -16,6 +16,8 @@ def save_context(self, details, workflow_manage):
1616
for key, value in details.get('result').items():
1717
self.context['key'] = value
1818
self.context['result'] = details.get('result')
19+
self.context['strategy'] = details.get('strategy')
20+
self.context['group_list'] = details.get('group_list')
1921

2022
def get_first_non_null(self, variable_list):
2123

@@ -30,17 +32,35 @@ def get_first_non_null(self, variable_list):
3032
def set_variable_to_json(self, variable_list):
3133

3234
return {variable.get('variable')[1:][0]: self.workflow_manage.get_reference_field(
33-
variable.get('variable')[0],
34-
variable.get('variable')[1:]) for variable in variable_list}
35+
variable.get('variable')[0],
36+
variable.get('variable')[1:]) for variable in variable_list}
37+
38+
def reset_variable(self, variable):
39+
value = self.workflow_manage.get_reference_field(
40+
variable.get('variable')[0],
41+
variable.get('variable')[1:])
42+
node_id = variable.get('variable')[0]
43+
node = self.workflow_manage.flow.get_node(node_id)
44+
return {"value": value, 'node_name': node.properties.get('stepName') if node is not None else node_id,
45+
'field': variable.get('variable')[1]}
46+
47+
def reset_group_list(self, group_list):
48+
result = []
49+
for g in group_list:
50+
b = {'label': g.get('label'),
51+
'variable_list': [self.reset_variable(variable) for variable in g.get('variable_list')]}
52+
result.append(b)
53+
return result
3554

36-
def execute(self,strategy,group_list,**kwargs) -> NodeResult:
37-
strategy_map = {'first_non_null':self.get_first_non_null,
55+
def execute(self, strategy, group_list, **kwargs) -> NodeResult:
56+
strategy_map = {'first_non_null': self.get_first_non_null,
3857
'variable_to_json': self.set_variable_to_json,
3958
}
4059

41-
result = { item.get('field'):strategy_map[strategy](item.get('variable_list')) for item in group_list}
60+
result = {item.get('field'): strategy_map[strategy](item.get('variable_list')) for item in group_list}
4261

43-
return NodeResult({'result': result,**result},{})
62+
return NodeResult(
63+
{'result': result, 'strategy': strategy, 'group_list': self.reset_group_list(group_list), **result}, {})
4464

4565
def get_details(self, index: int, **kwargs):
4666
return {
@@ -49,6 +69,8 @@ def get_details(self, index: int, **kwargs):
4969
'run_time': self.context.get('run_time'),
5070
'type': self.node.type,
5171
'result': self.context.get('result'),
72+
'strategy': self.context.get('strategy'),
73+
'group_list': self.context.get('group_list'),
5274
'status': self.status,
5375
'err_message': self.err_message
54-
}
76+
}

ui/src/locales/lang/en-US/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export default {
7474
editParam: 'Edit Parameter',
7575
addParam: 'Add Parameter',
7676
},
77+
aggregationStrategy: 'Aggregation Strategy',
7778
inputPlaceholder: 'Please input',
7879
selectPlaceholder: 'Please select',
7980
title: 'Title',

ui/src/locales/lang/zh-CN/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export default {
7878
editParam: '编辑参数',
7979
addParam: '添加参数',
8080
},
81+
aggregationStrategy: '聚合策略',
8182
inputPlaceholder: '请输入',
8283
selectPlaceholder: '请选择',
8384
title: '标题',

ui/src/locales/lang/zh-Hant/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export default {
7474
editParam: '編輯參數',
7575
addParam: '新增參數',
7676
},
77+
aggregationStrategy: '聚合策略',
7778
inputPlaceholder: '請輸入',
7879
selectPlaceholder: '請選擇',
7980
title: '標題',

ui/src/workflow/nodes/variable-aggregation-node/index.vue

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,7 @@
4343
<el-card shadow="never" class="card-never" style="--el-card-padding: 12px">
4444

4545
<div class="flex-between mb-12">
46-
<!-- <el-form-item
47-
v-if="editingGroupIndex === gIndex"
48-
:prop="`group_list.${gIndex}.group_name`"
49-
:rules="groupNameRules(gIndex)"
50-
style="margin-bottom: 0; flex: 1;"
51-
>
52-
<el-input
53-
v-model="form_data.group_list[gIndex].group_name"
54-
@blur="finishEditGroupName(gIndex)"
55-
@input="validateGroupNameField(gIndex)"
56-
ref="groupNameInputRef"
57-
size="small"
58-
style="width: 200px; font-weight: bold;"
59-
>
60-
</el-input>
61-
</el-form-item> -->
62-
<span class="font-bold">{{ group.field }}</span>
46+
<span class="font-bold">{{ group.label }}</span>
6347
<div class="flex align-center">
6448
<el-button @click="openAddOrEditDialog(group,gIndex)" size="large" link>
6549
<el-icon><EditPen /></el-icon>

0 commit comments

Comments
 (0)