HAHAHA97 commited on
Commit
d01dee4
·
1 Parent(s): 0b13717

UI update

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +10 -7
  3. src/display/academic.py +25 -0
README.md CHANGED
@@ -126,7 +126,7 @@ and add the resulting value as a private Space secret in both Spaces. It encrypt
126
  participant-provided fine-grained read tokens while a private-dataset submission
127
  is queued or running.
128
 
129
- Register `https://<space-subdomain>.hf.space/orcid/callback` as the ORCID OAuth
130
  redirect URI, and set `ORCID_REDIRECT_URI` to that exact URL. If an earlier
131
  registration used the Space root URL, update it in ORCID Developer Tools and
132
  the Frontend Space setting. The Frontend serves this callback directly, verifies
 
126
  participant-provided fine-grained read tokens while a private-dataset submission
127
  is queued or running.
128
 
129
+ Register `https://vlar-physinone-leaderboard.hf.space/orcid/callback` as the ORCID OAuth
130
  redirect URI, and set `ORCID_REDIRECT_URI` to that exact URL. If an earlier
131
  registration used the Space root URL, update it in ORCID Developer Tools and
132
  the Frontend Space setting. The Frontend serves this callback directly, verifies
app.py CHANGED
@@ -17,7 +17,7 @@ from src.about import (
17
  )
18
  from src.display.css_html_js import custom_css
19
  from src.display.table_layout import column_width, table_resize_js
20
- from src.display.academic import academic_css, auth_presentation_js, navigation_state_js, open_submission_js
21
  from src.display.leaderboard import render_leaderboard, public_table_js
22
  from src.envs import ensure_data_layout
23
  from src.populate import get_history_df, get_leaderboard_df, get_queue_df
@@ -636,7 +636,8 @@ def _render_submitter_profile(group_slug: str) -> None:
636
  with gr.Group(elem_classes="profile-card"):
637
  gr.Markdown("#### Researcher Identity")
638
  orcid_status = gr.Markdown()
639
- connect = gr.Button("Connect ORCID", size="sm", scale=0)
 
640
  orcid_url = gr.State("")
641
  with gr.Row():
642
  name = gr.Textbox(label="Name")
@@ -786,13 +787,15 @@ def _render_submitter_profile(group_slug: str) -> None:
786
  )
787
  connect.click(
788
  _start_orcid, outputs=[orcid_url, profile_message],
789
- js="() => { window.physinoneOrcidPopup = window.open('about:blank', 'physinone-orcid', "
790
- "'width=620,height=720'); if (!window.physinoneOrcidPopup) "
791
- "window.alert('Allow popups for this site to connect ORCID.'); return []; }",
792
  ).success(
793
  fn=None, inputs=orcid_url,
794
  js="(url) => { const popup = window.physinoneOrcidPopup; "
795
- "if (popup && !popup.closed) { if (url) popup.location.assign(url); else popup.close(); } }",
 
 
 
 
796
  )
797
  identity_header.attach_load_event(_header, every=None)
798
  orcid_status.attach_load_event(_orcid_label, every=None)
@@ -1296,7 +1299,7 @@ def _wire_submit_if_available(
1296
 
1297
  with gr.Blocks(
1298
  css=custom_css + academic_css,
1299
- js=f"() => {{ ({table_resize_js})(); ({public_table_js})(); ({auth_presentation_js})(); ({navigation_state_js})(); }}",
1300
  theme=gr.themes.Soft(),
1301
  title="PhysInOne Leaderboard",
1302
  delete_cache=(3600, 86400),
 
17
  )
18
  from src.display.css_html_js import custom_css
19
  from src.display.table_layout import column_width, table_resize_js
20
+ from src.display.academic import academic_css, auth_presentation_js, navigation_state_js, open_submission_js, orcid_popup_js
21
  from src.display.leaderboard import render_leaderboard, public_table_js
22
  from src.envs import ensure_data_layout
23
  from src.populate import get_history_df, get_leaderboard_df, get_queue_df
 
636
  with gr.Group(elem_classes="profile-card"):
637
  gr.Markdown("#### Researcher Identity")
638
  orcid_status = gr.Markdown()
639
+ connect = gr.Button("Connect ORCID", size="sm", scale=0,
640
+ elem_classes="orcid-connect-button")
641
  orcid_url = gr.State("")
642
  with gr.Row():
643
  name = gr.Textbox(label="Name")
 
787
  )
788
  connect.click(
789
  _start_orcid, outputs=[orcid_url, profile_message],
790
+ queue=False,
 
 
791
  ).success(
792
  fn=None, inputs=orcid_url,
793
  js="(url) => { const popup = window.physinoneOrcidPopup; "
794
+ "if (!popup || popup.closed) { window.physinoneOrcidPopup = null; "
795
+ "window.physinoneOrcidBusy = false; return; } "
796
+ "if (url) popup.location.href = url; "
797
+ "else { popup.close(); window.physinoneOrcidPopup = null; "
798
+ "window.physinoneOrcidBusy = false; } }",
799
  )
800
  identity_header.attach_load_event(_header, every=None)
801
  orcid_status.attach_load_event(_orcid_label, every=None)
 
1299
 
1300
  with gr.Blocks(
1301
  css=custom_css + academic_css,
1302
+ js=f"() => {{ ({table_resize_js})(); ({public_table_js})(); ({auth_presentation_js})(); ({navigation_state_js})(); ({orcid_popup_js})(); }}",
1303
  theme=gr.themes.Soft(),
1304
  title="PhysInOne Leaderboard",
1305
  delete_cache=(3600, 86400),
src/display/academic.py CHANGED
@@ -86,10 +86,35 @@ navigation_state_js = """() => {
86
  window.addEventListener('focus', refreshIdentity);
87
  window.addEventListener('message', event => {
88
  if (event.origin !== window.location.origin || event.data?.type !== 'physinone-orcid') return;
 
 
89
  refreshIdentity();
90
  });
91
  }"""
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  academic_css = """
94
  :root, .dark, .dark .gradio-container, .gradio-container {
95
  --page-max: 1760px; --layout-gap: 12px;
 
86
  window.addEventListener('focus', refreshIdentity);
87
  window.addEventListener('message', event => {
88
  if (event.origin !== window.location.origin || event.data?.type !== 'physinone-orcid') return;
89
+ window.physinoneOrcidPopup = null;
90
+ window.physinoneOrcidBusy = false;
91
  refreshIdentity();
92
  });
93
  }"""
94
 
95
+ orcid_popup_js = """() => {
96
+ document.addEventListener('click', event => {
97
+ const button = event.target.closest('button.orcid-connect-button, .orcid-connect-button button');
98
+ if (!button) return;
99
+ const existing = window.physinoneOrcidPopup;
100
+ if (window.physinoneOrcidBusy && existing && !existing.closed) {
101
+ event.preventDefault();
102
+ event.stopImmediatePropagation();
103
+ existing.focus();
104
+ return;
105
+ }
106
+ const popup = window.open('about:blank', 'physinone-orcid', 'width=620,height=720');
107
+ if (!popup) {
108
+ event.preventDefault();
109
+ event.stopImmediatePropagation();
110
+ window.alert('Allow popups for this site to connect ORCID.');
111
+ return;
112
+ }
113
+ window.physinoneOrcidPopup = popup;
114
+ window.physinoneOrcidBusy = true;
115
+ }, true);
116
+ }"""
117
+
118
  academic_css = """
119
  :root, .dark, .dark .gradio-container, .gradio-container {
120
  --page-max: 1760px; --layout-gap: 12px;