Nuevas funcionalidades y correcciones
This commit is contained in:
@@ -29,10 +29,10 @@ CORE_DB_PASSWORD=postgres
|
||||
|
||||
# ----- Frontend -----
|
||||
NODE_ENV=development
|
||||
VITE_API_URL=http://localhost:8000/api
|
||||
VITE_API_URL=http://localhost:8001/api
|
||||
INTERNAL_API_URL=http://backend:8000/api
|
||||
VITE_KEYCLOAK_REALM=master
|
||||
VITE_KEYCLOAK_URL=http://localhost:8080
|
||||
VITE_KEYCLOAK_URL=http://localhost:8081
|
||||
VITE_KEYCLOAK_CLIENT_ID=anexo76-frontend
|
||||
|
||||
# ----- Sitar API -----
|
||||
|
||||
@@ -27,16 +27,31 @@ def trigger_sync_or_broadcast(article_uuid: UUID):
|
||||
- If we are a Client (CENTRAL_SERVER_URL is set): Trigger upstream sync.
|
||||
- If we are the Hub (No CENTRAL_SERVER, but SPOKE_URLS set): Trigger broadcast.
|
||||
"""
|
||||
# 1. Upstream Sync (Client -> Hub)
|
||||
if settings.CENTRAL_SERVER_URL:
|
||||
sync_single_article_task.delay(str(article_uuid))
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# 2. Downstream Broadcast (Hub -> Spokes)
|
||||
# Only if we are the Hub (no upstream) and have spokes configured.
|
||||
elif not settings.CENTRAL_SERVER_URL and settings.SPOKE_URLS:
|
||||
from .tasks import broadcast_help_update
|
||||
# origin_client_uuid is None because this change originated on the Hub itself
|
||||
broadcast_help_update.delay(str(article_uuid), None)
|
||||
try:
|
||||
logger.info(f"DEBUG: Triggering sync/broadcast for article {article_uuid}")
|
||||
logger.debug(f"DEBUG: CENTRAL_SERVER_URL='{settings.CENTRAL_SERVER_URL}' SPOKE_URLS='{settings.SPOKE_URLS}'")
|
||||
|
||||
# 1. Upstream Sync (Client -> Hub)
|
||||
if settings.CENTRAL_SERVER_URL and settings.CENTRAL_SERVER_URL != '""':
|
||||
logger.info(f"DEBUG: Queueing sync_single_article_task for {article_uuid}")
|
||||
sync_single_article_task.delay(str(article_uuid))
|
||||
|
||||
# 2. Downstream Broadcast (Hub -> Spokes)
|
||||
# Only if we are the Hub (no upstream) and have spokes configured.
|
||||
elif (not settings.CENTRAL_SERVER_URL or settings.CENTRAL_SERVER_URL == '""') and settings.SPOKE_URLS:
|
||||
from .tasks import broadcast_help_update
|
||||
logger.info(f"DEBUG: Queueing broadcast_help_update for {article_uuid}")
|
||||
# origin_client_uuid is None because this change originated on the Hub itself
|
||||
broadcast_help_update.delay(str(article_uuid), None)
|
||||
else:
|
||||
logger.info(f"DEBUG: No sync/broadcast needed for {article_uuid} (Config empty or Hub mode without spokes)")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"ERROR in trigger_sync_or_broadcast for article {article_uuid}: {str(e)}", exc_info=True)
|
||||
# We don't re-raise here to avoid returning 500 to the user if the save was successful
|
||||
|
||||
@router.post("/sync/", response_model=HelpSyncResponse, dependencies=[Depends(verify_sync_token)])
|
||||
def sync_help_article(sync_data: HelpSyncRequest, db: Session = Depends(get_core_db)):
|
||||
@@ -103,8 +118,15 @@ def get_article(article_uuid: UUID, db: Session = Depends(get_core_db)):
|
||||
@router.post("/articles/", response_model=HelpArticleInDB, status_code=status.HTTP_201_CREATED)
|
||||
def create_article(article: HelpArticleCreate, db: Session = Depends(get_core_db)):
|
||||
"""Crea un nuevo artículo."""
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info(f"DEBUG: Creating new article: {article.title}")
|
||||
|
||||
new_article = HelpCenterService.create(db, article)
|
||||
logger.info(f"DEBUG: Article created successfully in DB. UUID: {new_article.uuid}")
|
||||
|
||||
trigger_sync_or_broadcast(new_article.uuid)
|
||||
|
||||
return new_article
|
||||
|
||||
@router.patch("/articles/{article_uuid}/", response_model=HelpArticleInDB)
|
||||
|
||||
@@ -64,6 +64,8 @@ def broadcast_help_update(article_uuid_str: str, origin_client_uuid_str: str = N
|
||||
client_title=article.title,
|
||||
client_slug=article.slug,
|
||||
last_editor=article.last_editor,
|
||||
client_category=article.category,
|
||||
client_order=article.order,
|
||||
origin_client_uuid=UUID(origin_client_uuid_str) if origin_client_uuid_str else None
|
||||
).model_dump(mode='json')
|
||||
|
||||
@@ -117,6 +119,8 @@ def sync_single_article(article_uuid):
|
||||
client_title=article.title,
|
||||
client_slug=article.slug,
|
||||
last_editor=article.last_editor,
|
||||
client_category=article.category,
|
||||
client_order=article.order,
|
||||
origin_client_uuid=UUID(settings.CLIENT_UUID) if settings.CLIENT_UUID else None
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Anexo76 - Aplicación SaaS para gestión de comercio exterior
|
||||
Backend API con FastAPI + Keycloak + SQLAlchemy
|
||||
"""
|
||||
"""
|
||||
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { AlertDialog as AlertDialogPrimitive } from "bits-ui";
|
||||
import { AlertDialog } from "bits-ui";
|
||||
const AlertDialogPrimitive = AlertDialog;
|
||||
import Trigger from "./alert-dialog-trigger.svelte";
|
||||
import Title from "./alert-dialog-title.svelte";
|
||||
import Action from "./alert-dialog-action.svelte";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Dialog as DialogPrimitive } from "bits-ui";
|
||||
import { Dialog } from "bits-ui";
|
||||
const DialogPrimitive = Dialog;
|
||||
|
||||
import Title from "./dialog-title.svelte";
|
||||
import Footer from "./dialog-footer.svelte";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Dialog as SheetPrimitive } from "bits-ui";
|
||||
import { Dialog } from "bits-ui";
|
||||
const SheetPrimitive = Dialog;
|
||||
import Trigger from "./sheet-trigger.svelte";
|
||||
import Close from "./sheet-close.svelte";
|
||||
import Overlay from "./sheet-overlay.svelte";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { browser } from '$app/environment';
|
||||
import { onMount, tick } from 'svelte';
|
||||
import { helpApi, type HelpArticle } from '$lib/api/help';
|
||||
import { Button } from '$lib/components/ui/button/index.js';
|
||||
@@ -139,6 +140,14 @@
|
||||
}
|
||||
|
||||
function renderMarkdown(text: string) {
|
||||
if (!browser) {
|
||||
// Basic fallback for SSR to avoid crashing
|
||||
return (text || '')
|
||||
.replace(/^# (.*$)/gim, '<h1>$1</h1>')
|
||||
.replace(/^## (.*$)/gim, '<h2>$1</h2>')
|
||||
.replace(/\*\*(.*)\*\*/gim, '<b>$1</b>')
|
||||
.replace(/\n/gim, '<br />');
|
||||
}
|
||||
// @ts-ignore
|
||||
return DOMPurify.sanitize(marked.parse(text || '') as string);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user