FABLESLIP commited on
Commit
ab92b74
·
verified ·
1 Parent(s): a9291a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -50
app.py CHANGED
@@ -1020,7 +1020,7 @@ HTML_TEMPLATE = r"""
1020
  </div>
1021
  <div id="warmup-logs" style="max-height:220px; overflow:auto; font-size:12px; color:#6b7280; white-space:pre-wrap"></div>
1022
  <div style="margin-top:10px; display:flex; gap:8px; justify-content:flex-end">
1023
- <button id="warmupCopyBtn" class="btn" title="Copier le contenu">Copier</button>
1024
  <button id="warmupCloseBtn" class="btn">Fermer</button>
1025
  </div>
1026
  </div>
@@ -1028,7 +1028,7 @@ HTML_TEMPLATE = r"""
1028
  <h3>Sélection des modèles à préparer</h3>
1029
  <div id="repoList" class="repo-list"></div>
1030
  <div style="margin-top:12px; display:flex; gap:8px; justify-content:flex-end; flex-wrap:wrap">
1031
- <button id="warmupSelectCopyBtn" class="btn" title="Copier le contenu">Copier</button>
1032
  <button id="selectAllBtn" class="btn">Tout cocher</button>
1033
  <button id="selectNoneBtn" class="btn">Tout décocher</button>
1034
  <button id="selectCancelBtn" class="btn">Annuler</button>
