UI
This commit is contained in:
1 parent
dcbea5799a
commit
e8a92bf87b
6 files changed
+874
-114
No files matched your search
@@ -29,7 +29,7 @@ export default function LogTerminal({ service, initialLogs = [] }: {
|
||||
setLogs(initialLogs);
|
||||
pendingLogsRef.current = [];
|
||||
|
||||
const handleLogLine = (data: { serviceId: number, line: string }) => {
|
||||
const handleLogLine = (data: { serviceId: number | string, line: string }) => {
|
||||
if (data.serviceId === service.id) {
|
||||
const isError = service.alertKeyword
|
||||
? data.line.includes(service.alertKeyword)
|
||||
@@ -103,6 +103,37 @@ export default function LogTerminal({ service, initialLogs = [] }: {
|
||||
}));
|
||||
};
|
||||
|
||||
const handleGlobalCheckup = () => {
|
||||
if (logs.length === 0) return;
|
||||
|
||||
// Limite de caractères par défaut (Ollama LLaMA3 = ~8K context, on reste safe avec 6000 chars)
|
||||
const MAX_CHARS = 6000;
|
||||
|
||||
let batchText = "";
|
||||
let truncated = false;
|
||||
let includedCount = 0;
|
||||
|
||||
// On part de la fin vers le début pour privilégier les logs les plus récents
|
||||
for (let i = logs.length - 1; i >= 0; i--) {
|
||||
const lineWithBreak = logs[i].line + '\n';
|
||||
if (batchText.length + lineWithBreak.length > MAX_CHARS) {
|
||||
truncated = true;
|
||||
break;
|
||||
}
|
||||
// Ajout au début pour conserver l'ordre chronologique (haut vers bas)
|
||||
batchText = lineWithBreak + batchText;
|
||||
includedCount++;
|
||||
}
|
||||
|
||||
const message = truncated
|
||||
? `Fais un diagnostic de ces logs récents. (Attention : l'historique a été tronqué car il était trop grand. Voici les ${includedCount} logs les plus récents) :\n\n${batchText}`
|
||||
: `Fais un diagnostic complet pour ce service. Voici l'intégralité des ${includedCount} logs dans la console :\n\n${batchText}`;
|
||||
|
||||
window.dispatchEvent(new CustomEvent('analyze-log', {
|
||||
detail: { line: message, serviceName: service.name }
|
||||
}));
|
||||
};
|
||||
|
||||
const chunkedLogs = [];
|
||||
// Chunk starting from the end so latest logs are strictly grouped by 5
|
||||
for (let i = logs.length; i > 0; i -= 5) {
|
||||
@@ -123,6 +154,14 @@ export default function LogTerminal({ service, initialLogs = [] }: {
|
||||
<button className="btn-terminal btn-outline-sm" onClick={handleExport} title="Exporter en CSV">
|
||||
<Download size={14} /> Exporter
|
||||
</button>
|
||||
<button
|
||||
className="btn-terminal btn-outline-sm"
|
||||
style={{ color: 'var(--accent-color)', borderColor: 'rgba(59, 130, 246, 0.3)' }}
|
||||
onClick={handleGlobalCheckup}
|
||||
title="Analyser l'intégralité de la console via l'IA"
|
||||
>
|
||||
<Sparkles size={14} /> Diagnostic Complet
|
||||
</button>
|
||||
</div>
|
||||
<span className="live-indicator">
|
||||
<span className={`status-dot ${isPaused ? 'dot-red' : 'dot-green'}`}></span>
|
||||
|
||||
Reference in new issue
Block a user