From cb775209e0a63bdcee6a47272e1de1201aeecdb4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?=
<78488229+viktor138irk@users.noreply.github.com>
Date: Thu, 7 May 2026 20:41:28 +0900
Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D1=89=D0=B8=D1=82=D0=B0=20=D0=B7?=
=?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20ISO=20=D0=BE=D1=82?=
=?UTF-8?q?=20=D1=81=D0=BB=D1=83=D1=87=D0=B0=D0=B9=D0=BD=D0=BE=D0=B3=D0=BE?=
=?UTF-8?q?=20=D0=BF=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=D0=B0=20=D0=B1?=
=?UTF-8?q?=D1=8B=D0=BB=D0=B0=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?=
=?UTF-8?q?=D0=BD=D0=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/templates/iso.html | 36 ++++++++++++++++++++++++++++++++++--
1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/web/templates/iso.html b/web/templates/iso.html
index 75edd24..a671a63 100644
--- a/web/templates/iso.html
+++ b/web/templates/iso.html
@@ -39,6 +39,7 @@
Файл ещё не выбран. В этом разделе разрешены только установочные образы .iso.
+
Подготовка…
@@ -104,6 +105,7 @@ ls -lh /var/lib/virtuality/iso
const fileInput = document.getElementById('iso-file-input');
const button = document.getElementById('iso-upload-button');
const hint = document.getElementById('iso-file-hint');
+ const errorBox = document.getElementById('iso-file-error');
const box = document.getElementById('upload-progress-wrap');
const bar = document.getElementById('upload-progress-bar');
const percent = document.getElementById('upload-percent');
@@ -126,8 +128,16 @@ ls -lh /var/lib/virtuality/iso
return file && file.name && file.name.toLowerCase().endsWith('.iso');
}
+ function setFileError(message) {
+ if (!errorBox) return;
+ errorBox.textContent = message || '';
+ errorBox.hidden = !message;
+ }
+
function setUploadMode(active) {
uploadActive = active;
+ window.VirtualityUploadActive = active;
+ document.body.classList.toggle('upload-active', active);
if (active) {
button.disabled = false;
button.type = 'button';
@@ -146,15 +156,33 @@ ls -lh /var/lib/virtuality/iso
}
}
+ window.addEventListener('beforeunload', function (event) {
+ if (!uploadActive) return;
+ event.preventDefault();
+ event.returnValue = 'Идёт загрузка ISO. Если уйти со страницы, загрузка будет прервана.';
+ });
+
+ document.addEventListener('click', function (event) {
+ if (!uploadActive) return;
+ const navTarget = event.target.closest('a, form button[type="submit"], form button:not([type])');
+ if (!navTarget || navTarget === button) return;
+ event.preventDefault();
+ event.stopPropagation();
+ statusLine.textContent = 'Сначала заверши или отмени текущую загрузку.';
+ }, true);
+
fileInput.addEventListener('change', function () {
const file = fileInput.files[0];
+ setFileError('');
if (!file) {
hint.textContent = 'Файл ещё не выбран. В этом разделе разрешены только установочные образы .iso.';
button.disabled = false;
return;
}
if (!validIsoFile(file)) {
- hint.textContent = 'Неверный тип файла. Здесь можно выбрать только .iso.';
+ const message = 'Неверный тип файла: ' + file.name + '. Здесь можно выбрать только .iso.';
+ hint.textContent = message;
+ setFileError(message);
fileInput.value = '';
button.disabled = true;
return;
@@ -172,8 +200,11 @@ ls -lh /var/lib/virtuality/iso
event.preventDefault();
if (uploadActive) return;
const file = fileInput.files[0];
+ setFileError('');
if (!validIsoFile(file)) {
- hint.textContent = 'Выбери установочный образ .iso.';
+ const message = 'Выбери установочный образ .iso.';
+ hint.textContent = message;
+ setFileError(message);
return;
}
@@ -210,6 +241,7 @@ ls -lh /var/lib/virtuality/iso
bar.style.width = '100%';
percent.textContent = '100%';
statusLine.textContent = 'Готово. Обновляем список ISO…';
+ setUploadMode(false);
window.location.href = '/iso';
} else {
statusLine.textContent = 'Ошибка загрузки: HTTP ' + xhr.status;