Skip to content

Commit e5c06ac

Browse files
added feature to show last run workflow
1 parent 76bfd0e commit e5c06ac

8 files changed

Lines changed: 95 additions & 5 deletions

File tree

src/features/deviceBLEconnection/Ble.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function Ble(props) {
2626
"10 minutes or less is the ideal time for a bag to store vapor",
2727
"For best results preheat the chamber for 2-5 seconds before attaching the bag",
2828
"Drag and drop can be used to reorder workflows and workflow items on all devices",
29-
"New Setting! You can now have your Volcano automatically turn on the heat when connecting to the app",
29+
"If you want to visually see the last workflow run you can enable highlight last run workflow in settings",
3030
"The Auto Seasonal Rotate theme selects a festive theme when it can and falls back on a semi-random theme",
3131
];
3232

src/features/deviceInteraction/WriteTemperature/WriteTemperature.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { Div } from "./styledComponents";
2-
import { ActiveButton, InactiveButton } from "./styledComponents";
2+
import {
3+
ActiveButton,
4+
InactiveButton,
5+
GlowyInactiveButton,
6+
} from "./styledComponents";
37

48
function WriteTemperature(props) {
5-
const Button = props.isActive ? ActiveButton : InactiveButton;
9+
const Button = props.isActive
10+
? ActiveButton
11+
: props.isGlowy
12+
? GlowyInactiveButton
13+
: InactiveButton;
614
const { onClick, buttonText, className, buttonClassName } = {
715
...props,
816
};

src/features/deviceInteraction/WriteTemperature/styledComponents.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import styled from "styled-components";
1+
import styled, { css } from "styled-components";
2+
3+
const glowStyles = css`
4+
${({ theme }) => {
5+
return css`
6+
box-shadow: 0 0 6px ${theme.primaryFontColor},
7+
0 0 12px ${theme.primaryFontColor};
8+
`;
9+
}}
10+
`;
211

312
export const InactiveButton = styled.button`
413
font-size: 1.25rem;
@@ -17,7 +26,9 @@ export const InactiveButton = styled.button`
1726
border-color: ${(props) => props.theme.buttonActive.borderColor};
1827
}
1928
`;
20-
29+
export const GlowyInactiveButton = styled(InactiveButton)`
30+
${glowStyles}
31+
`;
2132
export const ActiveButton = styled(InactiveButton)`
2233
background-color: ${(props) => props.theme.buttonActive.backgroundColor};
2334
color: ${(props) => props.theme.buttonActive.color};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { useSelector } from "react-redux";
2+
import StyledToggleSwitch from "../Shared/StyledComponents/StyledToggleDiv";
3+
import Div from "../Shared/StyledComponents/Div";
4+
import PrideText, { PrideTextWithDiv } from "../../../themes/PrideText";
5+
import { useDispatch } from "react-redux";
6+
import {
7+
ReadConfigFromLocalStorage,
8+
WriteNewConfigToLocalStorage,
9+
} from "../../../services/utils";
10+
import { setHighlightLastRunWorkflow } from "../settingsSlice";
11+
12+
export default function HighlightLastRunWorkflow() {
13+
const dispatch = useDispatch();
14+
const highlightLastRunWorkflow = useSelector(
15+
(state) => state.settings.config.highlightLastRunWorkflow
16+
);
17+
18+
const onChange = () => {
19+
const config = ReadConfigFromLocalStorage();
20+
config.highlightLastRunWorkflow = !highlightLastRunWorkflow;
21+
WriteNewConfigToLocalStorage(config);
22+
dispatch(setHighlightLastRunWorkflow(!highlightLastRunWorkflow));
23+
};
24+
25+
return (
26+
<Div>
27+
<h2>
28+
<PrideText text="Highlight last run workflow" />
29+
</h2>
30+
<div onClick={onChange}>
31+
<StyledToggleSwitch
32+
onText="On"
33+
offText={<PrideTextWithDiv text="Off" />}
34+
isToggleOn={highlightLastRunWorkflow}
35+
/>
36+
</div>
37+
</Div>
38+
);
39+
}

