Update public source
This commit is contained in:
@@ -505,6 +505,187 @@ def render_wifi_connections_page(conn, context=None):
|
|||||||
section_title="Reports",
|
section_title="Reports",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
html += card(
|
||||||
|
"Подключение к Wi-Fi",
|
||||||
|
"""
|
||||||
|
<div id="wifi-connections-controls">
|
||||||
|
<div style="margin-bottom:14px;">
|
||||||
|
<label for="wifi-connections-interface">
|
||||||
|
<strong>Wi-Fi интерфейс:</strong>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<select
|
||||||
|
id="wifi-connections-interface"
|
||||||
|
class="search"
|
||||||
|
style="display:block;width:100%;max-width:400px;"
|
||||||
|
disabled
|
||||||
|
>
|
||||||
|
<option value="">Загрузка интерфейсов...</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
id="wifi-connections-warning"
|
||||||
|
role="status"
|
||||||
|
hidden
|
||||||
|
style="
|
||||||
|
margin:12px 0;
|
||||||
|
padding:12px;
|
||||||
|
border:1px solid var(--yellow);
|
||||||
|
border-radius:8px;
|
||||||
|
line-height:1.5;
|
||||||
|
"
|
||||||
|
></div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
id="wifi-connections-message"
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
style="margin:12px 0;"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
const root = document.getElementById(
|
||||||
|
"wifi-connections-controls"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!root) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const interfaceSelect = document.getElementById(
|
||||||
|
"wifi-connections-interface"
|
||||||
|
);
|
||||||
|
|
||||||
|
const message = document.getElementById(
|
||||||
|
"wifi-connections-message"
|
||||||
|
);
|
||||||
|
|
||||||
|
const warning = document.getElementById(
|
||||||
|
"wifi-connections-warning"
|
||||||
|
);
|
||||||
|
|
||||||
|
function setMessage(text, isError = false) {
|
||||||
|
message.textContent = text || "";
|
||||||
|
message.style.color = isError
|
||||||
|
? "var(--red)"
|
||||||
|
: "var(--muted)";
|
||||||
|
}
|
||||||
|
|
||||||
|
function setWarning(text) {
|
||||||
|
warning.textContent = text || "";
|
||||||
|
warning.hidden = !text;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadInterfaces() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
"/api/network/wifi-devices",
|
||||||
|
{cache: "no-store"}
|
||||||
|
);
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (!response.ok || !data.ok) {
|
||||||
|
throw new Error(
|
||||||
|
data.error
|
||||||
|
|| "Не удалось получить Wi-Fi интерфейсы."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const devices = data.devices || [];
|
||||||
|
|
||||||
|
interfaceSelect.replaceChildren();
|
||||||
|
|
||||||
|
const placeholder = document.createElement("option");
|
||||||
|
placeholder.value = "";
|
||||||
|
placeholder.textContent = devices.length > 1
|
||||||
|
? "Выберите Wi-Fi интерфейс"
|
||||||
|
: "Нет доступных интерфейсов";
|
||||||
|
|
||||||
|
interfaceSelect.appendChild(placeholder);
|
||||||
|
|
||||||
|
devices.forEach(device => {
|
||||||
|
const option = document.createElement("option");
|
||||||
|
|
||||||
|
option.value = device.device;
|
||||||
|
option.textContent = device.available
|
||||||
|
? device.device + " (" + device.state + ")"
|
||||||
|
: device.device + " — " + (
|
||||||
|
device.reason || device.state
|
||||||
|
);
|
||||||
|
|
||||||
|
option.disabled = !device.available;
|
||||||
|
interfaceSelect.appendChild(option);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.selected_device
|
||||||
|
&& devices.some(device =>
|
||||||
|
device.device === data.selected_device
|
||||||
|
&& device.available
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
interfaceSelect.value = data.selected_device;
|
||||||
|
}
|
||||||
|
|
||||||
|
interfaceSelect.disabled =
|
||||||
|
!devices.some(device => device.available)
|
||||||
|
|| devices.filter(device => device.available).length <= 1;
|
||||||
|
|
||||||
|
if (!devices.length) {
|
||||||
|
setMessage(
|
||||||
|
data.error || "Wi-Fi интерфейсы не найдены.",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
!devices.some(device => device.available)
|
||||||
|
) {
|
||||||
|
setMessage(
|
||||||
|
devices.map(device =>
|
||||||
|
device.device + ": " + (
|
||||||
|
device.reason || device.state
|
||||||
|
)
|
||||||
|
).join("; "),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
} else if (devices.length > 1) {
|
||||||
|
setMessage(
|
||||||
|
"Выберите доступный Wi-Fi интерфейс."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.wireguard_active) {
|
||||||
|
setWarning(
|
||||||
|
"Обнаружено активное соединение WireGuard. "
|
||||||
|
+ "При необходимости отключите VPN вручную. "
|
||||||
|
+ "Приложение не изменяет состояние WireGuard."
|
||||||
|
);
|
||||||
|
} else if (data.wireguard_error) {
|
||||||
|
setWarning(
|
||||||
|
"Не удалось проверить состояние WireGuard: "
|
||||||
|
+ data.wireguard_error
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
interfaceSelect.disabled = true;
|
||||||
|
setMessage(
|
||||||
|
error.message
|
||||||
|
|| "Ошибка получения Wi-Fi интерфейсов.",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadInterfaces();
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
html += card(
|
html += card(
|
||||||
"""
|
"""
|
||||||
<span class="session-map-title">
|
<span class="session-map-title">
|
||||||
|
|||||||
Reference in New Issue
Block a user