Skip to content

Commit

Permalink
More 3d Revisions
Browse files Browse the repository at this point in the history
- default to 6 months back when selecting entity to graph on 3d.
  • Loading branch information
ChrisMart21 committed Mar 3, 2024
1 parent a5cb490 commit e97bdcf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/client/app/components/ThreeDPillComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export default function ThreeDPillComponent() {
});

// When a Pill Badge is clicked update threeD state to indicate new meter or group to render.
const handlePillClick = (pillData: MeterOrGroupPill) => dispatch(updateThreeDMeterOrGroupInfo(
{
const handlePillClick = (pillData: MeterOrGroupPill) => dispatch(
updateThreeDMeterOrGroupInfo({
meterOrGroupID: pillData.meterOrGroupID,
meterOrGroup: pillData.meterOrGroup
}
));
})
);

// Method Generates Reactstrap Pill Badges for selected meters or groups
const populatePills = (meterOrGroupPillData: MeterOrGroupPill[]) => {
Expand Down
23 changes: 16 additions & 7 deletions src/client/app/redux/slices/graphSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,24 @@ export const graphSlice = createSlice({
updateThreeDReadingInterval: (state, action: PayloadAction<ReadingInterval>) => {
state.current.threeD.readingInterval = action.payload;
},
updateThreeDMeterOrGroupInfo: (state, action: PayloadAction<{ meterOrGroupID: number | undefined, meterOrGroup: MeterOrGroup }>) => {
state.current.threeD.meterOrGroupID = action.payload.meterOrGroupID;
state.current.threeD.meterOrGroup = action.payload.meterOrGroup;
},
updateThreeDMeterOrGroupID: (state, action: PayloadAction<number>) => {
state.current.threeD.meterOrGroupID = action.payload;
updateThreeDMeterOrGroupID: (state, action: PayloadAction<number | undefined>) => {
if (state.current.threeD.meterOrGroupID !== action.payload) {
state.current.threeD.meterOrGroupID = action.payload;
}
},
updateThreeDMeterOrGroup: (state, action: PayloadAction<MeterOrGroup>) => {
state.current.threeD.meterOrGroup = action.payload;
if (state.current.threeD.meterOrGroup !== action.payload) {
state.current.threeD.meterOrGroup = action.payload;
}
},
updateThreeDMeterOrGroupInfo: (state, action: PayloadAction<{ meterOrGroupID: number | undefined, meterOrGroup: MeterOrGroup }>) => {
const { updateThreeDMeterOrGroupID, updateThreeDMeterOrGroup } = graphSlice.caseReducers;
updateThreeDMeterOrGroupID(state, graphSlice.actions.updateThreeDMeterOrGroupID(action.payload.meterOrGroupID));
updateThreeDMeterOrGroup(state, graphSlice.actions.updateThreeDMeterOrGroup(action.payload.meterOrGroup));
if (!state.current.queryTimeInterval.getIsBounded()) {
// Set the query time interval to 6 moths back when not bounded for 3D
state.current.queryTimeInterval = new TimeInterval(moment.utc().subtract(6, 'months'), moment.utc());
}
},
updateSelectedMetersOrGroups: ({ current }, action: PayloadAction<{ newMetersOrGroups: number[], meta: ActionMeta<SelectOption> }>) => {
// This reducer handles the addition and subtraction values for both the meter and group select components.
Expand Down

0 comments on commit e97bdcf

Please sign in to comment.