🐛 Bug: Fix the bug where after filtering through the filter, if there are a total of four rows, when clicking the edit configuration on the fourth row, the sheet still displays the data from the fourth row before the filter was applied.
Browse files- components/provider_table.py +14 -9
- main.py +2 -2
components/provider_table.py
CHANGED
|
@@ -143,7 +143,19 @@ Head.add_default_children([
|
|
| 143 |
""", id="data-table-script"),
|
| 144 |
])
|
| 145 |
|
| 146 |
-
def data_table(columns, data, id, with_filter=True):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
return Div(
|
| 148 |
Div(
|
| 149 |
input(type="text", placeholder="Filter...", id=f"{id}-filter", class_="mr-auto"),
|
|
@@ -178,14 +190,7 @@ def data_table(columns, data, id, with_filter=True):
|
|
| 178 |
Th("Actions") # 新增的操作列
|
| 179 |
)
|
| 180 |
),
|
| 181 |
-
|
| 182 |
-
*[Tr(
|
| 183 |
-
Td(checkbox(f"row-{i}", "", class_="row-checkbox")),
|
| 184 |
-
*[Td(row[col['value']], data_accessor=col['value']) for col in columns],
|
| 185 |
-
Td(row_actions_menu(i)), # 使用行索引作为 row_id
|
| 186 |
-
id=f"row-{i}"
|
| 187 |
-
) for i, row in enumerate(data)]
|
| 188 |
-
),
|
| 189 |
class_="data-table"
|
| 190 |
),
|
| 191 |
class_="data-table-container"
|
|
|
|
| 143 |
""", id="data-table-script"),
|
| 144 |
])
|
| 145 |
|
| 146 |
+
def data_table(columns, data, id, with_filter=True, row_ids=None):
|
| 147 |
+
if row_ids is None:
|
| 148 |
+
row_ids = range(len(data))
|
| 149 |
+
|
| 150 |
+
tbody_content = Tbody(
|
| 151 |
+
*[Tr(
|
| 152 |
+
Td(checkbox(f"row-{i}", "", class_="row-checkbox")),
|
| 153 |
+
*[Td(row[col['value']], data_accessor=col['value']) for col in columns],
|
| 154 |
+
Td(row_actions_menu(row_id)),
|
| 155 |
+
id=f"row-{row_id}"
|
| 156 |
+
) for i, (row, row_id) in enumerate(zip(data, row_ids))]
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
return Div(
|
| 160 |
Div(
|
| 161 |
input(type="text", placeholder="Filter...", id=f"{id}-filter", class_="mr-auto"),
|
|
|
|
| 190 |
Th("Actions") # 新增的操作列
|
| 191 |
)
|
| 192 |
),
|
| 193 |
+
tbody_content,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
class_="data-table"
|
| 195 |
),
|
| 196 |
class_="data-table-container"
|
main.py
CHANGED
|
@@ -1278,12 +1278,12 @@ async def get_columns_menu(menu_id: str):
|
|
| 1278 |
@frontend_router.get("/filter-table", response_class=HTMLResponse)
|
| 1279 |
async def filter_table(filter: str = ""):
|
| 1280 |
filtered_data = [
|
| 1281 |
-
provider for provider in app.state.config["providers"]
|
| 1282 |
if filter.lower() in str(provider["provider"]).lower() or
|
| 1283 |
filter.lower() in str(provider["base_url"]).lower() or
|
| 1284 |
filter.lower() in str(provider["tools"]).lower()
|
| 1285 |
]
|
| 1286 |
-
return data_table(data_table_columns, filtered_data, "users-table", with_filter=False).render()
|
| 1287 |
|
| 1288 |
@frontend_router.post("/add-model", response_class=HTMLResponse, dependencies=[Depends(frontend_rate_limit_dependency)])
|
| 1289 |
async def add_model():
|
|
|
|
| 1278 |
@frontend_router.get("/filter-table", response_class=HTMLResponse)
|
| 1279 |
async def filter_table(filter: str = ""):
|
| 1280 |
filtered_data = [
|
| 1281 |
+
(i, provider) for i, provider in enumerate(app.state.config["providers"])
|
| 1282 |
if filter.lower() in str(provider["provider"]).lower() or
|
| 1283 |
filter.lower() in str(provider["base_url"]).lower() or
|
| 1284 |
filter.lower() in str(provider["tools"]).lower()
|
| 1285 |
]
|
| 1286 |
+
return data_table(data_table_columns, [p for _, p in filtered_data], "users-table", with_filter=False, row_ids=[i for i, _ in filtered_data]).render()
|
| 1287 |
|
| 1288 |
@frontend_router.post("/add-model", response_class=HTMLResponse, dependencies=[Depends(frontend_rate_limit_dependency)])
|
| 1289 |
async def add_model():
|