feat: enhance sidebar functionality and styling
- Updated sidebar component to support dynamic width based on collapsed state. - Improved sidebar icon rendering and added user account management features. - Introduced new trend chart settings component for better user interaction. - Added utility functions for engineering units and trend chart settings. - Implemented color assignment logic for trend series to enhance visual representation. - Enhanced CSS styles for better responsiveness and usability across different screen sizes. - Introduced new configuration for Vite server to allow shared directory access. - Added .dockerignore file to optimize Docker build context.
This commit is contained in:
1 parent
2f5f86452f
commit
3203577a9d
28 files changed
+1508
-758
No files matched your search
@@ -2,10 +2,11 @@ FROM node:22-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
COPY collector/package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY src ./src
|
||||
COPY collector/src ./src
|
||||
COPY shared /shared
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
EXPOSE 18110
|
||||
|
||||
+11
-29
@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url";
|
||||
import { Buffer } from "node:buffer";
|
||||
import net from "node:net";
|
||||
import mysql from "mysql2/promise";
|
||||
import { resolveEngineeringUnit } from "../../shared/engineering-units.mjs";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const dataDir = join(__dirname, "..", "data");
|
||||
@@ -192,27 +193,8 @@ function normalizeText(value) {
|
||||
return repairText(String(value === undefined || value === null ? "" : value).trim());
|
||||
}
|
||||
|
||||
function normalizeUnit(value) {
|
||||
const raw = normalizeText(value);
|
||||
const collapsed = raw.replace(/\s+/g, "");
|
||||
if (!collapsed) {
|
||||
return "°C";
|
||||
}
|
||||
|
||||
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 normalizePointUnit(value, kind, name) {
|
||||
return resolveEngineeringUnit(normalizeText(value), normalizePointKind(kind), name);
|
||||
}
|
||||
|
||||
function normalizePointIndex(value, fallback) {
|
||||
@@ -308,7 +290,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: normalizePointUnit(get("unit"), get("kind", get("type", "analog"))),
|
||||
unit: normalizePointUnit(get("unit"), get("kind", get("type", "analog")), get("alias", get("name"))),
|
||||
dataType: get("datatype", "holding-register"),
|
||||
kind: normalizePointKind(get("kind", get("type", "analog"))),
|
||||
enabled: payload.enabled === true,
|
||||
@@ -361,7 +343,7 @@ function parseKnxXml(payload) {
|
||||
pointIndex: index + 1,
|
||||
name,
|
||||
alias: name,
|
||||
unit: normalizePointUnit("", dpt.startsWith("1.") ? "digital" : "analog"),
|
||||
unit: normalizePointUnit("", dpt.startsWith("1.") ? "digital" : "analog", name),
|
||||
dataType: dpt || "group-address",
|
||||
kind: dpt.startsWith("1.") ? "digital" : "analog",
|
||||
enabled: payload.enabled === true,
|
||||
@@ -401,7 +383,7 @@ function createManualDatapoint(store, payload) {
|
||||
pointIndex,
|
||||
name,
|
||||
alias,
|
||||
unit: normalizePointUnit(payload.unit, payload.kind),
|
||||
unit: normalizePointUnit(payload.unit, payload.kind, alias),
|
||||
kind: normalizePointKind(payload.kind),
|
||||
enabled: payload.enabled !== false,
|
||||
alarmEnabled: payload.alarmEnabled === true,
|
||||
@@ -438,7 +420,7 @@ function createScanDatapoint(source, payload, index) {
|
||||
pointIndex,
|
||||
name: normalizeText(payload.name || alias) || alias,
|
||||
alias,
|
||||
unit: normalizePointUnit(payload.unit, payload.kind),
|
||||
unit: normalizePointUnit(payload.unit, payload.kind, alias),
|
||||
kind: normalizePointKind(payload.kind),
|
||||
enabled: payload.enabled === true,
|
||||
alarmEnabled: payload.alarmEnabled === true,
|
||||
@@ -936,7 +918,7 @@ function mapIpsymconVariable(source, variable, categoryId, index) {
|
||||
nodeId: String(variableId),
|
||||
dataType: variableType ? `ipsymcon-${variableType}` : "ipsymcon-variable",
|
||||
kind,
|
||||
unit: normalizePointUnit(variable?.unit, kind),
|
||||
unit: normalizePointUnit(variable?.unit, kind, name),
|
||||
currentValue: variable?.value ?? null,
|
||||
quality: normalizeText(variable?.quality || "unknown"),
|
||||
path: normalizeText(variable?.actual_path || ""),
|
||||
@@ -1744,7 +1726,7 @@ async function ensureTrendTable(tableName) {
|
||||
CREATE TABLE IF NOT EXISTS \`${table}\` (
|
||||
\`id\` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
\`datum\` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
\`userlevel\` INT(1) NOT NULL,
|
||||
\`userlevel\` INT(1) NULL DEFAULT NULL,
|
||||
${buildValueColumns()},
|
||||
PRIMARY KEY (\`id\`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
@@ -1898,7 +1880,7 @@ async function syncDatapointRegistryEntries(datapoints) {
|
||||
normalizeText(datapoint.alias || datapoint.name || `Wert${datapoint.pointIndex}`),
|
||||
normalizeText(datapoint.name || datapoint.alias || `Wert${datapoint.pointIndex}`),
|
||||
String(datapoint.protocol || "unknown"),
|
||||
normalizeUnit(datapoint.unit || ""),
|
||||
normalizePointUnit(datapoint.unit, datapoint.kind, datapoint.alias || datapoint.name),
|
||||
String(datapoint.kind || "analog"),
|
||||
datapoint.enabled === true ? 1 : 0,
|
||||
datapoint.alarmEnabled === true ? 1 : 0,
|
||||
@@ -2359,7 +2341,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 ? normalizePointUnit(body.unit, body.kind || store.datapoints[index].kind) : store.datapoints[index].unit,
|
||||
unit: body.unit != null ? normalizePointUnit(body.unit, body.kind || store.datapoints[index].kind, body.alias || body.name || store.datapoints[index].alias) : 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,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user