mirror of
git://f0xx.org/ac/ac-platform-web
synced 2026-08-09 20:59:36 +03:00
Sync QR logo asset and app.js with platform-php updates.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 8.2 KiB |
@@ -1812,19 +1812,33 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fileForm) {
|
if (fileForm) {
|
||||||
|
const maxAttachmentBytes = 16 * 1024 * 1024;
|
||||||
fileForm.addEventListener('submit', function (e) {
|
fileForm.addEventListener('submit', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const fd = new FormData(fileForm);
|
const fd = new FormData(fileForm);
|
||||||
fd.append('ticket_id', id);
|
fd.append('ticket_id', id);
|
||||||
|
const fileInput = fileForm.querySelector('input[type="file"]');
|
||||||
|
const picked = fileInput && fileInput.files && fileInput.files[0];
|
||||||
|
if (picked && picked.size > maxAttachmentBytes) {
|
||||||
|
if (fileStatus) fileStatus.textContent = 'File too large (max 16 MiB)';
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (fileStatus) fileStatus.textContent = 'Uploading…';
|
if (fileStatus) fileStatus.textContent = 'Uploading…';
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.open('POST', basePath() + '/api/ticket_attachments.php', true);
|
xhr.open('POST', basePath() + '/api/ticket_attachments.php', true);
|
||||||
xhr.onload = function () {
|
xhr.onload = function () {
|
||||||
|
if (xhr.status === 413) {
|
||||||
|
if (fileStatus) fileStatus.textContent = 'File too large (max 16 MiB)';
|
||||||
|
return;
|
||||||
|
}
|
||||||
let data;
|
let data;
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(xhr.responseText);
|
data = JSON.parse(xhr.responseText);
|
||||||
} catch {
|
} catch {
|
||||||
if (fileStatus) fileStatus.textContent = 'Invalid response';
|
if (fileStatus) {
|
||||||
|
fileStatus.textContent =
|
||||||
|
xhr.status >= 400 ? 'Upload failed (HTTP ' + xhr.status + ')' : 'Invalid response';
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!data.ok) {
|
if (!data.ok) {
|
||||||
@@ -1838,7 +1852,12 @@
|
|||||||
if (fileStatus) fileStatus.textContent = 'Uploaded';
|
if (fileStatus) fileStatus.textContent = 'Uploaded';
|
||||||
};
|
};
|
||||||
xhr.onerror = function () {
|
xhr.onerror = function () {
|
||||||
if (fileStatus) fileStatus.textContent = t('reports.network_error');
|
if (fileStatus) {
|
||||||
|
fileStatus.textContent =
|
||||||
|
picked && picked.size > 1024 * 1024
|
||||||
|
? 'Upload failed — file may exceed server limit (max 16 MiB)'
|
||||||
|
: t('reports.network_error');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
xhr.send(fd);
|
xhr.send(fd);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user