This commit is contained in:
@@ -445,6 +445,11 @@ async function generateReport() {
|
||||
try {
|
||||
const params = buildReportParams();
|
||||
const resp = await fetch(`/elastic/report/?${params.toString()}`, { credentials: 'same-origin' });
|
||||
const ct = (resp.headers.get('content-type') || '').toLowerCase();
|
||||
if (!ct.includes('application/json')) {
|
||||
const text = await resp.text();
|
||||
throw new Error(text ? String(text).slice(0, 200) : `HTTP ${resp.status}`);
|
||||
}
|
||||
const data = await resp.json();
|
||||
if (data.status !== 'success') {
|
||||
reportBox.className = 'search-result error';
|
||||
|
||||
@@ -8,6 +8,7 @@ import base64
|
||||
import json
|
||||
import csv
|
||||
import io
|
||||
from datetime import datetime, timezone, timedelta
|
||||
import tempfile
|
||||
import concurrent.futures
|
||||
from django.conf import settings
|
||||
@@ -1580,6 +1581,7 @@ def _dt_label(dt, interval: str):
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
def report_view(request):
|
||||
try:
|
||||
session_user_id = request.session.get("user_id")
|
||||
if session_user_id is None:
|
||||
return JsonResponse({"status": "error", "message": "未登录"}, status=401)
|
||||
@@ -1678,6 +1680,8 @@ def report_view(request):
|
||||
},
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
return JsonResponse({"status": "error", "message": str(e) or "生成失败"}, status=500)
|
||||
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
|
||||
Reference in New Issue
Block a user