Skip to content

Commit

Permalink
Merge branch 'OpenEnergyDashboard:development' into Issue1217-csv-val…
Browse files Browse the repository at this point in the history
…idation
  • Loading branch information
SageMar authored Jan 3, 2025
2 parents 30d213e + 17d8af6 commit 06751f8
Show file tree
Hide file tree
Showing 30 changed files with 1,586 additions and 279 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ services:
"${install_args:-}"
]
# Use this if you are using a docker-compose that is earlier than version 2 and comment out the one above.
# command: ["bash", "./src/scripts/installOED.sh"]
# command: ["bash", "./src/scripts/installOED.sh"]
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"scripts": {
"start": "node ./src/bin/www",
"start:dev": "nodemon --legacy-watch --inspect=0.0.0.0 ./src/bin/www",
"checkWebsiteStatus": "node src/server/services/checkWebsiteStatus.js",
"webpack:dev": "webpack watch --color --progress --mode development",
"webpack:build": "webpack build --node-env production",
"webpack": "webpack build --color --progress --mode development",
Expand Down Expand Up @@ -43,7 +44,8 @@
"generateCosineSquaredTestingData": "node -e 'require(\"./src/server/data/automatedTestingData\").generateCosineSquaredTestingData(2.5)'",
"generateTestingData": "node -e 'require(\"./src/server/data/automatedTestingData\").generateTestingData()'",
"testData": "node -e 'require(\"./src/server/data/automatedTestingData.js\").insertSpecialUnitsConversionsMetersGroups()'",
"webData": "node -e 'require(\"./src/server/data/websiteData.js\").insertWebsiteData()'"
"webData": "node -e 'require(\"./src/server/data/websiteData.js\").insertWebsiteData()'",
"addLogMsg": "node -e 'require(\"./src/server/services/addLogMsg.js\").addLogMsgToDB()'"
},
"nodemonConfig": {
"watch": [
Expand Down Expand Up @@ -135,4 +137,4 @@
"webpack": "~5.76.0",
"webpack-cli": "~5.1.4"
}
}
}
11 changes: 10 additions & 1 deletion src/client/app/components/HeaderButtonsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default function HeaderButtonsComponent() {
shouldCSVReadingsButtonDisabled: true,
shouldUnitsButtonDisabled: true,
shouldConversionsButtonDisabled: true,
shouldLogMsgButtonDisabled: true,
shouldVisualUnitMapButtonDisabled: true,
// Translated menu title that depend on whether logged in.
menuTitle: '',
Expand Down Expand Up @@ -101,6 +102,7 @@ export default function HeaderButtonsComponent() {
shouldCSVReadingsButtonDisabled: pathname === '/csvReadings',
shouldUnitsButtonDisabled: pathname === '/units',
shouldConversionsButtonDisabled: pathname === '/conversions',
shouldLogMsgButtonDisabled: pathname === '/logmsg',
shouldVisualUnitMapButtonDisabled: pathname === '/visual-unit'
}));
}, [pathname]);
Expand Down Expand Up @@ -244,6 +246,13 @@ export default function HeaderButtonsComponent() {
to="/admin">
<FormattedMessage id='admin.settings' />
</DropdownItem>
<DropdownItem
style={state.adminViewableLinkStyle}
disabled={state.shouldLogMsgButtonDisabled}
tag={Link}
to="/logmsg">
<FormattedMessage id='log.messages' />
</DropdownItem>
<DropdownItem
style={state.adminViewableLinkStyle}
disabled={state.shouldUsersButtonDisabled}
Expand Down Expand Up @@ -306,7 +315,7 @@ export default function HeaderButtonsComponent() {
{translate('log.in')}
</ModalHeader>
<ModalBody>
<LoginComponent handleClose={handleClose}/>
<LoginComponent handleClose={handleClose} />
</ModalBody>
</Modal>
</>
Expand Down
30 changes: 12 additions & 18 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 All @@ -89,11 +91,6 @@ export default function RadarChartComponent() {
if (readingsData) {
const label = entity.identifier;
const colorID = meterID;
// TODO If we are sure the data is always defined then remove this commented out code.
// Be consistent for all graphing and groups below.
// if (readingsData.readings === undefined) {
// throw new Error('Unacceptable condition: readingsData.readings is undefined.');
// }
// Create two arrays for the distance (rData) and angle (thetaData) values. Fill the array with the data from the line readings.
// HoverText is the popup value show for each reading.
const thetaData: string[] = [];
Expand Down Expand Up @@ -146,9 +143,6 @@ export default function RadarChartComponent() {
if (readingsData) {
const label = entity.name;
const colorID = groupID;
// if (readingsData.readings === undefined) {
// throw new Error('Unacceptable condition: readingsData.readings is undefined.');
// }
// Create two arrays for the distance (rData) and angle (thetaData) values. Fill the array with the data from the line readings.
// HoverText is the popup value show for each reading.
const thetaData: string[] = [];
Expand Down
3 changes: 3 additions & 0 deletions src/client/app/components/RouteComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import RoleOutlet from './router/RoleOutlet';
import UnitsDetailComponent from './unit/UnitsDetailComponent';
import ErrorComponent from './router/ErrorComponent';
import { selectSelectedLanguage } from '../redux/slices/appStateSlice';
import LogMsgComponent from './admin/LogMsgComponent';
import VisualUnitDetailComponent from './visual-unit/VisualUnitDetailComponent';

/**
Expand Down Expand Up @@ -60,6 +61,8 @@ const router = createBrowserRouter([
{ path: 'maps', element: <MapsDetailContainer /> },
{ path: 'units', element: <UnitsDetailComponent /> },
{ path: 'users', element: <UsersDetailComponent /> },
{ path: 'logmsg', element: <LogMsgComponent /> },
{ path: 'users', element: <UsersDetailComponent /> },
{ path: 'visual-unit', element: <VisualUnitDetailComponent/> }
]
},
Expand Down
Loading

0 comments on commit 06751f8

Please sign in to comment.