اضافه شدن قابلیت share و نگهداری بلندمدت
Verify / test (push) Failing after 22s

This commit is contained in:
2026-11-09 14:55:36 +03:30
والد a4e8f0c6c0
کامیت 19824bd180
27فایلهای تغییر یافته به همراه267 افزوده شده و 51 حذف شده
+4 -3
مشاهده پرونده
@@ -1,3 +1,4 @@
import { mountShare } from './share.js?v=1';
const operations = {
schematic: { endpoint:'/api/v1/schematics/render', suffix:'.SchDoc', label:'Render schematic', fileLabel:'Schematic file', comparison:false },
'schematic-comparison': { endpoint:'/api/v1/comparisons', suffix:'.SchDoc', label:'Compare schematics', comparison:true },
@@ -10,7 +11,7 @@ const fields=document.querySelector('#upload-fields'), viewerLink=document.query
const details=document.querySelector('#response-details'), json=document.querySelector('#response-json');
let polling=null, uploading=false;
function reset(){
polling?.abort();polling=null;result.textContent='';viewerLink.replaceChildren();details.hidden=true;json.textContent='';
polling?.abort();polling=null;result.textContent='';viewerLink.replaceChildren();details.hidden=true;json.textContent='';document.querySelector('#upload-share').replaceChildren();
}
function configure(){
if(uploading)return;
@@ -73,14 +74,14 @@ form.addEventListener('submit',async event=>{
}
data.append('access',document.querySelector('#access').value);
const expiry=document.querySelector('#expires-in').value;
if(expiry){if(!/^\d+$/.test(expiry)||Number(expiry)<1){result.textContent='Expiry must be a positive whole number of seconds.';return;}data.append('expires_in',expiry);}
if(expiry){if(expiry!=='-1'&&(!/^\d+$/.test(expiry)||Number(expiry)<1)){result.textContent='Expiry must be -1 (unlimited) or a positive whole number of seconds.';return;}data.append('expires_in',expiry);}
const headers={},key=document.querySelector('#key').value;if(key)headers['X-API-Key']=key;
uploading=true;button.disabled=true;fields.disabled=true;result.textContent='Uploading…';
try{
const created=await decode(await fetch(config.endpoint,{method:'POST',headers,body:data}));showResponse(created);
const url=new URL(created.viewer_url||created.url,location.origin);
if(url.origin!==location.origin)throw new Error('Viewer URL must use this service origin. Check PUBLIC_BASE_URL.');
const link=document.createElement('a');link.href=url.href;link.target='_blank';link.rel='noopener noreferrer';link.textContent=config.comparison?'Open comparison ↗':'Open viewer ↗';viewerLink.append(link);
const link=document.createElement('a');link.href=url.href;link.target='_blank';link.rel='noopener noreferrer';link.textContent=config.comparison?'Open comparison ↗':'Open viewer ↗';viewerLink.append(link);mountShare(document.querySelector('#upload-share'),url.href);
result.textContent='Queued. You can open the viewer while processing continues.';
const controller=new AbortController();polling=controller;
poll(created,controller).catch(error=>{if(error.name!=='AbortError'&&!controller.signal.aborted)result.textContent=`${error.message} The accepted upload is not retried automatically.`;});