Skip to content

Commit

Permalink
Merge pull request #64 from NCAR/main
Browse files Browse the repository at this point in the history
Merge Main into Deployment
  • Loading branch information
JoshHare authored Nov 15, 2024
2 parents 0bb54b5 + 40719c5 commit 2768e34
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 111 deletions.
72 changes: 65 additions & 7 deletions backend/Services/OpenAtmosService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public async Task<byte[]> GetMusicboxJSON(Guid mechanismId)
speciesJson.AppendLine($" \"__description\": \"{species.Description}\"");
speciesJson.AppendLine(" },");
}
if (speciesList.Any()) speciesJson.Length -= 3; // Remove trailing comma and newline
if (speciesList.Any()) speciesJson.Length -= 2; // Remove trailing comma and newline
speciesJson.AppendLine();
speciesJson.AppendLine(" ]");
speciesJson.AppendLine("}");
Expand Down Expand Up @@ -242,7 +242,7 @@ public async Task<byte[]> GetMusicboxJSON(Guid mechanismId)
{
reactionsJson.AppendLine($" \"{reactant.SpeciesName}\": {{ }},");
}
if (reactants.Any()) reactionsJson.Length -= 1; // Remove trailing comma
if (reactants.Any()) reactionsJson.Length -= 2; // Remove trailing comma
reactionsJson.AppendLine();
reactionsJson.AppendLine(" },"); // Close reactants

Expand All @@ -253,46 +253,104 @@ public async Task<byte[]> GetMusicboxJSON(Guid mechanismId)
{
reactionsJson.AppendLine($" \"{product.SpeciesName}\": {{ }},");
}
if (products.Any()) reactionsJson.Length -= 1; // Remove trailing comma
if (products.Any()) reactionsJson.Length -= 2; // Remove trailing comma
reactionsJson.AppendLine();
reactionsJson.AppendLine(" }"); // Close products

reactionsJson.AppendLine(" },"); // Close reaction
}
if (reactionList.Any()) reactionsJson.Length -= 1; // Remove trailing comma
if (reactionList.Any()) reactionsJson.Length -= 2; // Remove trailing comma
reactionsJson.AppendLine();
reactionsJson.AppendLine(" ]");
reactionsJson.AppendLine(" }");
reactionsJson.AppendLine(" ]");
reactionsJson.AppendLine("}");

//my_config file
var myConfigJson = new StringBuilder();
myConfigJson.AppendLine("{");
myConfigJson.AppendLine(" \"box model options\": {");
myConfigJson.AppendLine(" \"grid\": \"box\",");
myConfigJson.AppendLine(" \"chemistry time step [min]\": 1.0,");
myConfigJson.AppendLine(" \"output time step [min]\": 1.0,");
myConfigJson.AppendLine(" \"simulation length [hr]\": 3.0");
myConfigJson.AppendLine(" },");
myConfigJson.AppendLine(" \"chemical species\": {");

// Add species with initial values
foreach (var species in speciesList)
{
myConfigJson.AppendLine($" \"{species.Name}\": {{");
myConfigJson.AppendLine($" \"initial value [mol m-3]\": 1.0e-09");
myConfigJson.AppendLine(" },");
}
if (speciesList.Any()) myConfigJson.Length -= 2; // Remove trailing comma and newline
myConfigJson.AppendLine();
myConfigJson.AppendLine(" },");
myConfigJson.AppendLine(" \"environmental conditions\": {");
myConfigJson.AppendLine(" \"temperature\": {");
myConfigJson.AppendLine(" \"initial value [K]\": 298.15");
myConfigJson.AppendLine(" },");
myConfigJson.AppendLine(" \"pressure\": {");
myConfigJson.AppendLine(" \"initial value [Pa]\": 101325.0");
myConfigJson.AppendLine(" }");
myConfigJson.AppendLine(" },");
myConfigJson.AppendLine(" \"evolving conditions\": {},");
myConfigJson.AppendLine(" \"initial conditions\": {");
// myConfigJson.AppendLine(" \"initial_reaction_rates.csv\": {}"); --when initial conditions are implemented, use this
myConfigJson.AppendLine(" },");
myConfigJson.AppendLine(" \"model components\": [");
myConfigJson.AppendLine(" {");
myConfigJson.AppendLine(" \"type\": \"CAMP\",");
myConfigJson.AppendLine(" \"configuration file\": \"camp_data/config.json\",");
myConfigJson.AppendLine(" \"override species\": {");
myConfigJson.AppendLine(" \"M\": {");
myConfigJson.AppendLine(" \"mixing ratio mol mol-1\": 1.0");
myConfigJson.AppendLine(" }");
myConfigJson.AppendLine(" },");
myConfigJson.AppendLine(" \"suppress output\": {");
myConfigJson.AppendLine(" \"M\": {}");
myConfigJson.AppendLine(" }");
myConfigJson.AppendLine(" }");
myConfigJson.AppendLine(" ]");
myConfigJson.AppendLine("}");

