mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 02:35:14 +00:00
Enhance logo upload functionality: allow custom logo names and update handling in LogoForm component.
Fixes [Bug]: Logo Manager not allowing a change to name field Fixes #320
This commit is contained in:
parent
6746588c15
commit
0a5e7a3231
3 changed files with 12 additions and 3 deletions
|
|
@ -1387,10 +1387,14 @@ class LogoViewSet(viewsets.ModelViewSet):
|
|||
except Exception as e:
|
||||
logger.warning(f"Failed to mark logo file as processed in Redis: {e}")
|
||||
|
||||
# Get custom name from request data, fallback to filename
|
||||
custom_name = request.data.get('name', '').strip()
|
||||
logo_name = custom_name if custom_name else file_name
|
||||
|
||||
logo, _ = Logo.objects.get_or_create(
|
||||
url=file_path,
|
||||
defaults={
|
||||
"name": file_name,
|
||||
"name": logo_name,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1331,11 +1331,16 @@ export default class API {
|
|||
}
|
||||
}
|
||||
|
||||
static async uploadLogo(file) {
|
||||
static async uploadLogo(file, name = null) {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
// Add custom name if provided
|
||||
if (name && name.trim()) {
|
||||
formData.append('name', name.trim());
|
||||
}
|
||||
|
||||
// Add timeout handling for file uploads
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), 30000); // 30 second timeout
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ const LogoForm = ({ logo = null, isOpen, onClose }) => {
|
|||
// If we have a selected file, upload it first
|
||||
if (selectedFile) {
|
||||
try {
|
||||
const uploadResponse = await API.uploadLogo(selectedFile);
|
||||
const uploadResponse = await API.uploadLogo(selectedFile, values.name);
|
||||
// Use the uploaded file data instead of form values
|
||||
values.name = uploadResponse.name;
|
||||
values.url = uploadResponse.url;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue