Commits vergleichen
27 Commits
46864c5457
...
main
| Autor | SHA1 | Datum | |
|---|---|---|---|
|
|
00d7dd70fc | ||
|
|
29c10e85cb | ||
|
|
03173eaa1a | ||
|
|
594b9cfa2c | ||
|
|
087ec547f7 | ||
|
|
f1b55dd104 | ||
|
|
e83f80dbe9 | ||
|
|
d71daee581 | ||
| 1e9cca2555 | |||
|
|
f4c0c930b8 | ||
| 03ee30a83e | |||
|
|
f73c21235e | ||
|
|
cbfb608471 | ||
|
|
9078489d0a | ||
|
|
e517de7404 | ||
| 07c3fed9c8 | |||
| 24d7500152 | |||
|
|
f0fe35b279 | ||
|
|
fb6e9fff19 | ||
| 6a24d0b51d | |||
|
|
b1a0e97a34 | ||
|
|
77797f6027 | ||
|
|
dc51ecafe8 | ||
|
|
31fa17465a | ||
| eaffd70575 | |||
|
|
2a654cc882 | ||
|
|
6293cef91e |
@@ -1,4 +1,13 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "2026-05-03T15:21Z",
|
||||||
|
"date": "2026-05-03",
|
||||||
|
"title": "Übersichtlichere Navigation in der Seitenleiste",
|
||||||
|
"items": [
|
||||||
|
"Schaltflächen in der Seitenleiste haben jetzt klarere Icons und kürzere Beschriftungen",
|
||||||
|
"Der Feedback-Button zeigt nun ein Brief-Symbol für bessere Erkennbarkeit"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "2026-04-30T23:12Z",
|
"version": "2026-04-30T23:12Z",
|
||||||
"date": "2026-04-30",
|
"date": "2026-04-30",
|
||||||
|
|||||||
@@ -489,6 +489,9 @@ class AgentOrchestrator:
|
|||||||
|
|
||||||
logger.info(f"Lage {incident_id} aus Warteschlange entfernt (removed={removed})")
|
logger.info(f"Lage {incident_id} aus Warteschlange entfernt (removed={removed})")
|
||||||
|
|
||||||
|
# refresh_log-Eintrag schreiben, damit Auto-Refresh nicht im naechsten Tick erneut einreiht
|
||||||
|
await self._log_queued_cancellation(incident_id)
|
||||||
|
|
||||||
# Send cancelled event
|
# Send cancelled event
|
||||||
if self._ws_manager:
|
if self._ws_manager:
|
||||||
try:
|
try:
|
||||||
@@ -624,18 +627,56 @@ class AgentOrchestrator:
|
|||||||
self._queue.task_done()
|
self._queue.task_done()
|
||||||
|
|
||||||
async def _mark_refresh_cancelled(self, incident_id: int):
|
async def _mark_refresh_cancelled(self, incident_id: int):
|
||||||
"""Markiert den laufenden Refresh-Log-Eintrag als cancelled."""
|
"""Markiert den laufenden Refresh-Log-Eintrag als cancelled und schliesst
|
||||||
|
alle noch aktiven Pipeline-Schritte. Ohne den zweiten Schritt blieb der
|
||||||
|
zuletzt aktive Step-Eintrag verwaist und das Frontend zeigte dauerhaft
|
||||||
|
'Schritt X laeuft', weil /api/incidents/<id>/pipeline aus
|
||||||
|
refresh_pipeline_steps liest."""
|
||||||
from database import get_db
|
from database import get_db
|
||||||
|
from services.pipeline_tracker import cancel_active_steps
|
||||||
db = await get_db()
|
db = await get_db()
|
||||||
try:
|
try:
|
||||||
|
now_str = datetime.now(TIMEZONE).strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
cur = await db.execute(
|
||||||
|
"SELECT id FROM refresh_log WHERE incident_id = ? AND status = 'running'",
|
||||||
|
(incident_id,),
|
||||||
|
)
|
||||||
|
row = await cur.fetchone()
|
||||||
|
refresh_log_id = row["id"] if row else None
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"""UPDATE refresh_log SET status = 'cancelled', error_message = 'Vom Nutzer abgebrochen',
|
"""UPDATE refresh_log SET status = 'cancelled', error_message = 'Vom Nutzer abgebrochen',
|
||||||
completed_at = ? WHERE incident_id = ? AND status = 'running'""",
|
completed_at = ? WHERE incident_id = ? AND status = 'running'""",
|
||||||
(datetime.now(TIMEZONE).strftime('%Y-%m-%d %H:%M:%S'), incident_id),
|
(now_str, incident_id),
|
||||||
|
)
|
||||||
|
await db.commit()
|
||||||
|
|
||||||
|
if refresh_log_id is not None:
|
||||||
|
await cancel_active_steps(db, refresh_log_id=refresh_log_id)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Konnte Refresh-Log nicht als abgebrochen markieren: {e}")
|
||||||
|
finally:
|
||||||
|
await db.close()
|
||||||
|
|
||||||
|
async def _log_queued_cancellation(self, incident_id: int):
|
||||||
|
"""Schreibt einen cancelled-Eintrag fuer einen Queue-Abbruch (Lage war noch nicht laufend).
|
||||||
|
Verhindert, dass der Auto-Refresh-Scheduler im naechsten Tick sofort wieder einreiht."""
|
||||||
|
from database import get_db
|
||||||
|
db = await get_db()
|
||||||
|
try:
|
||||||
|
cur = await db.execute("SELECT tenant_id FROM incidents WHERE id = ?", (incident_id,))
|
||||||
|
row = await cur.fetchone()
|
||||||
|
tid = row["tenant_id"] if row else None
|
||||||
|
now_str = datetime.now(TIMEZONE).strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
await db.execute(
|
||||||
|
"""INSERT INTO refresh_log (incident_id, started_at, completed_at, status,
|
||||||
|
trigger_type, error_message, tenant_id)
|
||||||
|
VALUES (?, ?, ?, 'cancelled', 'manual', 'Aus Warteschlange entfernt', ?)""",
|
||||||
|
(incident_id, now_str, now_str, tid),
|
||||||
)
|
)
|
||||||
await db.commit()
|
await db.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Konnte Refresh-Log nicht als abgebrochen markieren: {e}")
|
logger.warning(f"Konnte Queue-Cancel nicht in refresh_log loggen: {e}")
|
||||||
finally:
|
finally:
|
||||||
await db.close()
|
await db.close()
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ REGELN:
|
|||||||
{language_instruction}
|
{language_instruction}
|
||||||
- Faktenbasiert und neutral - keine Spekulationen
|
- Faktenbasiert und neutral - keine Spekulationen
|
||||||
- KRITISCH für source_url: Kopiere die EXAKTE URL aus den WebSearch-Ergebnissen. Erfinde oder konstruiere NIEMALS URLs aus Mustern oder Erinnerung. Wenn du die exakte URL eines Artikels nicht aus den Suchergebnissen hast, lass diesen Artikel komplett weg.
|
- KRITISCH für source_url: Kopiere die EXAKTE URL aus den WebSearch-Ergebnissen. Erfinde oder konstruiere NIEMALS URLs aus Mustern oder Erinnerung. Wenn du die exakte URL eines Artikels nicht aus den Suchergebnissen hast, lass diesen Artikel komplett weg.
|
||||||
- Nutze removepaywalls.com für Paywall-geschützte Artikel (z.B. Spiegel+, Zeit+, SZ+): https://www.removepaywalls.com/search?url=ARTIKEL_URL
|
- Nutze removepaywall.com für Paywall-geschützte Artikel (z.B. Spiegel+, Zeit+, SZ+): https://www.removepaywall.com/search?url=ARTIKEL_URL
|
||||||
- Nutze WebFetch um die 3-5 wichtigsten Artikel vollständig abzurufen und zusammenzufassen
|
- Nutze WebFetch um die 3-5 wichtigsten Artikel vollständig abzurufen und zusammenzufassen
|
||||||
|
|
||||||
Gib die Ergebnisse AUSSCHLIESSLICH als JSON-Array zurück, ohne Erklärungen davor oder danach.
|
Gib die Ergebnisse AUSSCHLIESSLICH als JSON-Array zurück, ohne Erklärungen davor oder danach.
|
||||||
@@ -124,7 +124,7 @@ Nutze spezifische Suchbegriffe für institutionelle Quellen. Ziel: 6-10 weitere
|
|||||||
PHASE 4 — VERIFIKATION UND VERTIEFUNG:
|
PHASE 4 — VERIFIKATION UND VERTIEFUNG:
|
||||||
Nutze WebFetch um die 6-10 wichtigsten Artikel vollständig abzurufen und ausführlich zusammenzufassen.
|
Nutze WebFetch um die 6-10 wichtigsten Artikel vollständig abzurufen und ausführlich zusammenzufassen.
|
||||||
Priorisiere dabei Primärquellen und investigative Berichte.
|
Priorisiere dabei Primärquellen und investigative Berichte.
|
||||||
Nutze removepaywalls.com für Paywall-geschützte Artikel (z.B. https://www.removepaywalls.com/search?url=ARTIKEL_URL)
|
Nutze removepaywall.com für Paywall-geschützte Artikel (z.B. https://www.removepaywall.com/search?url=ARTIKEL_URL)
|
||||||
|
|
||||||
{language_instruction}
|
{language_instruction}
|
||||||
|
|
||||||
@@ -199,14 +199,22 @@ AKTUELLE HEADLINES (die letzten Meldungen zu diesem Thema):
|
|||||||
|
|
||||||
AUFGABE:
|
AUFGABE:
|
||||||
Generiere 5 Begriffspaare (DE + EN), mit denen neue RSS-Artikel zu diesem Thema gefunden werden.
|
Generiere 5 Begriffspaare (DE + EN), mit denen neue RSS-Artikel zu diesem Thema gefunden werden.
|
||||||
Ein Artikel gilt als relevant, wenn mindestens 2 dieser Begriffe im Titel oder der Beschreibung vorkommen.
|
Ein Artikel gilt als relevant, wenn mindestens 2 dieser Begriffe im Titel oder der Beschreibung vorkommen
|
||||||
|
- bei spezifischen Begriffen (Eigennamen, lange Begriffe ab 7 Zeichen) reicht 1 Treffer.
|
||||||
|
|
||||||
REGELN:
|
REGELN:
|
||||||
- Die ersten 2 Begriffspaare MUESSEN die zentralen Akteure/Laender/Themen sein (z.B. iran, israel, usa) — also die Begriffe, die in fast JEDEM Artikel zum Thema vorkommen
|
- ZWINGEND: Eigennamen oder spezifische Begriffe aus dem THEMA (z.B. Personennamen, Tiernamen,
|
||||||
- Die letzten 3 Begriffspaare sind aktuelle Entwicklungen aus den Headlines (Orte, Akteure, Schluesselwoerter der aktuellen Phase)
|
Ortsnamen wie "timmy", "buckelwal", "merz", "dobrindt") MUESSEN als eigene Begriffspaare
|
||||||
- Begriffe muessen so gewaehlt sein, dass sie in kurzen RSS-Titeln matchen (einzelne Woerter, keine Phrasen)
|
enthalten sein. Solche Begriffe sind oft das einzige, was in kurzen Headlines vorkommt.
|
||||||
- Alle Begriffe in Kleinbuchstaben
|
- Die ersten 2 Begriffspaare sind die zentralen Akteure/Laender/Themen (z.B. iran, israel,
|
||||||
- Exakt 5 Begriffspaare
|
buckelwal, timmy) — also die Begriffe, die in fast JEDEM Artikel zum Thema vorkommen.
|
||||||
|
- Die uebrigen 3 Begriffspaare sind aktuelle Entwicklungen aus den Headlines (Orte, Akteure,
|
||||||
|
Schluesselwoerter der aktuellen Phase).
|
||||||
|
- Wenn DE und EN identisch sind (Eigennamen), trotzdem das Paar einreichen.
|
||||||
|
- Begriffe muessen so gewaehlt sein, dass sie in kurzen RSS-Titeln matchen (einzelne Woerter,
|
||||||
|
keine Phrasen, keine Konjunktionen).
|
||||||
|
- Alle Begriffe in Kleinbuchstaben.
|
||||||
|
- Exakt 5 Begriffspaare.
|
||||||
|
|
||||||
Antwort NUR als JSON-Array:
|
Antwort NUR als JSON-Array:
|
||||||
[{{"de": "iran", "en": "iran"}}, {{"de": "israel", "en": "israel"}}, {{"de": "teheran", "en": "tehran"}}, {{"de": "luftangriff", "en": "airstrike"}}, {{"de": "trump", "en": "trump"}}]"""
|
[{{"de": "iran", "en": "iran"}}, {{"de": "israel", "en": "israel"}}, {{"de": "teheran", "en": "tehran"}}, {{"de": "luftangriff", "en": "airstrike"}}, {{"de": "trump", "en": "trump"}}]"""
|
||||||
@@ -365,6 +373,17 @@ class ResearcherAgent:
|
|||||||
if en and en != de:
|
if en and en != de:
|
||||||
keywords.append(en)
|
keywords.append(en)
|
||||||
|
|
||||||
|
# Bug-2-Fallback: Lagentitel-Wörter (>=4 Zeichen) zwingend in Keyword-Liste,
|
||||||
|
# falls Haiku sie weggelassen hat. Verhindert "Buckelwal timmy"-Bug, bei dem
|
||||||
|
# der Eigenname "timmy" fehlte und damit Headlines mit nur "Buckelwal" durchfielen.
|
||||||
|
STOPWORDS = {"der", "die", "das", "und", "oder", "von", "vom", "zum", "zur",
|
||||||
|
"the", "and", "for", "with", "ueber", "über", "von", "for"}
|
||||||
|
for word in (title or "").lower().split():
|
||||||
|
w = word.strip(".,;:!?\"\'()[]{}")
|
||||||
|
if len(w) >= 4 and w not in STOPWORDS and w not in keywords:
|
||||||
|
keywords.append(w)
|
||||||
|
logger.info(f"Lagentitel-Keyword '{w}' nachträglich injiziert")
|
||||||
|
|
||||||
if keywords:
|
if keywords:
|
||||||
logger.info(f"Dynamische Keywords ({len(keywords)}): {keywords}")
|
logger.info(f"Dynamische Keywords ({len(keywords)}): {keywords}")
|
||||||
return keywords if keywords else None, usage
|
return keywords if keywords else None, usage
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import logging
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from agents.claude_client import call_claude, ClaudeUsage, UsageAccumulator
|
from agents.claude_client import call_claude, ClaudeUsage, UsageAccumulator
|
||||||
from config import CLAUDE_MODEL_FAST
|
from config import CLAUDE_MODEL_FAST, TRANSLATOR_ENABLED
|
||||||
|
|
||||||
logger = logging.getLogger("osint.translator")
|
logger = logging.getLogger("osint.translator")
|
||||||
|
|
||||||
@@ -95,10 +95,15 @@ WICHTIG:
|
|||||||
- Wenn der Artikel schon auf {lang_label} ist (z.B. source_lang="{output_lang}"),
|
- Wenn der Artikel schon auf {lang_label} ist (z.B. source_lang="{output_lang}"),
|
||||||
kopiere headline und content unveraendert.
|
kopiere headline und content unveraendert.
|
||||||
|
|
||||||
Antworte AUSSCHLIESSLICH als JSON-Array - eine Liste von Objekten in der Form:
|
Antworte AUSSCHLIESSLICH mit einem flachen JSON-Array (kein Wrapper-Objekt!).
|
||||||
[{{"id": <int>, "headline_de": "<uebersetzter Titel>", "content_de": "<uebersetzter Text>"}}, ...]
|
Format genau so:
|
||||||
|
[
|
||||||
|
{{"id": 1, "headline_de": "Titel auf Deutsch", "content_de": "Inhalt auf Deutsch"}},
|
||||||
|
{{"id": 2, "headline_de": "...", "content_de": "..."}}
|
||||||
|
]
|
||||||
|
|
||||||
Keine Einleitung, keine Erklaerung, nur das JSON-Array.
|
NICHT erlaubt: {{"translations": [...]}} oder {{"items": [...]}} oder Markdown-Codefences.
|
||||||
|
Nur das Array, ohne Einleitung, ohne Erklaerung.
|
||||||
|
|
||||||
ARTIKEL:
|
ARTIKEL:
|
||||||
{json.dumps(items, ensure_ascii=False, indent=2)}
|
{json.dumps(items, ensure_ascii=False, indent=2)}
|
||||||
@@ -134,6 +139,19 @@ def _parse_response(text: str) -> list[dict]:
|
|||||||
else:
|
else:
|
||||||
data = _extract_complete_objects(text)
|
data = _extract_complete_objects(text)
|
||||||
|
|
||||||
|
# Claude wraps das Array gelegentlich in {"translations": [...]} oder {"items": [...]}
|
||||||
|
if isinstance(data, dict):
|
||||||
|
for key in ("translations", "items", "results", "data"):
|
||||||
|
if isinstance(data.get(key), list):
|
||||||
|
data = data[key]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
# Einzelnes Objekt? Dann als Liste mit einem Element behandeln
|
||||||
|
if "id" in data:
|
||||||
|
data = [data]
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Translator-Antwort: Dict ohne erwarteten Array-Key (keys={list(data.keys())[:5]})")
|
||||||
|
|
||||||
if not isinstance(data, list):
|
if not isinstance(data, list):
|
||||||
raise ValueError(f"Translator-Antwort ist kein Array: {type(data).__name__}")
|
raise ValueError(f"Translator-Antwort ist kein Array: {type(data).__name__}")
|
||||||
|
|
||||||
@@ -212,6 +230,13 @@ async def translate_articles(
|
|||||||
if not articles:
|
if not articles:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
if not TRANSLATOR_ENABLED:
|
||||||
|
logger.info(
|
||||||
|
"Translator deaktiviert (TRANSLATOR_ENABLED=false), %d Artikel uebersprungen",
|
||||||
|
len(articles),
|
||||||
|
)
|
||||||
|
return []
|
||||||
|
|
||||||
all_translations = []
|
all_translations = []
|
||||||
for i in range(0, len(articles), batch_size):
|
for i in range(0, len(articles), batch_size):
|
||||||
batch = articles[i : i + batch_size]
|
batch = articles[i : i + batch_size]
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ OUTPUT_LANGUAGE = "Deutsch"
|
|||||||
# In Kundenversion auf False setzen oder Env-Variable entfernen
|
# In Kundenversion auf False setzen oder Env-Variable entfernen
|
||||||
DEV_MODE = os.environ.get("DEV_MODE", "true").lower() == "true"
|
DEV_MODE = os.environ.get("DEV_MODE", "true").lower() == "true"
|
||||||
|
|
||||||
|
# Feature-Flag: Translator-Agent (Haiku) komplett deaktivieren.
|
||||||
|
# False = keine Uebersetzungen mehr, fremdsprachige Artikel bleiben unuebersetzt.
|
||||||
|
TRANSLATOR_ENABLED = os.environ.get("TRANSLATOR_ENABLED", "true").lower() == "true"
|
||||||
|
|
||||||
# RSS-Feeds (Fallback, primär aus DB geladen)
|
# RSS-Feeds (Fallback, primär aus DB geladen)
|
||||||
RSS_FEEDS = {
|
RSS_FEEDS = {
|
||||||
"deutsch": [
|
"deutsch": [
|
||||||
@@ -91,3 +95,9 @@ TELEGRAM_API_ID = int(os.environ.get("TELEGRAM_API_ID", "0"))
|
|||||||
TELEGRAM_API_HASH = os.environ.get("TELEGRAM_API_HASH", "")
|
TELEGRAM_API_HASH = os.environ.get("TELEGRAM_API_HASH", "")
|
||||||
TELEGRAM_SESSION_PATH = os.environ.get("TELEGRAM_SESSION_PATH", "/home/claude-dev/.telegram/telegram_session")
|
TELEGRAM_SESSION_PATH = os.environ.get("TELEGRAM_SESSION_PATH", "/home/claude-dev/.telegram/telegram_session")
|
||||||
|
|
||||||
|
# Health-Check (genutzt von services/source_health.py)
|
||||||
|
HEALTH_CHECK_USER_AGENT = os.environ.get(
|
||||||
|
"HEALTH_CHECK_USER_AGENT",
|
||||||
|
"Mozilla/5.0 (compatible; AegisSight-HealthCheck/1.0)",
|
||||||
|
)
|
||||||
|
HEALTH_CHECK_TIMEOUT_S = float(os.environ.get("HEALTH_CHECK_TIMEOUT_S", "15.0"))
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ async def check_auto_refresh():
|
|||||||
|
|
||||||
# Letzten abgeschlossenen oder laufenden Refresh pruefen
|
# Letzten abgeschlossenen oder laufenden Refresh pruefen
|
||||||
cursor = await db.execute(
|
cursor = await db.execute(
|
||||||
"SELECT started_at, status FROM refresh_log WHERE incident_id = ? AND status IN ('completed', 'running') ORDER BY id DESC LIMIT 1",
|
"SELECT started_at, status FROM refresh_log WHERE incident_id = ? AND status IN ('completed', 'running', 'cancelled', 'error') ORDER BY id DESC LIMIT 1",
|
||||||
(incident_id,),
|
(incident_id,),
|
||||||
)
|
)
|
||||||
last_refresh = await cursor.fetchone()
|
last_refresh = await cursor.fetchone()
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ async def require_writable_license(
|
|||||||
if lic.get("read_only"):
|
if lic.get("read_only"):
|
||||||
reason = lic.get("read_only_reason") or "expired"
|
reason = lic.get("read_only_reason") or "expired"
|
||||||
if reason == "budget_exceeded":
|
if reason == "budget_exceeded":
|
||||||
detail = "Token-Budget aufgebraucht. Bitte Verwaltung kontaktieren."
|
detail = "Token-Budget aufgebraucht. Für Aufstockung oder Upgrade bitte info@aegis-sight.de kontaktieren."
|
||||||
elif reason == "expired":
|
elif reason == "expired":
|
||||||
detail = "Lizenz abgelaufen. Nur Lesezugriff moeglich."
|
detail = "Lizenz abgelaufen. Nur Lesezugriff moeglich."
|
||||||
elif reason == "no_license":
|
elif reason == "no_license":
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class IncidentCreate(BaseModel):
|
|||||||
refresh_interval: int = Field(default=15, ge=10, le=10080)
|
refresh_interval: int = Field(default=15, ge=10, le=10080)
|
||||||
refresh_start_time: Optional[str] = Field(default=None, pattern=r"^([01]\d|2[0-3]):[0-5]\d$")
|
refresh_start_time: Optional[str] = Field(default=None, pattern=r"^([01]\d|2[0-3]):[0-5]\d$")
|
||||||
retention_days: int = Field(default=0, ge=0, le=999)
|
retention_days: int = Field(default=0, ge=0, le=999)
|
||||||
international_sources: bool = True
|
international_sources: bool = False
|
||||||
include_telegram: bool = False
|
include_telegram: bool = False
|
||||||
visibility: str = Field(default="public", pattern="^(public|private)$")
|
visibility: str = Field(default="public", pattern="^(public|private)$")
|
||||||
|
|
||||||
|
|||||||
@@ -228,3 +228,25 @@ async def error_step(db, ws_manager, *, step_id: Optional[int], refresh_log_id:
|
|||||||
"status": "error",
|
"status": "error",
|
||||||
"pass_number": pass_number,
|
"pass_number": pass_number,
|
||||||
}, visibility, created_by, tenant_id)
|
}, visibility, created_by, tenant_id)
|
||||||
|
|
||||||
|
|
||||||
|
async def cancel_active_steps(db, *, refresh_log_id: int) -> int:
|
||||||
|
"""Schliesst alle noch aktiven Pipeline-Schritte eines Refreshs als 'cancelled' ab.
|
||||||
|
|
||||||
|
Wird vom Orchestrator nach einem User-Cancel aufgerufen. Ohne diesen Schritt
|
||||||
|
bleibt der zuletzt aktive Step-Eintrag verwaist und der Pipeline-Endpoint
|
||||||
|
liefert dauerhaft 'Schritt X laeuft' an die UI.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
cur = await db.execute(
|
||||||
|
"""UPDATE refresh_pipeline_steps
|
||||||
|
SET status = 'cancelled', completed_at = ?
|
||||||
|
WHERE refresh_log_id = ? AND status = 'active'""",
|
||||||
|
(_now_db(), refresh_log_id),
|
||||||
|
)
|
||||||
|
await db.commit()
|
||||||
|
return cur.rowcount or 0
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Pipeline cancel_active_steps DB-Fehler: {e}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +1,69 @@
|
|||||||
"""Quellen-Health-Check Engine - prüft Erreichbarkeit, Feed-Validität, Duplikate."""
|
"""Quellen-Health-Check Engine - prüft Erreichbarkeit, Feed-Validität, Duplikate."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
|
import uuid
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import feedparser
|
import feedparser
|
||||||
import aiosqlite
|
import aiosqlite
|
||||||
|
|
||||||
|
try:
|
||||||
|
from config import HEALTH_CHECK_USER_AGENT, HEALTH_CHECK_TIMEOUT_S
|
||||||
|
except ImportError:
|
||||||
|
HEALTH_CHECK_USER_AGENT = "Mozilla/5.0 (compatible; AegisSight-HealthCheck/1.0)"
|
||||||
|
HEALTH_CHECK_TIMEOUT_S = 15.0
|
||||||
|
|
||||||
|
# Phase 18: alternative User-Agents fuer Bot-Block-Bypass
|
||||||
|
USER_AGENT_GOOGLEBOT = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
|
||||||
|
USER_AGENT_BROWSER = (
|
||||||
|
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 "
|
||||||
|
"(KHTML, like Gecko) Chrome/120.0 Safari/537.36"
|
||||||
|
)
|
||||||
|
REMOVEPAYWALLS_PREFIX = "https://www.removepaywall.com/search?url="
|
||||||
|
|
||||||
|
# HTTP-Codes, die einen Retry mit anderem UA rechtfertigen
|
||||||
|
RETRY_ON_STATUS = {403, 406, 429}
|
||||||
|
|
||||||
logger = logging.getLogger("osint.source_health")
|
logger = logging.getLogger("osint.source_health")
|
||||||
|
|
||||||
|
|
||||||
async def run_health_checks(db: aiosqlite.Connection) -> dict:
|
async def run_health_checks(db: aiosqlite.Connection) -> dict:
|
||||||
"""Führt alle Health-Checks für aktive Grundquellen durch."""
|
"""Führt Health-Checks für alle aktiven Quellen durch (global + Tenant)."""
|
||||||
logger.info("Starte Quellen-Health-Check...")
|
logger.info("Starte Quellen-Health-Check...")
|
||||||
|
|
||||||
# Alle aktiven Grundquellen laden
|
# Alle aktiven Quellen laden (global UND Tenant-spezifisch)
|
||||||
cursor = await db.execute(
|
cursor = await db.execute(
|
||||||
"SELECT id, name, url, domain, source_type, article_count, last_seen_at "
|
"SELECT id, name, url, domain, source_type, article_count, last_seen_at, "
|
||||||
"FROM sources WHERE status = 'active' AND tenant_id IS NULL"
|
"COALESCE(fetch_strategy, 'default') AS fetch_strategy "
|
||||||
|
"FROM sources WHERE status = 'active' "
|
||||||
)
|
)
|
||||||
sources = [dict(row) for row in await cursor.fetchall()]
|
sources = [dict(row) for row in await cursor.fetchall()]
|
||||||
|
|
||||||
# Aktuelle Health-Check-Ergebnisse löschen (werden neu geschrieben)
|
# Bisherigen Stand in History archivieren, dann frisch starten
|
||||||
|
run_id = uuid.uuid4().hex[:12]
|
||||||
|
await db.execute(
|
||||||
|
"INSERT INTO source_health_history "
|
||||||
|
"(run_id, source_id, check_type, status, message, details, checked_at) "
|
||||||
|
"SELECT ?, source_id, check_type, status, message, details, checked_at "
|
||||||
|
"FROM source_health_checks",
|
||||||
|
(run_id,),
|
||||||
|
)
|
||||||
await db.execute("DELETE FROM source_health_checks")
|
await db.execute("DELETE FROM source_health_checks")
|
||||||
await db.commit()
|
await db.commit()
|
||||||
|
logger.info(f"Health-Check Run {run_id}: vorigen Stand archiviert")
|
||||||
|
|
||||||
checks_done = 0
|
checks_done = 0
|
||||||
issues_found = 0
|
issues_found = 0
|
||||||
|
|
||||||
# 1. Erreichbarkeit + Feed-Validität (nur Quellen mit URL)
|
# 1. Erreichbarkeit + Feed-Validität (nur Quellen mit URL)
|
||||||
sources_with_url = [s for s in sources if s["url"]]
|
sources_with_url = [s for s in sources if s["url"]]
|
||||||
|
|
||||||
async with httpx.AsyncClient(
|
async with httpx.AsyncClient(
|
||||||
timeout=15.0,
|
timeout=HEALTH_CHECK_TIMEOUT_S,
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
headers={"User-Agent": "Mozilla/5.0 (compatible; OSINT-Monitor/1.0)"},
|
headers={"User-Agent": HEALTH_CHECK_USER_AGENT},
|
||||||
) as client:
|
) as client:
|
||||||
for i in range(0, len(sources_with_url), 5):
|
for i in range(0, len(sources_with_url), 5):
|
||||||
batch = sources_with_url[i:i + 5]
|
batch = sources_with_url[i:i + 5]
|
||||||
@@ -46,7 +74,7 @@ async def run_health_checks(db: aiosqlite.Connection) -> dict:
|
|||||||
if isinstance(result, Exception):
|
if isinstance(result, Exception):
|
||||||
await _save_check(
|
await _save_check(
|
||||||
db, source["id"], "reachability", "error",
|
db, source["id"], "reachability", "error",
|
||||||
f"Prüfung fehlgeschlagen: {result}",
|
f"Prüfung fehlgeschlagen: {result}",
|
||||||
)
|
)
|
||||||
issues_found += 1
|
issues_found += 1
|
||||||
else:
|
else:
|
||||||
@@ -83,7 +111,7 @@ async def run_health_checks(db: aiosqlite.Connection) -> dict:
|
|||||||
|
|
||||||
await db.commit()
|
await db.commit()
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Health-Check abgeschlossen: {checks_done} Quellen geprüft, "
|
f"Health-Check abgeschlossen: {checks_done} Quellen geprüft, "
|
||||||
f"{issues_found} Probleme gefunden"
|
f"{issues_found} Probleme gefunden"
|
||||||
)
|
)
|
||||||
return {"checked": checks_done, "issues": issues_found}
|
return {"checked": checks_done, "issues": issues_found}
|
||||||
@@ -92,12 +120,63 @@ async def run_health_checks(db: aiosqlite.Connection) -> dict:
|
|||||||
async def _check_source_reachability(
|
async def _check_source_reachability(
|
||||||
client: httpx.AsyncClient, source: dict,
|
client: httpx.AsyncClient, source: dict,
|
||||||
) -> list[dict]:
|
) -> list[dict]:
|
||||||
"""Prüft Erreichbarkeit und Feed-Validität einer Quelle."""
|
"""Prüft Erreichbarkeit und Feed-Validität einer Quelle.
|
||||||
|
|
||||||
|
Phase 18: pro Quelle eine fetch_strategy ('default' | 'googlebot' | 'paywall' | 'skip').
|
||||||
|
Bei 'default' wird im Fehlerfall (403/406/429) ein Retry mit Googlebot-UA gemacht.
|
||||||
|
Bei 'paywall' wird auf removepaywall.com umgeleitet.
|
||||||
|
Bei 'skip' wird kein Check ausgeführt.
|
||||||
|
"""
|
||||||
checks = []
|
checks = []
|
||||||
url = source["url"]
|
url = source["url"]
|
||||||
|
strategy = source.get("fetch_strategy") or "default"
|
||||||
|
|
||||||
|
# 'skip' -> kein Check (bekannte unerreichbare Quellen, z.B. Login-only)
|
||||||
|
if strategy == "skip":
|
||||||
|
checks.append({
|
||||||
|
"type": "reachability", "status": "ok",
|
||||||
|
"message": "Health-Check uebersprungen (fetch_strategy=skip)",
|
||||||
|
})
|
||||||
|
return checks
|
||||||
|
|
||||||
|
# URL-Schema sicherstellen
|
||||||
|
if url and not url.startswith(("http://", "https://")):
|
||||||
|
url = "https://" + url.lstrip("/")
|
||||||
|
|
||||||
|
# Initialen UA waehlen
|
||||||
|
initial_ua = HEALTH_CHECK_USER_AGENT
|
||||||
|
initial_url = url
|
||||||
|
if strategy == "googlebot":
|
||||||
|
initial_ua = USER_AGENT_GOOGLEBOT
|
||||||
|
elif strategy == "paywall":
|
||||||
|
# Paywall-Quellen: Feed-URL direkt laden, aber mit Browser-UA (versucht Bot-Detection zu umgehen).
|
||||||
|
# removepaywall.com ist fuer Article-URLs, NICHT fuer RSS-Feed-Validity-Checks
|
||||||
|
# (gibt HTML statt XML zurueck). Researcher-Pipeline nutzt removepaywall fuer Inhalte.
|
||||||
|
initial_ua = USER_AGENT_BROWSER
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = await client.get(url)
|
resp = await client.get(initial_url, headers={"User-Agent": initial_ua})
|
||||||
|
|
||||||
|
# Paywall-Quellen: 4xx ist erwartbar (Bot-Detection), als warning markieren statt error
|
||||||
|
if strategy == "paywall" and resp.status_code in RETRY_ON_STATUS:
|
||||||
|
checks.append({
|
||||||
|
"type": "reachability", "status": "warning",
|
||||||
|
"message": f"Paywall-Quelle, Direkt-Zugang HTTP {resp.status_code} (Researcher-Pipeline nutzt removepaywall.com fuer Inhalte)",
|
||||||
|
})
|
||||||
|
return checks # Feed-Validity-Check skippen (Paywall liefert kein RSS)
|
||||||
|
|
||||||
|
# Bot-Block-Retry nur bei strategy='default'
|
||||||
|
if (
|
||||||
|
strategy == "default"
|
||||||
|
and resp.status_code in RETRY_ON_STATUS
|
||||||
|
):
|
||||||
|
retry = await client.get(url, headers={"User-Agent": USER_AGENT_GOOGLEBOT})
|
||||||
|
if retry.status_code < 400:
|
||||||
|
resp = retry # Retry hat geholfen
|
||||||
|
checks.append({
|
||||||
|
"type": "reachability", "status": "warning",
|
||||||
|
"message": f"Erreichbar nur mit Googlebot-UA (Standard-UA bekam HTTP {initial_url and 'unknown' or 'XXX'})",
|
||||||
|
})
|
||||||
|
|
||||||
if resp.status_code >= 400:
|
if resp.status_code >= 400:
|
||||||
checks.append({
|
checks.append({
|
||||||
@@ -125,14 +204,14 @@ async def _check_source_reachability(
|
|||||||
"message": "Erreichbar",
|
"message": "Erreichbar",
|
||||||
})
|
})
|
||||||
|
|
||||||
# Feed-Validität nur für RSS-Feeds
|
# Feed-Validität nur für RSS-Feeds
|
||||||
if source["source_type"] == "rss_feed":
|
if source["source_type"] == "rss_feed":
|
||||||
text = resp.text[:20000]
|
text = resp.text[:20000]
|
||||||
if "<rss" not in text and "<feed" not in text and "<channel" not in text:
|
if "<rss" not in text and "<feed" not in text and "<channel" not in text:
|
||||||
checks.append({
|
checks.append({
|
||||||
"type": "feed_validity",
|
"type": "feed_validity",
|
||||||
"status": "error",
|
"status": "error",
|
||||||
"message": "Kein gültiger RSS/Atom-Feed",
|
"message": "Kein gültiger RSS/Atom-Feed",
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
feed = await asyncio.to_thread(feedparser.parse, text)
|
feed = await asyncio.to_thread(feedparser.parse, text)
|
||||||
@@ -155,7 +234,7 @@ async def _check_source_reachability(
|
|||||||
checks.append({
|
checks.append({
|
||||||
"type": "feed_validity",
|
"type": "feed_validity",
|
||||||
"status": "ok",
|
"status": "ok",
|
||||||
"message": f"Feed gültig ({len(feed.entries)} Einträge)",
|
"message": f"Feed gültig ({len(feed.entries)} Einträge)",
|
||||||
})
|
})
|
||||||
|
|
||||||
except httpx.TimeoutException:
|
except httpx.TimeoutException:
|
||||||
@@ -181,7 +260,7 @@ async def _check_source_reachability(
|
|||||||
|
|
||||||
|
|
||||||
def _check_stale(source: dict) -> dict | None:
|
def _check_stale(source: dict) -> dict | None:
|
||||||
"""Prüft ob eine Quelle veraltet ist (keine Artikel seit >30 Tagen)."""
|
"""Prüft ob eine Quelle veraltet ist (keine Artikel seit >30 Tagen)."""
|
||||||
if source["source_type"] == "excluded":
|
if source["source_type"] == "excluded":
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -249,7 +328,7 @@ async def _save_check(
|
|||||||
|
|
||||||
|
|
||||||
async def get_health_summary(db: aiosqlite.Connection) -> dict:
|
async def get_health_summary(db: aiosqlite.Connection) -> dict:
|
||||||
"""Gibt eine Zusammenfassung der letzten Health-Check-Ergebnisse zurück."""
|
"""Gibt eine Zusammenfassung der letzten Health-Check-Ergebnisse zurück."""
|
||||||
cursor = await db.execute("""
|
cursor = await db.execute("""
|
||||||
SELECT
|
SELECT
|
||||||
h.id, h.source_id, s.name, s.domain, s.url, s.source_type,
|
h.id, h.source_id, s.name, s.domain, s.url, s.source_type,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""KI-gestützte Quellen-Vorschläge via Haiku."""
|
"""KI-gestützte Quellen-Vorschläge via Haiku."""
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
@@ -12,8 +12,8 @@ logger = logging.getLogger("osint.source_suggester")
|
|||||||
|
|
||||||
|
|
||||||
async def generate_suggestions(db: aiosqlite.Connection) -> int:
|
async def generate_suggestions(db: aiosqlite.Connection) -> int:
|
||||||
"""Generiert Quellen-Vorschläge basierend auf Health-Checks und Lückenanalyse."""
|
"""Generiert Quellen-Vorschläge basierend auf Health-Checks und Lückenanalyse."""
|
||||||
logger.info("Starte Quellen-Vorschläge via Haiku...")
|
logger.info("Starte Quellen-Vorschläge via Haiku...")
|
||||||
|
|
||||||
# 1. Aktuelle Quellen laden
|
# 1. Aktuelle Quellen laden
|
||||||
cursor = await db.execute(
|
cursor = await db.execute(
|
||||||
@@ -33,13 +33,13 @@ async def generate_suggestions(db: aiosqlite.Connection) -> int:
|
|||||||
""")
|
""")
|
||||||
issues = [dict(row) for row in await cursor.fetchall()]
|
issues = [dict(row) for row in await cursor.fetchall()]
|
||||||
|
|
||||||
# 3. Alte pending-Vorschläge entfernen (älter als 30 Tage)
|
# 3. Alte pending-Vorschläge entfernen (älter als 30 Tage)
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"DELETE FROM source_suggestions "
|
"DELETE FROM source_suggestions "
|
||||||
"WHERE status = 'pending' AND created_at < datetime('now', '-30 days')"
|
"WHERE status = 'pending' AND created_at < datetime('now', '-30 days')"
|
||||||
)
|
)
|
||||||
|
|
||||||
# 4. Quellen-Zusammenfassung für Haiku
|
# 4. Quellen-Zusammenfassung für Haiku
|
||||||
categories = {}
|
categories = {}
|
||||||
for s in sources:
|
for s in sources:
|
||||||
cat = s["category"]
|
cat = s["category"]
|
||||||
@@ -67,7 +67,7 @@ async def generate_suggestions(db: aiosqlite.Connection) -> int:
|
|||||||
f"{issue['check_type']} = {issue['status']} - {issue['message']}\n"
|
f"{issue['check_type']} = {issue['status']} - {issue['message']}\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
prompt = f"""Du bist ein OSINT-Analyst und verwaltest die Quellensammlung eines Lagebildmonitors für Sicherheitsbehörden.
|
prompt = f"""Du bist ein OSINT-Analyst und verwaltest die Quellensammlung eines Lagebildmonitors für Sicherheitsbehörden.
|
||||||
|
|
||||||
Aktuelle Quellensammlung:{source_summary}{issues_summary}
|
Aktuelle Quellensammlung:{source_summary}{issues_summary}
|
||||||
|
|
||||||
@@ -78,13 +78,13 @@ Beachte:
|
|||||||
2. Fehlende wichtige OSINT-Quellen: Schlage "add_source" mit konkreter RSS-Feed-URL vor
|
2. Fehlende wichtige OSINT-Quellen: Schlage "add_source" mit konkreter RSS-Feed-URL vor
|
||||||
3. Fokus auf deutschsprachige + wichtige internationale Nachrichtenquellen
|
3. Fokus auf deutschsprachige + wichtige internationale Nachrichtenquellen
|
||||||
4. Nur Quellen vorschlagen, die NICHT bereits vorhanden sind
|
4. Nur Quellen vorschlagen, die NICHT bereits vorhanden sind
|
||||||
5. Maximal 5 Vorschläge
|
5. Maximal 5 Vorschläge
|
||||||
|
|
||||||
Antworte NUR mit einem JSON-Array. Jedes Element:
|
Antworte NUR mit einem JSON-Array. Jedes Element:
|
||||||
{{
|
{{
|
||||||
"type": "add_source|deactivate_source|fix_url|remove_source",
|
"type": "add_source|deactivate_source|fix_url|remove_source",
|
||||||
"title": "Kurzer Titel",
|
"title": "Kurzer Titel",
|
||||||
"description": "Begründung",
|
"description": "Begründung",
|
||||||
"priority": "low|medium|high",
|
"priority": "low|medium|high",
|
||||||
"source_id": null,
|
"source_id": null,
|
||||||
"data": {{
|
"data": {{
|
||||||
@@ -104,7 +104,7 @@ Nur das JSON-Array, kein anderer Text."""
|
|||||||
|
|
||||||
json_match = re.search(r'\[.*\]', response, re.DOTALL)
|
json_match = re.search(r'\[.*\]', response, re.DOTALL)
|
||||||
if not json_match:
|
if not json_match:
|
||||||
logger.warning("Keine Vorschläge von Haiku erhalten (kein JSON)")
|
logger.warning("Keine Vorschläge von Haiku erhalten (kein JSON)")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
suggestions = json.loads(json_match.group(0))
|
suggestions = json.loads(json_match.group(0))
|
||||||
@@ -164,14 +164,14 @@ Nur das JSON-Array, kein anderer Text."""
|
|||||||
|
|
||||||
await db.commit()
|
await db.commit()
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Quellen-Vorschläge: {count} neue Vorschläge generiert "
|
f"Quellen-Vorschläge: {count} neue Vorschläge generiert "
|
||||||
f"(Haiku: {usage.input_tokens} in / {usage.output_tokens} out / "
|
f"(Haiku: {usage.input_tokens} in / {usage.output_tokens} out / "
|
||||||
f"${usage.cost_usd:.4f})"
|
f"${usage.cost_usd:.4f})"
|
||||||
)
|
)
|
||||||
return count
|
return count
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Fehler bei Quellen-Vorschlägen: {e}", exc_info=True)
|
logger.error(f"Fehler bei Quellen-Vorschlägen: {e}", exc_info=True)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ async def apply_suggestion(
|
|||||||
(url,),
|
(url,),
|
||||||
)
|
)
|
||||||
if await cursor.fetchone():
|
if await cursor.fetchone():
|
||||||
result["action"] = "übersprungen (URL bereits vorhanden)"
|
result["action"] = "übersprungen (URL bereits vorhanden)"
|
||||||
new_status = "rejected"
|
new_status = "rejected"
|
||||||
else:
|
else:
|
||||||
await db.execute(
|
await db.execute(
|
||||||
@@ -230,7 +230,7 @@ async def apply_suggestion(
|
|||||||
)
|
)
|
||||||
result["action"] = f"Quelle '{name}' angelegt"
|
result["action"] = f"Quelle '{name}' angelegt"
|
||||||
else:
|
else:
|
||||||
result["action"] = "übersprungen (keine URL)"
|
result["action"] = "übersprungen (keine URL)"
|
||||||
new_status = "rejected"
|
new_status = "rejected"
|
||||||
|
|
||||||
elif stype == "deactivate_source":
|
elif stype == "deactivate_source":
|
||||||
@@ -242,7 +242,7 @@ async def apply_suggestion(
|
|||||||
)
|
)
|
||||||
result["action"] = "Quelle deaktiviert"
|
result["action"] = "Quelle deaktiviert"
|
||||||
else:
|
else:
|
||||||
result["action"] = "übersprungen (keine source_id)"
|
result["action"] = "übersprungen (keine source_id)"
|
||||||
|
|
||||||
elif stype == "remove_source":
|
elif stype == "remove_source":
|
||||||
source_id = suggestion["source_id"]
|
source_id = suggestion["source_id"]
|
||||||
@@ -250,9 +250,9 @@ async def apply_suggestion(
|
|||||||
await db.execute(
|
await db.execute(
|
||||||
"DELETE FROM sources WHERE id = ?", (source_id,),
|
"DELETE FROM sources WHERE id = ?", (source_id,),
|
||||||
)
|
)
|
||||||
result["action"] = "Quelle gelöscht"
|
result["action"] = "Quelle gelöscht"
|
||||||
else:
|
else:
|
||||||
result["action"] = "übersprungen (keine source_id)"
|
result["action"] = "übersprungen (keine source_id)"
|
||||||
|
|
||||||
elif stype == "fix_url":
|
elif stype == "fix_url":
|
||||||
source_id = suggestion["source_id"]
|
source_id = suggestion["source_id"]
|
||||||
@@ -264,7 +264,7 @@ async def apply_suggestion(
|
|||||||
)
|
)
|
||||||
result["action"] = f"URL aktualisiert auf {new_url}"
|
result["action"] = f"URL aktualisiert auf {new_url}"
|
||||||
else:
|
else:
|
||||||
result["action"] = "übersprungen (keine source_id oder URL)"
|
result["action"] = "übersprungen (keine source_id oder URL)"
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"UPDATE source_suggestions SET status = ?, reviewed_at = CURRENT_TIMESTAMP "
|
"UPDATE source_suggestions SET status = ?, reviewed_at = CURRENT_TIMESTAMP "
|
||||||
|
|||||||
@@ -549,6 +549,31 @@ a:hover {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header-dropdown-action {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
width: 100%;
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
padding: 8px 12px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 12px;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 6px;
|
||||||
|
text-align: left;
|
||||||
|
transition: background 0.15s ease, color 0.15s ease;
|
||||||
|
}
|
||||||
|
.header-dropdown-action:hover {
|
||||||
|
background: var(--bg-hover, rgba(255, 255, 255, 0.04));
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
.header-dropdown-action svg {
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
.header-license-badge {
|
.header-license-badge {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
|
|||||||
@@ -72,6 +72,11 @@
|
|||||||
<span class="credits-percent" id="credits-percent"></span>
|
<span class="credits-percent" id="credits-percent"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="credits-divider"></div>
|
||||||
|
<button class="header-dropdown-action" type="button" onclick="AIDisclaimer && AIDisclaimer.show()">
|
||||||
|
<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" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>
|
||||||
|
<span>Über KI-Inhalte</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-license-warning" id="header-license-warning"></div>
|
<div class="header-license-warning" id="header-license-warning"></div>
|
||||||
@@ -118,8 +123,14 @@
|
|||||||
<div id="archived-incidents" aria-live="polite" style="display:none;"></div>
|
<div id="archived-incidents" aria-live="polite" style="display:none;"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar-sources-link">
|
<div class="sidebar-sources-link">
|
||||||
<button class="btn btn-secondary btn-full btn-small" onclick="App.openSourceManagement()">Quellen verwalten</button>
|
<button class="btn btn-secondary btn-full btn-small" onclick="App.openSourceManagement()" title="Quellen verwalten">
|
||||||
<button class="btn btn-secondary btn-full btn-small sidebar-feedback-btn" onclick="App.openFeedback()">Feedback senden</button>
|
<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" aria-hidden="true"><ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"/><path d="M3 12c0 1.66 4.03 3 9 3s9-1.34 9-3"/></svg>
|
||||||
|
<span>Quellen</span>
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-secondary btn-full btn-small sidebar-feedback-btn" onclick="App.openFeedback()" title="Feedback senden">
|
||||||
|
<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" aria-hidden="true"><rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-10 5L2 7"/></svg>
|
||||||
|
<span>Feedback</span>
|
||||||
|
</button>
|
||||||
<!-- Tutorial-Einstieg temporaer deaktiviert (Ueberarbeitung) - reaktivieren durch Entfernen der Kommentarzeichen:
|
<!-- Tutorial-Einstieg temporaer deaktiviert (Ueberarbeitung) - reaktivieren durch Entfernen der Kommentarzeichen:
|
||||||
<button class="btn btn-secondary btn-full btn-small" onclick="Tutorial.start()" title="Interaktiven Rundgang starten">Rundgang starten</button>
|
<button class="btn btn-secondary btn-full btn-small" onclick="Tutorial.start()" title="Interaktiven Rundgang starten">Rundgang starten</button>
|
||||||
-->
|
-->
|
||||||
@@ -351,9 +362,9 @@
|
|||||||
<label>Quellen</label>
|
<label>Quellen</label>
|
||||||
<div class="toggle-group">
|
<div class="toggle-group">
|
||||||
<label class="toggle-label">
|
<label class="toggle-label">
|
||||||
<input type="checkbox" id="inc-international" checked>
|
<input type="checkbox" id="inc-international">
|
||||||
<span class="toggle-switch"></span>
|
<span class="toggle-switch"></span>
|
||||||
<span class="toggle-text">Internationale Quellen einbeziehen <span class="info-icon tooltip-below" data-tooltip="Aktiviert: Sucht auch in englischsprachigen und internationalen Medien. Deaktiviert: Nur deutschsprachige Quellen."><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></span>
|
<span class="toggle-text">Internationale Quellen einbeziehen <span class="info-icon tooltip-below" data-tooltip="Aktiviert: Sucht auch in englischsprachigen und internationalen Medien. Deaktiviert (Standard): Nur deutschsprachige Quellen - empfohlen für DACH-Lagen."><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></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="toggle-group" style="margin-top: 8px;">
|
<div class="toggle-group" style="margin-top: 8px;">
|
||||||
@@ -738,5 +749,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/update-system.js"></script>
|
<script src="/static/js/update-system.js"></script>
|
||||||
|
<script src="/static/js/ai-disclaimer.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
195
src/static/js/ai-disclaimer.js
Normale Datei
195
src/static/js/ai-disclaimer.js
Normale Datei
@@ -0,0 +1,195 @@
|
|||||||
|
/**
|
||||||
|
* AI-Hallucination-Disclaimer fuer den AegisSight Monitor.
|
||||||
|
*
|
||||||
|
* Zeigt:
|
||||||
|
* 1) Beim ersten Besuch (oder bei neuem v-Bump) ein Modal mit Hinweisen
|
||||||
|
* zur Fehlbarkeit von KI-Modellen.
|
||||||
|
* 2) Im Header-User-Dropdown immer einen Eintrag "Ueber KI-Inhalte",
|
||||||
|
* ueber den der User das Modal jederzeit erneut oeffnen kann.
|
||||||
|
*
|
||||||
|
* Persistenz:
|
||||||
|
* localStorage 'aegis_ai_disclaimer_seen' -> Versionsstring (z.B. "v1").
|
||||||
|
* Wenn die Version sich aendert (Wortlaut-Update), erscheint das Modal
|
||||||
|
* beim naechsten Login erneut.
|
||||||
|
*/
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const STORAGE_KEY = 'aegis_ai_disclaimer_seen';
|
||||||
|
const CURRENT_VERSION = 'v1';
|
||||||
|
|
||||||
|
// ---- DOM-Helpers (analog zu update-system.js) ----
|
||||||
|
function el(tag, attrs, ...children) {
|
||||||
|
const e = document.createElement(tag);
|
||||||
|
for (const k in (attrs || {})) {
|
||||||
|
if (k === 'class') e.className = attrs[k];
|
||||||
|
else if (k === 'html') e.innerHTML = attrs[k];
|
||||||
|
else if (k.startsWith('on')) e.addEventListener(k.slice(2), attrs[k]);
|
||||||
|
else e.setAttribute(k, attrs[k]);
|
||||||
|
}
|
||||||
|
for (const c of children) {
|
||||||
|
if (c == null) continue;
|
||||||
|
e.appendChild(typeof c === 'string' ? document.createTextNode(c) : c);
|
||||||
|
}
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
function injectStyles() {
|
||||||
|
if (document.getElementById('aegis-aidisc-styles')) return;
|
||||||
|
const css = `
|
||||||
|
#aegis-aidisc-overlay {
|
||||||
|
position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 99998;
|
||||||
|
backdrop-filter: blur(3px);
|
||||||
|
display: flex; align-items: center; justify-content: center; padding: 24px;
|
||||||
|
animation: aegis-aidisc-fade 0.25s ease;
|
||||||
|
}
|
||||||
|
@keyframes aegis-aidisc-fade { from { opacity: 0; } to { opacity: 1; } }
|
||||||
|
#aegis-aidisc-modal {
|
||||||
|
background: var(--bg-card);
|
||||||
|
color: var(--text-primary);
|
||||||
|
border-radius: 14px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
box-shadow: 0 24px 80px rgba(0,0,0,0.4);
|
||||||
|
font-family: 'Inter', -apple-system, sans-serif;
|
||||||
|
max-width: 580px; width: 100%; max-height: 85vh; overflow: hidden;
|
||||||
|
display: flex; flex-direction: column;
|
||||||
|
}
|
||||||
|
#aegis-aidisc-modal header {
|
||||||
|
padding: 22px 28px 18px; border-bottom: 1px solid var(--border);
|
||||||
|
display: flex; align-items: center; gap: 12px;
|
||||||
|
}
|
||||||
|
#aegis-aidisc-modal header svg { color: var(--accent); flex-shrink: 0; }
|
||||||
|
#aegis-aidisc-modal h2 { margin: 0; color: var(--accent); font-size: 1.25rem; font-weight: 700; }
|
||||||
|
#aegis-aidisc-modal .body { padding: 18px 28px; overflow-y: auto; line-height: 1.55; }
|
||||||
|
#aegis-aidisc-modal .body p { margin: 0 0 12px; color: var(--text-primary); font-size: 0.94rem; }
|
||||||
|
#aegis-aidisc-modal .body strong { color: var(--accent); }
|
||||||
|
#aegis-aidisc-modal .body ul { margin: 8px 0 14px; padding-left: 22px; }
|
||||||
|
#aegis-aidisc-modal .body li { margin-bottom: 6px; color: var(--text-secondary); font-size: 0.92rem; }
|
||||||
|
#aegis-aidisc-modal .footnote {
|
||||||
|
margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border);
|
||||||
|
color: var(--text-tertiary); font-size: 0.82rem;
|
||||||
|
}
|
||||||
|
#aegis-aidisc-modal footer {
|
||||||
|
padding: 14px 28px 20px; border-top: 1px solid var(--border);
|
||||||
|
display: flex; justify-content: flex-end; gap: 10px;
|
||||||
|
}
|
||||||
|
#aegis-aidisc-modal footer button {
|
||||||
|
background: var(--accent); color: #fff; border: 0; padding: 10px 22px;
|
||||||
|
border-radius: 6px; font: inherit; font-size: 0.92rem; font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
#aegis-aidisc-modal footer button:hover { background: var(--accent-hover); }
|
||||||
|
#aegis-aidisc-modal footer button.secondary {
|
||||||
|
background: transparent; color: var(--text-secondary); border: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
#aegis-aidisc-modal footer button.secondary:hover {
|
||||||
|
background: var(--bg-hover, rgba(255,255,255,0.04)); color: var(--text-primary);
|
||||||
|
}`;
|
||||||
|
document.head.appendChild(el('style', { id: 'aegis-aidisc-styles', html: css }));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Modal-Aufbau ----
|
||||||
|
function buildModal(opts) {
|
||||||
|
const isFromUser = !!(opts && opts.fromUserAction);
|
||||||
|
|
||||||
|
// Lucide info-Icon (gleiches Pattern wie .info-icon im Repo)
|
||||||
|
const headerIcon = el('span', {
|
||||||
|
html: '<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" '
|
||||||
|
+ '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>'
|
||||||
|
});
|
||||||
|
|
||||||
|
const body = el('div', { class: 'body' });
|
||||||
|
body.appendChild(el('p', null,
|
||||||
|
'Der AegisSight Monitor nutzt Künstliche Intelligenz '
|
||||||
|
+ 'zur Analyse, Übersetzung und Zusammenfassung von Nachrichten.'));
|
||||||
|
|
||||||
|
const warn = el('p');
|
||||||
|
warn.innerHTML = '<strong>KI-Modelle können Fehler machen</strong> '
|
||||||
|
+ '(sogenannte „Halluzinationen"): erfundene Details, falsche Verbindungen oder '
|
||||||
|
+ 'ungenaue Zusammenfassungen sind möglich, auch wenn der Text plausibel klingt.';
|
||||||
|
body.appendChild(warn);
|
||||||
|
|
||||||
|
body.appendChild(el('p', null, 'Wir empfehlen daher:'));
|
||||||
|
body.appendChild(el('ul', null,
|
||||||
|
el('li', null, 'Wichtige Informationen mit den verlinkten Quellen verifizieren'),
|
||||||
|
el('li', null, 'Bei kritischen Entscheidungen die Originalartikel prüfen'),
|
||||||
|
el('li', null, 'Faktenchecks als Hinweis verstehen, nicht als endgültige Wahrheit')
|
||||||
|
));
|
||||||
|
|
||||||
|
body.appendChild(el('p', { class: 'footnote' },
|
||||||
|
'Diesen Hinweis findest du jederzeit wieder im Menü oben rechts unter „Über KI-Inhalte".'));
|
||||||
|
|
||||||
|
const closeAndStore = () => {
|
||||||
|
try { localStorage.setItem(STORAGE_KEY, CURRENT_VERSION); } catch (e) {}
|
||||||
|
overlay.remove();
|
||||||
|
document.removeEventListener('keydown', escHandler);
|
||||||
|
};
|
||||||
|
const closeOnly = () => {
|
||||||
|
overlay.remove();
|
||||||
|
document.removeEventListener('keydown', escHandler);
|
||||||
|
};
|
||||||
|
|
||||||
|
const footer = el('footer', null);
|
||||||
|
if (!isFromUser) {
|
||||||
|
footer.appendChild(el('button', { class: 'secondary', onclick: closeOnly }, 'Später nochmal'));
|
||||||
|
}
|
||||||
|
footer.appendChild(el('button', { onclick: closeAndStore }, 'Verstanden'));
|
||||||
|
|
||||||
|
const overlay = el('div', { id: 'aegis-aidisc-overlay' },
|
||||||
|
el('div', { id: 'aegis-aidisc-modal' },
|
||||||
|
el('header', null, headerIcon, el('h2', null, 'Hinweis zu KI-generierten Inhalten')),
|
||||||
|
body,
|
||||||
|
footer
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
function escHandler(ev) {
|
||||||
|
if (ev.key === 'Escape' && document.getElementById('aegis-aidisc-overlay')) {
|
||||||
|
// ESC = wie "Verstanden" beim erstmaligen Anzeigen, sonst nur schliessen
|
||||||
|
if (isFromUser) closeOnly(); else closeAndStore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
overlay.addEventListener('click', (ev) => {
|
||||||
|
if (ev.target === overlay) {
|
||||||
|
if (isFromUser) closeOnly(); else closeAndStore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.addEventListener('keydown', escHandler);
|
||||||
|
|
||||||
|
return overlay;
|
||||||
|
}
|
||||||
|
|
||||||
|
function show(opts) {
|
||||||
|
if (document.getElementById('aegis-aidisc-overlay')) return;
|
||||||
|
injectStyles();
|
||||||
|
document.body.appendChild(buildModal(opts));
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
// Nur auf der Dashboard-Seite zeigen, nicht auf der Login-Seite
|
||||||
|
if (!document.body || document.body.classList.contains('login-page')) return;
|
||||||
|
|
||||||
|
injectStyles();
|
||||||
|
let seenVersion = '';
|
||||||
|
try { seenVersion = localStorage.getItem(STORAGE_KEY) || ''; } catch (e) {}
|
||||||
|
if (seenVersion !== CURRENT_VERSION) {
|
||||||
|
// Etwas verzoegern, damit Hauptdashboard sichtbar ist bevor Modal kommt
|
||||||
|
setTimeout(() => show({ fromUserAction: false }), 600);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Globaler Zugriff zum manuellen Oeffnen aus dem Header-Dropdown
|
||||||
|
window.AIDisclaimer = {
|
||||||
|
show: () => show({ fromUserAction: true }),
|
||||||
|
VERSION: CURRENT_VERSION,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (document.readyState === 'loading') {
|
||||||
|
document.addEventListener('DOMContentLoaded', init);
|
||||||
|
} else {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -523,7 +523,7 @@ const App = {
|
|||||||
let text = 'Nur Lesezugriff';
|
let text = 'Nur Lesezugriff';
|
||||||
const reason = user.read_only_reason;
|
const reason = user.read_only_reason;
|
||||||
if (reason === 'budget_exceeded') {
|
if (reason === 'budget_exceeded') {
|
||||||
text = 'Token-Budget aufgebraucht – nur Lesezugriff. Bitte Verwaltung kontaktieren.';
|
text = 'Token-Budget aufgebraucht – nur Lesezugriff. Für Aufstockung oder Upgrade bitte info@aegis-sight.de kontaktieren.';
|
||||||
} else if (reason === 'expired') {
|
} else if (reason === 'expired') {
|
||||||
text = 'Lizenz abgelaufen – nur Lesezugriff';
|
text = 'Lizenz abgelaufen – nur Lesezugriff';
|
||||||
} else if (reason === 'no_license') {
|
} else if (reason === 'no_license') {
|
||||||
@@ -618,6 +618,10 @@ const App = {
|
|||||||
const inc = this.incidents.find(i => i.id === id);
|
const inc = this.incidents.find(i => i.id === id);
|
||||||
const isFirst = inc && !inc.has_summary;
|
const isFirst = inc && !inc.has_summary;
|
||||||
UI.showProgress('queued', { queue_position: idx + 1 }, id, isFirst);
|
UI.showProgress('queued', { queue_position: idx + 1 }, id, isFirst);
|
||||||
|
// Pipeline-Reset auch nach F5: aktive Lage in Queue -> Icons grau
|
||||||
|
if (id === this.currentIncidentId && typeof Pipeline !== 'undefined' && Pipeline.beginQueue) {
|
||||||
|
Pipeline.beginQueue(id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1926,6 +1930,11 @@ async handleRefresh() {
|
|||||||
this._updateRefreshButton(true);
|
this._updateRefreshButton(true);
|
||||||
// showProgress called via handleStatusUpdate
|
// showProgress called via handleStatusUpdate
|
||||||
const result = await API.refreshIncident(this.currentIncidentId);
|
const result = await API.refreshIncident(this.currentIncidentId);
|
||||||
|
// Pipeline auf "pending" setzen, damit alte gruene Haekchen nicht
|
||||||
|
// faelschlich "schon fertig" suggerieren waehrend die Lage in der Queue steht
|
||||||
|
if (typeof Pipeline !== 'undefined' && Pipeline.beginQueue) {
|
||||||
|
Pipeline.beginQueue(this.currentIncidentId);
|
||||||
|
}
|
||||||
if (result && result.status === 'skipped') {
|
if (result && result.status === 'skipped') {
|
||||||
UI.showToast('Aktualisierung ist in der Warteschlange und wird ausgefuehrt, sobald die aktuelle Recherche abgeschlossen ist.', 'info');
|
UI.showToast('Aktualisierung ist in der Warteschlange und wird ausgefuehrt, sobald die aktuelle Recherche abgeschlossen ist.', 'info');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -354,9 +354,22 @@ const UI = {
|
|||||||
const minBtn = document.getElementById('progress-popup-minimize');
|
const minBtn = document.getElementById('progress-popup-minimize');
|
||||||
if (minBtn) minBtn.style.display = state.isFirst ? 'none' : '';
|
if (minBtn) minBtn.style.display = state.isFirst ? 'none' : '';
|
||||||
|
|
||||||
// Title
|
// Title - haengt von Status ab (queued = wartet, cancelling = bricht ab, sonst laeuft)
|
||||||
const titleEl = document.getElementById('progress-popup-title');
|
const titleEl = document.getElementById('progress-popup-title');
|
||||||
if (titleEl) titleEl.textContent = state.isFirst ? 'Erste Recherche l\u00e4uft' : 'Aktualisierung l\u00e4uft';
|
if (titleEl) {
|
||||||
|
let title;
|
||||||
|
if (status === 'queued') {
|
||||||
|
const pos = (state && state._queuePos) ? ' (#' + state._queuePos + ')' : '';
|
||||||
|
title = 'In Warteschlange' + pos;
|
||||||
|
} else if (status === 'cancelling') {
|
||||||
|
title = 'Wird abgebrochen\u2026';
|
||||||
|
} else if (state.isFirst) {
|
||||||
|
title = 'Erste Recherche l\u00e4uft';
|
||||||
|
} else {
|
||||||
|
title = 'Aktualisierung l\u00e4uft';
|
||||||
|
}
|
||||||
|
titleEl.textContent = title;
|
||||||
|
}
|
||||||
|
|
||||||
// Multi-pass info
|
// Multi-pass info
|
||||||
const passEl = document.getElementById('progress-popup-pass');
|
const passEl = document.getElementById('progress-popup-pass');
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const Pipeline = {
|
|||||||
_incidentId: null,
|
_incidentId: null,
|
||||||
_definition: null, // PIPELINE_STEPS vom Backend
|
_definition: null, // PIPELINE_STEPS vom Backend
|
||||||
_stateByKey: {}, // step_key -> {status, count_value, count_secondary, pass_number}
|
_stateByKey: {}, // step_key -> {status, count_value, count_secondary, pass_number}
|
||||||
|
_snapshotState: null, // deep-copy von _stateByKey vor Refresh-Start (fuer Cancel-Restore)
|
||||||
_isResearch: false,
|
_isResearch: false,
|
||||||
_passTotal: 1,
|
_passTotal: 1,
|
||||||
_lastRefreshHeader: null,
|
_lastRefreshHeader: null,
|
||||||
@@ -42,10 +43,11 @@ const Pipeline = {
|
|||||||
if (this._wsBound) return;
|
if (this._wsBound) return;
|
||||||
if (typeof WS !== 'undefined' && WS.on) {
|
if (typeof WS !== 'undefined' && WS.on) {
|
||||||
WS.on('pipeline_step', (msg) => this._onWsStep(msg));
|
WS.on('pipeline_step', (msg) => this._onWsStep(msg));
|
||||||
// Bei Refresh-Complete den finalen Stand neu laden, damit Zahlen gefroren sichtbar bleiben
|
// Erfolg: API-State neu laden (finaler Stand sichtbar)
|
||||||
WS.on('refresh_complete', (msg) => this._onRefreshDone(msg));
|
WS.on('refresh_complete', (msg) => this._onRefreshDoneSuccess(msg));
|
||||||
WS.on('refresh_cancelled', (msg) => this._onRefreshDone(msg));
|
// Cancel/Error: vor-Refresh-Snapshot zurueckspielen, damit Pipeline nicht im Mix-Zustand stehen bleibt
|
||||||
WS.on('refresh_error', (msg) => this._onRefreshDone(msg));
|
WS.on('refresh_cancelled', (msg) => this._onRefreshDoneCancel(msg));
|
||||||
|
WS.on('refresh_error', (msg) => this._onRefreshDoneError(msg));
|
||||||
this._wsBound = true;
|
this._wsBound = true;
|
||||||
}
|
}
|
||||||
// Hover-Tooltip-Element vorbereiten
|
// Hover-Tooltip-Element vorbereiten
|
||||||
@@ -68,6 +70,7 @@ const Pipeline = {
|
|||||||
async bindToIncident(incidentId) {
|
async bindToIncident(incidentId) {
|
||||||
this._incidentId = incidentId;
|
this._incidentId = incidentId;
|
||||||
this._stateByKey = {};
|
this._stateByKey = {};
|
||||||
|
this._snapshotState = null; // Snapshot ist immer lagen-spezifisch
|
||||||
this._isResearch = false;
|
this._isResearch = false;
|
||||||
this._passTotal = 1;
|
this._passTotal = 1;
|
||||||
this._lastRefreshHeader = null;
|
this._lastRefreshHeader = null;
|
||||||
@@ -101,6 +104,20 @@ const Pipeline = {
|
|||||||
|
|
||||||
this._render();
|
this._render();
|
||||||
this._renderMini();
|
this._renderMini();
|
||||||
|
|
||||||
|
// Edge-Case: Lage ist gerade in Queue (z.B. via Lagen-Wechsel beim
|
||||||
|
// Klick in der Sidebar). API liefert den LETZTEN gespeicherten Stand
|
||||||
|
// (alles done = gruen), aber tatsaechlich wartet ein neuer Refresh.
|
||||||
|
// -> beginQueue() selbst ausloesen, damit Icons grau zeigen.
|
||||||
|
try {
|
||||||
|
if (typeof App !== 'undefined' && App._refreshingIncidents
|
||||||
|
&& App._refreshingIncidents.has(incidentId)
|
||||||
|
&& typeof UI !== 'undefined' && UI._progressState
|
||||||
|
&& UI._progressState[incidentId]
|
||||||
|
&& UI._progressState[incidentId].step === 'queued') {
|
||||||
|
this.beginQueue(incidentId);
|
||||||
|
}
|
||||||
|
} catch (e) { /* tolerant */ }
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('Pipeline laden fehlgeschlagen:', e);
|
console.warn('Pipeline laden fehlgeschlagen:', e);
|
||||||
this._renderEmpty('Pipeline-Daten konnten nicht geladen werden.');
|
this._renderEmpty('Pipeline-Daten konnten nicht geladen werden.');
|
||||||
@@ -166,14 +183,65 @@ const Pipeline = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_onRefreshDone(msg) {
|
/**
|
||||||
|
* Wird vom Frontend gerufen, wenn ein Refresh angestossen wurde (queued).
|
||||||
|
* Macht einen Snapshot des aktuellen Pipeline-Stands (zur spaeteren Wiederherstellung
|
||||||
|
* bei Cancel/Error) und setzt dann alle Steps auf "pending" - damit der User sieht:
|
||||||
|
* "neuer Refresh laeuft an, alte gruene Haekchen sind nicht mehr aktuell".
|
||||||
|
*/
|
||||||
|
beginQueue(incidentId) {
|
||||||
|
if (this._incidentId !== incidentId) return; // andere Lage offen
|
||||||
|
if (!this._definition) return; // noch keine Pipeline-Definition geladen
|
||||||
|
// Aktuellen Stand sichern (deep-copy). Bei Mehrfach-Refresh ohne Cancel
|
||||||
|
// dazwischen wird der Snapshot bewusst ueberschrieben - er soll immer
|
||||||
|
// der "Stand kurz vor diesem Refresh" sein.
|
||||||
|
this._snapshotState = JSON.parse(JSON.stringify(this._stateByKey));
|
||||||
|
// Alle Steps auf pending setzen
|
||||||
|
this._definition.forEach(s => {
|
||||||
|
if (this._stateByKey[s.key]) {
|
||||||
|
this._stateByKey[s.key].status = 'pending';
|
||||||
|
} else {
|
||||||
|
this._stateByKey[s.key] = { status: 'pending', count_value: null, count_secondary: null, pass_number: 1 };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this._render();
|
||||||
|
this._renderMini();
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Restauriert den letzten Snapshot. Rueckgabe: true bei Erfolg, false wenn keiner da war. */
|
||||||
|
_restoreSnapshot() {
|
||||||
|
if (!this._snapshotState) return false;
|
||||||
|
this._stateByKey = this._snapshotState;
|
||||||
|
this._snapshotState = null;
|
||||||
|
this._render();
|
||||||
|
this._renderMini();
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
_onRefreshDoneSuccess(msg) {
|
||||||
if (this._incidentId == null || (msg && msg.incident_id !== this._incidentId)) return;
|
if (this._incidentId == null || (msg && msg.incident_id !== this._incidentId)) return;
|
||||||
|
this._snapshotState = null; // verworfen, neuer Stand wird vom API geladen
|
||||||
// Daten frisch nachladen, damit Header (Dauer) und finale Zahlen passen
|
// Daten frisch nachladen, damit Header (Dauer) und finale Zahlen passen
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this._incidentId != null) this.bindToIncident(this._incidentId);
|
if (this._incidentId != null) this.bindToIncident(this._incidentId);
|
||||||
}, 600);
|
}, 600);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_onRefreshDoneCancel(msg) {
|
||||||
|
if (this._incidentId == null || (msg && msg.incident_id !== this._incidentId)) return;
|
||||||
|
if (!this._restoreSnapshot()) {
|
||||||
|
// Kein Snapshot vorhanden (z.B. Page-Reload mitten im Refresh) -> wie bisher API-Reload
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this._incidentId != null) this.bindToIncident(this._incidentId);
|
||||||
|
}, 600);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_onRefreshDoneError(msg) {
|
||||||
|
// Wie Cancel: vorheriger Stand zurueck (nicht im Mix-Zustand stehenbleiben)
|
||||||
|
this._onRefreshDoneCancel(msg);
|
||||||
|
},
|
||||||
|
|
||||||
/** Vollbild-Pipeline (Tab "Analysepipeline") als 3x3-Snake rendern. */
|
/** Vollbild-Pipeline (Tab "Analysepipeline") als 3x3-Snake rendern. */
|
||||||
_render() {
|
_render() {
|
||||||
const stage = document.getElementById('pipeline-stage');
|
const stage = document.getElementById('pipeline-stage');
|
||||||
|
|||||||
In neuem Issue referenzieren
Einen Benutzer sperren