Commits vergleichen
16 Commits
0b335263c9
...
main
| Autor | SHA1 | Datum | |
|---|---|---|---|
| 7d9bca12ee | |||
|
|
3e64539aa3 | ||
|
|
1647a6f50a | ||
|
|
c53e260c6c | ||
| c3a0ee4538 | |||
|
|
e20b3de0fa | ||
| aa36a9a38f | |||
|
|
d570e13dc6 | ||
|
|
7777b77abd | ||
| b02578e48b | |||
|
|
952df87afa | ||
| 38ce26f0be | |||
| 7f7b30c1d6 | |||
|
|
d986d611cf | ||
| 7954a78964 | |||
|
|
453c505a7e |
@@ -1,4 +1,12 @@
|
||||
[
|
||||
{
|
||||
"version": "2026-05-22T19:10Z",
|
||||
"date": "2026-05-22",
|
||||
"title": "Exportdialog: Ersteller manuell eintragbar",
|
||||
"items": [
|
||||
"Im Export-Dialog kann der Ersteller jetzt manuell eingegeben werden."
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2026-05-22T07:41Z",
|
||||
"date": "2026-05-22",
|
||||
|
||||
@@ -124,7 +124,7 @@ BISHERIGE QUELLEN:
|
||||
AUFTRAG:
|
||||
1. Aktualisiere das Lagebild basierend auf den neuen Meldungen. Das Lagebild soll so ausführlich wie nötig sein, um alle wesentlichen Themenstränge abzudecken
|
||||
2. Behalte bestätigte Fakten aus dem bisherigen Lagebild bei
|
||||
3. Ergänze neue Erkenntnisse und markiere wichtige neue Entwicklungen
|
||||
3. Arbeite neue Erkenntnisse direkt in den thematisch passenden Abschnitt ein. Erzeuge KEINE datierten Verlaufsblöcke wie "Neu am DD.MM." oder "Neu seit ...". Das Lagebild ist eine zusammenhängende thematische Darstellung des AKTUELLEN Stands, kein chronologisches Änderungsprotokoll. Die zeitliche Abfolge der jüngsten Ereignisse wird separat in der Kachel "Neueste Entwicklungen" gepflegt und darf hier NICHT als Datums-Changelog dupliziert werden
|
||||
4. Aktualisiere die Quellenverweise — neue Quellen bekommen fortlaufende Nummern nach den bisherigen
|
||||
5. Entferne nur nachweislich widerlegte Informationen. Behalte alle thematischen Abschnitte bei, auch wenn sie nicht durch neue Meldungen aktualisiert werden
|
||||
|
||||
@@ -133,6 +133,8 @@ STRUKTUR:
|
||||
- Wenn sich Daten strukturiert vergleichen lassen (z.B. Produkte, Unternehmen, Kennzahlen, Modelle), verwende eine Markdown-Tabelle (| Spalte1 | Spalte2 | ... mit Trennzeile |---|---|)
|
||||
- KEIN Fettdruck (**) verwenden
|
||||
- ERZEUGE KEINE Sektion "## ZUSAMMENFASSUNG", "## ÜBERBLICK" oder "## KERNPUNKTE". Falls das BISHERIGE LAGEBILD eine solche Sektion enthält, ENTFERNE sie vollständig beim Aktualisieren. Die neuesten Entwicklungen werden separat als eigene Kachel gepflegt und dürfen im Lagebild NICHT dupliziert werden.
|
||||
- KEINE datierten Verlaufsmarker im Lagebild. Einleitungen wie "Neu am 31.05./01.06.:", "Neu seit gestern:" oder vergleichbare Datums-Changelog-Phrasen sind nicht erlaubt. Falls das BISHERIGE LAGEBILD solche Blöcke enthält, LÖSE SIE AUF: integriere ihren Inhalt in den thematisch passenden Abschnitt und ENTFERNE die "Neu am"-Einleitung samt reiner Datumsgruppierung restlos. Innerhalb eines Abschnitts steht der aktuelle Stand vorne, ältere Belege werden im Fließtext zeitlich eingeordnet (z.B. "Ende Mai berichtete ...").
|
||||
- KEINE stichwortartigen Fragmente und KEINE blanken Quellennummern-Sammlungen. Verboten sind Telegramm-Verkürzungen wie "Teheran-Bluff-Vorwurf [2897]. NYT-Abraham-Accords [2890]." sowie Auffangblöcke ohne Aussage wie "Frühere Belege [2806][2807]...". Jede Quellennummer muss an einem vollständigen, eigenständigen Satz hängen. Falls das BISHERIGE LAGEBILD solche Fragment- oder Sammelblöcke enthält, formuliere sie zu vollständigen Sätzen aus oder lass die betreffende Quellennummer weg. Am Ende eines Abschnitts oder des Lagebildes darf KEINE reine Aufzählung von Quellennummern stehen.
|
||||
|
||||
REGELN:
|
||||
- Neutral und sachlich - keine Wertungen oder Spekulationen
|
||||
|
||||
@@ -1753,6 +1753,7 @@ class AgentOrchestrator:
|
||||
# Idempotent: nur Artikel ohne headline_de/content_de werden geholt.
|
||||
# Lauft nach der Analyse (Lagebild ist schon committed) und vor QC
|
||||
# (damit normalize_umlaut_articles auch die frischen DE-Texte fasst).
|
||||
_translate_step_started = False
|
||||
try:
|
||||
tr_cursor = await db.execute(
|
||||
"""SELECT id, headline, content_original, language
|
||||
@@ -1764,7 +1765,10 @@ class AgentOrchestrator:
|
||||
(incident_id,),
|
||||
)
|
||||
pending_translations = [dict(r) for r in await tr_cursor.fetchall()]
|
||||
if pending_translations:
|
||||
if pending_translations and translator_enabled:
|
||||
# Pipeline-Schritt 9: Artikel uebersetzen (nur sichtbar wenn was zu uebersetzen)
|
||||
await _pipe_start("translate")
|
||||
_translate_step_started = True
|
||||
logger.info(
|
||||
"Translator fuer Incident %d: %d Artikel ohne DE-Uebersetzung",
|
||||
incident_id, len(pending_translations),
|
||||
@@ -1795,8 +1799,11 @@ class AgentOrchestrator:
|
||||
"Translator fuer Incident %d: %d/%d Artikel uebersetzt",
|
||||
incident_id, len(translations), len(pending_translations),
|
||||
)
|
||||
await _pipe_done("translate", count_value=len(translations), count_secondary=len(pending_translations))
|
||||
except Exception as e:
|
||||
logger.error("Translator-Fehler fuer Incident %d: %s", incident_id, e, exc_info=True)
|
||||
if _translate_step_started:
|
||||
await _pipe_done("translate", count_value=0, count_secondary=0)
|
||||
# Refresh trotz Translator-Fehler weiterlaufen lassen
|
||||
|
||||
# --- Neueste Entwicklungen (nur Live-Monitoring / adhoc) ---
|
||||
|
||||
49
src/main.py
49
src/main.py
@@ -246,7 +246,14 @@ async def cleanup_expired():
|
||||
)
|
||||
logger.info(f"Lage {incident['id']} archiviert (Aufbewahrung abgelaufen)")
|
||||
|
||||
# Verwaiste running-Einträge bereinigen (> 15 Minuten ohne Abschluss)
|
||||
# Verwaiste running-Einträge bereinigen.
|
||||
# Pruefen auf Pipeline-Fortschritt: legitime Long-Runner (z.B. Translator
|
||||
# nach summary fuer jp_demo mit 200+ Artikeln ~20 Min) duerfen nicht
|
||||
# vorzeitig gekillt werden. Ein Refresh gilt als verwaist, wenn entweder
|
||||
# (a) seit ORPHAN_IDLE_LIMIT Min kein Pipeline-Step Fortschritt zeigte,
|
||||
# oder (b) das harte Limit ORPHAN_HARD_LIMIT Min ueberschritten wurde.
|
||||
ORPHAN_IDLE_LIMIT = 60
|
||||
ORPHAN_HARD_LIMIT = 120
|
||||
cursor = await db.execute(
|
||||
"SELECT id, incident_id, started_at FROM refresh_log WHERE status = 'running'"
|
||||
)
|
||||
@@ -258,12 +265,46 @@ async def cleanup_expired():
|
||||
else:
|
||||
started = started.astimezone(TIMEZONE)
|
||||
age_minutes = (now - started).total_seconds() / 60
|
||||
if age_minutes >= 15:
|
||||
if age_minutes < ORPHAN_IDLE_LIMIT:
|
||||
continue
|
||||
|
||||
# Letzter Pipeline-Step-Fortschritt (Start ODER Ende)
|
||||
prog_cursor = await db.execute(
|
||||
"""SELECT MAX(COALESCE(completed_at, started_at)) AS last_activity
|
||||
FROM refresh_pipeline_steps WHERE refresh_log_id = ?""",
|
||||
(orphan["id"],),
|
||||
)
|
||||
prog_row = await prog_cursor.fetchone()
|
||||
last_activity_str = prog_row["last_activity"] if prog_row else None
|
||||
|
||||
is_orphan = False
|
||||
reason = None
|
||||
if age_minutes >= ORPHAN_HARD_LIMIT:
|
||||
is_orphan = True
|
||||
reason = f"Verwaist (>{int(age_minutes)} Min, hartes Limit {ORPHAN_HARD_LIMIT} Min)"
|
||||
elif last_activity_str:
|
||||
last_activity = datetime.fromisoformat(last_activity_str)
|
||||
if last_activity.tzinfo is None:
|
||||
last_activity = last_activity.replace(tzinfo=TIMEZONE)
|
||||
else:
|
||||
last_activity = last_activity.astimezone(TIMEZONE)
|
||||
idle_minutes = (now - last_activity).total_seconds() / 60
|
||||
if idle_minutes >= ORPHAN_IDLE_LIMIT:
|
||||
is_orphan = True
|
||||
reason = (
|
||||
f"Verwaist (kein Pipeline-Fortschritt seit {int(idle_minutes)} Min, "
|
||||
f"gesamt {int(age_minutes)} Min)"
|
||||
)
|
||||
else:
|
||||
is_orphan = True
|
||||
reason = f"Verwaist (keine Pipeline-Schritte nach {int(age_minutes)} Min)"
|
||||
|
||||
if is_orphan:
|
||||
await db.execute(
|
||||
"UPDATE refresh_log SET status = 'error', completed_at = ?, error_message = ? WHERE id = ?",
|
||||
(now.strftime('%Y-%m-%d %H:%M:%S'), f"Verwaist (>{int(age_minutes)} Min ohne Abschluss, automatisch bereinigt)", orphan["id"]),
|
||||
(now.strftime('%Y-%m-%d %H:%M:%S'), reason, orphan["id"]),
|
||||
)
|
||||
logger.warning(f"Verwaisten Refresh #{orphan['id']} für Lage {orphan['incident_id']} bereinigt ({int(age_minutes)} Min)")
|
||||
logger.warning(f"Verwaisten Refresh #{orphan['id']} fuer Lage {orphan['incident_id']} bereinigt: {reason}")
|
||||
|
||||
# Alte Notifications bereinigen (> 7 Tage)
|
||||
await db.execute("DELETE FROM notifications WHERE created_at < datetime('now', '-7 days')")
|
||||
|
||||
@@ -7,6 +7,7 @@ import re
|
||||
import uuid
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
from html import escape as _html_escape
|
||||
from pathlib import Path
|
||||
|
||||
import pikepdf
|
||||
@@ -153,6 +154,66 @@ def _markdown_to_html(text: str) -> str:
|
||||
return '\n'.join(result)
|
||||
|
||||
|
||||
def _parse_developments_for_export(text: str) -> list[tuple[str, str]]:
|
||||
"""Parst die 'Neuesten Entwicklungen' (latest_developments) fuer den Export.
|
||||
|
||||
Eingabeformat je Eintrag: '- [DD.MM. HH:MM] Text {Quelle|URL, ...}'.
|
||||
Liefert (datum_label, body) je Eintrag in gespeicherter Reihenfolge.
|
||||
Quellen-Klammern und [N]-Zitate werden entfernt — der Export zeigt bewusst
|
||||
KEINE Links. Das gespeicherte Format enthaelt kein Jahr; fehlt es, wird das
|
||||
aktuelle Jahr ergaenzt (Live-Monitoring-Berichte sind tagesaktuell).
|
||||
"""
|
||||
if not text:
|
||||
return []
|
||||
year2 = datetime.now(TIMEZONE).strftime("%y")
|
||||
bullet_re = re.compile(
|
||||
r"^\s*(?:[-*•]\s*)?\[\s*(\d{1,2})\.(\d{1,2})\.?(?:(\d{2,4}))?\s+(\d{1,2}:\d{2})\s*\]\s*(.+?)\s*$"
|
||||
)
|
||||
trailing_braces = re.compile(r"\s*\{[^{}]*\}\s*\.?\s*$")
|
||||
citation_re = re.compile(r"\s*\[\d{1,5}[a-z]?\]")
|
||||
result: list[tuple[str, str]] = []
|
||||
for raw in text.splitlines():
|
||||
line = raw.strip()
|
||||
if not line:
|
||||
continue
|
||||
m = bullet_re.match(line)
|
||||
if not m:
|
||||
continue
|
||||
day, month, year, time = m.group(1), m.group(2), m.group(3), m.group(4)
|
||||
body = m.group(5).strip()
|
||||
# Quellen-Klammer am Ende und Inline-[N]-Zitate entfernen (keine Links)
|
||||
body = trailing_braces.sub("", body).strip()
|
||||
body = citation_re.sub("", body).strip()
|
||||
if not body:
|
||||
continue
|
||||
yy = year[-2:] if year else year2
|
||||
label = f"{int(day):02d}.{int(month):02d}.{yy}, {time} Uhr"
|
||||
result.append((label, body))
|
||||
return result
|
||||
|
||||
|
||||
def _format_latest_developments_html(text: str) -> str:
|
||||
"""Rendert die 'Neuesten Entwicklungen' als HTML-Block fuer den PDF-Export.
|
||||
|
||||
Pro Eintrag: Datum/Uhrzeit-Zeile, darunter (eigener Absatz) der Meldungstext.
|
||||
Keine Quellen-Links. Faellt bei nicht-parsebarem Text auf _markdown_to_html zurueck.
|
||||
"""
|
||||
pairs = _parse_developments_for_export(text)
|
||||
if not pairs:
|
||||
return _markdown_to_html(text)
|
||||
blocks = []
|
||||
for label, body in pairs:
|
||||
body_html = _html_escape(body)
|
||||
body_html = re.sub(r'\*\*(.+?)\*\*', r'<strong>\1</strong>', body_html)
|
||||
blocks.append(
|
||||
'<div class="dev-entry">'
|
||||
f'<div class="dev-entry-date">{_html_escape(label)}</div>'
|
||||
f'<div class="dev-entry-body">{body_html}</div>'
|
||||
'</div>'
|
||||
)
|
||||
return "\n".join(blocks)
|
||||
|
||||
|
||||
def _truncate_lagebild(summary_text: str, max_chars: int = 4000) -> str:
|
||||
"""Lagebild für den Lagebericht auf die Zusammenfassung kürzen.
|
||||
|
||||
@@ -479,6 +540,10 @@ def _build_export_metadata(
|
||||
subject = (incident.get("description") or "").strip()
|
||||
if not subject:
|
||||
subject = f"{type_label} zu: {title_raw}"
|
||||
# DOCX-Core-Property "subject" erzwingt ein 255-Zeichen-Limit; laengere
|
||||
# Beschreibungen wuerden den Word-Export sonst mit ValueError abbrechen.
|
||||
if len(subject) > 255:
|
||||
subject = subject[:255]
|
||||
|
||||
# Keywords sammeln (Reihenfolge relevant für Anzeige, Dedup mit dict.fromkeys)
|
||||
keywords: list[str] = ["OSINT", type_label]
|
||||
@@ -711,22 +776,33 @@ async def generate_pdf(
|
||||
else: # full
|
||||
sections = {"zusammenfassung", "bericht", "faktencheck", "quellen", "timeline"}
|
||||
|
||||
# Fuer Research-Lagen: Zusammenfassung aus dem Bericht extrahieren
|
||||
# Zusammenfassungs-Quelle bestimmen:
|
||||
# - Research: ZUSAMMENFASSUNG/UEBERBLICK aus dem Bericht extrahieren.
|
||||
# - Live-Monitoring (adhoc): "Neueste Entwicklungen" aus latest_developments,
|
||||
# ohne Quellen-Links, Datum/Uhrzeit als eigene Zeile.
|
||||
# - sonst: KI-Executive-Summary (executive_summary_html).
|
||||
is_research = incident.get("type") == "research"
|
||||
all_sources = _prepare_sources(incident)
|
||||
latest_dev = (incident.get("latest_developments") or "").strip()
|
||||
zusammenfassung_html = executive_summary_html
|
||||
bericht_summary = incident.get("summary", "")
|
||||
zusammenfassung_title = "Zusammenfassung"
|
||||
summary_has_links = True
|
||||
|
||||
if is_research and bericht_summary:
|
||||
extracted_html, remaining = _extract_zusammenfassung(bericht_summary, all_sources)
|
||||
if extracted_html:
|
||||
zusammenfassung_html = extracted_html
|
||||
zusammenfassung_title = "Zusammenfassung"
|
||||
bericht_summary = remaining
|
||||
elif not is_research and latest_dev:
|
||||
dev_html = _format_latest_developments_html(latest_dev)
|
||||
if dev_html:
|
||||
zusammenfassung_html = dev_html
|
||||
zusammenfassung_title = "Neueste Entwicklungen"
|
||||
summary_has_links = False # Quellen bewusst entfernt
|
||||
|
||||
# Auch das (nicht-research) Executive Summary linkifizieren — ggf. enthaelt es Zitate
|
||||
if not is_research and zusammenfassung_html:
|
||||
# KI-/Research-Zusammenfassung linkifizieren; Developments bleiben linkfrei
|
||||
if not is_research and summary_has_links and zusammenfassung_html:
|
||||
zusammenfassung_html = _linkify_citations_html(zusammenfassung_html, all_sources)
|
||||
|
||||
meta = _build_export_metadata(
|
||||
@@ -799,20 +875,27 @@ async def generate_docx(
|
||||
else: # full
|
||||
sections = {"zusammenfassung", "bericht", "faktencheck", "quellen", "timeline"}
|
||||
|
||||
# Fuer Research-Lagen: Zusammenfassung aus dem Bericht extrahieren
|
||||
# Zusammenfassungs-Quelle bestimmen (analog generate_pdf):
|
||||
# Research -> Bericht-Extrakt, Live-Monitoring -> "Neueste Entwicklungen", sonst KI.
|
||||
is_research = incident.get("type") == "research"
|
||||
all_sources = _prepare_sources(incident)
|
||||
latest_dev = (incident.get("latest_developments") or "").strip()
|
||||
zusammenfassung_text = executive_summary_text
|
||||
bericht_summary = incident.get("summary") or "Keine Zusammenfassung verfügbar."
|
||||
zusammenfassung_title = "Zusammenfassung"
|
||||
zusammenfassung_lines: list[str] = []
|
||||
zusammenfassung_developments: list[tuple[str, str]] = []
|
||||
|
||||
if is_research and bericht_summary:
|
||||
extracted_lines, remaining = _extract_zusammenfassung_lines(bericht_summary)
|
||||
if extracted_lines:
|
||||
zusammenfassung_lines = extracted_lines
|
||||
zusammenfassung_title = "Zusammenfassung"
|
||||
bericht_summary = remaining
|
||||
elif not is_research and latest_dev:
|
||||
dev_pairs = _parse_developments_for_export(latest_dev)
|
||||
if dev_pairs:
|
||||
zusammenfassung_developments = dev_pairs
|
||||
zusammenfassung_title = "Neueste Entwicklungen"
|
||||
|
||||
meta = _build_export_metadata(
|
||||
incident, articles, fact_checks, all_sources, creator, scope, sections,
|
||||
@@ -890,11 +973,23 @@ async def generate_docx(
|
||||
|
||||
doc.add_page_break()
|
||||
|
||||
# --- Zusammenfassung / Executive Summary ---
|
||||
# --- Zusammenfassung / Neueste Entwicklungen ---
|
||||
if "zusammenfassung" in sections:
|
||||
doc.add_heading(zusammenfassung_title, level=1)
|
||||
|
||||
if zusammenfassung_lines:
|
||||
if zusammenfassung_developments:
|
||||
# Live-Monitoring: pro Eintrag Datum/Uhrzeit-Zeile + Absatz mit Text, ohne Links
|
||||
for label, body in zusammenfassung_developments:
|
||||
date_para = doc.add_paragraph()
|
||||
date_para.paragraph_format.space_after = Pt(1)
|
||||
run = date_para.add_run(label)
|
||||
run.bold = True
|
||||
run.font.size = Pt(9)
|
||||
run.font.color.rgb = RGBColor(0x0a, 0x18, 0x32)
|
||||
body_para = doc.add_paragraph()
|
||||
body_para.paragraph_format.space_after = Pt(8)
|
||||
body_para.add_run(re.sub(r'\*\*(.+?)\*\*', r'\1', body))
|
||||
elif zusammenfassung_lines:
|
||||
for line in zusammenfassung_lines:
|
||||
_add_docx_paragraph_with_citations(doc, line, all_sources, style='List Bullet')
|
||||
else:
|
||||
|
||||
@@ -47,6 +47,12 @@ body { font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-se
|
||||
.exec-summary ul { margin: 8px 0 0 18px; }
|
||||
.exec-summary li { margin-bottom: 6px; line-height: 1.6; }
|
||||
|
||||
/* Neueste Entwicklungen (Live-Monitoring) */
|
||||
.dev-entry { margin-bottom: 12px; }
|
||||
.dev-entry:last-child { margin-bottom: 0; }
|
||||
.dev-entry-date { font-size: 9pt; font-weight: 600; color: #0a1832; margin-bottom: 2px; }
|
||||
.dev-entry-body { font-size: 10.5pt; line-height: 1.5; }
|
||||
|
||||
/* Lagebild */
|
||||
.lagebild-content { line-height: 1.7; }
|
||||
.lagebild-content p { margin-bottom: 8px; }
|
||||
@@ -99,7 +105,7 @@ tr:nth-child(even) { background: #f8f9fa; }
|
||||
<div class="toc">
|
||||
<h2>Inhaltsverzeichnis</h2>
|
||||
<ul class="toc-list">
|
||||
{% if 'zusammenfassung' in sections %}<li><a href="#sec-zusammenfassung">Zusammenfassung</a></li>{% endif %}
|
||||
{% if 'zusammenfassung' in sections %}<li><a href="#sec-zusammenfassung">{{ zusammenfassung_title }}</a></li>{% endif %}
|
||||
{% if 'bericht' in sections %}<li><a href="#sec-bericht">{% if incident.type == "research" %}Recherchebericht{% else %}Lagebild{% endif %}</a></li>{% endif %}
|
||||
{% if 'faktencheck' in sections and fact_checks %}<li><a href="#sec-faktencheck">Faktencheck</a></li>{% endif %}
|
||||
{% if 'quellen' in sections and sources %}<li><a href="#sec-quellen">Quellenverzeichnis</a></li>{% endif %}
|
||||
|
||||
@@ -1153,6 +1153,7 @@ async def export_incident(
|
||||
scope: str = Query("report", pattern="^(summary|report|full)$"),
|
||||
sections: str = Query(None),
|
||||
branding: str = Query("on", pattern="^(on|off)$"),
|
||||
creator: str = Query(None, max_length=120),
|
||||
current_user: dict = Depends(get_current_user),
|
||||
db: aiosqlite.Connection = Depends(db_dependency),
|
||||
):
|
||||
@@ -1171,10 +1172,13 @@ async def export_incident(
|
||||
row = await _check_incident_access(db, incident_id, current_user["id"], tenant_id)
|
||||
incident = dict(row)
|
||||
|
||||
# Ersteller-Name
|
||||
cursor = await db.execute("SELECT email FROM users WHERE id = ?", (incident["created_by"],))
|
||||
user_row = await cursor.fetchone()
|
||||
creator = user_row["email"] if user_row else "Unbekannt"
|
||||
# Ersteller-Name: manuell uebergebener Wert hat Vorrang, sonst E-Mail des Lage-Erstellers
|
||||
if creator and creator.strip():
|
||||
creator = creator.strip()
|
||||
else:
|
||||
cursor = await db.execute("SELECT email FROM users WHERE id = ?", (incident["created_by"],))
|
||||
user_row = await cursor.fetchone()
|
||||
creator = user_row["email"] if user_row else "Unbekannt"
|
||||
|
||||
# Organisation (fuer Dateimetadaten)
|
||||
organization_name = None
|
||||
@@ -1228,18 +1232,14 @@ async def export_incident(
|
||||
snapshots = [dict(r) for r in await cursor.fetchall()]
|
||||
|
||||
# Zusammenfassung fuer den Export:
|
||||
# - Bei Adhoc-Lagen primaer "Neueste Entwicklungen" (latest_developments) als Markdown-Bullets,
|
||||
# weil Live-Monitoring von Aktualitaet lebt.
|
||||
# - Fallback (oder bei Research): Executive Summary (KI-generiert, gecacht).
|
||||
# - Live-Monitoring (adhoc) zeigt primaer "Neueste Entwicklungen" (latest_developments).
|
||||
# Das Rendering (Datum/Uhrzeit als eigene Zeile, ohne Links) uebernimmt der
|
||||
# Report-Generator direkt aus incident["latest_developments"].
|
||||
# - Executive Summary (KI, gecacht) dient nur als Fallback (oder bei Research-Lagen).
|
||||
is_adhoc = (incident.get("type") or "adhoc") != "research"
|
||||
latest_dev = (incident.get("latest_developments") or "").strip()
|
||||
exec_summary = None
|
||||
if is_adhoc and latest_dev:
|
||||
from report_generator import _markdown_to_html as _md_to_html
|
||||
exec_summary = _md_to_html(latest_dev)
|
||||
if not exec_summary:
|
||||
exec_summary = incident.get("executive_summary")
|
||||
if not exec_summary:
|
||||
exec_summary = incident.get("executive_summary")
|
||||
if not exec_summary and not (is_adhoc and latest_dev):
|
||||
summary_text = incident.get("summary") or ""
|
||||
exec_summary = await generate_executive_summary(summary_text)
|
||||
await db.execute(
|
||||
@@ -1247,6 +1247,7 @@ async def export_incident(
|
||||
(exec_summary, incident_id),
|
||||
)
|
||||
await db.commit()
|
||||
exec_summary = exec_summary or ""
|
||||
|
||||
date_str = datetime.now(TIMEZONE).strftime("%Y%m%d")
|
||||
slug = _slugify(incident["title"])
|
||||
|
||||
@@ -36,6 +36,8 @@ _PIPELINE_STEPS_DE = [
|
||||
"tooltip": "Aus Foren-Quellen (z.B. 5ch, Hatena, Note) wird ein Stimmungsbild der öffentlichen Diskussion extrahiert. Keine Faktenlage, sondern dominante Themen und Bruchlinien."},
|
||||
{"key": "summary", "label": "Lagebild verfassen", "icon": "file-text",
|
||||
"tooltip": "Aus allen geprüften Meldungen wird ein zusammenhängendes Lagebild geschrieben, mit Quellenangaben am Text."},
|
||||
{"key": "translate", "label": "Artikel uebersetzen", "icon": "languages",
|
||||
"tooltip": "Fremdsprachige Meldungen (z.B. japanisch) werden ins Lagebild-Output uebersetzt. Laeuft nur fuer Quellen-Pools mit nicht-deutschen Sprachen und kann bei vielen neuen Artikeln einige Minuten dauern."},
|
||||
{"key": "qc", "label": "Qualitätscheck", "icon": "check-circle",
|
||||
"tooltip": "Eine letzte Kontrollprüfung am Ergebnis: Doppelte Fakten zusammenführen, Karten-Verortung prüfen, bevor du benachrichtigt wirst."},
|
||||
{"key": "notify", "label": "Benachrichtigen", "icon": "bell",
|
||||
@@ -59,6 +61,8 @@ _PIPELINE_STEPS_EN = [
|
||||
"tooltip": "Forum sources (5ch, Hatena, Note, etc.) are summarised into a public-mood overview. Not factual, but dominant themes and fault lines."},
|
||||
{"key": "summary", "label": "Writing the briefing", "icon": "file-text",
|
||||
"tooltip": "All verified articles are combined into a coherent briefing with inline citations."},
|
||||
{"key": "translate", "label": "Translating articles", "icon": "languages",
|
||||
"tooltip": "Foreign-language articles (e.g. Japanese) are translated into the briefing output language. Runs only when the source pool contains non-target-language items and can take several minutes for large incoming batches."},
|
||||
{"key": "qc", "label": "Quality check", "icon": "check-circle",
|
||||
"tooltip": "A final review: consolidate duplicate facts, verify map locations, before you get notified."},
|
||||
{"key": "notify", "label": "Notifying", "icon": "bell",
|
||||
|
||||
@@ -352,6 +352,16 @@
|
||||
</div>
|
||||
<form id="new-incident-form">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="inc-type" data-i18n="modal.field.type">Art der Lage</label>
|
||||
<select id="inc-type" onchange="toggleTypeDefaults()">
|
||||
<option value="adhoc" data-i18n="modal.option.type_adhoc">Live-Monitoring : Ereignis beobachten</option>
|
||||
<option value="research" data-i18n="modal.option.type_research">Recherche : Thema analysieren</option>
|
||||
</select>
|
||||
<div class="form-hint" id="type-hint" data-i18n="modal.hint.type_adhoc">
|
||||
Durchsucht laufend hunderte Nachrichtenquellen nach neuen Meldungen. Empfohlen: Automatische Aktualisierung.
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inc-title" data-i18n="modal.new_incident.title_field">Titel des Vorfalls</label>
|
||||
<input type="text" id="inc-title" required aria-required="true" placeholder="z.B. Explosion in Madrid" data-i18n-attr="placeholder:modal.placeholder.title">
|
||||
@@ -367,16 +377,6 @@
|
||||
<textarea id="inc-description" placeholder="Weitere Details zum Vorfall (optional)" data-i18n-attr="placeholder:modal.placeholder.description"></textarea>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inc-type" data-i18n="modal.field.type">Art der Lage</label>
|
||||
<select id="inc-type" onchange="toggleTypeDefaults()">
|
||||
<option value="adhoc" data-i18n="modal.option.type_adhoc">Live-Monitoring : Ereignis beobachten</option>
|
||||
<option value="research" data-i18n="modal.option.type_research">Recherche : Thema analysieren</option>
|
||||
</select>
|
||||
<div class="form-hint" id="type-hint" data-i18n="modal.hint.type_adhoc">
|
||||
Durchsucht laufend hunderte Nachrichtenquellen nach neuen Meldungen. Empfohlen: Automatische Aktualisierung.
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label data-i18n="modal.field.sources">Quellen</label>
|
||||
<div class="toggle-group">
|
||||
@@ -420,7 +420,7 @@
|
||||
<div class="form-group conditional-field" id="refresh-interval-field">
|
||||
<label for="inc-refresh-value" data-i18n="modal.field.interval">Intervall</label>
|
||||
<div class="interval-input-group">
|
||||
<input type="number" id="inc-refresh-value" min="10" value="15">
|
||||
<input type="number" id="inc-refresh-value" min="30" value="30">
|
||||
<select id="inc-refresh-unit" onchange="updateIntervalMin()">
|
||||
<option value="1" selected data-i18n="modal.unit.minutes">Minuten</option>
|
||||
<option value="60" data-i18n="modal.unit.hours">Stunden</option>
|
||||
@@ -428,6 +428,7 @@
|
||||
<option value="10080" data-i18n="modal.unit.weeks">Wochen</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-hint" id="interval-min-hint" style="display:none;"></div>
|
||||
</div>
|
||||
<div class="form-group conditional-field" id="refresh-starttime-field">
|
||||
<label for="inc-refresh-starttime"><span data-i18n="modal.field.start_time">Erste Aktualisierung um</span> <span class="info-icon tooltip-below" data-tooltip="Legt den Startzeitpunkt fest. Danach wird im eingestellten Intervall aktualisiert."><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></span></label>
|
||||
@@ -805,12 +806,12 @@
|
||||
<script src="/static/vendor/leaflet.js"></script>
|
||||
<script src="/static/vendor/leaflet.markercluster.js"></script>
|
||||
<script src="/static/js/i18n.js?v=20260513a"></script>
|
||||
<script src="/static/js/api.js?v=20260423a"></script>
|
||||
<script src="/static/js/api.js?v=20260522f"></script>
|
||||
<script src="/static/js/ws.js?v=20260316b"></script>
|
||||
<script src="/static/js/components.js?v=20260522d"></script>
|
||||
<script src="/static/js/layout.js?v=20260513f"></script>
|
||||
<script src="/static/js/pipeline.js?v=20260513d"></script>
|
||||
<script src="/static/js/app.js?v=20260522c"></script>
|
||||
<script src="/static/js/app.js?v=20260522f"></script>
|
||||
<script src="/static/js/cluster-data.js?v=20260322f"></script>
|
||||
<script src="/static/js/tutorial.js?v=20260316z"></script>
|
||||
<script src="/static/js/chat.js?v=20260514e"></script>
|
||||
@@ -855,6 +856,11 @@
|
||||
<label class="export-radio"><input type="radio" name="export-branding" value="on" checked><span data-i18n="export.branding.on">Mit AegisSight-Branding</span></label>
|
||||
<label class="export-radio"><input type="radio" name="export-branding" value="off"><span data-i18n="export.branding.off">Ohne Firmen-Branding</span></label>
|
||||
</div>
|
||||
<div style="margin-bottom:0;">
|
||||
<label for="export-ersteller" style="font-size:11px;text-transform:uppercase;letter-spacing:1px;color:var(--text-secondary);display:block;margin-bottom:8px;">Ersteller</label>
|
||||
<input type="text" id="export-ersteller" maxlength="120" placeholder="Name des Erstellers (optional)" style="width:100%;box-sizing:border-box;">
|
||||
<div style="font-size:11px;color:var(--text-secondary);margin-top:6px;">Leer lassen, dann wird automatisch der Lage-Ersteller verwendet.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer" style="padding:12px 20px;display:flex;justify-content:flex-end;gap:8px;border-top:1px solid var(--border);">
|
||||
<button class="btn btn-secondary" onclick="closeModal('modal-export')" data-i18n="common.cancel">Abbrechen</button>
|
||||
|
||||
@@ -330,7 +330,7 @@ const API = {
|
||||
resetTutorialState() {
|
||||
return this._request('DELETE', '/tutorial/state');
|
||||
},
|
||||
exportReport(id, format, scope, sections, includeBranding) {
|
||||
exportReport(id, format, scope, sections, includeBranding, creator) {
|
||||
const token = localStorage.getItem('osint_token');
|
||||
let url = `${this.baseUrl}/incidents/${id}/export?format=${format}`;
|
||||
if (sections && sections.length > 0) {
|
||||
@@ -341,6 +341,9 @@ const API = {
|
||||
if (includeBranding === false) {
|
||||
url += `&branding=off`;
|
||||
}
|
||||
if (creator) {
|
||||
url += `&creator=${encodeURIComponent(creator)}`;
|
||||
}
|
||||
return fetch(url, {
|
||||
headers: { 'Authorization': `Bearer ${token}` },
|
||||
});
|
||||
|
||||
@@ -578,8 +578,16 @@ const App = {
|
||||
// Telegram-Kategorien Toggle
|
||||
const tgCheckbox = document.getElementById('inc-telegram');
|
||||
if (tgCheckbox) {
|
||||
|
||||
tgCheckbox.addEventListener('change', () => updateIntervalMin());
|
||||
}
|
||||
{ const xCheckbox = document.getElementById('inc-x');
|
||||
if (xCheckbox) xCheckbox.addEventListener('change', () => updateIntervalMin()); }
|
||||
{ const ivInput = document.getElementById('inc-refresh-value');
|
||||
if (ivInput) ivInput.addEventListener('change', () => {
|
||||
const u = parseInt(document.getElementById('inc-refresh-unit').value);
|
||||
const m = (u === 1) ? _getMinIntervalMinutes() : 1;
|
||||
if (isNaN(parseInt(ivInput.value)) || parseInt(ivInput.value) < m) ivInput.value = m;
|
||||
}); }
|
||||
|
||||
|
||||
// Feedback
|
||||
@@ -1836,9 +1844,9 @@ const App = {
|
||||
// === Event Handlers ===
|
||||
|
||||
_getFormData() {
|
||||
const value = parseInt(document.getElementById('inc-refresh-value').value) || 15;
|
||||
const value = parseInt(document.getElementById('inc-refresh-value').value) || 30;
|
||||
const unit = parseInt(document.getElementById('inc-refresh-unit').value) || 1;
|
||||
const interval = Math.max(10, Math.min(10080, value * unit));
|
||||
const interval = Math.max(_getMinIntervalMinutes(), Math.min(10080, value * unit));
|
||||
return {
|
||||
title: document.getElementById('inc-title').value.trim(),
|
||||
description: document.getElementById('inc-description').value.trim() || null,
|
||||
@@ -2294,6 +2302,7 @@ async handleRefresh() {
|
||||
updateSourcesHint();
|
||||
toggleTypeDefaults(true);
|
||||
toggleRefreshInterval();
|
||||
updateIntervalMin();
|
||||
|
||||
// Modal-Titel und Submit ändern
|
||||
{ const _e = document.getElementById('modal-new-title'); if (_e) _e.textContent = (typeof T === 'function') ? T('modal.new_incident.edit_title', 'Lage bearbeiten') : 'Lage bearbeiten'; }
|
||||
@@ -2639,6 +2648,7 @@ async handleRefresh() {
|
||||
const format = document.querySelector('input[name="export-format"]:checked').value;
|
||||
const brandingEl = document.querySelector('input[name="export-branding"]:checked');
|
||||
const includeBranding = !brandingEl || brandingEl.value === 'on';
|
||||
const ersteller = (document.getElementById('export-ersteller')?.value || '').trim();
|
||||
|
||||
const btn = document.getElementById('export-submit-btn');
|
||||
const origText = btn.textContent;
|
||||
@@ -2646,7 +2656,7 @@ async handleRefresh() {
|
||||
btn.textContent = (typeof T === 'function' ? T('action.creating', 'Wird erstellt...') : 'Wird erstellt...');
|
||||
|
||||
try {
|
||||
const response = await API.exportReport(this.currentIncidentId, format, null, sections, includeBranding);
|
||||
const response = await API.exportReport(this.currentIncidentId, format, null, sections, includeBranding, ersteller);
|
||||
if (!response.ok) {
|
||||
const err = await response.json().catch(() => ({}));
|
||||
throw new Error(err.detail || 'Fehler ' + response.status);
|
||||
@@ -3632,6 +3642,7 @@ function openModal(id) {
|
||||
document.getElementById('inc-notify-status-change').checked = false;
|
||||
toggleTypeDefaults();
|
||||
toggleRefreshInterval();
|
||||
updateIntervalMin();
|
||||
}
|
||||
const modal = document.getElementById(id);
|
||||
modal._previousFocus = document.activeElement;
|
||||
@@ -3813,17 +3824,38 @@ function toggleRefreshInterval() {
|
||||
if (startField) startField.classList.toggle('visible', mode === 'auto');
|
||||
}
|
||||
|
||||
function _getMinIntervalMinutes() {
|
||||
// Mindest-Intervall (Minuten) je nach Quellen: 30 Basis, 45 bei X oder Telegram, 60 bei beiden. International zaehlt nicht.
|
||||
const tg = document.getElementById('inc-telegram');
|
||||
const x = document.getElementById('inc-x');
|
||||
const tgOn = !!(tg && tg.checked);
|
||||
const xOn = !!(x && x.checked);
|
||||
if (tgOn && xOn) return 60;
|
||||
if (tgOn || xOn) return 45;
|
||||
return 30;
|
||||
}
|
||||
|
||||
function updateIntervalMin() {
|
||||
const unit = parseInt(document.getElementById('inc-refresh-unit').value);
|
||||
const input = document.getElementById('inc-refresh-value');
|
||||
const minMinutes = _getMinIntervalMinutes();
|
||||
const hint = document.getElementById('interval-min-hint');
|
||||
if (unit === 1) {
|
||||
// Minuten: Minimum 10
|
||||
input.min = 10;
|
||||
if (parseInt(input.value) < 10) input.value = 10;
|
||||
// Minuten: dynamisches Minimum (30 / 45 bei X oder Telegram / 60 bei beiden)
|
||||
input.min = minMinutes;
|
||||
if (isNaN(parseInt(input.value)) || parseInt(input.value) < minMinutes) input.value = minMinutes;
|
||||
if (hint) {
|
||||
let zusatz = '';
|
||||
if (minMinutes === 45) zusatz = ' (X oder Telegram aktiv)';
|
||||
else if (minMinutes === 60) zusatz = ' (X und Telegram aktiv)';
|
||||
hint.textContent = 'Mindestens ' + minMinutes + ' Minuten' + zusatz;
|
||||
hint.style.display = '';
|
||||
}
|
||||
} else {
|
||||
// Stunden/Tage/Wochen: Minimum 1
|
||||
// Stunden/Tage/Wochen: eine Einheit liegt ueber jedem Minuten-Minimum
|
||||
input.min = 1;
|
||||
if (parseInt(input.value) < 1) input.value = 1;
|
||||
if (isNaN(parseInt(input.value)) || parseInt(input.value) < 1) input.value = 1;
|
||||
if (hint) hint.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren