Spaces:
Sleeping

mhpl commited on
Commit
40b877e
Β·
verified Β·
1 Parent(s): 9a0984a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -33
app.py CHANGED
@@ -19,45 +19,75 @@ PASSWORD_HASH = os.environ.get('PASSWORD_HASH', '')
19
  # ================== CUSTOM CSS ==================
20
  app_css = """
21
  /* Authentication styles */
22
- .app-blur {
23
- filter: blur(5px) brightness(0.7);
 
 
 
 
 
 
24
  pointer-events: none;
 
 
25
  }
26
- .auth-dialog {
27
  position: fixed;
28
- top: 50%;
29
- left: 50%;
30
- transform: translate(-50%, -50%);
 
 
 
 
 
 
 
 
 
31
  background: white;
32
  padding: 2rem;
33
  border-radius: 12px;
34
- z-index: 1000;
35
  width: 450px;
 
36
  box-shadow: 0 0 30px rgba(0,0,0,0.2);
 
 
37
  }
38
- .auth-backdrop {
39
- position: fixed;
40
- top: 0;
41
- left: 0;
42
- right: 0;
43
- bottom: 0;
44
- background: rgba(0,0,0,0.5);
45
- z-index: 999;
46
- }
47
  .dialog-title {
48
  font-size: 1.5em;
49
  margin-bottom: 1.5rem;
50
  text-align: center;
51
  color: #333;
52
  }
 
53
  /* Main content styles */
54
- '''
55
  .main-content {
56
  min-height: calc(100vh - 6rem); /* Full viewport height minus footer */
57
  margin-bottom: 3rem; /* Space for the fixed footer */
58
  overflow-y: auto; /* Enable scrolling if content overflows */
 
 
 
 
 
 
 
 
 
59
  }
60
- '''
 
 
 
 
 
 
 
 
61
  .header-row {
62
  margin-bottom: 1.5rem !important;
63
  }
@@ -728,9 +758,11 @@ with gr.Blocks(css=app_css) as demo:
728
  temp_report_type = gr.State("Cleaned Revenue Report") # Temporary state for report type
729
  current_interface_type = gr.State(None) # Track current interface type
730
 
 
 
 
731
  # ----- Authentication Overlay -----
732
- with gr.Column(visible=True) as auth_overlay:
733
- gr.HTML("<div class='auth-backdrop'></div>")
734
  with gr.Column(elem_classes=["auth-dialog"]):
735
  gr.Markdown("## πŸ”’ Authentication Required")
736
  username = gr.Textbox(label="Username")
@@ -739,7 +771,7 @@ with gr.Blocks(css=app_css) as demo:
739
  error_msg = gr.Markdown("", visible=False)
740
 
741
  # ----- Main Content (blurred initially) -----
742
- with gr.Column(elem_classes=["main-content","app-blur"]) as main_content:
743
  # Header Row with Logo & Title
744
  with gr.Row(elem_classes=["header-row"]):
745
  gr.HTML("""
@@ -875,39 +907,39 @@ with gr.Blocks(css=app_css) as demo:
875
  if authenticate(username, password):
876
  yield [
877
  gr.update(visible=True),
878
- {"authenticated": False},
879
- gr.update(elem_classes=["app-blur"]),
880
  gr.update(value="βœ… Access Granted", visible=True)
881
  ]
882
  time.sleep(0.5)
883
  yield [
884
- gr.update(visible=False),
885
- {"authenticated": True},
886
- gr.update(elem_classes=[]),
887
  gr.update(value="", visible=False)
888
  ]
889
  else:
890
  yield [
891
- gr.update(visible=True),
892
- {"authenticated": False},
893
- gr.update(elem_classes=["app-blur"]),
894
- gr.update(value="β›” Invalid Credentials", visible=True)
895
  ]
896
 
897
  login_btn.click(
898
  handle_login,
899
  [username, password, auth_state],
900
- [auth_overlay, auth_state, main_content, error_msg]
901
  )
902
  username.submit(
903
  handle_login,
904
  [username, password, auth_state],
905
- [auth_overlay, auth_state, main_content, error_msg]
906
  )
907
  password.submit(
908
  handle_login,
909
  [username, password, auth_state],
910
- [auth_overlay, auth_state, main_content, error_msg]
911
  )
912
 
913
  # Updated Working Fully with fixed Upload Interfaces with working stop button
 
19
  # ================== CUSTOM CSS ==================
