Skip to content

Commit

Permalink
Merge pull request #319 from NREL/develop
Browse files Browse the repository at this point in the history
0.3.0 Release
  • Loading branch information
anyaelena authored Jun 30, 2022
2 parents 4944775 + 65b6c81 commit f940fd5
Show file tree
Hide file tree
Showing 47 changed files with 15,938 additions and 8,148 deletions.
35 changes: 18 additions & 17 deletions .env
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ tests/worker/lib/output
*.rdd
*.rvaudit
*.sql
*.svg
*Zsz.csv
*Ssz.csv
*Meter.csv
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
19 changes: 0 additions & 19 deletions alfalfa_web/.babelrc

This file was deleted.

28 changes: 28 additions & 0 deletions alfalfa_web/.babelrc.js
Original file line number Diff line number Diff line change
@@ -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"
};
2 changes: 0 additions & 2 deletions alfalfa_web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions alfalfa_web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions alfalfa_web/alfalfa.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions alfalfa_web/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -47,7 +47,7 @@ const styles = {
flex: 1
},
button: {
margin: theme.spacing(1)
margin: `${theme.spacing(1)}!important`
}
};

Expand All @@ -66,9 +66,9 @@ class App extends React.Component {
Alfalfa
</Typography>
</Link>
<Grid container justifyContent="flex-end" spacing={2}>
<Grid container justifyContent="flex-end" spacing={2} style={{ marginLeft: 0 }}>
<Grid item>
<Link to={"/sites"} style={{ textDecoration: "none", color: "unset" }}>
<Link to={"/models"} style={{ textDecoration: "none", color: "unset" }}>
<Typography className={classes.button} variant="button" color="inherit">
Models
</Typography>
Expand All @@ -86,8 +86,8 @@ class App extends React.Component {
</AppBar>
<Routes>
<Route path="/" element={<Upload />} />
<Route path="models" element={<Sites />} />
<Route path="sims" element={<Sims />} />
<Route path="sites" element={<Sites />} />
</Routes>
</div>
</LocalizationProvider>
Expand Down
20 changes: 15 additions & 5 deletions alfalfa_web/components/Sims/Sims.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]";
Expand Down Expand Up @@ -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;
Expand All @@ -181,7 +183,10 @@ class Sims extends React.Component {
{sims.map((sim) => {
const isSelected = this.isSelected(sim.simRef);
return (
<TableRow key={sim.simRef} onClick={(event) => this.handleRowClick(event, sim.simRef)}>
<TableRow
key={sim.simRef}
style={{ cursor: "default" }}
onClick={(event) => this.handleRowClick(event, sim.simRef)}>
<TableCell padding="checkbox">
<Checkbox checked={isSelected} />
</TableCell>
Expand All @@ -202,7 +207,12 @@ class Sims extends React.Component {
</Table>
</Grid>
<Grid item>
<Grid className={classes.controls} container justifyContent="flex-start" alignItems="center">
<Grid
className={classes.controls}
container
justifyContent="flex-start"
alignItems="center"
style={{ marginLeft: 0, paddingLeft: 16 }}>
<Grid item>
<Button className={classes.button} variant="contained" disabled={true} onClick={this.handleRemove}>
Remove Test Results
Expand Down Expand Up @@ -252,7 +262,7 @@ const styles = (theme) => ({
marginLeft: 16
},
button: {
margin: theme.spacing(1)
margin: `${theme.spacing(1)}!important`
}
});

Expand Down
50 changes: 43 additions & 7 deletions alfalfa_web/components/Sites/PointDialogComponent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
/***********************************************************************************************************************
* Copyright (c) 2008-2022, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.
*
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission from the respective party.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************************************************************/

import { ExpandMore } from "@mui/icons-material";
import {
Accordion,
AccordionDetails,
AccordionSummary,
CircularProgress,
Dialog,
DialogContent,
Expand All @@ -15,20 +42,28 @@ import {
} from "@mui/material";
import React, { useState } from "react";

function mapHaystack(row) {
return Object.keys(row).reduce((result, key) => {
if (Array.isArray(row[key])) {
result[key] = row[key].map((record) => mapHaystack(record));
} else {
result[key] = row[key].replace(/^[a-z]:/, "");
}
return result;
}, {});
}

function PointDialogComponent(props) {
//handleRequestClose = () => {
// this.props.onClosePointsClick();
//}
const { data } = props;

const [expanded, setExpanded] = useState(null);
const [expanded, setExpanded] = useState(false);

const handleChange = (pointId) => (event, expanded) => {
setExpanded(expanded ? pointId : false);
};

const table = () => {
if (props.data.networkStatus === 1) {
// 1 for loading https://www.apollographql.com/docs/react/api/react-apollo.html#graphql-query-data-networkStatus
if (data.loading) {
return (
<Grid container justifyContent="center" alignItems="center">
<Grid item>
Expand All @@ -37,10 +72,11 @@ function PointDialogComponent(props) {
</Grid>
);
} else {
const points = props.data.viewer.sites[0].points;
const points = data.viewer.sites[0].points;
return (
<div>
{points.map((point, i) => {
point = mapHaystack(point);
return (
<Accordion key={i} expanded={expanded === i} onChange={handleChange(i)}>
<AccordionSummary expandIcon={<ExpandMore />}>
Expand Down
Loading

0 comments on commit f940fd5

Please sign in to comment.