src/features/settings/Settings.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ThemesContainer from "./Theming/ThemesContainer";
1111
import PrideText from "../../themes/PrideText";
1212
import TurnHeatOnWhenConnectionIsEstablished from "./TurnHeatOnWhenConnectionIsEstablished/TurnHeatOnWhenConnectionIsEstablished";
1313
import ShowCurrentWorkflowDetails from "./ShowCurrentWorkflowDetails/ShowCurrentWorkflowDetails";
14+
import HighlightLastRunWorkflow from "./HighlightLastRunWorkflow/HighlightLastRunWorkflow";
1415
export default function Settings() {
1516
return (
1617
<Div>
@@ -25,6 +26,7 @@ export default function Settings() {
2526
<AdjustAutoShutoffTimeContainer />
2627
<VibrationToggleContainer />
2728
<DisplayOnCoolingToggleContainer />
29+
<HighlightLastRunWorkflow />
2830
<ShowCurrentWorkflowDetails />
2931
<TurnHeatOnWhenConnectionIsEstablished />
3032
<TemperatureControlSettings />

src/features/settings/settingsSlice.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export const settingsSlice = createSlice({
4343
setShowCurrentWorkflowDetails: (state, action) => {
4444
state.config.showCurrentWorkflowDetails = action.payload;
4545
},
46+
setHighlightLastRunWorkflow: (state, action) => {
47+
state.config.highlightLastRunWorkflow = action.payload;
48+
},
4649
},
4750
extraReducers: (builder) => {
4851
builder.addCase(RE_INITIALIZE_STORE, (state) => {
@@ -70,6 +73,7 @@ export const {
7073
setCurrentWorkflows,
7174
setFanOnGlobal,
7275
setShowCurrentWorkflowDetails,
76+
setHighlightLastRunWorkflow,
7377
} = settingsSlice.actions;
7478

7579
export default settingsSlice.reducer;

src/features/workflowEditor/WorkflowButtons.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,18 @@ export default function WorkFlow() {
4444
const workflows = useSelector(
4545
(state) => state.settings.config.workflows.items
4646
);
47+
48+
const highlightLastRunWorkflow = useSelector(
49+
(state) => state.settings.config.highlightLastRunWorkflow
50+
);
4751
const currentWorkflow = useSelector(
4852
(state) => state.workflow.currentWorkflow
4953
);
5054

55+
const lastWorkflowRunId = useSelector(
56+
(state) => state.workflow.lastWorkflowRunId
57+
);
58+
5159
const executeWithManagedSetTimeout = (func, timeout = 100) => {
5260
currentSetTimeouts.push(
5361
setTimeout(() => {
@@ -244,13 +252,15 @@ export default function WorkFlow() {
244252
<div className="temperature-write-div">
245253
{workflows.map((item, index) => {
246254
const isActive = currentWorkflow?.id === item.id;
255+
const isLastRunWorkflow = item.id === lastWorkflowRunId && !isActive;
247256
const buttonText = isActive ? "Tap to Cancel" : item.name;
248257
return (
249258
<WriteTemperature
250259
key={index}
251260
onClick={() => onClick(index)}
252261
buttonText={<PrideText text={buttonText} />}
253262
isActive={isActive}
263+
isGlowy={highlightLastRunWorkflow && isLastRunWorkflow}
254264
/>
255265
);
256266
})}

src/features/workflowEditor/workflowSlice.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
import { createSlice } from "@reduxjs/toolkit";
22
import { RE_INITIALIZE_STORE } from "../../constants/actions";
3+
import {
4+
ReadConfigFromLocalStorage,
5+
WriteNewConfigToLocalStorage,
6+
} from "../../services/utils";
37

48
export const workflowSlice = createSlice({
59
name: "workflow",
610
initialState: {
711
currentWorkflow: undefined,
812
currentWorkflowStepId: undefined,
913
currentStepEllapsedTimeInSeconds: 0,
14+
lastWorkflowRunId:
15+
ReadConfigFromLocalStorage().workflows?.lastWorkflowRunId,
1016
},
1117
reducers: {
1218
setCurrentWorkflow: (state, action) => {
1319
state.currentWorkflow = action.payload;
20+
const newLastWorkFlowRunId =
21+
action.payload?.id || state.lastWorkflowRunId;
22+
if (newLastWorkFlowRunId !== state.lastWorkflowRunId) {
23+
state.lastWorkflowRunId = newLastWorkFlowRunId;
24+
const config = ReadConfigFromLocalStorage();
25+
config.workflows.lastWorkflowRunId = newLastWorkFlowRunId;
26+
WriteNewConfigToLocalStorage(config);
27+
}
1428
},
1529
setCurrentWorkflowStepId: (state, action) => {
1630
state.currentWorkflowStepId = action.payload;
@@ -26,6 +40,8 @@ export const workflowSlice = createSlice({
2640
currentWorkflow: undefined,
2741
currentWorkflowStepId: undefined,
2842
currentStepEllapsedTimeInSeconds: 0,
43+
lastWorkflowRunId:
44+
ReadConfigFromLocalStorage().workflows?.lastWorkflowRunId,
2945
};
3046
});
3147
},

0 commit comments

Comments
 (0)