Skip to content

Commit 910c498

Browse files
committed
feat: add API methods for retrieving tool records and integrate ToolRecordDrawer
1 parent 33a195f commit 910c498

File tree

3 files changed

+134
-1
lines changed

3 files changed

+134
-1
lines changed

apps/tools/migrations/0005_taskrecord.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,99 @@
55
import uuid_utils.compat
66
from django.db import migrations, models
77

8+
old = [
9+
"https://apps-assets.fit2cloud.com/stable/maxkb/md2docx/logo.png",
10+
"https://apps-assets.fit2cloud.com/stable/maxkb/mcp_output/logo.png",
11+
"https://apps-assets.fit2cloud.com/stable/maxkb/feishubot/logo.png",
12+
"https://apps-assets.fit2cloud.com/stable/maxkb/mongo/logo.png",
13+
"https://apps-assets.fit2cloud.com/stable/maxkb/OFD_Parse/logo.png",
14+
"https://apps-assets.fit2cloud.com/stable/maxkb/html_to_pdf/logo.png",
15+
"https://apps-assets.fit2cloud.com/stable/maxkb/feishu_datasource/logo.png",
16+
"https://apps-assets.fit2cloud.com/stable/maxkb/quotation_generation_agent/logo.png",
17+
"https://apps-assets.fit2cloud.com/stable/maxkb/html2pdf/logo.png",
18+
"https://apps-assets.fit2cloud.com/stable/maxkb/sqlbot_ai/logo.png",
19+
"https://apps-assets.fit2cloud.com/stable/maxkb/metaso/logo.png",
20+
"https://apps-assets.fit2cloud.com/stable/maxkb/registry/logo.png",
21+
"https://apps-assets.fit2cloud.com/stable/maxkb/smtp_email/logo.png",
22+
"https://apps-assets.fit2cloud.com/stable/maxkb/wecomrobot/logo.png",
23+
"https://apps-assets.fit2cloud.com/stable/maxkb/paperx/logo.png",
24+
"https://apps-assets.fit2cloud.com/stable/maxkb/case_inquire/logo.png",
25+
"https://apps-assets.fit2cloud.com/stable/maxkb/data_analysis_assistant/logo.png",
26+
"https://apps-assets.fit2cloud.com/stable/maxkb/crm_intelligent_search/logo.png",
27+
"https://apps-assets.fit2cloud.com/stable/maxkb/case_collection/logo.png",
28+
"https://apps-assets.fit2cloud.com/stable/maxkb/knowledge_self_assessment/logo.png",
29+
"https://apps-assets.fit2cloud.com/stable/maxkb/minerU_util/logo.png",
30+
"https://apps-assets.fit2cloud.com/stable/maxkb/invoice_recognition/logo.png",
31+
"https://apps-assets.fit2cloud.com/stable/maxkb/fragment/logo.png",
32+
"https://apps-assets.fit2cloud.com/stable/maxkb/contract_review/logo.png",
33+
"https://apps-assets.fit2cloud.com/stable/maxkb/echart_to_svg/logo.png",
34+
"https://apps-assets.fit2cloud.com/stable/maxkb/extract/logo.png",
35+
"https://apps-assets.fit2cloud.com/stable/maxkb/big_order/logo.png",
36+
"https://apps-assets.fit2cloud.com/stable/maxkb/crm_intelligent_recording/logo.png",
37+
"https://apps-assets.fit2cloud.com/stable/maxkb/dingrobot/logo.png",
38+
"https://apps-assets.fit2cloud.com/stable/maxkb/timestamp/logo.png",
39+
"https://apps-assets.fit2cloud.com/stable/maxkb/knowledge_workflow/logo.png",
40+
"https://apps-assets.fit2cloud.com/stable/maxkb/household_registration_policy_qa_assistant/logo.png",
41+
"https://apps-assets.fit2cloud.com/stable/maxkb/httputils/logo.png",
42+
"https://apps-assets.fit2cloud.com/stable/maxkb/html_compression/logo.png",
43+
"https://apps-assets.fit2cloud.com/stable/maxkb/crm_customer_entry_ai_agent/logo.png",
44+
"https://apps-assets.fit2cloud.com/stable/maxkb/anspire/logo.png",
45+
"https://apps-assets.fit2cloud.com/stable/maxkb/application_template/logo.png",
46+
"https://apps-assets.fit2cloud.com/stable/maxkb/baidu-translate/logo.png",
47+
"https://apps-assets.fit2cloud.com/stable/maxkb/website_translation/logo.png",
48+
]
49+
new = [
50+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_md2docx/logo.png",
51+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_mcp_output/logo.png",
52+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_feishubot/logo.png",
53+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_mongo/logo.png",
54+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_OFD_Parse/logo.png",
55+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_html_to_pdf/logo.png",
56+
"https://apps-assets.fit2cloud.com/stable/maxkb/db_feishu_datasource/logo.png",
57+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_quotation_generation_agent/logo.png",
58+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_html2pdf/logo.png",
59+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_sqlbot_ai/logo.png",
60+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_metaso/logo.png",
61+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_registry/logo.png",
62+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_smtp_email/logo.png",
63+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_wecomrobot/logo.png",
64+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_paperx/logo.png",
65+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_case_inquire/logo.png",
66+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_data_analysis_assistant/logo.png",
67+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_crm_intelligent_search/logo.png",
68+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_case_collection/logo.png",
69+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_knowledge_self_assessment/logo.png",
70+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_minerU_util/logo.png",
71+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_invoice_recognition/logo.png",
72+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_fragment/logo.png",
73+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_contract_review/logo.png",
74+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_echart_to_svg/logo.png",
75+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_extract/logo.png",
76+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_big_order/logo.png",
77+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_crm_intelligent_recording/logo.png",
78+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_dingrobot/logo.png",
79+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_timestamp/logo.png",
80+
"https://apps-assets.fit2cloud.com/stable/maxkb/kbwf_knowledge_workflow/logo.png",
81+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_household_registration_policy_qa_assistant/logo.png",
82+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_httputils/logo.png",
83+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_html_compression/logo.png",
84+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_crm_customer_entry_ai_agent/logo.png",
85+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_anspire/logo.png",
86+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_application_template/logo.png",
87+
"https://apps-assets.fit2cloud.com/stable/maxkb/tool_baidu-translate/logo.png",
88+
"https://apps-assets.fit2cloud.com/stable/maxkb/app_website_translation/logo.png",
89+
]
90+
91+
def _replace_tool_icons(apps, schema_editor):
92+
if len(old) != len(new):
93+
raise ValueError("`old` 与 `new` 长度不一致,无法一一替换")
94+
95+
Tool = apps.get_model("tools", "Tool")
96+
mapping = dict(zip(old, new))
97+
98+
# 逐个 update,避免依赖数据库对 CASE/WHEN 的兼容差异
99+
for old_icon, new_icon in mapping.items():
100+
Tool.objects.filter(icon=old_icon).update(icon=new_icon)
8101