20
  app_css = """
21
  /* Authentication styles */
22
+ .blur-overlay {
23
+ position: fixed;
24
+ top: 0;
25
+ left: 0;
26
+ width: 100%;
27
+ height: 100%;
28
+ background: rgba(0, 0, 0, 0.1);
29
+ z-index: 998;
30
  pointer-events: none;
31
+ filter: blur(5px) brightness(0.7);
32
+ display: none;
33
  }
34
+ .auth-overlay {
35
  position: fixed;
36
+ top: 0;
37
+ left: 0;
38
+ width: 100%;
39
+ height: 100%;
40
+ background: rgba(0, 0, 0, 0.5);
41
+ z-index: 999;
42
+ display: flex;
43
+ justify-content: center;
44
+ align-items: center;
45
+ }
46
+
47
+ .auth-dialog {
48
  background: white;
49
  padding: 2rem;
50
  border-radius: 12px;
 
51
  width: 450px;
52
+ max-width: 95%;
53
  box-shadow: 0 0 30px rgba(0,0,0,0.2);
54
+ z-index: 1000;
55
+ position: relative;
56
  }
57
+
58
+
 
 
 
 
 
 
 
59
  .dialog-title {
60
  font-size: 1.5em;
61
  margin-bottom: 1.5rem;
62
  text-align: center;
63
  color: #333;
64
  }
65
+
66
  /* Main content styles */
67
+
68
  .main-content {
69
  min-height: calc(100vh - 6rem); /* Full viewport height minus footer */
70
  margin-bottom: 3rem; /* Space for the fixed footer */
71
  overflow-y: auto; /* Enable scrolling if content overflows */
72
+ width: 100% !important;
73
+ }
74
+
75
+ /* CRITICAL HF SPACES FIXES */
76
+ #app {
77
+ padding: 0 !important;
78
+ margin: 0 !important;
79
+ height: 100vh !important;
80
+ overflow: hidden;
81
  }
82
+ .gradio-container {
83
+ height: 100% !important;
84
+ max-width: 100% !important;
85
+ padding: 0 !important;
86
+ }
87
+ .block {
88
+ max-width: 100% !important;
89
+ }
90
+
91
  .header-row {
92
  margin-bottom: 1.5rem !important;
93
  }
 
758
  temp_report_type = gr.State("Cleaned Revenue Report") # Temporary state for report type
759
  current_interface_type = gr.State(None) # Track current interface type
760
 
761
+ # ===== NEW STRUCTURE: SEPARATE BLUR LAYER =====
762
+ blur_overlay = gr.HTML('<div class="blur-overlay"></div>', visible=False)
763
+
764
  # ----- Authentication Overlay -----
765
+ with gr.Column(visible=True, elem_classes = ["auth-overlay"]) as auth_overlay:
 
766
  with gr.Column(elem_classes=["auth-dialog"]):
767
  gr.Markdown("## πŸ”’ Authentication Required")
768
  username = gr.Textbox(label="Username")
 
771
  error_msg = gr.Markdown("", visible=False)
772
 
773
  # ----- Main Content (blurred initially) -----
774
+ with gr.Column(elem_classes=["main-content"], visible=False) as main_content:
775
  # Header Row with Logo & Title
776
  with gr.Row(elem_classes=["header-row"]):
777
  gr.HTML("""
 
907
  if authenticate(username, password):
908
  yield [
909
  gr.update(visible=True),
910
+ gr.update(visible=False), # auth_overlay
911
+ gr.update(visible=True), # main_content
912
  gr.update(value="βœ… Access Granted", visible=True)
913
  ]
914
  time.sleep(0.5)
915
  yield [
916
+ gr.update(visible=False), # blur_overlay
917
+ gr.update(visible=False), # auth_overlay
918
+ gr.update(visible=True), # main_content
919
  gr.update(value="", visible=False)
920
  ]
921
  else:
922
  yield [
923
+ gr.update(visible=True), # blur_overlay
924
+ gr.update(visible=True), # auth_overlay
925
+ gr.update(visible=False), # main_content
926
+ gr.update(value="⚠️ Invalid Credentials", visible=True)
927
  ]
928
 
929
  login_btn.click(
930
  handle_login,
931
  [username, password, auth_state],
932
+ [blur_overlay, auth_overlay, main_content, error_msg]
933
  )
934
  username.submit(
935
  handle_login,
936
  [username, password, auth_state],
937
+ [blur_overlay, auth_overlay, main_content, error_msg]
938
  )
939
  password.submit(
940
  handle_login,
941
  [username, password, auth_state],
942
+ [blur_overlay, auth_overlay, main_content, error_msg]
943
  )
944
 
945
  # Updated Working Fully with fixed Upload Interfaces with working stop button