// Create ZIP file in memory
using (var memoryStream = new MemoryStream())
{
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
{
var campDataFolder = archive.CreateEntry("camp_data/");

// Add species.json to ZIP
var speciesEntry = archive.CreateEntry("species.json");
var speciesEntry = archive.CreateEntry("camp_data/species.json");
using (var entryStream = speciesEntry.Open())
using (var writer = new StreamWriter(entryStream))
{
writer.Write(speciesJson.ToString());
}

// Add reactions.json to ZIP
var reactionsEntry = archive.CreateEntry("reactions.json");
var reactionsEntry = archive.CreateEntry("camp_data/reactions.json");
using (var entryStream = reactionsEntry.Open())
using (var writer = new StreamWriter(entryStream))
{
writer.Write(reactionsJson.ToString());
}

var configEntry = archive.CreateEntry("config.json");
var configEntry = archive.CreateEntry("camp_data/config.json");
using (var entryStream = configEntry.Open())
using (var writer = new StreamWriter(entryStream))
{
writer.Write("{\"camp-files\": [\"species.json\", \"reactions.json\"]}");
}

var myconfigEntry = archive.CreateEntry("my_config.json");
using (var entryStream = myconfigEntry.Open())
using (var writer = new StreamWriter(entryStream))
{
writer.Write(myConfigJson.ToString());
}
}

// Return the ZIP file as a byte array
Expand Down
60 changes: 51 additions & 9 deletions frontend/src/components/HeaderFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Paper from "@mui/material/Paper";
import Container from "@mui/material/Container";
import DensitySmallSharpIcon from "@mui/icons-material/DensitySmallSharp";
import { useAuth } from "../pages/AuthContext";
// import Modal from '@mui/material/Modal';
// import Typography from '@mui/material/Typography';
import Modal from '@mui/material/Modal';
import Typography from '@mui/material/Typography';

export const Header = () => {
const [openDrawer, setOpenDrawer] = useState(false);
Expand Down Expand Up @@ -82,12 +82,10 @@ export const Footer = () => {
window.open("https://www.ucar.edu/accessibility", "_blank");
};

const [, setAboutOpen] = useState(false);
const handleAboutOpen = () => setAboutOpen(true);
const handleAbout = () => {
handleAboutOpen();
};
const [aboutOpen, setAboutOpen] = useState(false);

const handleAboutOpen = () => setAboutOpen(true);
const handleAboutClose = () => setAboutOpen(false);

return (
<Paper component="footer" square={true} variant="outlined">
Expand All @@ -98,7 +96,7 @@ export const Footer = () => {
sx={{ height: "80px", width: "auto", pr: 10 }}
></Box>
<Box sx={{ pr: 10 }}>
<Button onClick={handleAbout}>About</Button>
<Button onClick={handleAboutOpen}>About</Button>
</Box>
<Box sx={{ pr: 10 }}>
<Button onClick={handleBugClick} variant="text">
Expand All @@ -109,6 +107,50 @@ export const Footer = () => {
<Button onClick={handleAccessibilityClick}>Accessibility</Button>
</Box>
</Container>

{/* Modal for About */}
<Modal open={aboutOpen} onClose={handleAboutClose}>
<Box
sx={{
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
bgcolor: "background.paper",
boxShadow: 24,
p: 4,
borderRadius: 2,
textAlign: "center",
}}
>
<Typography variant="h4">About</Typography>
<Box
component="img"
src={"src/assets/NSF-NCAR_Lockup-UCAR-Dark.png"}
alt={"Texas A&M"}
sx={{ height: "100px", width: "auto" }}
/>
<Box
component="img"
src={"src/assets/TAMULogo.png"}
alt={"Texas A&M"}
sx={{ height: "100px", width: "auto" }}
/>
<Typography variant="body1">
The Chemistry Cafe tool was made possible by the collaboration
between NCAR and Texas A&M through the CSCE Capstone program.
</Typography>
<p></p>
<Typography variant="h6">Credits</Typography>
<Typography variant="body1">
Paul Cyr, Brandon Longuet, Brian Nguyen <br></br> Spring 2024
Capstone Team <br></br> <p></p>
Britt Schiller, Ore Ogunleye, Nishka Mittal, Josh Hare, Sydney Ferris <br></br> Fall 2024
Capstone Team <br></br> <p></p>
Kyle Shores <br></br> Spring 2024 Capstone Sponsor Representative
</Typography>
</Box>
</Modal>
</Paper>
);
};
};
28 changes: 8 additions & 20 deletions frontend/src/pages/logIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useAuth } from "../pages/AuthContext"; // Import the AuthContext
import "../styles/logIn.css";
import Button from "@mui/material/Button";
import Box from "@mui/material/Box";
import Modal from "@mui/material/Modal";
//import Modal from "@mui/material/Modal";
import Typography from "@mui/material/Typography";
import GoogleIcon from "@mui/icons-material/Google";
import NoAccountsIcon from "@mui/icons-material/NoAccounts";
Expand All @@ -31,13 +31,9 @@ const LogIn = () => {
const [profile, setProfile] = useState<Profile | null>(null);
const navigate = useNavigate();
const handleClick = () => navigate("/LoggedIn");
const [aboutOpen, setAboutOpen] = useState(false);
const handleAboutOpen = () => setAboutOpen(true);
const handleAboutClose = () => setAboutOpen(false);


const handleAbout = () => {
handleAboutOpen();
};


const login = useGoogleLogin({
onSuccess: (codeResponse) => {
Expand Down Expand Up @@ -127,17 +123,7 @@ const LogIn = () => {
setUser(null); // Clear user from AuthContext on logout
};

const style = {
position: "absolute" as const,
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
width: 400,
bgcolor: "background.paper",
border: "2px solid #000",
boxShadow: 24,
p: 4,
};


return (
<section className="layoutLogIn">
Expand Down Expand Up @@ -211,7 +197,7 @@ const LogIn = () => {
Continue as Guest
</Button>
</div>
<div className="M7">
{/* <div className="M7">
<Button variant="contained" onClick={handleAbout} sx={{ width: "50%" }}>
About
</Button>
Expand Down Expand Up @@ -241,11 +227,13 @@ const LogIn = () => {
<Typography variant="body1">
Paul Cyr, Brandon Longuet, Brian Nguyen <br></br> Spring 2024
Capstone Team <br></br> <p></p>
Britt Schiller, Ore Ogunleye, Nishka Mittal, Josh Hare, Sydney Ferris <br></br> Fall 2024
Capstone Team <br></br> <p></p>
Kyle Shores <br></br> Spring 2024 Capstone Sponsor Representative
</Typography>
</Box>
</Modal>
</div>
</div> */}
<div className="L9LogIn">
<Footer></Footer>
</div>
Expand Down
Loading

0 comments on commit 2768e34

Please sign in to comment.