From 2495403cfd0bd432a9a2a09f0f49407be7e2f290 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Tue, 8 Oct 2024 12:59:23 +0200 Subject: [PATCH 1/3] [Fix #593] Add localized messages for hints of the MOH input field in fault tree editor sidebar. --- public/locales/cs/translation.json | 6 +++++- public/locales/en/translation.json | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/public/locales/cs/translation.json b/public/locales/cs/translation.json index a006fa7f..53c541d6 100644 --- a/public/locales/cs/translation.json +++ b/public/locales/cs/translation.json @@ -47,7 +47,11 @@ "diagramSidePanel": { "cutsetToggleToolTip": "Přepnout do pohledu řezu", "minimumOperationalHours": "Min. provozní doba", - "diagramOptions": "Možnosti diagramu" + "diagramOptions": "Možnosti diagramu", + "messages": { + "mohNewValue": "Nová hodnota, která se není použíta při vyhodnocování stromu chyb.", + "mohExperimental": "Hodnota se liší od min. hodnota provozní hodiny systému." + } }, "faultEventScenariosTable": { "cutset": "Řez", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index ffa4dc6a..a0b7c219 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -47,7 +47,11 @@ "diagramSidePanel": { "cutsetToggleToolTip": "Switch to cutsets view", "minimumOperationalHours": "Min. operational hours", - "diagramOptions": "Diagram Options" + "diagramOptions": "Diagram Options", + "messages": { + "mohNewValue": "New value, not used in fault tree evaluation.", + "mohExperimental": "Value is different from the system's min. operational hour value." + } }, "faultEventScenariosTable": { "cutset": "Cutset", From a309e74ca6bfe2feaaff738a6c10703b545379a9 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Tue, 8 Oct 2024 13:00:28 +0200 Subject: [PATCH 2/3] [Fix #593] Fix jsonld context for system in faultTreeModel.tsx --- src/models/faultTreeModel.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/models/faultTreeModel.tsx b/src/models/faultTreeModel.tsx index fe18332c..75b9a5d9 100644 --- a/src/models/faultTreeModel.tsx +++ b/src/models/faultTreeModel.tsx @@ -3,18 +3,28 @@ import { FaultEvent, CONTEXT as EVENT_CONTEXT } from "@models/eventModel"; import { AbstractModel, CONTEXT as ABSTRACT_CONTEXT } from "@models/abstractModel"; import { FaultEventScenario, CONTEXT as SCENARIO_CONTEXT } from "@models/faultEventScenario"; import { OperationalDataFilter, CONTEXT as FILTER_CONTEXT } from "@models/operationalDataFilterModel"; -import { System } from "@models/systemModel"; +import { System, CONTEXT as SYSTEM_CONTEXT } from "@models/systemModel"; import { Status } from "@utils/constants"; const ctx = { manifestingEvent: VocabularyUtils.PREFIX + "is-manifested-by", faultEventScenarios: VocabularyUtils.PREFIX + "has-scenario", operationalDataFilter: VocabularyUtils.PREFIX + "has-operational-data-filter", + system: VocabularyUtils.PREFIX + "is-artifact-of", + subSystem: VocabularyUtils.PREFIX + "is-performed-by", name: VocabularyUtils.PREFIX + "name", status: VocabularyUtils.PREFIX + "status", }; -export const CONTEXT = Object.assign({}, ctx, ABSTRACT_CONTEXT, EVENT_CONTEXT, SCENARIO_CONTEXT, FILTER_CONTEXT); +export const CONTEXT = Object.assign( + {}, + ctx, + ABSTRACT_CONTEXT, + EVENT_CONTEXT, + SCENARIO_CONTEXT, + FILTER_CONTEXT, + SYSTEM_CONTEXT, +); export interface FaultTree extends AbstractModel { name: string; From f33f1056b5481e8570d4f559cb4b1fa7c75eb72f Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Tue, 8 Oct 2024 13:01:32 +0200 Subject: [PATCH 3/3] [Fix #593] Fix reset MOH button and rendering the states of the MOH input field. --- .../editor/faultTree/canvas/EditorCanvas.tsx | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/components/editor/faultTree/canvas/EditorCanvas.tsx b/src/components/editor/faultTree/canvas/EditorCanvas.tsx index 6fd44aec..7e07d706 100644 --- a/src/components/editor/faultTree/canvas/EditorCanvas.tsx +++ b/src/components/editor/faultTree/canvas/EditorCanvas.tsx @@ -22,7 +22,6 @@ import { useTranslation } from "react-i18next"; import RestartAltIcon from "@mui/icons-material/RestartAlt"; import PlayArrow from "@mui/icons-material/PlayArrow"; import { useCurrentFaultTree } from "@hooks/useCurrentFaultTree"; -import { useFaultTrees } from "@hooks/useFaultTrees"; import { calculateCutSets } from "@services/faultTreeService"; import { SnackbarType, useSnackbar } from "@hooks/useSnackbar"; import { useNavigate } from "react-router-dom"; @@ -94,8 +93,8 @@ const EditorCanvas = ({ const [rendering, setRendering] = useState(false); const [faultTree] = useCurrentFaultTree(); const initialMinOperationalHours = faultTree?.operationalDataFilter?.minOperationalHours || 0; + const systemMinOperationalHours = faultTree?.system?.operationalDataFilter?.minOperationalHours || 0; const [updatedMinOperationalHours, setUpdatedMinOperationalHours] = useState(initialMinOperationalHours); - const [inputColor, setInputColor] = useState(""); const [showSnackbar] = useSnackbar(); const { isModified, setShowUnsavedChangesDialog } = useAppBar(); @@ -295,16 +294,13 @@ const EditorCanvas = ({ const handleMinOperationalHoursChange = (event) => { const newValue = event.target.value; setUpdatedMinOperationalHours(newValue); - if (newValue !== faultTree?.operationalDataFilter?.minOperationalHours) { - setInputColor(theme.notSynchronized.color); - } else { - setInputColor(theme.synchronized.color); - } }; const handleReset = () => { - setUpdatedMinOperationalHours(initialMinOperationalHours); - setInputColor(theme.synchronized.color); + if (initialMinOperationalHours != updatedMinOperationalHours) + setUpdatedMinOperationalHours(initialMinOperationalHours); + else if (initialMinOperationalHours != systemMinOperationalHours) + setUpdatedMinOperationalHours(systemMinOperationalHours); }; const handleSetNewDefaultOperationalHours = () => { @@ -322,10 +318,26 @@ const EditorCanvas = ({ .catch((reason) => { showSnackbar(reason, SnackbarType.ERROR); }); - - setInputColor(theme.synchronized.color); }; + const dirty = initialMinOperationalHours != updatedMinOperationalHours; + const experimental = systemMinOperationalHours != updatedMinOperationalHours; + const inputColor = experimental ? theme.notSynchronized.color : theme.synchronized.color; + const inputProps = + updatedMinOperationalHours !== initialMinOperationalHours + ? { style: { borderStyle: "dashed", borderWidth: "4px", borderColor: theme.notSynchronized.color } } + : null; + const props = {}; + if (inputProps) props.inputProps = inputProps; + + if (dirty || experimental) { + const messages = [ + dirty ? t("diagramSidePanel.messages.mohNewValue") : null, + experimental ? t("diagramSidePanel.messages.mohExperimental") : null, + ].filter((m) => m != null); + props.title = messages.length > 1 ? messages.map((m, i) => i + 1 + ") " + m).join("\n") : messages[0]; + } + return (
@@ -348,6 +360,7 @@ const EditorCanvas = ({ sx={{ flex: 2, input: { color: inputColor } }} value={updatedMinOperationalHours} onChange={handleMinOperationalHoursChange} + {...props} />