bugfix
This commit is contained in:
parent
c93be77289
commit
a7557dddcc
@ -506,6 +506,45 @@ def get_engine():
|
||||
id = randint(0, cnt-1)
|
||||
return env.flow_engines[id]
|
||||
|
||||
async def list_org_instances(request, flow_def_id=None):
|
||||
env = request._run_ns
|
||||
orgid = await env.get_userorgid()
|
||||
async with get_sor_context(env, 'dagflow') as sor:
|
||||
sql = """select b.name, a.*
|
||||
from flow_instance a, flow_definition b
|
||||
where a.flow_def_id = b.id
|
||||
and status='running'
|
||||
and org_id=${orgid}$"""
|
||||
if flow_def_id:
|
||||
sql += ' and flow_def_id = ${flow_def_id}$'
|
||||
recs = await sor.sqlExe(sql, {
|
||||
'orgid': orgid,
|
||||
'flow_def_id': flow_def_id
|
||||
})
|
||||
return recs
|
||||
return []
|
||||
|
||||
async def get_my_flow_works(request, inst_id=None):
|
||||
env = request._run_ns
|
||||
orgid = await env.get_userorgid()
|
||||
userid = await env.get_user()
|
||||
myroles = await env.get_user_roles(userid)
|
||||
async with get_sor_context(env, 'dagflow') as sor:
|
||||
sql = """select *
|
||||
from node_execute
|
||||
where a.type = 'human'
|
||||
and status in ['pending', 'running']
|
||||
and (assignee = ${userid}$ or (assignee is NULL and role in ${myroles}$))"""
|
||||
if inst_id:
|
||||
sql += ' and instance_id = ${inst_id}$'
|
||||
recs = await sor.sqlExe(sql, {
|
||||
'userid': userid,
|
||||
'myroles': myroles,
|
||||
'inst_id': inst_id
|
||||
})
|
||||
return recs
|
||||
return []
|
||||
|
||||
async def get_exists_workflows(request):
|
||||
env = request._run_ns
|
||||
orgid = await env.get_userorgid()
|
||||
|
||||
@ -1,54 +0,0 @@
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"options": {
|
||||
"css": "flowdefinition"
|
||||
},
|
||||
"subwidgets": [
|
||||
{
|
||||
"widgettype": "Title4",
|
||||
"options": {
|
||||
"otext": "{{params_kw.name}}",
|
||||
"i18n": true,
|
||||
"wrap": true,
|
||||
"halign": "left"
|
||||
}
|
||||
}, {
|
||||
"widgettype": "text",
|
||||
"options": {
|
||||
"otext": "{{params_kw.description}}",
|
||||
"i18n": true,
|
||||
"wrap": true,
|
||||
"halign": "left"
|
||||
}
|
||||
}, {
|
||||
"widgettype": "IconTextBar",
|
||||
"options": {
|
||||
"margin": "5px",
|
||||
"rate": 1,
|
||||
"tools":[
|
||||
{
|
||||
"tip": "新建流程的一个实例",
|
||||
"name": "new_instance",
|
||||
"icon": "{{entire_url('/bricks/imgs/flow_instance.svg')}}",
|
||||
"label": "创建实例"
|
||||
}
|
||||
]
|
||||
},
|
||||
"binds":[
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "new_instance",
|
||||
"actiontype": "urlwidget",
|
||||
"target": "wish_panel",
|
||||
"options": {
|
||||
"url": "{{entire_url('instance_input.ui')}}",
|
||||
"params": {
|
||||
"id": "{{params_kw.id}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
{
|
||||
"widgettype":"HBox",
|
||||
"options": {
|
||||
"width": "100%",
|
||||
"heigit": "100%"
|
||||
},
|
||||
"subwidgets":[
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"options": {
|
||||
"cwidth": 12
|
||||
},
|
||||
"subwidgets": [
|
||||
{
|
||||
"widgettype": "urlwidget",
|
||||
"options": {
|
||||
"url": "{{entire_url('tabpanel.ui')}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"id": "ai_x_area",
|
||||
"options": {
|
||||
"css": "filler"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,3 +1,5 @@
|
||||
{% set definitions = get_org_flow_definition(request) %}
|
||||
{% if definitions %}
|
||||
{
|
||||
"widgettype": "menu",
|
||||
"options": {
|
||||
@ -6,21 +8,54 @@
|
||||
"height": "100%",
|
||||
"items": [
|
||||
{
|
||||
"name": "definitions",
|
||||
"icon": "{{entire_url('/bricks/imgs/workflow.svg')}}",
|
||||
"label": "已有流程",
|
||||
"url": "{{entire_url('exists_flow_definition')}}",
|
||||
}, {
|
||||
"name": "instances",
|
||||
"icon": "{{entire_url('/bricks/imgs/flow_instance.svg')}}",
|
||||
"label": "进行中流程",
|
||||
"url": "{{entire_url('running_instances')}}"
|
||||
}, {
|
||||
"name": "mywork",
|
||||
"icon": "{{entire_url('/bricks/imgs/workflow.svg')}}",
|
||||
"label": "新建流程",
|
||||
"url": "{{entire_url('new_definition')}}"
|
||||
},
|
||||
{% for d in definitions %}
|
||||
{
|
||||
"name": "{{d.id}}",
|
||||
"icon": "{{entire_url('/bricks/imgs/mywork.svg')}}",
|
||||
"label": "我的任务",
|
||||
"url": "{{entire_url('mywork')}}"
|
||||
}
|
||||
"label": "{{d.name}}",
|
||||
"tip": "{{d.desciption}}",
|
||||
"items": [
|
||||
{
|
||||
"name": "instances",
|
||||
"icon": "{{entire_url('/bricks/imgs/wf-instance.svg')}}",
|
||||
"label": "新建流程",
|
||||
"url": "{{entire_url('new_instance.ui')}}"
|
||||
},
|
||||
{% instances = list_org_instances(request, flow_def_id=params_kw.id) %}
|
||||
{% for inst in instances %}
|
||||
{
|
||||
"name": "{{inst.id}}",
|
||||
"icon": "{{entire_url('/bricks/imgs/wf-instance.svg')}}",
|
||||
"label": "{{inst.name}}:{{inst.id}}",
|
||||
"items": [
|
||||
{
|
||||
"name": "{{inst.id}}_show",
|
||||
"icon": "{{entire_url('/bricks/imgs/wf-instance.svg')}}",
|
||||
"label": "实例明细:{{inst.id}}",
|
||||
“url": "{{entire_url('show_instance.ui')}}"
|
||||
},
|
||||
{% works = get_my_flow_works(request) %}
|
||||
{% for work in works %}
|
||||
{
|
||||
"name": "{{inst.id}}_show",
|
||||
"icon": "{{entire_url('/bricks/imgs/wf-instance.svg')}}",
|
||||
"label": "我的工作:{{inst.id}}",
|
||||
"items": [
|
||||
]
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endif %}
|
||||
]
|
||||
},
|
||||
|
||||
{% endfor %}
|
||||
]
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
2
wwwroot/show_instance.ui
Normal file
2
wwwroot/show_instance.ui
Normal file
@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
||||
58
wwwroot/show_work.ui
Normal file
58
wwwroot/show_work.ui
Normal file
@ -0,0 +1,58 @@
|
||||
{% set definitions = get_org_flow_definition(request) %}
|
||||
{% if definitions %}
|
||||
{
|
||||
"widgettype": "VScrollPanel",
|
||||
"options": {
|
||||
"width": "100%",
|
||||
"height": "100%",
|
||||
},
|
||||
"subwidgets": [
|
||||
{% for d in definitions %}
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"css": "clickable",
|
||||
"i18n": true,
|
||||
"otext": "{{d.title}}",
|
||||
"tip": "{{d.description}}",
|
||||
"wrap": true,
|
||||
"valign": "left"
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "urlwidget",
|
||||
"target": "root.ai_x_area",
|
||||
"options": {
|
||||
"url": "{{entire_url('new_instance.ui')}}",
|
||||
"params": {
|
||||
"id": "{{d.id}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
]
|
||||
}
|
||||
{% else %}
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"options": {
|
||||
"css": "card",
|
||||
"cwidth": 15,
|
||||
"height": 10
|
||||
},
|
||||
"subwidgets": [
|
||||
{
|
||||
"widget": "text",
|
||||
"options": {
|
||||
"i18n": true,
|
||||
"otext": "没有流程"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
{% endif %}
|
||||
Loading…
x
Reference in New Issue
Block a user