Upload 8 files
Browse files- web/static/app.js +13 -8
web/static/app.js
CHANGED
|
@@ -577,14 +577,19 @@ function handleLogoutClick(){
|
|
| 577 |
clearClientAuthState();
|
| 578 |
}
|
| 579 |
|
| 580 |
-
function configureAuthAnchor(anchor,href){
|
| 581 |
if(!anchor)return;
|
| 582 |
if(href)anchor.href=href;
|
| 583 |
-
|
| 584 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 585 |
}
|
| 586 |
-
function authLoginUrl(){return '/oauth/huggingface/login
|
| 587 |
-
function authLogoutUrl(){return '/oauth/huggingface/logout
|
| 588 |
|
| 589 |
|
| 590 |
function normalizeModelInput(value){return String(value||'').trim().replace('https://huggingface.co/','').split('?')[0].split('#')[0].replace(/^\/+|\/+$/g,'')}
|
|
@@ -920,9 +925,9 @@ async function refreshAnonymousEvalStatus(){
|
|
| 920 |
return null;
|
| 921 |
}
|
| 922 |
}
|
| 923 |
-
async function loadAppInfo(){setOperation('Checking sign-in and run storage…','loading');setBucketFeedback('checking','Checking private bucket access…');try{const me=await apiGet('/api/me');state.user=me;startAuthLifetimeTicker();renderAnonymousEvalStatus(me);setText('userChip','@'+me.username);configureAuthAnchor($('userChip'),`https://huggingface.co/${me.username}`);const logout=$('logoutLink');if(logout){logout.hidden=false;configureAuthAnchor(logout,me.logout_url||authLogoutUrl())}state.bucketSource=me.username+'/'+state.bucketName;setText('bucketInlineLabel',state.bucketSource);renderAuthWarnings(me);renderBillingPanel(me);loadBillingStatus().catch(()=>{});await checkBucket(false);await loadRuns(true);clearSavedRun();if(!state.bucketReady)setOperation('Create your private run bucket before launching builds.','warning');else setOperation('')}catch(e){clearClientAuthState();await refreshAnonymousEvalStatus();setText('userChip','Sign in');configureAuthAnchor($('userChip'),authLoginUrl());const logout=$('logoutLink');if(logout)logout.hidden=true;renderSignedOut();renderBillingPanel(null);setBucketReady(false,'Sign in with Hugging Face first.');showMessage('Please sign in with Hugging Face
|
| 924 |
-
function renderSignedOut(){const auth=$('authPanel');if(!auth)return;auth.hidden=false;auth.className='auth-panel warning';auth.innerHTML=`<strong>Sign in required</strong><p>Use Hugging Face OAuth before launching Jobs or reading your Bucket.
|
| 925 |
-
function renderAuthWarnings(me){const auth=$('authPanel');if(!auth)return;const missing=me.missing_scopes||[];const warnings=[...(me.warnings||[])];const lifetime=authLifetimeFromUser(me);if(['warning','critical','expired'].includes(lifetime.status))warnings.push(lifetime.recommendation||authLifetimeLabel(lifetime));if(!missing.length&&!warnings.length){auth.hidden=true;auth.innerHTML='';return}auth.hidden=false;auth.className='auth-panel warning';auth.innerHTML=`<strong>OAuth session warning</strong><p>${escapeHtml([...warnings,missing.length?'Missing scopes: '+missing.join(', '):''].filter(Boolean).join(' • '))}</p><a class="link-btn" href="${authLoginUrl()}"
|
| 926 |
function renderBillingPanel(info){
|
| 927 |
// Open HF Billing: Live quotas, spend and compute usage remain in the HF Billing dashboard.
|
| 928 |
const badge=$('billingStatusBadge');
|
|
|
|
| 577 |
clearClientAuthState();
|
| 578 |
}
|
| 579 |
|
| 580 |
+
function configureAuthAnchor(anchor,href,{newTab=false}={}){
|
| 581 |
if(!anchor)return;
|
| 582 |
if(href)anchor.href=href;
|
| 583 |
+
if(newTab){
|
| 584 |
+
anchor.target='_blank';
|
| 585 |
+
anchor.rel='noopener noreferrer';
|
| 586 |
+
}else{
|
| 587 |
+
anchor.removeAttribute('target');
|
| 588 |
+
anchor.removeAttribute('rel');
|
| 589 |
+
}
|
| 590 |
}
|
| 591 |
+
function authLoginUrl(){return '/oauth/huggingface/login'}
|
| 592 |
+
function authLogoutUrl(){return '/oauth/huggingface/logout'}
|
| 593 |
|
| 594 |
|
| 595 |
function normalizeModelInput(value){return String(value||'').trim().replace('https://huggingface.co/','').split('?')[0].split('#')[0].replace(/^\/+|\/+$/g,'')}
|
|
|
|
| 925 |
return null;
|
| 926 |
}
|
| 927 |
}
|
| 928 |
+
async function loadAppInfo(){setOperation('Checking sign-in and run storage…','loading');setBucketFeedback('checking','Checking private bucket access…');try{const me=await apiGet('/api/me');state.user=me;startAuthLifetimeTicker();renderAnonymousEvalStatus(me);setText('userChip','@'+me.username);configureAuthAnchor($('userChip'),`https://huggingface.co/${me.username}`);const logout=$('logoutLink');if(logout){logout.hidden=false;configureAuthAnchor(logout,me.logout_url||authLogoutUrl(),{newTab:false})}state.bucketSource=me.username+'/'+state.bucketName;setText('bucketInlineLabel',state.bucketSource);renderAuthWarnings(me);renderBillingPanel(me);loadBillingStatus().catch(()=>{});await checkBucket(false);await loadRuns(true);clearSavedRun();if(!state.bucketReady)setOperation('Create your private run bucket before launching builds.','warning');else setOperation('')}catch(e){clearClientAuthState();await refreshAnonymousEvalStatus();setText('userChip','Sign in');configureAuthAnchor($('userChip'),authLoginUrl());const logout=$('logoutLink');if(logout)logout.hidden=true;renderSignedOut();renderBillingPanel(null);setBucketReady(false,'Sign in with Hugging Face first.');showMessage('Please sign in with Hugging Face to continue.',true)}}
|
| 929 |
+
function renderSignedOut(){const auth=$('authPanel');if(!auth)return;auth.hidden=false;auth.className='auth-panel warning';auth.innerHTML=`<strong>Sign in required</strong><p>Use Hugging Face OAuth before launching Jobs or reading your Bucket.</p><a class="link-btn" href="${authLoginUrl()}">Sign in with Hugging Face</a>`}
|
| 930 |
+
function renderAuthWarnings(me){const auth=$('authPanel');if(!auth)return;const missing=me.missing_scopes||[];const warnings=[...(me.warnings||[])];const lifetime=authLifetimeFromUser(me);if(['warning','critical','expired'].includes(lifetime.status))warnings.push(lifetime.recommendation||authLifetimeLabel(lifetime));if(!missing.length&&!warnings.length){auth.hidden=true;auth.innerHTML='';return}auth.hidden=false;auth.className='auth-panel warning';auth.innerHTML=`<strong>OAuth session warning</strong><p>${escapeHtml([...warnings,missing.length?'Missing scopes: '+missing.join(', '):''].filter(Boolean).join(' • '))}</p><a class="link-btn" href="${authLoginUrl()}">Refresh sign-in</a>`}
|
| 931 |
function renderBillingPanel(info){
|
| 932 |
// Open HF Billing: Live quotas, spend and compute usage remain in the HF Billing dashboard.
|
| 933 |
const badge=$('billingStatusBadge');
|