Skip to content

Commit

Permalink
Merge pull request #458 from kbss-cvut/fix-play-and-cutset-evaluation…
Browse files Browse the repository at this point in the history
…-button

Fix play/cutset buttons responsibilities
  • Loading branch information
blcham authored Jun 21, 2024
2 parents 98429aa + 932f81d commit adc7e8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 1 addition & 7 deletions src/components/editor/faultTree/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,7 @@ const Editor = () => {
const handleCutSetAnalysis = () => {
setShowPath(!showPath);
setShowTable(!showTable);
calculateCutSets(faultTree.iri, faultTree.operationalDataFilter)
.then((d) => {
refreshTree();
})
.catch((reason) => {
showSnackbar(reason, SnackbarType.ERROR);
});
refreshTree();
};

const [failureModesTableOpen, setFailureModesTableOpen] = useState(false);
Expand Down
15 changes: 11 additions & 4 deletions src/components/editor/faultTree/canvas/EditorCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ 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";

enum MOVE_NODE {
DRAGGING = 0,
Expand Down Expand Up @@ -89,6 +91,7 @@ const EditorCanvas = ({
const [, , updateTree] = useFaultTrees();
const [updatedMinOperationalHours, setUpdatedMinOperationalHours] = useState(initialMinOperationalHours);
const [inputColor, setInputColor] = useState("");
const [showSnackbar] = useSnackbar();

let dragStartPosition = null;

Expand Down Expand Up @@ -286,10 +289,14 @@ const EditorCanvas = ({
};

const handleSetNewDefaultOperationalHours = () => {
updateTree({
...faultTree,
operationalDataFilter: { ...faultTree.operationalDataFilter, minOperationalHours: updatedMinOperationalHours },
});
calculateCutSets(faultTree.iri, faultTree.operationalDataFilter)
.then((d) => {
refreshTree();
})
.catch((reason) => {
showSnackbar(reason, SnackbarType.ERROR);
});

setInputColor(theme.synchronized.color);
};

Expand Down

0 comments on commit adc7e8a

Please sign in to comment.