réécriture de la partie log
This commit is contained in:
parent
f4d9dd7a91
commit
0decab4064
@ -330,32 +330,64 @@ autopostRouter.get('/', async (req, res) => {
|
||||
</div>
|
||||
|
||||
<!-- Modale d'édition -->
|
||||
<div id="editModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center">
|
||||
<div class="bg-gray-800 p-6 rounded relative w-1/2">
|
||||
<span class="absolute top-2 right-2 text-white cursor-pointer close">×</span>
|
||||
<h2 class="text-xl font-semibold mb-4">Editer Release <span id="modalReleaseId"></span></h2>
|
||||
<div id="editModal" class="hidden fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm flex items-center justify-center z-50">
|
||||
<div class="bg-gray-900 p-6 rounded-2xl shadow-2xl w-full max-w-md transform transition-all scale-95">
|
||||
|
||||
<!-- Bouton fermer -->
|
||||
<button type="button" class="absolute top-4 right-4 text-gray-400 hover:text-white text-2xl font-bold close">
|
||||
×
|
||||
</button>
|
||||
|
||||
<!-- Titre -->
|
||||
<h2 class="text-2xl font-bold mb-6 text-center text-white">
|
||||
✏️ Éditer Release <span id="modalReleaseId" class="text-blue-400"></span>
|
||||
</h2>
|
||||
|
||||
<!-- Formulaire -->
|
||||
<form id="editForm">
|
||||
<label for="statusSelect" class="block mb-2">Status :</label>
|
||||
<select id="statusSelect" name="status" class="w-full p-2 mb-4 rounded border border-gray-300">
|
||||
<option value="0">EN ATTENTE</option>
|
||||
<option value="1">ENVOI TERMINÉ</option>
|
||||
<option value="2">ERREUR</option>
|
||||
<option value="3">DEJA DISPONIBLE</option>
|
||||
|
||||
<!-- Label + Select -->
|
||||
<label for="statusSelect" class="block mb-2 text-gray-300 font-medium">Status :</label>
|
||||
<select id="statusSelect" name="status"
|
||||
class="w-full p-3 mb-6 rounded-lg border border-gray-700 bg-gray-800 text-white focus:ring-2 focus:ring-blue-500 focus:outline-none">
|
||||
<option value="0" class="text-cyan-400">EN ATTENTE</option>
|
||||
<option value="1" class="text-green-400">ENVOI TERMINÉ</option>
|
||||
<option value="2" class="text-red-400">ERREUR</option>
|
||||
<option value="3" class="text-pink-400">DEJA DISPONIBLE</option>
|
||||
</select>
|
||||
|
||||
<!-- Hidden ID -->
|
||||
<input type="hidden" id="releaseId" name="id" value=""/>
|
||||
<button type="submit" class="w-full p-2 bg-blue-600 text-white rounded hover:bg-blue-700">
|
||||
Mettre à jour
|
||||
|
||||
<!-- Bouton -->
|
||||
<button type="submit"
|
||||
class="w-full p-3 bg-gradient-to-r from-blue-600 to-blue-500 text-white font-semibold rounded-lg shadow hover:from-blue-500 hover:to-blue-400 transform hover:-translate-y-0.5 transition">
|
||||
💾 Mettre à jour
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Modale pour afficher le log -->
|
||||
<div id="logModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center">
|
||||
<div class="bg-gray-800 p-6 rounded relative w-2/3">
|
||||
<span class="absolute top-2 right-2 text-white cursor-pointer close log-close">×</span>
|
||||
<h2 class="text-xl font-semibold mb-4">Contenu du log</h2>
|
||||
<pre id="logContent" class="max-h-[80vh] overflow-y-auto"></pre>
|
||||
<div id="logModal" class="hidden fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm flex items-center justify-center z-50">
|
||||
<div class="bg-gray-900 p-6 rounded-2xl shadow-2xl w-full max-w-7xl relative"> <!-- élargi max-w -->
|
||||
|
||||
<!-- Bouton fermer -->
|
||||
<button type="button" class="absolute top-4 right-4 text-gray-400 hover:text-white text-2xl font-bold close log-close">
|
||||
×
|
||||
</button>
|
||||
|
||||
<!-- Titre -->
|
||||
<h2 class="text-2xl font-bold mb-6 text-center text-white">
|
||||
📄 Contenu du log
|
||||
</h2>
|
||||
|
||||
<!-- Contenu du log -->
|
||||
<pre id="logContent"
|
||||
class="max-h-[90vh] overflow-y-auto p-6 rounded-lg bg-gray-800 text-green-400 font-mono text-sm leading-relaxed border border-gray-700 shadow-inner whitespace-pre-wrap">
|
||||
</pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -676,11 +708,49 @@ autopostRouter.get('/log', (req, res) => {
|
||||
console.error(err.message);
|
||||
return res.status(500).json({ error: "Erreur lors du chargement du fichier log." });
|
||||
}
|
||||
const htmlContent = convert.toHtml(data);
|
||||
|
||||
// 1) enlever les codes curseur (début de ligne/clear) mais garder les couleurs (…m)
|
||||
// ex: \x1b[0G, \x1b[0K, etc. — ce sont EUX qui “collent” les blocs
|
||||
let s = data.replace(/\x1b\[[0-9;]*[GK]/g, '');
|
||||
|
||||
// 2) supprimer TOUT segment de progression, même s’ils sont enchaînés sur UNE SEULE ligne
|
||||
// forme couverte : "12.34% [======] 487.86 MiB/s, ETA 00:01"
|
||||
// + variantes “ETA -”, et même le cas minimal "0.00% [ ]"
|
||||
const ANSI_M = '(?:\\x1b\\[[0-9;]*m)*';
|
||||
const NUM = '\\d{1,3}(?:\\.\\d+)?';
|
||||
const PROG = new RegExp(
|
||||
// pourcentage
|
||||
ANSI_M + '\\s*' + NUM + '\\s*%' +
|
||||
// barre
|
||||
'\\s*' + ANSI_M + '\\[[^\\]]*\\]' +
|
||||
// (option) vitesse + ETA
|
||||
'(?:\\s*' + ANSI_M + NUM + '\\s*MiB\\/s,\\s*ETA\\s*[^\\x1bG\\n]*)?',
|
||||
'g'
|
||||
);
|
||||
s = s.replace(PROG, '');
|
||||
|
||||
// 3) nettoyer les résidus "-G" / "G" laissés juste avant G[INFO] (quand une progression était collée)
|
||||
s = s.replace(/-?\s*G(?=\[INFO\])/g, '');
|
||||
|
||||
// 4) petite normalisation (sans casser les couleurs)
|
||||
s = s.replace(/[ \t]+/g, ' ')
|
||||
.replace(/\r/g, '')
|
||||
.replace(/\n{3,}/g, '\n\n')
|
||||
// Retour à la ligne avant chaque mot-clé (sauf début)
|
||||
.replace(/(?!^)(?=\[INFO\])/gm, '\n')
|
||||
.replace(/(?!^)Calculating\s*:/gm, '\nCalculating :')
|
||||
.replace(/(?!^)Writing\s*:/gm, '\nWriting :')
|
||||
.replace(/(?!^)Finalizing\s*:/gm, '\nFinalizing :')
|
||||
.replace(/(?!^)Finished\s*:/gm, '\nFinished :')
|
||||
.trim();
|
||||
|
||||
const htmlContent = convert.toHtml(s); // conserve les couleurs ANSI
|
||||
res.json({ content: htmlContent });
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
// --------------------------- Mediainfo -----------------------------
|
||||
autopostRouter.get('/mediainfo', (req, res) => {
|
||||
const filename = req.query.name;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user