diff --git a/.env b/.env index c4cd96d4..ac688e57 100644 --- a/.env +++ b/.env @@ -1,22 +1,23 @@ -WEB_REGISTRY_URI=nrel/alfalfa-web -WORKER_REGISTRY_URI=nrel/alfalfa-worker -HISTORIAN_GUI_REGISTRY_URI=nrel/alfalfa-grafana -VERSION_TAG=latest AWS_ACCESS_KEY_ID=user AWS_SECRET_ACCESS_KEY=password -NODE_ENV=production -S3_URL=http://minio:9000 -S3_URL_EXTERNAL=http://localhost:9000 -S3_BUCKET=alfalfa -REDIS_HOST=redis +GF_SECURITY_ADMIN_PASSWORD=password +GF_SECURITY_ADMIN_USER=admin +HISTORIAN_GUI_REGISTRY_URI=nrel/alfalfa-grafana +INFLUXDB_ADMIN_PASSWORD=password +INFLUXDB_ADMIN_USER=admin +INFLUXDB_DB=alfalfa +INFLUXDB_HOST=influxdb +INFLUXDB_HTTP_AUTH_ENABLED=true JOB_QUEUE_URL=http://goaws:4100/queue/local-queue1 -MONGO_URL=mongodb://mongo:27017/ +LOGGING=false MONGO_DB_NAME=alfalfa +MONGO_URL=mongodb://mongo:27017/ +NODE_ENV=production +REDIS_HOST=redis REGION=us-west-1 -INFLUXDB_DB=alfalfa -INFLUXDB_HTTP_AUTH_ENABLED=true -INFLUXDB_ADMIN_USER=admin -INFLUXDB_ADMIN_PASSWORD=password -INFLUXDB_HOST=influxdb -GF_SECURITY_ADMIN_USER=admin -GF_SECURITY_ADMIN_PASSWORD=password +S3_BUCKET=alfalfa +S3_URL=http://minio:9000 +S3_URL_EXTERNAL=http://localhost:9000 +VERSION_TAG=latest +WEB_REGISTRY_URI=nrel/alfalfa-web +WORKER_REGISTRY_URI=nrel/alfalfa-worker diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 310aa1df..be2c743e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,11 +77,11 @@ jobs: - name: Run modelica job tests in Docker worker container run: | - docker exec alfalfa_worker_1 bash -c "cd /alfalfa && pytest -m docker tests/jobs/modelica -o log_cli=true -o log_level=info" + docker exec alfalfa_worker bash -c "cd /alfalfa && pytest -m docker tests/jobs/modelica -o log_cli=true -o log_level=info" - name: Run openstudio job tests in Docker worker container run: | - docker exec alfalfa_worker_1 bash -c "cd /alfalfa && pytest -m docker tests/jobs/openstudio -o log_cli=true -o log_level=info" + docker exec alfalfa_worker bash -c "cd /alfalfa && pytest -m docker tests/jobs/openstudio -o log_cli=true -o log_level=info" - name: Dump docker logs on failure if: failure() diff --git a/.gitignore b/.gitignore index a8e9bae8..db710205 100644 --- a/.gitignore +++ b/.gitignore @@ -78,7 +78,6 @@ tests/worker/lib/output *.rdd *.rvaudit *.sql -*.svg *Zsz.csv *Ssz.csv *Meter.csv diff --git a/README.md b/README.md index 8941566c..03c5da5c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Alfalfa -Alfalfa is an open source web application forged in the melting pot of Building Energy Modeling (BEM), Building Controls, and Software Engineering domain expertise.​ Alfalfa transforms a Building Energy Models (BEMs) into virtual buildings by providing industry standard building control interfaces for interacting with models as they run.​ From a software engineering perspective, Alfalfa leverages widely adopted open source products and is architected according to best practices for a robust, modular, and scalable architecture. +Alfalfa is an open source web application forged in the melting pot of Building Energy Modeling (BEM), Building Controls, and Software Engineering domain expertise. Alfalfa transforms Building Energy Models (BEMs) into virtual buildings by providing industry standard building control interfaces for interacting with models as they run. From a software engineering perspective, Alfalfa leverages widely adopted open source products and is architected according to best practices for a robust, modular, and scalable architecture. ## User Documentation diff --git a/alfalfa_web/.babelrc b/alfalfa_web/.babelrc deleted file mode 100644 index 2a74426d..00000000 --- a/alfalfa_web/.babelrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "assumptions": { - "noDocumentAll": true, - "noClassCalls": true - }, - "comments": false, - "plugins": ["@babel/plugin-proposal-class-properties"], - "presets": [ - "@babel/preset-react", - [ - "@babel/preset-env", - { - "corejs": "3.21", - "useBuiltIns": "usage" - } - ], - "minify" - ] -} diff --git a/alfalfa_web/.babelrc.js b/alfalfa_web/.babelrc.js new file mode 100644 index 00000000..66ed1ac5 --- /dev/null +++ b/alfalfa_web/.babelrc.js @@ -0,0 +1,28 @@ +const fs = require("fs"); +if (fs.existsSync("../.env")) require("dotenv").config({ path: "../.env" }); + +const isProd = process.env.NODE_ENV === "production"; + +const presets = [ + "@babel/preset-react", + [ + "@babel/preset-env", + { + corejs: "3.21", + useBuiltIns: "usage" + } + ] +]; + +if (isProd) presets.push(["minify", { builtIns: false }]); + +module.exports = { + assumptions: { + noDocumentAll: true, + noClassCalls: true + }, + comments: false, + plugins: ["@babel/plugin-proposal-class-properties"], + presets, + sourceMaps: isProd ? false : "inline" +}; diff --git a/alfalfa_web/Dockerfile b/alfalfa_web/Dockerfile index ac748bed..3d0ed33a 100644 --- a/alfalfa_web/Dockerfile +++ b/alfalfa_web/Dockerfile @@ -2,8 +2,6 @@ FROM node:16 AS base RUN apt-get update && apt-get install -y \ ca-certificates \ - git \ - vim \ && rm -rf /var/lib/apt/lists/* WORKDIR /srv/alfalfa diff --git a/alfalfa_web/README.md b/alfalfa_web/README.md index adab79de..d77e89e0 100644 --- a/alfalfa_web/README.md +++ b/alfalfa_web/README.md @@ -2,16 +2,15 @@ ## Development -Install and build the packages +Install and build the packages, then run locally using webpack to rebuild the UI as files are modified: ```bash npm install - -npm run build +npm run build-server +npm run start-dev ``` -To run this container locally, start goaws, minio, mc, mongo, and redis. Set the environment variables below in -your local shell. +To run this container locally, start goaws, minio, mc, mongo, and redis. Set the environment variables below in your local shell. ``` export AWS_ACCESS_KEY_ID=user diff --git a/alfalfa_web/alfalfa.svg b/alfalfa_web/alfalfa.svg new file mode 100644 index 00000000..9e265438 --- /dev/null +++ b/alfalfa_web/alfalfa.svg @@ -0,0 +1 @@ + diff --git a/alfalfa_web/components/App/App.js b/alfalfa_web/components/App/App.js index 33eadbdb..242dee6b 100644 --- a/alfalfa_web/components/App/App.js +++ b/alfalfa_web/components/App/App.js @@ -23,8 +23,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************************************************************/ -import AdapterLuxon from "@mui/lab/AdapterLuxon"; -import LocalizationProvider from "@mui/lab/LocalizationProvider"; +import { AdapterLuxon } from "@mui/x-date-pickers/AdapterLuxon"; +import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider"; import { AppBar, Grid, Toolbar, Typography } from "@mui/material"; import { createTheme, ThemeProvider } from "@mui/material/styles"; import { withStyles } from "@mui/styles"; @@ -47,7 +47,7 @@ const styles = { flex: 1 }, button: { - margin: theme.spacing(1) + margin: `${theme.spacing(1)}!important` } }; @@ -66,9 +66,9 @@ class App extends React.Component { Alfalfa - + - + Models @@ -86,8 +86,8 @@ class App extends React.Component { } /> + } /> } /> - } /> diff --git a/alfalfa_web/components/Sims/Sims.js b/alfalfa_web/components/Sims/Sims.js index c0d64f8a..ad98841f 100644 --- a/alfalfa_web/components/Sims/Sims.js +++ b/alfalfa_web/components/Sims/Sims.js @@ -53,6 +53,9 @@ class ResultsDialog extends React.Component { const { sim } = this.props; const items = (content) => { + if (!content) { + return <>; + } return Object.entries(content).map(([key, value]) => { if (key === "energy") { key += " [kWh]"; @@ -157,8 +160,7 @@ class Sims extends React.Component { render = () => { const { classes } = this.props; - if (this.props.data.networkStatus === 1) { - // 1 for loading https://www.apollographql.com/docs/react/api/react-apollo.html#graphql-query-data-networkStatus + if (this.props.data.loading) { return null; } else { const sims = this.props.data.viewer.sims; @@ -181,7 +183,10 @@ class Sims extends React.Component { {sims.map((sim) => { const isSelected = this.isSelected(sim.simRef); return ( - this.handleRowClick(event, sim.simRef)}> + this.handleRowClick(event, sim.simRef)}> @@ -202,7 +207,12 @@ class Sims extends React.Component { - +