fffiloni commited on
Commit
28c5d54
·
verified ·
1 Parent(s): 19f7f6c

Upload 8 files

Browse files
Files changed (1) hide show
  1. web/static/app.js +13 -3
web/static/app.js CHANGED
@@ -577,6 +577,16 @@ function handleLogoutClick(){
577
  clearClientAuthState();
578
  }
579
 
 
 
 
 
 
 
 
 
 
 
580
  function normalizeModelInput(value){return String(value||'').trim().replace('https://huggingface.co/','').split('?')[0].split('#')[0].replace(/^\/+|\/+$/g,'')}
581
  function modelScanMatchesCurrent(){return state.modelScan?.ok&&normalizeModelInput(state.modelScan.model_id)===normalizeModelInput(formValue('modelId'))}
582
  function scanVerdictClass(verdict){verdict=String(verdict||'').toLowerCase();if(verdict==='safe')return'success';if(verdict==='caution')return'warn';if(verdict==='risky'||verdict==='unsupported')return'error';if(verdict==='scanning')return'running';return'neutral'}
@@ -910,9 +920,9 @@ async function refreshAnonymousEvalStatus(){
910
  return null;
911
  }
912
  }
913
- 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);const userChip=$('userChip');if(userChip)userChip.href=`https://huggingface.co/${me.username}`;const logout=$('logoutLink');if(logout){logout.hidden=false;logout.href=me.logout_url||'/oauth/huggingface/logout?_target_url=/'}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');const userChip=$('userChip');if(userChip)userChip.href='/oauth/huggingface/login?_target_url=/';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, then refresh this page.',true)}}
914
- 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="/oauth/huggingface/login">Sign in with Hugging Face ↗</a>'}
915
- 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="/oauth/huggingface/login">Refresh sign-in ↗</a>`}
916
  function renderBillingPanel(info){
917
  // Open HF Billing: Live quotas, spend and compute usage remain in the HF Billing dashboard.
918
  const badge=$('billingStatusBadge');
 
577
  clearClientAuthState();
578
  }
579
 
580
+ function configureAuthAnchor(anchor,href){
581
+ if(!anchor)return;
582
+ if(href)anchor.href=href;
583
+ anchor.target='_blank';
584
+ anchor.rel='noopener noreferrer';
585
+ }
586
+ function authLoginUrl(){return '/oauth/huggingface/login?_target_url=/'}
587
+ function authLogoutUrl(){return '/oauth/huggingface/logout?_target_url=/'}
588
+
589
+
590
  function normalizeModelInput(value){return String(value||'').trim().replace('https://huggingface.co/','').split('?')[0].split('#')[0].replace(/^\/+|\/+$/g,'')}
591
  function modelScanMatchesCurrent(){return state.modelScan?.ok&&normalizeModelInput(state.modelScan.model_id)===normalizeModelInput(formValue('modelId'))}
592
  function scanVerdictClass(verdict){verdict=String(verdict||'').toLowerCase();if(verdict==='safe')return'success';if(verdict==='caution')return'warn';if(verdict==='risky'||verdict==='unsupported')return'error';if(verdict==='scanning')return'running';return'neutral'}
 
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 in the opened tab, then return here or use that tab.',true)}}
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. The sign-in page opens in a new tab to avoid iframe cookie issues.</p><a class="link-btn" href="${authLoginUrl()}" target="_blank" rel="noopener noreferrer">Sign in with Hugging Face ↗</a>`}
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()}" target="_blank" rel="noopener noreferrer">Refresh sign-in ↗</a>`}
926
  function renderBillingPanel(info){
927
  // Open HF Billing: Live quotas, spend and compute usage remain in the HF Billing dashboard.
928
  const badge=$('billingStatusBadge');