Skip to content

Commit

Permalink
Merge branch 'development' into MaxMinValues
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakesh-Ranga-Buram authored Jan 13, 2025
2 parents 1851023 + 355bbb7 commit 8523554
Show file tree
Hide file tree
Showing 10 changed files with 717 additions and 378 deletions.
22 changes: 12 additions & 10 deletions src/client/app/components/RadarChartComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ import { lineUnitLabel } from '../utils/graphics';
import { useTranslate } from '../redux/componentHooks';
import SpinnerComponent from './SpinnerComponent';


// Display Plotly Buttons Feature
// The number of items in defaultButtons and advancedButtons must differ as discussed below
const defaultButtons: Plotly.ModeBarDefaultButtons[] = [
'zoom2d', 'pan2d', 'select2d', 'lasso2d', 'zoomIn2d',
'zoomOut2d', 'autoScale2d', 'resetScale2d'
];
const advancedButtons: Plotly.ModeBarDefaultButtons[] = ['select2d', 'lasso2d', 'autoScale2d', 'resetScale2d'];

/**
* @returns radar plotly component
*/
Expand All @@ -35,7 +44,6 @@ export default function RadarChartComponent() {
const { meterArgs, groupArgs, meterShouldSkip, groupShouldSkip } = useAppSelector(selectRadarChartQueryArgs);
const { data: meterReadings, isLoading: meterIsLoading } = readingsApi.useLineQuery(meterArgs, { skip: meterShouldSkip });
const { data: groupData, isLoading: groupIsLoading } = readingsApi.useLineQuery(groupArgs, { skip: groupShouldSkip });
const datasets: any[] = [];
// graphic unit selected
const graphingUnit = useAppSelector(selectSelectedUnit);
// The current selected rate
Expand All @@ -48,10 +56,12 @@ export default function RadarChartComponent() {
const selectedGroups = useAppSelector(selectSelectedGroups);
const meterDataById = useAppSelector(selectMeterDataById);
const groupDataById = useAppSelector(selectGroupDataById);
// Manage button states with useState
const [listOfButtons, setListOfButtons] = React.useState(defaultButtons);
const datasets: any[] = [];

if (meterIsLoading || groupIsLoading) {
return <SpinnerComponent loading width={50} height={50} />;
// return <SpinnerComponent loading width={50} height={50} />
}

let unitLabel = '';
Expand All @@ -70,14 +80,6 @@ export default function RadarChartComponent() {
// The rate will be 1 if it is per hour (since state readings are per hour) or no rate scaling so no change.
const rateScaling = needsRateScaling ? currentSelectedRate.rate : 1;

// Display Plotly Buttons Feature
// The number of items in defaultButtons and advancedButtons must differ as discussed below
const defaultButtons: Plotly.ModeBarDefaultButtons[] = ['zoom2d', 'pan2d', 'select2d', 'lasso2d', 'zoomIn2d', 'zoomOut2d', 'autoScale2d',
'resetScale2d'];
const advancedButtons: Plotly.ModeBarDefaultButtons[] = ['select2d', 'lasso2d', 'autoScale2d', 'resetScale2d'];
// Manage button states with useState
const [listOfButtons, setListOfButtons] = React.useState(defaultButtons);

// Add all valid data from existing meters to the radar plot
for (const meterID of selectedMeters) {
if (meterReadings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ export default function CreateConversionModalComponent() {
setConversionState(defaultValues);
};

// Unlike edit, we decided to discard and inputs when you choose to leave the page. The reasoning is
// that create starts from an empty template.

// Submit
const handleSubmit = () => {
if (validConversion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export default function EditConversionModalComponent(props: EditConversionModalC
};

const handleClose = () => {
resetState();
props.handleClose();
resetState();
};

// Save changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ export default function CreateGroupModalComponent() {
setGraphicUnitsState(graphicUnitsStateDefaults);
};

// Unlike edit, we decided to discard inputs when you choose to leave the page. The reasoning is
// that create starts from an empty template.

// Save changes
const handleSubmit = () => {
// Close modal first to avoid repeat clicks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ export default function CreateMeterModalComponent(props: CreateMeterModalProps):
resetState();
};

// Unlike edit, we decided to discard and inputs when you choose to leave the page. The reasoning is
// that create starts from an empty template.

// Submit
const handleSubmit = async () => {
// Close modal first to avoid repeat clicks
Expand Down Expand Up @@ -697,4 +694,4 @@ export default function CreateMeterModalComponent(props: CreateMeterModalProps):
</Modal >
</>
);
}
}
Loading

0 comments on commit 8523554

Please sign in to comment.