fix(guest_mode,telegram): fix guest mode view, translations and bot language switcher

This commit is contained in:
Dushnilin
2026-09-08 09:58:43 +03:00
parent 4ed85f5b30
commit 625fa1e9b3
11 changed files with 5100 additions and 4415 deletions
@@ -1299,6 +1299,23 @@ function createParentalContent(section) {
// ─── Guest Mode Section ───────────────────────────────────────────────────────
function validateGuestDevice(_sectionId, value) {
if (value === "" || value === null || value === undefined) return true;
const v = String(value).trim();
const isMac = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(v);
const isIpv4 = /^(\d{1,3}\.){3}\d{1,3}(\/\d{1,2})?$/.test(v);
const isIpv6 = /^[0-9a-fA-F:]+(\/\d{1,3})?$/.test(v);
if (isMac || isIpv4 || isIpv6) return true;
return _("Invalid IP or MAC address format");
}
function validateGuestTime(_sectionId, value) {
if (value === "" || value === null || value === undefined) return true;
const v = String(value).trim();
if (/^([01]\d|2[0-3]):[0-5]\d$/.test(v)) return true;
return _("Invalid time format. Use HH:MM (e.g. 08:00 or 22:30)");
}
function createGuestModeContent(section) {
// Enabled switch
let o = section.option(form.Flag, "enabled", _("Enable Guest Mode"));
@@ -1329,7 +1346,7 @@ function createGuestModeContent(section) {
);
o.rmempty = true;
o.placeholder = "192.168.1.150 or AA:BB:CC:DD:EE:FF";
o.validate = validateDevice;
o.validate = validateGuestDevice;
o.depends("mode", "selected");
o.renderWidget = function (sectionId, optionIndex, cfgvalue) {
return local_devices.createLocalDeviceDynamicListWidget(
@@ -1350,7 +1367,7 @@ function createGuestModeContent(section) {
);
o.rmempty = true;
o.placeholder = "192.168.1.100 or AA:BB:CC:DD:EE:FF";
o.validate = validateDevice;
o.validate = validateGuestDevice;
o.depends("mode", "inverted");
o.renderWidget = function (sectionId, optionIndex, cfgvalue) {
return local_devices.createLocalDeviceDynamicListWidget(
@@ -1433,7 +1450,7 @@ function createGuestModeContent(section) {
);
o.placeholder = "08:00";
o.rmempty = true;
o.validate = validateTime;
o.validate = validateGuestTime;
o = section.option(
form.Value,
@@ -1443,7 +1460,7 @@ function createGuestModeContent(section) {
);
o.placeholder = "22:00";
o.rmempty = true;
o.validate = validateTime;
o.validate = validateGuestTime;
// Days of week
o = section.option(
@@ -386,6 +386,9 @@ const EntryPoint = {
if (!uci.get(self.config, "telegram")) {
uci.add(self.config, "telegram", "telegram");
}
if (!uci.get(self.config, "guest_mode")) {
uci.add(self.config, "guest_mode", "guest_mode");
}
return form.Map.prototype.load.call(self);
});
};
@@ -578,16 +581,18 @@ const EntryPoint = {
},
guest_mode: () => {
const s = tachyonMap.section(
form.NamedSection,
"guest_mode",
form.TypedSection,
"guest_mode",
_("Guest Mode"),
_(
"Guest mode isolates guest devices from local LAN and router administration, while allowing internet access with daily quotas and schedules.",
),
);
s.anonymous = false;
s.anonymous = true;
s.addremove = false;
s.cfgsections = function () {
return ["guest_mode"];
};
parental.createGuestModeContent(s);
return s;
},