Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c9611fa622 |
@@ -445,6 +445,11 @@ async function generateReport() {
|
|||||||
try {
|
try {
|
||||||
const params = buildReportParams();
|
const params = buildReportParams();
|
||||||
const resp = await fetch(`/elastic/report/?${params.toString()}`, { credentials: 'same-origin' });
|
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();
|
const data = await resp.json();
|
||||||
if (data.status !== 'success') {
|
if (data.status !== 'success') {
|
||||||
reportBox.className = 'search-result error';
|
reportBox.className = 'search-result error';
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import base64
|
|||||||
import json
|
import json
|
||||||
import csv
|
import csv
|
||||||
import io
|
import io
|
||||||
|
from datetime import datetime, timezone, timedelta
|
||||||
import tempfile
|
import tempfile
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -1580,6 +1581,7 @@ def _dt_label(dt, interval: str):
|
|||||||
|
|
||||||
@require_http_methods(["GET"])
|
@require_http_methods(["GET"])
|
||||||
def report_view(request):
|
def report_view(request):
|
||||||
|
try:
|
||||||
session_user_id = request.session.get("user_id")
|
session_user_id = request.session.get("user_id")
|
||||||
if session_user_id is None:
|
if session_user_id is None:
|
||||||
return JsonResponse({"status": "error", "message": "未登录"}, status=401)
|
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"])
|
@require_http_methods(["GET"])
|
||||||
|
|||||||
Reference in New Issue
Block a user