增加get_local_agent_list
This commit is contained in:
parent
ed3229683b
commit
a00a1cc32c
@ -107,6 +107,120 @@ def get_local_app_list(filters=None, order_by=None, limit_start=None, limit_page
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@jingrow.whitelist(allow_guest=True)
|
||||||
|
def get_local_node_list(filters=None, order_by=None, limit_start=None, limit_page_length=None):
|
||||||
|
"""获取本地节点列表"""
|
||||||
|
|
||||||
|
# 构建查询条件
|
||||||
|
query_filters = {"public": 1}
|
||||||
|
|
||||||
|
if filters:
|
||||||
|
if isinstance(filters, str):
|
||||||
|
import json
|
||||||
|
filters = json.loads(filters)
|
||||||
|
query_filters.update(filters)
|
||||||
|
|
||||||
|
# 默认排序
|
||||||
|
if not order_by:
|
||||||
|
order_by = "node_type asc"
|
||||||
|
|
||||||
|
# 获取节点列表
|
||||||
|
nodes = jingrow.get_all(
|
||||||
|
"Local Node",
|
||||||
|
filters=query_filters,
|
||||||
|
fields=[
|
||||||
|
"name", "node_type", "title", "subtitle",
|
||||||
|
"enabled", "public", "team", "status", "repository_url",
|
||||||
|
"file_url", "node_image", "creation", "modified"
|
||||||
|
],
|
||||||
|
order_by=order_by,
|
||||||
|
limit_start=limit_start,
|
||||||
|
limit_page_length=limit_page_length
|
||||||
|
)
|
||||||
|
|
||||||
|
# 批量获取团队用户名称
|
||||||
|
team_user_names = _get_team_user_names(nodes)
|
||||||
|
|
||||||
|
# 格式化返回数据
|
||||||
|
result = []
|
||||||
|
for node in nodes:
|
||||||
|
node_data = {
|
||||||
|
"name": node.name,
|
||||||
|
"node_type": node.node_type,
|
||||||
|
"title": node.title,
|
||||||
|
"subtitle": node.subtitle,
|
||||||
|
"enabled": node.enabled,
|
||||||
|
"public": node.public,
|
||||||
|
"team": team_user_names.get(node.team),
|
||||||
|
"status": node.status,
|
||||||
|
"repository_url": node.repository_url,
|
||||||
|
"file_url": node.file_url,
|
||||||
|
"node_image": node.node_image,
|
||||||
|
"creation": node.creation,
|
||||||
|
"modified": node.modified
|
||||||
|
}
|
||||||
|
result.append(node_data)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@jingrow.whitelist(allow_guest=True)
|
||||||
|
def get_local_agent_list(filters=None, order_by=None, limit_start=None, limit_page_length=None):
|
||||||
|
"""获取本地Agent列表"""
|
||||||
|
|
||||||
|
# 构建查询条件
|
||||||
|
query_filters = {"public": 1}
|
||||||
|
|
||||||
|
if filters:
|
||||||
|
if isinstance(filters, str):
|
||||||
|
import json
|
||||||
|
filters = json.loads(filters)
|
||||||
|
query_filters.update(filters)
|
||||||
|
|
||||||
|
# 默认排序
|
||||||
|
if not order_by:
|
||||||
|
order_by = "agent_name asc"
|
||||||
|
|
||||||
|
# 获取Agent列表
|
||||||
|
agents = jingrow.get_all(
|
||||||
|
"Local Agent",
|
||||||
|
filters=query_filters,
|
||||||
|
fields=[
|
||||||
|
"name", "agent_name", "title", "subtitle",
|
||||||
|
"enabled", "public", "team", "status", "repository_url",
|
||||||
|
"file_url", "agent_image", "creation", "modified"
|
||||||
|
],
|
||||||
|
order_by=order_by,
|
||||||
|
limit_start=limit_start,
|
||||||
|
limit_page_length=limit_page_length
|
||||||
|
)
|
||||||
|
|
||||||
|
# 批量获取团队用户名称
|
||||||
|
team_user_names = _get_team_user_names(agents)
|
||||||
|
|
||||||
|
# 格式化返回数据
|
||||||
|
result = []
|
||||||
|
for agent in agents:
|
||||||
|
agent_data = {
|
||||||
|
"name": agent.name,
|
||||||
|
"agent_name": agent.agent_name,
|
||||||
|
"title": agent.title,
|
||||||
|
"subtitle": agent.subtitle,
|
||||||
|
"enabled": agent.enabled,
|
||||||
|
"public": agent.public,
|
||||||
|
"team": team_user_names.get(agent.team),
|
||||||
|
"status": agent.status,
|
||||||
|
"repository_url": agent.repository_url,
|
||||||
|
"file_url": agent.file_url,
|
||||||
|
"agent_image": agent.agent_image,
|
||||||
|
"creation": agent.creation,
|
||||||
|
"modified": agent.modified
|
||||||
|
}
|
||||||
|
result.append(agent_data)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
@jingrow.whitelist(allow_guest=True)
|
@jingrow.whitelist(allow_guest=True)
|
||||||
def get_local_app(name):
|
def get_local_app(name):
|
||||||
"""获取本地应用详情"""
|
"""获取本地应用详情"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user