PraneshJs commited on
Commit
c3de99b
·
verified ·
1 Parent(s): 2a2bd75

fixed layout issue in System Information

Browse files
Files changed (1) hide show
  1. app.py +29 -12
app.py CHANGED
@@ -1007,8 +1007,8 @@ with gr.Blocks(title="Student Reward Points Check", theme=gr.themes.Soft()) as a
1007
  system_btn = gr.Button("📊 Get System Information", variant="secondary")
1008
  system_output = gr.Textbox(
1009
  label="System Information",
1010
- lines=30,
1011
- max_lines=50,
1012
  show_copy_button=True,
1013
  autoscroll=False,
1014
  interactive=False,
@@ -1016,7 +1016,7 @@ with gr.Blocks(title="Student Reward Points Check", theme=gr.themes.Soft()) as a
1016
  )
1017
 
1018
  # NEW: Admin Controls as a separate tab
1019
- with gr.TabItem("🔧 Admin Controls") as admin_tab:
1020
  gr.Markdown("### 🔐 Administrative Functions")
1021
  gr.Markdown("⚠️ **Access restricted to authorized personnel only**")
1022
 
@@ -1124,23 +1124,40 @@ with gr.Blocks(title="Student Reward Points Check", theme=gr.themes.Soft()) as a
1124
  elem_id="footer"
1125
  )
1126
 
1127
- # Admin mode handler on app load (for tab visibility)
1128
  def setup_admin_mode(request: gr.Request):
1129
  """Setup admin mode based on URL parameters"""
1130
- is_admin = check_admin_mode(request)
1131
- if is_admin:
1132
- return gr.update(visible=True) # Show admin tab
1133
- else:
1134
- return gr.update(visible=False) # Hide admin tab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1135
 
1136
- # Apply admin mode check on load
1137
  app.load(
1138
  fn=setup_admin_mode,
1139
  outputs=admin_tab
1140
  )
1141
 
1142
- # Load system info on startup
1143
- app.load(fn=get_system_info, outputs=system_output)
 
 
 
1144
 
1145
  # Launch the app
1146
  if __name__ == "__main__":
 
1007
  system_btn = gr.Button("📊 Get System Information", variant="secondary")
1008
  system_output = gr.Textbox(
1009
  label="System Information",
1010
+ lines=50,
1011
+ max_lines=60,
1012
  show_copy_button=True,
1013
  autoscroll=False,
1014
  interactive=False,
 
1016
  )
1017
 
1018
  # NEW: Admin Controls as a separate tab
1019
+ with gr.TabItem("🔧 Admin Controls", visible=False) as admin_tab: # Start hidden by default
1020
  gr.Markdown("### 🔐 Administrative Functions")
1021
  gr.Markdown("⚠️ **Access restricted to authorized personnel only**")
1022
 
 
1124
  elem_id="footer"
1125
  )
1126
 
1127
+ # FIXED: Admin mode handler on app load (for tab visibility) - SIMPLIFIED
1128
  def setup_admin_mode(request: gr.Request):
1129
  """Setup admin mode based on URL parameters"""
1130
+ try:
1131
+ is_admin = check_admin_mode(request)
1132
+ if is_admin:
1133
+ print("🔧 Admin tab will be visible")
1134
+ return gr.update(visible=True) # Show admin tab
1135
+ else:
1136
+ return gr.update(visible=False) # Hide admin tab
1137
+ except Exception as e:
1138
+ print(f"⚠️ Error in setup_admin_mode: {str(e)}")
1139
+ return gr.update(visible=False) # Hide admin tab on error
1140
+
1141
+ # FIXED: System info initialization function
1142
+ def initialize_system_info():
1143
+ """Initialize system information display"""
1144
+ try:
1145
+ return get_system_info()
1146
+ except Exception as e:
1147
+ print(f"⚠️ Error initializing system info: {str(e)}")
1148
+ return "⚠️ System information will be available after data loads completely."
1149
 
1150
+ # Apply admin mode check on load (only affects admin tab visibility)
1151
  app.load(
1152
  fn=setup_admin_mode,
1153
  outputs=admin_tab
1154
  )
1155
 
1156
+ # Load system info on startup (separate from admin mode)
1157
+ app.load(
1158
+ fn=initialize_system_info,
1159
+ outputs=system_output
1160
+ )
1161
 
1162
  # Launch the app
1163
  if __name__ == "__main__":