Skip to content

Commit

Permalink
place holder for case summary component
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoren committed Oct 25, 2023
1 parent 7c8b827 commit 0e9d548
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 33 deletions.
49 changes: 49 additions & 0 deletions heat-stack/app/components/CaseSummary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export function CaseSummary() {
return (
<div>
<br />
<h1>Winnie Carroll's Case Summary</h1>
<h3>179 Broadway, Somerville, MA 02145, United States</h3>
<ul>
<li>Summary of heat load analysis outputs</li>
<ul>
<li>Avg heat load at design temp: 58,582 BTU/h</li>
<li>Average indoor temperature, Ti: 60.0 F</li>
<li>Standard deviation of UA: 5.08%</li>
</ul>
<br />
<ul>
<li>Max heat load at design temp: 69,783 BTU/h</li>
<li>Design temperature: 8.4 F</li>
<li>Whole-home UA: 1057 BTU/h-F</li>
</ul>
</ul>
</div>
)
}

// export function CaseSummary() {
// }

// return (
// <div>
// {/* <span>time/temp first item: {time}/{temp}</span> */}
// <h1>Winnie Carroll's Case Summary</h1>
// <h3>179 Broadway, Somerville, MA 02145, United States</h3>
// <ul>
// <li>Summary of heat load analysis outputs</li>
// <ul>
// <li>Avg heat load at design temp: 58,582 BTU/h</li>
// <li>Average indoor temperature, Ti: 60.0 F</li>
// <li>Standard deviation of UA: 5.08%</li>
// </ul>
// <br />
// <ul>
// <li>Max heat load at design temp: 69,783 BTU/h</li>
// <li>Design temperature: 8.4 F</li>
// <li>Whole-home UA: 1057 BTU/h-F</li>
// </ul>
// </ul>
// </div>
// )
// }
68 changes: 35 additions & 33 deletions heat-stack/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ import { getToast } from './utils/toast.server.ts'
import { useOptionalUser, useUser } from './utils/user.ts'

import { WeatherExample } from './components/WeatherExample.tsx'
import type { Weather } from './WeatherExample.d.ts';
import { CaseSummary } from './components/CaseSummary.tsx'
import type { Weather } from './WeatherExample.d.ts'

import * as pyodideModule from 'pyodide'
import engine from '../../rules-engine/src/rules_engine/engine.py';
import engine from '../../rules-engine/src/rules_engine/engine.py'

const getPyodide = async () => {
// public folder:
Expand All @@ -74,13 +75,12 @@ const getPyodide = async () => {
}

const runPythonScript = async () => {
const pyodide: any = await getPyodide();
const pyodide: any = await getPyodide()
// console.log(engine);
await pyodide.loadPackage("numpy")
await pyodide.runPythonAsync(engine);
return pyodide;
};

await pyodide.loadPackage('numpy')
await pyodide.runPythonAsync(engine)
return pyodide
}

export const links: LinksFunction = () => {
return [
Expand Down Expand Up @@ -159,8 +159,9 @@ export async function loader({ request }: DataFunctionArgs) {
const { confettiId, headers: confettiHeaders } = getConfetti(request)

// Weather station data
const w_href: string = 'https://archive-api.open-meteo.com/v1/archive?latitude=52.52&longitude=13.41&daily=temperature_2m_max&timezone=America%2FNew_York&start_date=2022-01-01&end_date=2023-08-30&temperature_unit=fahrenheit';
const w_res: Response = await fetch(w_href);
const w_href: string =
'https://archive-api.open-meteo.com/v1/archive?latitude=52.52&longitude=13.41&daily=temperature_2m_max&timezone=America%2FNew_York&start_date=2022-01-01&end_date=2023-08-30&temperature_unit=fahrenheit'
const w_res: Response = await fetch(w_href)
const weather: Weather = (await w_res.json()) as Weather

return json(
Expand Down Expand Up @@ -235,17 +236,17 @@ function Document({
theme?: Theme
env?: Record<string, string>
}) {
const [output, setOutput] = useState<string | null>('(loading python...)');
const [output, setOutput] = useState<string | null>('(loading python...)')

useEffect(() => {
const run = async () => {
const pyodide: any = await runPythonScript();
// console.log(pyodide);
const result = await pyodide.runPythonAsync("hdd(57, 60)");
setOutput(result);
};
run();
}, []);
const pyodide: any = await runPythonScript()
// console.log(pyodide);
const result = await pyodide.runPythonAsync('hdd(57, 60)')
setOutput(result)
}
run()
}, [])
return (
<html lang="en" className={`${theme} h-full overflow-x-hidden`}>
<head>
Expand All @@ -256,21 +257,21 @@ function Document({
<Links />
</head>
<body className="bg-background text-foreground">
<div>
<div>Output:</div>
{output}
</div>
<WeatherExample />
{children}
<script
nonce={nonce}
dangerouslySetInnerHTML={{
__html: `window.ENV = ${JSON.stringify(env)}`,
}}
/>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
<div>
<div>Output:</div>
{output}
</div>
<WeatherExample />
{children}
<script
nonce={nonce}
dangerouslySetInnerHTML={{
__html: `window.ENV = ${JSON.stringify(env)}`,
}}
/>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
</body>
</html>
)
Expand Down Expand Up @@ -311,6 +312,7 @@ function App() {
</header>

<div className="flex-1">
<CaseSummary />
<Outlet />
</div>

Expand Down

0 comments on commit 0e9d548

Please sign in to comment.