fix: remove hand-written tags_list to avoid conflict with auto-CRUD from json/tags.json
This commit is contained in:
parent
8a4498e65c
commit
458d68c3f4
@ -1,19 +0,0 @@
|
|||||||
ns = params_kw.copy()
|
|
||||||
db = DBPools()
|
|
||||||
dbname = get_module_dbname('rag')
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
name = ns.get('name', '').strip()
|
|
||||||
kb_id = ns.get('kb_id', '')
|
|
||||||
color = ns.get('color', '#3b82f6')
|
|
||||||
|
|
||||||
if not name or not kb_id:
|
|
||||||
result = {"widgettype": "Message", "options": {"user_data": {"error": "name and kb_id required"}}}
|
|
||||||
else:
|
|
||||||
async with db.sqlorContext(dbname) as sor:
|
|
||||||
tag_id = uuid.uuid4().hex[:16]
|
|
||||||
await sor.sqlExe(
|
|
||||||
"INSERT INTO tags (id, kb_id, name, color, org_id, created_at) VALUES (${id}$, ${kb_id}$, ${name}$, ${color}$, '', NOW())",
|
|
||||||
{"id": tag_id, "kb_id": kb_id, "name": name, "color": color})
|
|
||||||
result = {"widgettype": "Message", "options": {"user_data": {"id": tag_id, "name": name, "color": color, "kb_id": kb_id}}}
|
|
||||||
result
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
ns = params_kw.copy()
|
|
||||||
db = DBPools()
|
|
||||||
dbname = get_module_dbname('rag')
|
|
||||||
userorgid = ns.get('org_id', '')
|
|
||||||
import json
|
|
||||||
|
|
||||||
async with db.sqlorContext(dbname) as sor:
|
|
||||||
recs = await sor.R('tags', {})
|
|
||||||
result = []
|
|
||||||
for r in recs:
|
|
||||||
result.append({
|
|
||||||
"id": r.id,
|
|
||||||
"name": r.name,
|
|
||||||
"color": r.color,
|
|
||||||
"kb_id": r.kb_id,
|
|
||||||
"created_at": str(r.created_at) if r.created_at else ''
|
|
||||||
})
|
|
||||||
result
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
ns = params_kw.copy()
|
|
||||||
db = DBPools()
|
|
||||||
dbname = get_module_dbname('rag')
|
|
||||||
|
|
||||||
tag_id = ns.get('id', '')
|
|
||||||
|
|
||||||
if not tag_id:
|
|
||||||
result = {"widgettype": "Message", "options": {"user_data": {"error": "id required"}}}
|
|
||||||
else:
|
|
||||||
async with db.sqlorContext(dbname) as sor:
|
|
||||||
await sor.sqlExe("DELETE FROM media_tags WHERE tag_id=${id}$", {"id": tag_id})
|
|
||||||
await sor.sqlExe("DELETE FROM tags WHERE id=${id}$", {"id": tag_id})
|
|
||||||
result = {"widgettype": "Message", "options": {"user_data": {"id": tag_id}}}
|
|
||||||
result
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
{
|
|
||||||
"widgettype": "VBox",
|
|
||||||
"options": {
|
|
||||||
"cheight": 40,
|
|
||||||
"width": "100%",
|
|
||||||
"padding": "16px",
|
|
||||||
"spacing": "12px"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"widgettype": "VBox",
|
|
||||||
"options": {"spacing": "4px"},
|
|
||||||
"subwidgets": [
|
|
||||||
{"widgettype": "Text", "options": {"text": "🏷️ 标签管理", "cfontsize": 22, "fontWeight": "bold", "color": "#333"}},
|
|
||||||
{"widgettype": "Text", "options": {"text": "创建和管理知识库标签", "cfontsize": 14, "color": "#888"}}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widgettype": "Tabular",
|
|
||||||
"options": {
|
|
||||||
"dataurl": "{{entire_url('/tags_list/data.dspy')}}",
|
|
||||||
"title": "标签列表",
|
|
||||||
"height": "70vh",
|
|
||||||
"browserfields": [
|
|
||||||
{"field": "name", "title": "标签名", "width": "25%"},
|
|
||||||
{"field": "color", "title": "颜色", "width": "15%"},
|
|
||||||
{"field": "kb_id", "title": "知识库", "width": "30%"},
|
|
||||||
{"field": "created_at", "title": "创建时间", "width": "30%"}
|
|
||||||
],
|
|
||||||
"editable": {
|
|
||||||
"fields": [
|
|
||||||
{"field": "name", "title": "标签名", "uitype": "str", "label": "标签名", "required": true},
|
|
||||||
{"field": "kb_id", "title": "知识库ID", "uitype": "str", "label": "知识库ID", "required": true},
|
|
||||||
{"field": "color", "title": "颜色", "uitype": "str", "label": "颜色(#hex)", "default": "#3b82f6"}
|
|
||||||
],
|
|
||||||
"add_url": "{{entire_url('/tags_list/add.dspy')}}",
|
|
||||||
"update_url": "{{entire_url('/tags_list/update.dspy')}}",
|
|
||||||
"delete_url": "{{entire_url('/tags_list/delete.dspy')}}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
ns = params_kw.copy()
|
|
||||||
db = DBPools()
|
|
||||||
dbname = get_module_dbname('rag')
|
|
||||||
|
|
||||||
tag_id = ns.get('id', '')
|
|
||||||
name = ns.get('name', '').strip()
|
|
||||||
color = ns.get('color', '#3b82f6')
|
|
||||||
|
|
||||||
if not tag_id:
|
|
||||||
result = {"widgettype": "Message", "options": {"user_data": {"error": "id required"}}}
|
|
||||||
else:
|
|
||||||
async with db.sqlorContext(dbname) as sor:
|
|
||||||
parts = []
|
|
||||||
params = {"id": tag_id}
|
|
||||||
if name:
|
|
||||||
parts.append("name=${name}$")
|
|
||||||
params["name"] = name
|
|
||||||
if color:
|
|
||||||
parts.append("color=${color}$")
|
|
||||||
params["color"] = color
|
|
||||||
if parts:
|
|
||||||
await sor.sqlExe(f"UPDATE tags SET {', '.join(parts)} WHERE id=${{id}}$", params)
|
|
||||||
result = {"widgettype": "Message", "options": {"user_data": {"id": tag_id, "name": name, "color": color}}}
|
|
||||||
result
|
|
||||||
Loading…
x
Reference in New Issue
Block a user