feat: the videos panel in the Site tab, captions optional (front 8.4)
Dropstar uploads the six videos themselves, so the panel moves from Integrações to the Site tab, next to products and prices. A video can be published without a VTT: the Site plays it without a captions track. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3853,53 +3853,7 @@ function renderEvents(){
|
||||
|
||||
// Integrações: the print room's folder for whoever produces, what is on and off
|
||||
// for the managers, and the buttons, details and the Tiny log for the superadmin.
|
||||
const eventsIfAllowed=async()=>{if(may('integrations'))await loadEvents();if(may('manage'))await loadSiteVideos();};
|
||||
|
||||
async function loadSiteVideos(){
|
||||
const host=$('site-videos-list'),panel=$('site-videos-panel');
|
||||
panel.hidden=!may('manage');
|
||||
if(panel.hidden)return;
|
||||
const data=await api('/site-videos');
|
||||
host.replaceChildren(...data.videos.map(video=>{
|
||||
const row=node('div',undefined,'siteVideoRow');
|
||||
const heading=node('div',undefined,'siteVideoHeading');
|
||||
heading.append(node('b',video.title),node('span',video.enabled?'Publicado':'Rascunho','pill'+(video.enabled?' ok':'')));
|
||||
const videoInput=node('input');videoInput.type='file';videoInput.accept='.mp4,.webm,video/mp4,video/webm';
|
||||
const captionsInput=node('input');captionsInput.type='file';captionsInput.accept='.vtt,text/vtt';
|
||||
const videoLabel=node('label',undefined,'siteVideoField');
|
||||
videoLabel.append(node('span','Vídeo · '+(video.video_name||'nenhum arquivo')),videoInput);
|
||||
const captionsLabel=node('label',undefined,'siteVideoField');
|
||||
captionsLabel.append(node('span','Legenda · '+(video.captions_name||'nenhuma legenda')),captionsInput);
|
||||
const product=node('select');product.setAttribute('aria-label','Produto do vídeo '+video.title);
|
||||
for(const [value,title] of [['','Só na categoria DTF'],['file','Arquivo por metro'],
|
||||
['avulsa','Artes avulsas'],['uvfile','Arquivo por metro UV'],['uv','Artes avulsas UV']]){
|
||||
const option=node('option',title);option.value=value;product.append(option);
|
||||
}
|
||||
product.value=video.product||'';
|
||||
const productLabel=node('label',undefined,'siteVideoField');productLabel.append(node('span','Vídeo flutuante'),product);
|
||||
const enabled=node('input');enabled.type='checkbox';enabled.checked=video.enabled;
|
||||
const publish=node('label',undefined,'siteVideoToggle');publish.append(enabled,node('span','Publicado no Site'));
|
||||
const errorMessage=node('p',undefined,'siteVideoError');errorMessage.setAttribute('role','alert');
|
||||
const save=button('Salvar vídeo',async()=>{
|
||||
save.disabled=true;
|
||||
errorMessage.textContent='';
|
||||
try{
|
||||
let uploadId=video.upload_id,captionsId=video.captions_id;
|
||||
if(videoInput.files[0])uploadId=await dtfUpload(videoInput.files[0],{api,startPath:'/site-videos/uploads',
|
||||
scope:'site-video:'+video.id+':video',progress:text=>say(text)});
|
||||
if(captionsInput.files[0])captionsId=await dtfUpload(captionsInput.files[0],{api,startPath:'/site-videos/uploads',
|
||||
scope:'site-video:'+video.id+':captions',progress:text=>say(text)});
|
||||
await api('/site-videos/'+video.id,{upload_id:uploadId,captions_id:captionsId,
|
||||
product:product.value||null,enabled:enabled.checked});
|
||||
say('Vídeo salvo. O Site mostrará a nova versão na próxima abertura.');
|
||||
await loadSiteVideos();
|
||||
}catch(error){errorMessage.textContent=error.message;save.disabled=false;}
|
||||
},'btn');
|
||||
const fields=node('div',undefined,'siteVideoFields');
|
||||
fields.append(videoLabel,captionsLabel,productLabel,publish,save,errorMessage);
|
||||
row.append(heading,fields);return row;
|
||||
}));
|
||||
}
|
||||
const eventsIfAllowed=async()=>{if(may('integrations'))await loadEvents();};
|
||||
// A row with only its name, state and summary, for whoever may not change it.
|
||||
const integRow=o=>may('integrations')?integration(o):integration({name:o.name,state:o.state,tone:o.tone,summary:o.summary});
|
||||
let mpCheck=null;
|
||||
|
||||
Reference in New Issue
Block a user