added better text for the popup error message

kgb-logging
LA3QMA 2025-03-14 18:24:41 +01:00
parent 25fa8a828f
commit 9cfedb4627
3 changed files with 33 additions and 22 deletions

View File

@ -156,28 +156,26 @@ export function eventDispatcher(data) {
case "message-logging":
if (data.endpoint === "wavelog") {
if (data.status === true) {
const message = `
<div>
<strong>${i18next.t('popups.loggingsuccess')}:</strong>
<span class="badge bg-success">${data.endpoint}</span>
<div class="mt-2">
<span class="badge bg-secondary">${i18next.t('popups.loggingsuccessmessage')}</span>
</div>
</div>
const message = `
<div>
<strong>${i18next.t('popups.loggingsuccess')}:</strong>
<span class="badge bg-success">${data.endpoint}</span>
<div class="mt-2">
<span class="badge bg-secondary">${i18next.t('popups.loggingsuccessmessage')}</span>
</div>
</div>
`;
displayToast("success", "bi-check-circle", message, 5000);
} else {
const message = `
const message = `
<div>
<strong>${i18next.t('popups.loggingfailed')}:</strong>
<span class="badge bg-danger">${data.endpoint}</span>
<div class="mt-2">
<span class="badge bg-secondary">${i18next.t('popups.loggingfailedmessage')}</span>
</div>
</div>
`;
<strong>${i18next.t('Wavelog post failed')}:</strong>
<span class="badge bg-danger">${data.message}</span>
<div class="mt-2">
<span class="badge bg-secondary">${i18next.t('Wavelog post failed')}</span>
</div>
</div>
`;
displayToast("warning", "bi-exclamation-circle", message, 5000);
}
}

View File

@ -240,7 +240,7 @@ class EventManager:
"""
self.broadcast({"message-db": "changed", "message_id": message_id})
def freedata_logging(self, type, status):
def freedata_logging(self, type, status, message):
"""Broadcasts a FreeDATA logging event.
This method broadcasts an event related to FreeDATA logging,
@ -253,4 +253,4 @@ class EventManager:
status (any): The status of the logging operation.
"""
self.broadcast({"type": "message-logging", "endpoint": type, "status": status})
self.broadcast({"type": "message-logging", "endpoint": type, "status": status, "message": message})

View File

@ -2,6 +2,7 @@ import requests
import threading
import structlog
def send_wavelog_qso_data(config, event_manager, wavelog_data):
"""
Sends wavelog QSO data to the specified server via API call.
@ -41,15 +42,27 @@ def send_wavelog_qso_data(config, event_manager, wavelog_data):
"string": wavelog_data
}
def extract_between(text, start_marker, end_marker):
start = text.find(start_marker)
if start == -1:
return None # Marker not found
start += len(start_marker) # Move past the start marker
end = text.find(end_marker, start)
if end == -1:
return text[start:] # If end marker not found, take rest of the string
return text[start:end]
def send_api():
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status() # Raise an error for bad status codes
log.info(f"[CHAT] Wavelog API: {wavelog_data}")
event_manager.freedata_logging(type="wavelog", status=True)
# event_manager.freedata_logging(type="wavelog", status=True)
event_manager.freedata_logging(type="wavelog", status=False, message=f"QSO added")
except requests.exceptions.RequestException as e:
log.warning(f"[WAVELOG ADIF API EXCEPTION]: {e}")
event_manager.freedata_logging(type="wavelog", status=False)
#FIXME format the output to get the actual error
event_manager.freedata_logging(type="wavelog", status=False, message=f"Wavelog error check log")
# Run the API call in a background thread to avoid blocking the main thread
thread = threading.Thread(target=send_api, daemon=True)