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
@@ -0,0 +1,49 @@
|
||||
export const AUTO_UNIT = "__auto__";
|
||||
export const DEFAULT_ANALOG_UNIT = "\u00B0C";
|
||||
export const DIGITAL_UNIT = "Digital";
|
||||
|
||||
export const DEFAULT_UNITS = [
|
||||
[DEFAULT_ANALOG_UNIT, "Grad Celsius"],
|
||||
["%", "Prozent"],
|
||||
["K", "Kelvin"],
|
||||
["V", "Volt"],
|
||||
["A", "Ampere"],
|
||||
["Pa", "Pascal"],
|
||||
[DIGITAL_UNIT, "Digital"],
|
||||
["ppm", "Parts per million"],
|
||||
["%RH", "Relative Feuchte"],
|
||||
["COV", "COV"],
|
||||
["mBar", "Millibar"],
|
||||
["Bar", "Bar"],
|
||||
["kW", "Kilowatt"],
|
||||
["kWh", "Kilowattstunden"],
|
||||
["Liter", "Liter"],
|
||||
["m\u00B3", "Kubikmeter"],
|
||||
].map(([symbol, label]) => ({ symbol, label, isSystem: true }));
|
||||
|
||||
export function normalizeUnitSymbol(value) {
|
||||
const symbol = String(value ?? "").trim();
|
||||
if (/^(?:bool|boolean|digital)$/i.test(symbol)) return DIGITAL_UNIT;
|
||||
if (/^(?:\?C|\u00C2*\u00B0\s*C)$/i.test(symbol)) return DEFAULT_ANALOG_UNIT;
|
||||
if (/^%\s*rh$/i.test(symbol)) return "%RH";
|
||||
if (/^m(?:\^?3|\u00B3)$/i.test(symbol)) return "m\u00B3";
|
||||
return DEFAULT_UNITS.find((unit) => unit.symbol.toLowerCase() === symbol.toLowerCase())?.symbol ?? symbol;
|
||||
}
|
||||
|
||||
export function detectEngineeringUnit(name, kind) {
|
||||
if (kind === "digital") return DIGITAL_UNIT;
|
||||
const label = String(name ?? "").toLowerCase();
|
||||
if (/co[2\u2082]/.test(label)) return "ppm";
|
||||
if (/feucht|humidity/.test(label)) return "%RH";
|
||||
if (/energie|energy|kwh/.test(label)) return "kWh";
|
||||
if (/leistung|power/.test(label)) return "kW";
|
||||
if (/druck|pressure/.test(label)) return /m\s*bar|millibar/.test(label) ? "mBar" : "Pa";
|
||||
if (/temp|f(?:\u00FC|ue)hler/.test(label)) return DEFAULT_ANALOG_UNIT;
|
||||
return "";
|
||||
}
|
||||
|
||||
export function resolveEngineeringUnit(value, kind, name) {
|
||||
const unit = normalizeUnitSymbol(value);
|
||||
if (unit && unit !== AUTO_UNIT) return unit;
|
||||
return detectEngineeringUnit(name, kind) || DEFAULT_ANALOG_UNIT;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
export const CHART_DIVISIONS = [3, 4, 6, 8, 10];
|
||||
|
||||
export const DEFAULT_CHART_SETTINGS = {
|
||||
divisions: 6,
|
||||
grid: "both",
|
||||
gridStyle: "dashed",
|
||||
shadedBands: false,
|
||||
opacity: 100,
|
||||
highContrast: false,
|
||||
axes: {},
|
||||
assignments: {},
|
||||
};
|
||||
|
||||
function entries(value) {
|
||||
return value && typeof value === "object" && !Array.isArray(value) ? Object.entries(value) : [];
|
||||
}
|
||||
|
||||
function numericBound(value) {
|
||||
if (typeof value === "number" && Number.isFinite(value)) return value;
|
||||
if (typeof value === "string" && value.trim() && Number.isFinite(Number(value))) return Number(value);
|
||||
return "";
|
||||
}
|
||||
|
||||
export function normalizeTrendChartSettings(input, points) {
|
||||
const settings = input || {};
|
||||
const pointKeys = points && new Set(points.map((point) => `${point.isp}:${point.pointIndex}`));
|
||||
const axes = Object.fromEntries(entries(settings.axes)
|
||||
.filter(([id, axis]) => axis && typeof axis === "object" && (
|
||||
(id.startsWith("unit:") && id.length <= 261)
|
||||
|| (id.startsWith("point:") && (!pointKeys || pointKeys.has(id.slice(6))))
|
||||
))
|
||||
.map(([id, axis]) => [id, {
|
||||
...(axis.side === "left" || axis.side === "right" ? { side: axis.side } : {}),
|
||||
mode: axis.mode === "manual" ? "manual" : "auto",
|
||||
min: numericBound(axis.min),
|
||||
max: numericBound(axis.max),
|
||||
}]));
|
||||
const assignments = Object.fromEntries(entries(settings.assignments)
|
||||
.filter(([key, value]) => value === "own" && (!pointKeys || pointKeys.has(key))));
|
||||
|
||||
return {
|
||||
divisions: CHART_DIVISIONS.includes(settings.divisions) ? settings.divisions : DEFAULT_CHART_SETTINGS.divisions,
|
||||
grid: ["both", "horizontal", "vertical", "none"].includes(settings.grid) ? settings.grid : DEFAULT_CHART_SETTINGS.grid,
|
||||
gridStyle: settings.gridStyle === "solid" ? "solid" : DEFAULT_CHART_SETTINGS.gridStyle,
|
||||
shadedBands: settings.shadedBands === true,
|
||||
opacity: Number.isFinite(settings.opacity) ? Math.max(20, Math.min(100, settings.opacity)) : DEFAULT_CHART_SETTINGS.opacity,
|
||||
highContrast: settings.highContrast === true,
|
||||
axes,
|
||||
assignments,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
export const DEFAULT_TREND_PRESET = "1";
|
||||
export const DEFAULT_MAX_TREND_SERIES = 10;
|
||||
export const MAX_TREND_SERIES = 100;
|
||||
|
||||
export const TREND_PRESETS = [
|
||||
{ value: "0.0034722222", label: "5 min" },
|
||||
{ value: "0.0069444444", label: "10 min" },
|
||||
{ value: "0.0208333333", label: "30 min" },
|
||||
{ value: "0.0416666667", label: "1 h" },
|
||||
{ value: "0.0833333333", label: "2 h" },
|
||||
{ value: "0.25", label: "6 h" },
|
||||
{ value: "0.5", label: "12 h" },
|
||||
{ value: "1", label: "24 h" },
|
||||
{ value: "2", label: "2 Tage" },
|
||||
{ value: "3", label: "3 Tage" },
|
||||
{ value: "7", label: "7 Tage" },
|
||||
{ value: "14", label: "14 Tage" },
|
||||
{ value: "30", label: "30 Tage" },
|
||||
];
|
||||
|
||||
export function normalizeMaxTrendSeries(value, fallback = DEFAULT_MAX_TREND_SERIES) {
|
||||
const count = Number(value);
|
||||
return Number.isInteger(count) && count >= 1 && count <= MAX_TREND_SERIES ? count : fallback;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export const LEGACY_TREND_TIME_ZONE = process.env.LEGACY_TREND_TIME_ZONE || "Europe/Berlin";
|
||||
export const LEGACY_DATUM_UTC = "CONVERT_TZ(datum, ?, '+00:00')";
|
||||
|
||||
export function setUtcSession(connection) {
|
||||
connection.query("SET time_zone = '+00:00'");
|
||||
}
|
||||
Reference in new issue
Block a user