From a7557dddcc46d0fb21b494ba39fb52c90926a77a Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 15 Mar 2026 19:49:28 +0800 Subject: [PATCH] bugfix --- dagflow/dagflow.py | 39 ++++++++++++ .../brief_definition.ui | 54 ---------------- wwwroot/exists_flow_definition/index.ui | 30 --------- wwwroot/menu.ui | 61 +++++++++++++++---- .../definition.ui => new_definition.ui} | 0 .../new_instance.ui | 0 wwwroot/show_instance.ui | 2 + wwwroot/show_work.ui | 58 ++++++++++++++++++ .../{exists_flow_definition => }/tabpanel.ui | 0 9 files changed, 147 insertions(+), 97 deletions(-) delete mode 100644 wwwroot/exists_flow_definition/brief_definition.ui delete mode 100644 wwwroot/exists_flow_definition/index.ui rename wwwroot/{exists_flow_definition/definition.ui => new_definition.ui} (100%) rename wwwroot/{exists_flow_definition => }/new_instance.ui (100%) create mode 100644 wwwroot/show_instance.ui create mode 100644 wwwroot/show_work.ui rename wwwroot/{exists_flow_definition => }/tabpanel.ui (100%) diff --git a/dagflow/dagflow.py b/dagflow/dagflow.py index 18abe83..a4b80fc 100644 --- a/dagflow/dagflow.py +++ b/dagflow/dagflow.py @@ -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() diff --git a/wwwroot/exists_flow_definition/brief_definition.ui b/wwwroot/exists_flow_definition/brief_definition.ui deleted file mode 100644 index 4a9a464..0000000 --- a/wwwroot/exists_flow_definition/brief_definition.ui +++ /dev/null @@ -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}}" - } - } - } - ] - } - ] -} - diff --git a/wwwroot/exists_flow_definition/index.ui b/wwwroot/exists_flow_definition/index.ui deleted file mode 100644 index 145bfe8..0000000 --- a/wwwroot/exists_flow_definition/index.ui +++ /dev/null @@ -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" - } - } - ] -} diff --git a/wwwroot/menu.ui b/wwwroot/menu.ui index e8d2cb5..9b5376d 100644 --- a/wwwroot/menu.ui +++ b/wwwroot/menu.ui @@ -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 %} ] } } diff --git a/wwwroot/exists_flow_definition/definition.ui b/wwwroot/new_definition.ui similarity index 100% rename from wwwroot/exists_flow_definition/definition.ui rename to wwwroot/new_definition.ui diff --git a/wwwroot/exists_flow_definition/new_instance.ui b/wwwroot/new_instance.ui similarity index 100% rename from wwwroot/exists_flow_definition/new_instance.ui rename to wwwroot/new_instance.ui diff --git a/wwwroot/show_instance.ui b/wwwroot/show_instance.ui new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/wwwroot/show_instance.ui @@ -0,0 +1,2 @@ +{ +} diff --git a/wwwroot/show_work.ui b/wwwroot/show_work.ui new file mode 100644 index 0000000..25d196a --- /dev/null +++ b/wwwroot/show_work.ui @@ -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 %} diff --git a/wwwroot/exists_flow_definition/tabpanel.ui b/wwwroot/tabpanel.ui similarity index 100% rename from wwwroot/exists_flow_definition/tabpanel.ui rename to wwwroot/tabpanel.ui