Refactor database credentials and user permissions; update UI components for better usability and accessibility

- Changed default MariaDB password in docker-compose.yml from 'SE3112' to '3112'.
- Added user creation and permissions for 'wago' in the MariaDB initialization script.
- Updated unit options in App.jsx to include a digital/bool option.
- Enhanced LoginScreen component to support inline display and improved error handling.
- Improved point filtering logic in PointLibrary and adjusted default unit handling.
- Refined authentication checks for dashboard and admin permissions.
- Simplified API calls by removing unnecessary token checks.
- Enhanced TrendChart component with better data handling and formatting.
- Updated CSS styles for improved layout and responsiveness in trend views and sidebar.
This commit is contained in:
jhartworks
2026-07-01 11:58:42 +02:00
parent e34626f15b
commit 2b9ff12a9f
11 changed files with 412 additions and 279 deletions
+18 -9
View File
@@ -156,16 +156,25 @@ function normalizeUnit(value) {
const raw = normalizeText(value);
const collapsed = raw.replace(/\s+/g, "");
if (!collapsed) {
return "\u00B0C";
return "°C";
}
if (/^\?C$/i.test(collapsed) || /^\u00B0C$/i.test(collapsed)) {
return "\u00B0C";
if (/^(?:\?C|\u00B0C)$/i.test(collapsed)) {
return "°C";
}
return raw;
}
function normalizePointUnit(value, kind = "analog") {
const normalizedKind = normalizePointKind(kind);
const raw = normalizeText(value);
if (!raw) {
return normalizedKind === "digital" ? "bool" : "°C";
}
return normalizeUnit(raw);
}
function normalizePointIndex(value, fallback) {
const numeric = Number(value);
return Number.isInteger(numeric) && numeric >= 1 && numeric <= LOCAL_POINT_LIMIT ? numeric : fallback;
@@ -244,7 +253,7 @@ function parseModbusCsv(payload) {
pointIndex,
name: normalizeText(get("name", `Register ${index + 1}`)) || `Register ${index + 1}`,
alias: normalizeText(get("alias", get("name", `Register ${index + 1}`))) || normalizeText(get("name", `Register ${index + 1}`)) || `Register ${index + 1}`,
unit: normalizeUnit(get("unit")),
unit: normalizePointUnit(get("unit"), get("kind", get("type", "analog"))),
dataType: get("datatype", "holding-register"),
kind: normalizePointKind(get("kind", get("type", "analog"))),
enabled: payload.enabled === true,
@@ -294,7 +303,7 @@ function parseKnxXml(payload) {
pointIndex: index + 1,
name,
alias: name,
unit: normalizeUnit(""),
unit: normalizePointUnit("", dpt.startsWith("1.") ? "digital" : "analog"),
dataType: dpt || "group-address",
kind: dpt.startsWith("1.") ? "digital" : "analog",
enabled: payload.enabled === true,
@@ -331,7 +340,7 @@ function createManualDatapoint(store, payload) {
pointIndex,
name,
alias,
unit: normalizeUnit(payload.unit),
unit: normalizePointUnit(payload.unit, payload.kind),
kind: normalizePointKind(payload.kind),
enabled: payload.enabled !== false,
writeMode: normalizeWriteMode(payload.writeMode || source.writeMode),
@@ -365,7 +374,7 @@ function createScanDatapoint(source, payload, index) {
pointIndex,
name: normalizeText(payload.name || alias) || alias,
alias,
unit: normalizeUnit(payload.unit),
unit: normalizePointUnit(payload.unit, payload.kind),
kind: normalizePointKind(payload.kind),
enabled: payload.enabled === true,
writeMode: normalizeWriteMode(payload.writeMode || source.writeMode),
@@ -413,7 +422,7 @@ function buildScannedDatapoints(store, source, rawPoints, toPayload) {
pointIndex: existing.pointIndex,
alias: existing.alias || scanned.alias,
name: existing.name || scanned.name,
unit: normalizeUnit(existing.unit || scanned.unit),
unit: normalizePointUnit(existing.unit || scanned.unit, existing.kind || scanned.kind),
kind: existing.kind || scanned.kind,
enabled: existing.enabled === true,
writeMode: normalizeWriteMode(existing.writeMode || scanned.writeMode),
@@ -1707,7 +1716,7 @@ const server = createServer(async (req, res) => {
address: typeof body.address === "string" ? normalizeText(body.address) : store.datapoints[index].address,
nodeId: typeof body.nodeId === "string" ? normalizeText(body.nodeId) : store.datapoints[index].nodeId,
dataType: typeof body.dataType === "string" && body.dataType.trim() ? normalizeText(body.dataType) : store.datapoints[index].dataType,
unit: body.unit ? normalizeUnit(body.unit) : store.datapoints[index].unit,
unit: body.unit ? normalizePointUnit(body.unit, body.kind || store.datapoints[index].kind) : store.datapoints[index].unit,
kind: body.kind ? normalizePointKind(body.kind) : store.datapoints[index].kind,
scale: Number.isFinite(Number(body.scale)) ? Number(body.scale) : store.datapoints[index].scale,
};