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:
+14
-9
@@ -113,14 +113,19 @@ function createRandomPointColor(seed) {
|
||||
return hslToHex(hue, saturation, lightness);
|
||||
}
|
||||
|
||||
export function normalizeEngineeringUnit(value) {
|
||||
export function normalizeEngineeringUnit(value, kind = "analog") {
|
||||
const normalizedKind = kind === "digital" ? "digital" : "analog";
|
||||
const raw = String(value ?? "").trim();
|
||||
if (!raw) {
|
||||
return "\u00B0C";
|
||||
return normalizedKind === "digital" ? "bool" : "\u00B0C";
|
||||
}
|
||||
|
||||
if (normalizedKind === "digital" && /^(?:bool|boolean)$/i.test(raw)) {
|
||||
return "bool";
|
||||
}
|
||||
|
||||
if (/^\?C$/i.test(raw) || /^\u00B0\s*C$/i.test(raw) || (/[^\x00-\x7F]/.test(raw) && /C/i.test(raw))) {
|
||||
return "\u00B0C";
|
||||
return normalizedKind === "digital" ? "bool" : "\u00B0C";
|
||||
}
|
||||
|
||||
return raw;
|
||||
@@ -388,7 +393,7 @@ export async function ensureIspMetadata(pool, redis, isp, pointCount = LEGACY_PO
|
||||
parsed.points[pointKey] = {
|
||||
...defaultPoint,
|
||||
alias: initialAlias,
|
||||
unit: normalizeEngineeringUnit(sourceSeed?.unit || defaultPoint.unit),
|
||||
unit: normalizeEngineeringUnit(sourceSeed?.unit || defaultPoint.unit, sourceSeed?.kind || defaultPoint.kind),
|
||||
kind: sourceSeed?.kind || defaultPoint.kind,
|
||||
};
|
||||
changed = true;
|
||||
@@ -407,13 +412,13 @@ export async function ensureIspMetadata(pool, redis, isp, pointCount = LEGACY_PO
|
||||
point.kind = sourceSeed.kind;
|
||||
changed = true;
|
||||
}
|
||||
const normalizedUnit = normalizeEngineeringUnit(point.unit);
|
||||
const normalizedUnit = normalizeEngineeringUnit(point.unit, point.kind || sourceSeed?.kind || defaultPoint.kind);
|
||||
if (normalizedUnit !== point.unit) {
|
||||
point.unit = normalizedUnit;
|
||||
changed = true;
|
||||
}
|
||||
if ((!point.unit || point.unit === normalizeEngineeringUnit(defaultPoint.unit)) && sourceSeed?.unit) {
|
||||
const seededUnit = normalizeEngineeringUnit(sourceSeed.unit);
|
||||
if ((!point.unit || point.unit === normalizeEngineeringUnit(defaultPoint.unit, defaultPoint.kind)) && sourceSeed?.unit) {
|
||||
const seededUnit = normalizeEngineeringUnit(sourceSeed.unit, sourceSeed.kind || point.kind || defaultPoint.kind);
|
||||
if (point.unit !== seededUnit) {
|
||||
point.unit = seededUnit;
|
||||
changed = true;
|
||||
@@ -463,7 +468,7 @@ export async function ensureIspMetadata(pool, redis, isp, pointCount = LEGACY_PO
|
||||
metadata.points[pointKey] = {
|
||||
...metadata.points[pointKey],
|
||||
alias: sourceSeed.alias || sourceSeed.name || metadata.points[pointKey].alias,
|
||||
unit: normalizeEngineeringUnit(sourceSeed.unit || metadata.points[pointKey].unit),
|
||||
unit: normalizeEngineeringUnit(sourceSeed.unit || metadata.points[pointKey].unit, sourceSeed.kind || metadata.points[pointKey].kind),
|
||||
kind: sourceSeed.kind || metadata.points[pointKey].kind,
|
||||
};
|
||||
});
|
||||
@@ -506,7 +511,7 @@ export async function getPointDescriptors(pool, redis, points) {
|
||||
key: buildPointKey(isp, pointIndex),
|
||||
displayName: metadata.displayName,
|
||||
alias: pointMeta.alias,
|
||||
unit: normalizeEngineeringUnit(pointMeta.unit),
|
||||
unit: normalizeEngineeringUnit(pointMeta.unit, pointMeta.kind),
|
||||
factor: pointMeta.factor,
|
||||
kind: pointMeta.kind,
|
||||
min: pointMeta.min,
|
||||
|
||||
Reference in New Issue
Block a user