from dash import dcc, html
import feffery_antd_components as fac
from flask import session
from . import profile
from api.modmag import get_cluster_info_api
from config.global_config import ApiBaseUrlConfig
# import callbacks.system_c.user_c.user_c
import callbacks.model_c.modmag_c
from utils.common import process_string
from utils.mod_mag import get_supervisor_info
def render(*args, **kwargs):
button_perms = kwargs.get('button_perms')
cluster_info = get_cluster_info_api()
supervisor_data = get_supervisor_info(cluster_info)
return [
html.Div(
[
fac.AntdSpace(
[
fac.AntdDivider('Supervisor', innerTextOrientation='left'),
fac.AntdSpace(
fac.AntdTable(
columns=[
{
'dataIndex': '字段1',
'title': 'item',
'width': '20%'
},
{
'dataIndex': '字段2',
'title': 'value/Usage',
'width': '20%'
},
{
'dataIndex': '字段3',
'title': 'other/total',
'width': '40%'
},
],
data=supervisor_data,
pagination={'hideOnSinglePage': True},
style={
'cursor': 'pointer',
'width': "100%", # 使表格宽度适应父容器
'height': '20vh', # 使表格高度占视口高度的 20%
'overflowY': 'auto', # 使表格在高度超过容器时可滚动
},
)
),
fac.AntdDivider('Workers', innerTextOrientation='left', style={'marginTop': '10px'}),
],
direction='vertical',
style={
'width': '100%',
'gap': '10px', # 设置子元素之间的间距,避免重叠
}
)
],
style={
'width': '100%',
'height': '100vh', # 使布局高度适配屏幕高度
'boxSizing': 'border-box', # 确保 padding 不影响整体宽度计算
'display': 'flex',
'flexDirection': 'column', # 垂直排列元素
'alignItems': 'stretch', # 子元素拉伸以适应父容器宽度
'overflow': 'auto', # 防止内容溢出导致重叠
'padding': '10px', # 添加内边距以防止内容紧贴边界
}
)
]