Spaces:
Sleeping
Sleeping
| """This module implements the table component for the AI Dashboard.""" | |
| from typing import Any | |
| import logging | |
| from dash import dash_table | |
| from ..base import BaseTablePlugin | |
| logger = logging.getLogger(__name__) | |
| class SampleTablePlugin(BaseTablePlugin): | |
| """A sample table plugin for the AI Dashboard.""" | |
| name = "Sample Table" | |
| def controls(self) -> None: | |
| """Generate plot controls.""" | |
| logger.debug("Generating controls for SampleTablePlugin.") | |
| def render(self, **kwargs: Any) -> Any: | |
| """Render the table component.""" | |
| return dash_table.DataTable( # type: ignore | |
| id="sample-table", | |
| columns=[ | |
| { | |
| "name": col, | |
| "id": col, | |
| "hideable": True, | |
| "deletable": False, | |
| "renamable": False, | |
| } | |
| for col in self.dataframe.columns | |
| ], | |
| data=self.dataframe.to_dict("records"), | |
| page_size=len(self.dataframe), | |
| page_action="native", | |
| filter_action="native", | |
| row_selectable=None, | |
| column_selectable="multi", | |
| editable=False, | |
| fixed_rows={"headers": True}, | |
| style_table={"overflowY": "auto", "overflowX": "auto", "height": "500px"}, | |
| style_cell={ | |
| "textAlign": "center", | |
| "padding": "6px", | |
| "border": "1px solid #ccc", | |
| "fontFamily": "Times New Roman, Times, serif", | |
| }, | |
| style_header={"backgroundColor": "#f0f0f0", "fontWeight": "bold"}, | |
| ) | |
| def register_callbacks(self, app: Any) -> None: | |
| """Register callbacks for the table plugin.""" | |
| logger.debug("Registering callbacks for SampleTablePlugin.") | |