@@ -1157,55 +1157,55 @@ function closeWarmupPopup(){ if(warmupPopup) warmupPopup.style.display = 'none';
1157
  let userClosedWarmupPopup = false;
1158
 
1159
  if (warmupCloseBtn) warmupCloseBtn.addEventListener('click', closeWarmupPopup);
1160
- if (warmupCloseBtn) warmupCloseBtn.addEventListener('click', ()=>{ userClosedWarmupPopup = true; });
1161
- // Bouton "Copier" — popup Téléchargement
1162
- if (warmupCopyBtn){
1163
- warmupCopyBtn.addEventListener('click', async ()=>{
1164
- const title = (warmupPopup.querySelector('h3')?.innerText || '').trim();
1165
- const status = (warmupPopupStatus?.innerText || '').trim();
1166
- const body = (warmupLogs?.innerText || '').trim();
1167
- const txt = [title, status, '', body].filter(Boolean).join('\n');
1168
- try{ await navigator.clipboard.writeText(txt); showToast('Contenu copié ✅'); }
1169
- catch{ alert('Copie impossible'); }
1170
- });
1171
- }
1172
-
1173
- // Bouton "Copier" popup Sélection
1174
- if (warmupSelectCopyBtn){
1175
- warmupSelectCopyBtn.addEventListener('click', async ()=>{
1176
- const title = (warmupSelectPopup.querySelector('h3')?.innerText || '').trim();
1177
- const list = (repoListEl?.innerText || '').trim();
1178
- const txt = [title, '', list].filter(Boolean).join('\n');
1179
- try{ await navigator.clipboard.writeText(txt); showToast('Contenu copié '); }
1180
- catch{ alert('Copie impossible'); }
1181
- });
1182
- }
1183
-
1184
- // Rendre les popups déplaçables en saisissant leur <h3>
1185
- function makeDraggable(el, handle){
1186
- if(!el || !handle) return;
1187
- let drag=false, sx=0, sy=0, bx=0, by=0;
1188
- handle.addEventListener('mousedown', (e)=>{
1189
- const r = el.getBoundingClientRect();
1190
- el.style.left = r.left + 'px';
1191
- el.style.top = r.top + 'px';
1192
- el.style.transform = 'none';
1193
- drag=true; sx=e.clientX; sy=e.clientY; bx=r.left; by=r.top; e.preventDefault();
1194
- });
1195
- window.addEventListener('mousemove', (e)=>{
1196
- if(!drag) return;
1197
- const nx = bx + (e.clientX - sx);
1198
- const ny = by + (e.clientY - sy);
1199
- const maxX = window.innerWidth - el.offsetWidth - 8;
1200
- const maxY = window.innerHeight - el.offsetHeight - 8;
1201
- el.style.left = Math.max(8, Math.min(maxX, nx)) + 'px';
1202
- el.style.top = Math.max(8, Math.min(maxY, ny)) + 'px';
1203
- });
1204
- window.addEventListener('mouseup', ()=>{ drag=false; });
1205
- }
1206
- makeDraggable(warmupPopup, warmupPopup?.querySelector('h3'));
1207
- makeDraggable(warmupSelectPopup, warmupSelectPopup?.querySelector('h3'));
1208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1209
 
1210
  // Rafraîchissement d’état
1211
  let warmupTimer = null;
 
1020
  </div>
1021
  <div id="warmup-logs" style="max-height:220px; overflow:auto; font-size:12px; color:#6b7280; white-space:pre-wrap"></div>
1022
  <div style="margin-top:10px; display:flex; gap:8px; justify-content:flex-end">
1023
+ <button id="warmupCopyBtn" class="btn" title="Copier le contenu">Copier</button>
1024
  <button id="warmupCloseBtn" class="btn">Fermer</button>
1025
  </div>
1026
  </div>
 
1028
  <h3>Sélection des modèles à préparer</h3>
1029
  <div id="repoList" class="repo-list"></div>
1030
  <div style="margin-top:12px; display:flex; gap:8px; justify-content:flex-end; flex-wrap:wrap">
1031
+ <button id="selectCopyBtn" class="btn" title="Copier la liste visible">Copier</button>
1032
  <button id="selectAllBtn" class="btn">Tout cocher</button>
1033
  <button id="selectNoneBtn" class="btn">Tout décocher</button>
1034
  <button id="selectCancelBtn" class="btn">Annuler</button>
 
1157
  let userClosedWarmupPopup = false;
1158
 
1159
  if (warmupCloseBtn) warmupCloseBtn.addEventListener('click', closeWarmupPopup);
1160
+ // -- DRAG & COPY (popups warmup) --
1161
+ (function(){
1162
+ const $popup = document.getElementById('warmupPopup');
1163
+ const $sel = document.getElementById('warmupSelectPopup');
1164
+ const $copy = document.getElementById('warmupCopyBtn');
1165
+ const $copy2 = document.getElementById('selectCopyBtn');
1166
+
1167
+ function makeDraggable(box){
1168
+ if (!box) return;
1169
+ let sx=0, sy=0, ox=0, oy=0, drag=false;
1170
+ box.addEventListener('mousedown', e=>{
1171
+ if (e.target.tagName === 'BUTTON' || e.target.closest('button')) return;
1172
+ drag=true; box.style.transform='none';
1173
+ ox = box.offsetLeft; oy = box.offsetTop; sx = e.clientX; sy = e.clientY;
1174
+ document.body.style.userSelect='none';
1175
+ });
1176
+ window.addEventListener('mousemove', e=>{
1177
+ if(!drag) return;
1178
+ box.style.left = (ox + (e.clientX - sx)) + 'px';
1179
+ box.style.top = (oy + (e.clientY - sy)) + 'px';
1180
+ });
1181
+ window.addEventListener('mouseup', ()=>{ drag=false; document.body.style.userSelect=''; });
1182
+ }
1183
+ makeDraggable($popup);
1184
+ makeDraggable($sel);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1185
 
1186
+ function copyText(txt){
1187
+ if (navigator.clipboard && navigator.clipboard.writeText){
1188
+ navigator.clipboard.writeText(txt||'').then(()=> (window.showToast?showToast('Copié ✅'):alert('Copié ✅')) );
1189
+ } else {
1190
+ const ta=document.createElement('textarea'); ta.value=txt||''; document.body.appendChild(ta); ta.select();
1191
+ try{ document.execCommand('copy'); (window.showToast?showToast('Copié ✅'):alert('Copié ✅')); }catch{}
1192
+ ta.remove();
1193
+ }
1194
+ }
1195
+ if ($copy){
1196
+ $copy.addEventListener('click', ()=>{
1197
+ const s = document.getElementById('warmupPopupStatus');
1198
+ const l = document.getElementById('warmup-logs');
1199
+ copyText((s?('[Status] '+s.textContent+'\n\n'):'') + (l?l.textContent:''));
1200
+ });
1201
+ }
1202
+ if ($copy2){
1203
+ $copy2.addEventListener('click', ()=>{
1204
+ const list = document.getElementById('repoList');
1205
+ copyText(list ? list.innerText : '');
1206
+ });
1207
+ }
1208
+ })();
1209
 
1210
  // Rafraîchissement d’état
1211
  let warmupTimer = null;