parass13 commited on
Commit
cac13e1
Β·
verified Β·
1 Parent(s): a5c43b8

Update dashboard.py

Browse files
Files changed (1) hide show
  1. dashboard.py +10 -6
dashboard.py CHANGED
@@ -81,7 +81,8 @@ def login_user(email, password):
81
  # Gradio UI
82
  with gr.Blocks() as demo:
83
  is_logged_in = gr.State(False)
84
-
 
85
  with gr.Tabs():
86
  # Login Tab (Visible by default)
87
  with gr.Tab("πŸ” Login") as login_tab:
@@ -102,6 +103,9 @@ with gr.Blocks() as demo:
102
  predict_btn = gr.Button("Predict")
103
  predict_btn.click(fn=predict_image, inputs=image_input, outputs=result)
104
 
 
 
 
105
  # About, Community, User Guide (Always visible)
106
  with gr.Tab("ℹ️ About"):
107
  about.layout()
@@ -112,9 +116,6 @@ with gr.Blocks() as demo:
112
  with gr.Tab("πŸ“˜ User Guide"):
113
  user_guide.layout()
114
 
115
- # Logout Button (Initially Hidden)
116
- logout_btn = gr.Button("Logout", visible=False)
117
-
118
  # Handlers
119
  def handle_login(email, password):
120
  success = login_user(email, password)
@@ -125,6 +126,7 @@ with gr.Blocks() as demo:
125
  gr.update(visible=False), # Hide Login tab
126
  gr.update(visible=True), # Show Detect tab
127
  gr.update(visible=True), # Show Logout button
 
128
  )
129
  return (
130
  "❌ Invalid credentials", # Error message
@@ -132,6 +134,7 @@ with gr.Blocks() as demo:
132
  gr.update(visible=True), # Keep Login tab visible
133
  gr.update(visible=False), # Hide Detect tab
134
  gr.update(visible=False), # Hide Logout button
 
135
  )
136
 
137
  def handle_signup(name, phone, email, password):
@@ -144,13 +147,14 @@ with gr.Blocks() as demo:
144
  gr.update(visible=True), # Show Login tab again
145
  gr.update(visible=False), # Hide Detect tab
146
  gr.update(visible=False), # Hide Logout button
 
147
  )
148
 
149
  # Button clicks
150
  login_btn.click(
151
  fn=handle_login,
152
  inputs=[email, password],
153
- outputs=[message_output, is_logged_in, login_tab, detect_tab, logout_btn]
154
  )
155
 
156
  signup_btn.click(
@@ -162,7 +166,7 @@ with gr.Blocks() as demo:
162
  logout_btn.click(
163
  fn=handle_logout,
164
  inputs=[],
165
- outputs=[is_logged_in, login_tab, detect_tab, logout_btn]
166
  )
167
 
168
  if __name__ == "__main__":
 
81
  # Gradio UI
82
  with gr.Blocks() as demo:
83
  is_logged_in = gr.State(False)
84
+ active_tab = gr.State(0) # To manage which tab is active
85
+
86
  with gr.Tabs():
87
  # Login Tab (Visible by default)
88
  with gr.Tab("πŸ” Login") as login_tab:
 
103
  predict_btn = gr.Button("Predict")
104
  predict_btn.click(fn=predict_image, inputs=image_input, outputs=result)
105
 
106
+ # Logout button inside the Detect tab
107
+ logout_btn = gr.Button("Logout", visible=False)
108
+
109
  # About, Community, User Guide (Always visible)
110
  with gr.Tab("ℹ️ About"):
111
  about.layout()
 
116
  with gr.Tab("πŸ“˜ User Guide"):
117
  user_guide.layout()
118
 
 
 
 
119
  # Handlers
120
  def handle_login(email, password):
121
  success = login_user(email, password)
 
126
  gr.update(visible=False), # Hide Login tab
127
  gr.update(visible=True), # Show Detect tab
128
  gr.update(visible=True), # Show Logout button
129
+ gr.update(visible=True), # Show Detect Deepfake tab
130
  )
131
  return (
132
  "❌ Invalid credentials", # Error message
 
134
  gr.update(visible=True), # Keep Login tab visible
135
  gr.update(visible=False), # Hide Detect tab
136
  gr.update(visible=False), # Hide Logout button
137
+ gr.update(visible=False), # Hide Detect Deepfake tab
138
  )
139
 
140
  def handle_signup(name, phone, email, password):
 
147
  gr.update(visible=True), # Show Login tab again
148
  gr.update(visible=False), # Hide Detect tab
149
  gr.update(visible=False), # Hide Logout button
150
+ gr.update(visible=False), # Hide Detect Deepfake tab
151
  )
152
 
153
  # Button clicks
154
  login_btn.click(
155
  fn=handle_login,
156
  inputs=[email, password],
157
+ outputs=[message_output, is_logged_in, login_tab, detect_tab, logout_btn, detect_tab]
158
  )
159
 
160
  signup_btn.click(
 
166
  logout_btn.click(
167
  fn=handle_logout,
168
  inputs=[],
169
+ outputs=[is_logged_in, login_tab, detect_tab, logout_btn, detect_tab]
170
  )
171
 
172
  if __name__ == "__main__":