简化local_app.py
This commit is contained in:
parent
860764fa74
commit
4d6278a8d6
@ -140,6 +140,68 @@ def get_local_app(name):
|
|||||||
return app_data
|
return app_data
|
||||||
|
|
||||||
|
|
||||||
|
@dashboard_whitelist()
|
||||||
|
def get_my_local_app_list(filters=None, order_by=None, limit_start=None, limit_page_length=None):
|
||||||
|
"""获取当前团队的应用列表"""
|
||||||
|
|
||||||
|
team = get_current_team()
|
||||||
|
if not team:
|
||||||
|
return {"success": False, "message": "未找到当前团队信息"}
|
||||||
|
|
||||||
|
# 构建查询条件
|
||||||
|
query_filters = {"team": team}
|
||||||
|
|
||||||
|
if filters:
|
||||||
|
if isinstance(filters, str):
|
||||||
|
import json
|
||||||
|
filters = json.loads(filters)
|
||||||
|
query_filters.update(filters)
|
||||||
|
|
||||||
|
# 默认排序
|
||||||
|
if not order_by:
|
||||||
|
order_by = "app_name asc"
|
||||||
|
|
||||||
|
# 获取应用列表
|
||||||
|
apps = jingrow.get_all(
|
||||||
|
"Local App",
|
||||||
|
filters=query_filters,
|
||||||
|
fields=[
|
||||||
|
"name", "app_name", "title", "subtitle", "category",
|
||||||
|
"enabled", "public", "team", "status", "repository_url",
|
||||||
|
"file_url", "app_image", "creation", "modified"
|
||||||
|
],
|
||||||
|
order_by=order_by,
|
||||||
|
limit_start=limit_start,
|
||||||
|
limit_page_length=limit_page_length
|
||||||
|
)
|
||||||
|
|
||||||
|
# 批量获取团队用户名称
|
||||||
|
team_user_names = _get_team_user_names(apps)
|
||||||
|
|
||||||
|
# 格式化返回数据
|
||||||
|
result = []
|
||||||
|
for app in apps:
|
||||||
|
app_data = {
|
||||||
|
"name": app.name,
|
||||||
|
"app_name": app.app_name,
|
||||||
|
"title": app.title,
|
||||||
|
"subtitle": app.subtitle,
|
||||||
|
"category": app.category,
|
||||||
|
"enabled": app.enabled,
|
||||||
|
"public": app.public,
|
||||||
|
"team": team_user_names.get(app.team),
|
||||||
|
"status": app.status,
|
||||||
|
"repository_url": app.repository_url,
|
||||||
|
"file_url": app.file_url,
|
||||||
|
"app_image": app.app_image,
|
||||||
|
"creation": app.creation,
|
||||||
|
"modified": app.modified
|
||||||
|
}
|
||||||
|
result.append(app_data)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
@dashboard_whitelist()
|
@dashboard_whitelist()
|
||||||
def create_local_app(app_data):
|
def create_local_app(app_data):
|
||||||
"""创建本地应用"""
|
"""创建本地应用"""
|
||||||
@ -217,87 +279,62 @@ def delete_local_app(name):
|
|||||||
return {"success": True, "message": "应用删除成功"}
|
return {"success": True, "message": "应用删除成功"}
|
||||||
|
|
||||||
|
|
||||||
@jingrow.whitelist(allow_guest=True)
|
@dashboard_whitelist()
|
||||||
def get_local_app_meta():
|
def get_my_local_node_list(filters=None, order_by=None, limit_start=None, limit_page_length=None):
|
||||||
"""获取 Local App 元数据信息"""
|
"""获取当前团队的节点列表"""
|
||||||
|
|
||||||
meta = jingrow.get_meta("Local App")
|
team = get_current_team()
|
||||||
return meta.as_dict()
|
if not team:
|
||||||
|
return {"success": False, "message": "未找到当前团队信息"}
|
||||||
|
|
||||||
@jingrow.whitelist(allow_guest=True)
|
|
||||||
def get_local_app_categories():
|
|
||||||
"""获取本地应用分类列表"""
|
|
||||||
|
|
||||||
categories = jingrow.get_all(
|
# 构建查询条件
|
||||||
"Marketplace App Category",
|
query_filters = {"team": team}
|
||||||
fields=["name", "description", "slug"],
|
|
||||||
order_by="name asc"
|
|
||||||
)
|
|
||||||
|
|
||||||
result = []
|
|
||||||
for category in categories:
|
|
||||||
category_data = {
|
|
||||||
"name": category.name,
|
|
||||||
"description": category.description,
|
|
||||||
"slug": category.slug
|
|
||||||
}
|
|
||||||
result.append(category_data)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
@jingrow.whitelist(allow_guest=True)
|
|
||||||
def search_local_apps(query, filters=None, limit=20):
|
|
||||||
"""搜索本地应用"""
|
|
||||||
|
|
||||||
# 构建搜索条件
|
|
||||||
search_filters = {
|
|
||||||
"enabled": 1,
|
|
||||||
"app_name": ["like", f"%{query}%"]
|
|
||||||
}
|
|
||||||
|
|
||||||
if filters:
|
if filters:
|
||||||
if isinstance(filters, str):
|
if isinstance(filters, str):
|
||||||
import json
|
import json
|
||||||
filters = json.loads(filters)
|
filters = json.loads(filters)
|
||||||
search_filters.update(filters)
|
query_filters.update(filters)
|
||||||
|
|
||||||
# 搜索应用
|
# 默认排序
|
||||||
apps = jingrow.get_all(
|
if not order_by:
|
||||||
"Local App",
|
order_by = "node_type asc"
|
||||||
filters=search_filters,
|
|
||||||
|
# 获取节点列表
|
||||||
|
nodes = jingrow.get_all(
|
||||||
|
"Local Node",
|
||||||
|
filters=query_filters,
|
||||||
fields=[
|
fields=[
|
||||||
"name", "app_name", "title", "subtitle", "category",
|
"name", "node_type", "title", "subtitle",
|
||||||
"enabled", "public", "team", "status", "repository_url",
|
"enabled", "public", "team", "status", "repository_url",
|
||||||
"file_url", "app_image", "creation", "modified"
|
"file_url", "node_image", "creation", "modified"
|
||||||
],
|
],
|
||||||
order_by="app_name asc",
|
order_by=order_by,
|
||||||
limit=limit
|
limit_start=limit_start,
|
||||||
|
limit_page_length=limit_page_length
|
||||||
)
|
)
|
||||||
|
|
||||||
# 批量获取团队用户名称
|
# 批量获取团队用户名称
|
||||||
team_user_names = _get_team_user_names(apps)
|
team_user_names = _get_team_user_names(nodes)
|
||||||
|
|
||||||
# 格式化返回数据
|
# 格式化返回数据
|
||||||
result = []
|
result = []
|
||||||
for app in apps:
|
for node in nodes:
|
||||||
app_data = {
|
node_data = {
|
||||||
"name": app.name,
|
"name": node.name,
|
||||||
"app_name": app.app_name,
|
"node_type": node.node_type,
|
||||||
"title": app.title,
|
"title": node.title,
|
||||||
"subtitle": app.subtitle,
|
"subtitle": node.subtitle,
|
||||||
"category": app.category,
|
"enabled": node.enabled,
|
||||||
"enabled": app.enabled,
|
"public": node.public,
|
||||||
"public": app.public,
|
"team": team_user_names.get(node.team),
|
||||||
"team": team_user_names.get(app.team),
|
"status": node.status,
|
||||||
"status": app.status,
|
"repository_url": node.repository_url,
|
||||||
"repository_url": app.repository_url,
|
"file_url": node.file_url,
|
||||||
"file_url": app.file_url,
|
"node_image": node.node_image,
|
||||||
"app_image": app.app_image,
|
"creation": node.creation,
|
||||||
"creation": app.creation,
|
"modified": node.modified
|
||||||
"modified": app.modified
|
|
||||||
}
|
}
|
||||||
result.append(app_data)
|
result.append(node_data)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -24,6 +24,8 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "team",
|
"fieldname": "team",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
"label": "Team",
|
"label": "Team",
|
||||||
"options": "Team",
|
"options": "Team",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
@ -96,7 +98,7 @@
|
|||||||
"fieldname": "status",
|
"fieldname": "status",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Status",
|
"label": "Status",
|
||||||
"options": "Published\nUnpublished\nDraft"
|
"options": "Pending Review\nPublished\nUnpublished\nDraft"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "subtitle",
|
"fieldname": "subtitle",
|
||||||
@ -105,7 +107,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-10-22 22:35:00.480783",
|
"modified": "2025-11-02 22:55:33.457151",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Jcloud",
|
"module": "Jcloud",
|
||||||
"name": "Local App",
|
"name": "Local App",
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class LocalApp(Page):
|
|||||||
file_url: DF.Data | None
|
file_url: DF.Data | None
|
||||||
public: DF.Check
|
public: DF.Check
|
||||||
repository_url: DF.Data | None
|
repository_url: DF.Data | None
|
||||||
status: DF.Literal["Published", "Unpublished", "Draft"]
|
status: DF.Literal["Pending Review", "Published", "Unpublished", "Draft"]
|
||||||
subtitle: DF.SmallText | None
|
subtitle: DF.SmallText | None
|
||||||
team: DF.Link | None
|
team: DF.Link | None
|
||||||
title: DF.Data
|
title: DF.Data
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "team",
|
"fieldname": "team",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
"label": "Team",
|
"label": "Team",
|
||||||
"options": "Team",
|
"options": "Team",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
@ -73,7 +75,7 @@
|
|||||||
"fieldname": "status",
|
"fieldname": "status",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Status",
|
"label": "Status",
|
||||||
"options": "Published\nUnpublished\nDraft"
|
"options": "Pending Review\nPublished\nUnpublished\nDraft"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "subtitle",
|
"fieldname": "subtitle",
|
||||||
@ -96,7 +98,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-11-02 04:50:27.312179",
|
"modified": "2025-11-02 23:06:55.789746",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Jcloud",
|
"module": "Jcloud",
|
||||||
"name": "Local Node",
|
"name": "Local Node",
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class LocalNode(Page):
|
|||||||
node_type: DF.Data
|
node_type: DF.Data
|
||||||
public: DF.Check
|
public: DF.Check
|
||||||
repository_url: DF.Data | None
|
repository_url: DF.Data | None
|
||||||
status: DF.Literal["Published", "Unpublished", "Draft"]
|
status: DF.Literal["Pending Review", "Published", "Unpublished", "Draft"]
|
||||||
subtitle: DF.SmallText | None
|
subtitle: DF.SmallText | None
|
||||||
team: DF.Link | None
|
team: DF.Link | None
|
||||||
title: DF.Data
|
title: DF.Data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user