fix: the video dialog names a wrong video or caption file before sending it (DTF-WEB-J)
All checks were successful
Build and deploy / Validate source (push) Successful in 10s
Build and deploy / Integration suite on a real stack (push) Successful in 7m52s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m25s
All checks were successful
Build and deploy / Validate source (push) Successful in 10s
Build and deploy / Integration suite on a real stack (push) Successful in 7m52s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m25s
The picker's accept list does not stop a dropped file, so a .mov or a file over the limit reached the server and was refused with one message for both fields. The dialog now checks extension and size with the server's limits as soon as a file is chosen or dropped, says under the field which file cannot be sent, and Salvar stays in the dialog. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -570,6 +570,23 @@ function siteVideoRow(video){
|
|||||||
tr.append(title,file,captions,where,situation,action);
|
tr.append(title,file,captions,where,situation,action);
|
||||||
return tr;
|
return tr;
|
||||||
}
|
}
|
||||||
|
// The server's own limits (app/api/site_videos.py _kind), checked in the dialog
|
||||||
|
// so a wrong file, also a dropped one, is named before any upload (DTF-WEB-J).
|
||||||
|
const SITE_VIDEO_FILES={
|
||||||
|
video:{ext:['.mp4','.webm'],max:500*1024*1024,rule:'O vídeo precisa ser MP4 ou WebM de até 500 MB.'},
|
||||||
|
captions:{ext:['.vtt'],max:1024*1024,rule:'A legenda precisa ser um arquivo VTT de até 1 MB.'}};
|
||||||
|
function siteVideoFileOk(file,kind){
|
||||||
|
const {ext,max}=SITE_VIDEO_FILES[kind];
|
||||||
|
return ext.some(end=>file.name.toLowerCase().endsWith(end))&&file.size<=max;
|
||||||
|
}
|
||||||
|
// Shows under the field whether the chosen file can be sent; true when it can.
|
||||||
|
function siteVideoFileCheck(input,fieldBox,kind,current){
|
||||||
|
const file=input.files[0],small=fieldBox.querySelector(':scope > small');
|
||||||
|
const ok=!file||siteVideoFileOk(file,kind);
|
||||||
|
fieldBox.classList.toggle('warn',!ok);
|
||||||
|
small.textContent=ok?current:'"'+file.name+'" não pode ser enviado. '+SITE_VIDEO_FILES[kind].rule;
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
function videoDialog(video){
|
function videoDialog(video){
|
||||||
let published=!!video.enabled;
|
let published=!!video.enabled;
|
||||||
const videoInput=node('input');videoInput.type='file';videoInput.accept='.mp4,.webm,video/mp4,video/webm';
|
const videoInput=node('input');videoInput.type='file';videoInput.accept='.mp4,.webm,video/mp4,video/webm';
|
||||||
@@ -582,6 +599,10 @@ function videoDialog(video){
|
|||||||
captionsField.append(node('span',video.captions_name?'Legenda':'Legenda · opcional'),
|
captionsField.append(node('span',video.captions_name?'Legenda':'Legenda · opcional'),
|
||||||
dropField(captionsInput,{title:'Escolher legenda',hint:'Arquivo VTT.'}),
|
dropField(captionsInput,{title:'Escolher legenda',hint:'Arquivo VTT.'}),
|
||||||
node('small',video.captions_name||'Nenhuma legenda enviada.'));
|
node('small',video.captions_name||'Nenhuma legenda enviada.'));
|
||||||
|
const checkVideo=()=>siteVideoFileCheck(videoInput,videoField,'video',video.video_name||'Nenhum arquivo enviado.');
|
||||||
|
const checkCaptions=()=>siteVideoFileCheck(captionsInput,captionsField,'captions',video.captions_name||'Nenhuma legenda enviada.');
|
||||||
|
videoInput.addEventListener('change',checkVideo);
|
||||||
|
captionsInput.addEventListener('change',checkCaptions);
|
||||||
// A product page shows one floating video: the products another published
|
// A product page shows one floating video: the products another published
|
||||||
// video holds are marked, and closed while this one is published (DTF-WEB-G).
|
// video holds are marked, and closed while this one is published (DTF-WEB-G).
|
||||||
const taken=new Map(siteVideos.filter(other=>other.id!==video.id&&other.enabled&&other.product)
|
const taken=new Map(siteVideos.filter(other=>other.id!==video.id&&other.enabled&&other.product)
|
||||||
@@ -616,6 +637,8 @@ function videoDialog(video){
|
|||||||
formDialog(video.title,{width:640,className:'siteDialog',
|
formDialog(video.title,{width:640,className:'siteDialog',
|
||||||
text:video.enabled?'Publicado no Site':'Rascunho · ainda não aparece no Site',
|
text:video.enabled?'Publicado no Site':'Rascunho · ainda não aparece no Site',
|
||||||
fields:[videoField,captionsField,row],label:'Salvar vídeo',onsave:async()=>{
|
fields:[videoField,captionsField,row],label:'Salvar vídeo',onsave:async()=>{
|
||||||
|
const videoOk=checkVideo(),captionsOk=checkCaptions();
|
||||||
|
if(!videoOk||!captionsOk){(videoOk?captionsField:videoField).scrollIntoView({block:'center'});return false;}
|
||||||
let uploadId=video.upload_id,captionsId=video.captions_id;
|
let uploadId=video.upload_id,captionsId=video.captions_id;
|
||||||
if(videoInput.files[0])uploadId=await dtfUpload(videoInput.files[0],{api,startPath:'/site-videos/uploads',
|
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)});
|
scope:'site-video:'+video.id+':video',progress:text=>say(text)});
|
||||||
|
|||||||
Reference in New Issue
Block a user