9102
class Migration(migrations.Migration):
10103

@@ -31,4 +124,5 @@ class Migration(migrations.Migration):
31124
'db_table': 'tool_record',
32125
},
33126
),
127+
migrations.RunPython(_replace_tool_icons, reverse_code=migrations.RunPython.noop),
34128
]

ui/src/api/system-resource-management/tool.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,27 @@ const postPylint: (code: string, loading?: Ref<boolean>) => Promise<Result<any>>
129129
return post(`${prefix}/pylint`, { code }, {}, loading)
130130
}
131131

132+
const pageToolRecord = (
133+
tool_id: string,
134+
page: pageRequest,
135+
param: any,
136+
loading?: Ref<boolean>,
137+
) => {
138+
return get(
139+
`${prefix}/${tool_id}/tool_record/${page.current_page}/${page.page_size}`,
140+
param,
141+
loading,
142+
)
143+
}
144+
145+
const getToolRecordDetail = (
146+
tool_id: string,
147+
record_id: string
148+
) => {
149+
return get(`${prefix}/${tool_id}/tool_record/${record_id}`)
150+
}
151+
152+
132153
export default {
133154
getToolListPage,
134155
getToolList,
@@ -140,5 +161,7 @@ export default {
140161
exportTool,
141162
putToolIcon,
142163
delTool,
143-
postToolTestConnection
164+
postToolTestConnection,
165+
pageToolRecord,
166+
getToolRecordDetail,
144167
}

ui/src/views/system-resource-management/ToolResourceIndex.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,14 @@
341341
<AppIcon iconName="app-resource-mapping" class="color-secondary"></AppIcon>
342342
{{ $t('views.system.resourceMapping.title') }}
343343
</el-dropdown-item>
344+
<el-dropdown-item
345+
text
346+
@click.stop="openToolRecordDrawer(row)"
347+
v-if="permissionPrecise.relate_map()"
348+
>
349+
<AppIcon iconName="app-schedule-report" class="color-secondary" />
350+
{{ $t('common.ExecutionRecord.subTitle') }}
351+
</el-dropdown-item>
344352
<el-dropdown-item
345353
v-if="permissionPrecise.delete()"
346354
divided
@@ -366,6 +374,7 @@
366374
<McpToolConfigDialog ref="McpToolConfigDialogRef" @refresh="refresh"/>
367375
<ResourceAuthorizationDrawer :type="SourceTypeEnum.TOOL" ref="ResourceAuthorizationDrawerRef"/>
368376
<ResourceMappingDrawer ref="resourceMappingDrawerRef"></ResourceMappingDrawer>
377+
<ToolRecordDrawer ref="toolRecordDrawerRef"/>
369378
</div>
370379
</template>
371380

@@ -391,6 +400,7 @@ import {MsgSuccess, MsgConfirm, MsgError} from '@/utils/message'
391400
import permissionMap from '@/permission'
392401
import McpToolConfigDialog from '@/views/tool/component/McpToolConfigDialog.vue'
393402
import ResourceMappingDrawer from "@/components/resource_mapping/index.vue";
403+
import ToolRecordDrawer from "@/views/tool/execution-record/TriggerRecordDrawer.vue";
394404
395405
const {user} = useStore()
396406
@@ -698,6 +708,12 @@ const openResourceMappingDrawer = (tool: any) => {
698708
resourceMappingDrawerRef.value?.open('TOOL', tool)
699709
}
700710
711+
const toolRecordDrawerRef = ref<InstanceType<typeof ToolRecordDrawer>>()
712+
const openToolRecordDrawer = (data: any) => {
713+
toolRecordDrawerRef.value?.open(data)
714+
}
715+
716+
701717
onMounted(() => {
702718
getWorkspaceList()
703719
getList()

0 commit comments

Comments
 (0)