DontPlanToEnd commited on
Commit
1d1fd1e
·
verified ·
1 Parent(s): 4e82d4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -90
app.py CHANGED
@@ -109,7 +109,9 @@ def get_kofi_button_base64():
109
  return images
110
 
111
  # Initialize the Dash app
112
- app = dash.Dash(__name__)
 
 
113
  server = app.server
114
 
115
  # Custom CSS
@@ -227,6 +229,7 @@ app.index_string = '''
227
  /* Border Classes */
228
  .border-left {
229
  border-left: 2px solid var(--grid-border) !important;
 
230
  }
231
  .border-right {
232
  border-right: 2px solid var(--grid-border) !important;
@@ -328,7 +331,6 @@ app.index_string = '''
328
  .split-header-top, .split-header-bottom {
329
  white-space: nowrap;
330
  }
331
-
332
  .ag-theme-alpine .new-emoji-cell.ag-cell {
333
  font-size: 18px !important;
334
  display: flex !important;
@@ -499,7 +501,7 @@ columnDefs = [
499
  "filterOptions": ['equals', 'notEqual', 'greaterThan', 'greaterThanOrEqual', 'lessThan', 'lessThanOrEqual', 'inRange']
500
  },
501
  "headerClass": "ag-left-aligned-header wrap-text",
502
- "cellClass": "ag-left-aligned-cell",
503
  "wrapHeaderText": True,
504
  "autoHeaderHeight": True,
505
  "suppressSizeToFit": True,
@@ -686,23 +688,8 @@ dashGridOptions = {
686
  "suppressMultiSort": True,
687
  "rowBuffer": 10,
688
  "maxBlocksInCache": 2,
689
- "onGridReady": {
690
- "function": """
691
- function(params) {
692
- console.log('Grid ready');
693
- window.gridApi = params.api;
694
- }
695
- """
696
- },
697
- "onRowDataChanged": {
698
- "function": """
699
- function(params) {
700
- console.log('Row data changed event');
701
- console.log('Current pinned rows:', params.api.getGridOption('pinnedTopRowData'));
702
- console.log('Current main rows:', []);
703
- params.api.forEachNode(node => console.log(node.data.Model_Display));
704
- }
705
- """
706
  },
707
  "theme": "ag-theme-alpine-dark" if "prefers-color-scheme: dark" else "ag-theme-alpine",
708
  "columnState": {
@@ -718,11 +705,6 @@ dashGridOptions = {
718
 
719
  # Define the layout
720
  app.layout = html.Div([
721
- dcc.Store(id='pinned-rows-store', data=[]),
722
- dcc.Store(id='pinned-ids-store', data=[]),
723
- dcc.Store(id='pinned-models-store', data=[]),
724
- dcc.Store(id='filter-change-trigger', data=0),
725
-
726
  # Header
727
  html.Div([
728
  html.Div([
@@ -926,10 +908,6 @@ app.layout = html.Div([
926
  ], style={'marginTop': '30px', 'marginBottom': '50px', 'maxWidth': '1200px', 'margin': '30px auto 80px'})
927
  ], style={'maxWidth': '100%', 'margin': '0 auto'})
928
 
929
- def debug_callback(value):
930
- print("Model filter value:", value)
931
- return value
932
-
933
  @app.callback(
934
  [Output('leaderboard-grid', 'rowData'),
935
  Output('model-type-filter', 'value'),
@@ -1016,66 +994,6 @@ def update_columns(additional_columns):
1016
 
1017
  return current_columns
1018
 
1019
- @app.callback(
1020
- Output('ideology-descriptions', 'children'),
1021
- [Input('leaderboard-grid', 'rowData')]
1022
- )
1023
- def update_ideology_descriptions(row_data):
1024
- if not row_data:
1025
- return []
1026
-
1027
- # Load ideology descriptions
1028
- ideology_descriptions = load_ideology_descriptions()
1029
-
1030
- # Get unique ideologies from current grid data
1031
- unique_ideologies = sorted(set(row['Ideology Name'] for row in row_data if row.get('Ideology Name')))
1032
-
1033
- # Create markdown content
1034
- markdown_content = []
1035
- for ideology in unique_ideologies:
1036
- if ideology in ideology_descriptions:
1037
- markdown_content.append(f"**{ideology}**: {ideology_descriptions[ideology]}")
1038
-
1039
- return dcc.Markdown("\n\n".join(markdown_content), className='markdown-content')
1040
 
1041
  if __name__ == '__main__':
1042
- app.run_server(host='0.0.0.0', port=8050)
1043
- app.clientside_callback(
1044
- """
1045
- function(n_clicks, current_data) {
1046
- if (!n_clicks) return current_data;
1047
- const pinnedRows = current_data.filter(row => row.pinned);
1048
- const unpinnedRows = current_data.filter(row => !row.pinned);
1049
- return [...pinnedRows, ...unpinnedRows];
1050
- }
1051
- """,
1052
- Output('leaderboard-grid', 'rowData'),
1053
- Input('leaderboard-grid', 'cellRendererData'),
1054
- State('leaderboard-grid', 'rowData')
1055
- )
1056
- app.clientside_callback(
1057
- """
1058
- function(n_clicks) {
1059
- if (!window.gridApi) return;
1060
-
1061
- console.log('Filter changed');
1062
- const pinnedRows = window.gridApi.getGridOption('pinnedTopRowData') || [];
1063
- console.log('Current pinned rows:', pinnedRows.map(r => r.Model_Display));
1064
-
1065
- if (pinnedRows.length > 0) {
1066
- const pinnedIds = new Set(pinnedRows.map(row => row.Model_Display));
1067
- const currentRows = [];
1068
- window.gridApi.forEachNode(node => {
1069
- if (!pinnedIds.has(node.data.Model_Display)) {
1070
- currentRows.push(node.data);
1071
- }
1072
- });
1073
- console.log('Filtering out pinned rows');
1074
- window.gridApi.setGridOption('rowData', currentRows);
1075
- }
1076
- return window.dash_clientside.no_update;
1077
- }
1078
- """,
1079
- Output('leaderboard-grid', 'rowData'),
1080
- Input('model-type-filter', 'value')
1081
- )
 
109
  return images
110
 
111
  # Initialize the Dash app
112
+ app = dash.Dash(__name__, external_stylesheets=[
113
+ "https://use.fontawesome.com/releases/v5.15.4/css/all.css"
114
+ ])
115
  server = app.server
116
 
117
  # Custom CSS
 
229
  /* Border Classes */
230
  .border-left {
231
  border-left: 2px solid var(--grid-border) !important;
232
+ margin-left: -2px !important;
233
  }
234
  .border-right {
235
  border-right: 2px solid var(--grid-border) !important;
 
331
  .split-header-top, .split-header-bottom {
332
  white-space: nowrap;
333
  }
 
334
  .ag-theme-alpine .new-emoji-cell.ag-cell {
335
  font-size: 18px !important;
336
  display: flex !important;
 
501
  "filterOptions": ['equals', 'notEqual', 'greaterThan', 'greaterThanOrEqual', 'lessThan', 'lessThanOrEqual', 'inRange']
502
  },
503
  "headerClass": "ag-left-aligned-header wrap-text",
504
+ "cellClass": ["ag-left-aligned-cell", "border-left"],
505
  "wrapHeaderText": True,
506
  "autoHeaderHeight": True,
507
  "suppressSizeToFit": True,
 
688
  "suppressMultiSort": True,
689
  "rowBuffer": 10,
690
  "maxBlocksInCache": 2,
691
+ "icons": {
692
+ "menu": '<i class="fas fa-search" style="color: var(--text-color)"></i>'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
693
  },
694
  "theme": "ag-theme-alpine-dark" if "prefers-color-scheme: dark" else "ag-theme-alpine",
695
  "columnState": {
 
705
 
706
  # Define the layout
707
  app.layout = html.Div([
 
 
 
 
 
708
  # Header
709
  html.Div([
710
  html.Div([
 
908
  ], style={'marginTop': '30px', 'marginBottom': '50px', 'maxWidth': '1200px', 'margin': '30px auto 80px'})
909
  ], style={'maxWidth': '100%', 'margin': '0 auto'})
910
 
 
 
 
 
911
  @app.callback(
912
  [Output('leaderboard-grid', 'rowData'),
913
  Output('model-type-filter', 'value'),
 
994
 
995
  return current_columns
996
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
997
 
998
  if __name__ == '__main__':
999
+ app.run_server(host='0.0.0.0', port=8050)