Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
Erikvv committed Dec 19, 2024
2 parents 8972760 + 29c1a48 commit 42d07af
Show file tree
Hide file tree
Showing 30 changed files with 2,283 additions and 3,689 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
node-version: 23
cache: npm
cache-dependency-path: ./frontend/package-lock.json
- run: npm install
Expand Down
4 changes: 3 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,11 @@ services:
}
npm:
image: node:22
image: node:23
working_dir: /app/frontend
volumes:
- .:/app
- npm-cache:/root/.npm
entrypoint: npm
environment:
VITE_ZTOR_URL: http://localhost:8082
Expand Down Expand Up @@ -255,4 +256,5 @@ volumes:
gradle-test-cache:
gradle-run-cache:
gradle-cmd-cache:
npm-cache:
postgres:
5,184 changes: 1,729 additions & 3,455 deletions frontend/package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"@emotion/babel-plugin": "^11.11.0",
"@emotion/react": "^11.11.1",
"@geoman-io/leaflet-geoman-free": "^2.17.0",
"@js-joda/core": "^5.6.3",
"@js-joda/timezone": "^2.21.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
Expand Down Expand Up @@ -65,11 +67,11 @@
"@babel/preset-env": "^7.22.10",
"@babel/preset-react": "^7.22.5",
"@types/leaflet": "^1.9.12",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react": "^4.3.4",
"babel-jest": "^29.6.2",
"jest": "^29.6.2",
"process": "^0.11.10",
"react-test-renderer": "^18.2.0",
"vite": "^5.3.1"
"vite": "^6.0.1"
}
}
2 changes: 1 addition & 1 deletion frontend/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {render, screen} from '@testing-library/react'
import React from 'react'
import App from './App'
import {App} from './App'

test('renders learn react link', () => {
render(<App/>)
Expand Down
62 changes: 10 additions & 52 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,54 +1,12 @@
import 'leaflet/dist/leaflet.css'
import React, {createElement as h, useState} from 'react'
import './App.css'
import {AggregatedAreaData} from './components/aggregated-area-data'
import {AnyLogic} from './components/any-logic'
import {BuurtPicker} from './components/buurt-picker'
import {MainMap} from './components/main-map'
import {PandDataDisplay} from './components/pand-display'
import {useApp} from './services/appState'
import {assertDefined} from './services/util'
import {Buurt} from './services/wijkenbuurten/buurten'
import {ZeroLayout} from "./components/zero-layout"

function App() {
const appHook = useApp()
const {setGeometry, getPandData, bag2dPanden} = appHook

const [currentPandId, setCurrentPandId] = useState('')

const [buurt, setBuurt] = useState<Buurt | undefined>()
import React, {FunctionComponent} from 'react'
import {ZeroHeader} from "./components/zero-header";
import {Outlet} from "react-router-dom";

export const App: FunctionComponent = () => {
return (
<ZeroLayout subtitle="Simuleer je buurt">
{/* Three-column layout*/}
<div style={{display: "flex"}}>
<div style={{width: '20rem', padding: '1rem', paddingTop: '5rem'}}>
{h(AggregatedAreaData, {appHook: appHook})}
<BuurtPicker onSelectBuurt={buurt => {
setBuurt(buurt)
setGeometry(buurt.geometry)
}}/>
</div>
<div style={{
height: '100vh',
flexGrow: 1,
display: 'flex',
flexDirection: 'column',
}}>
<MainMap bag2dPanden={bag2dPanden}
setGeometry={setGeometry}
setCurrentPandId={setCurrentPandId}
buurt={buurt} />
<AnyLogic appHook={appHook}/>
</div>
<div style={{width: '20rem', padding: '1rem'}}>
{currentPandId && getPandData(currentPandId) &&
<PandDataDisplay pandData={assertDefined(getPandData(currentPandId))}/>}
</div>
</div>
</ZeroLayout>
)
}

export default App
<>
<ZeroHeader />
<Outlet />
</>
);
};
8 changes: 4 additions & 4 deletions frontend/src/admin/import-excel-button.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {FunctionComponent} from "react"
import {useNavigate} from "react-router-dom"
import {Button} from "primereact/button"
import { SiMicrosoftexcel } from "react-icons/si";
import {PiMicrosoftExcelLogoFill} from "react-icons/pi"

export const ImportExcelButton: FunctionComponent = () => {
const navigate = useNavigate()

return (
<Button onClick={() => navigate("/admin/import-excel")} aria-label="Importeer Excel">
<SiMicrosoftexcel />
<Button onClick={() => navigate("/admin/import-excel")} aria-label="Importeer Excel" style={{padding: "0 1em"}}>
<PiMicrosoftExcelLogoFill size="1.6rem" />
&nbsp;
Importeer Excel
</Button>
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {ZeroLayout} from "../components/zero-layout"
import {AdminButtonRow} from "./admin-button-row"
import {SurveyIncludeInSimulationCheckbox} from "./survey-include-in-simulation-checkbox"

export const Admin: FunctionComponent = () => {
export const Surveys: FunctionComponent = () => {
const {loading, surveys, changeSurvey, removeSurvey} = useSurveys()

const multipleProjects = surveys.map(survey => survey.zenmoProject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {ProjectConfiguration} from './project'
export enum ConsumptionSpec {
PLACEHOLDER_AUTHORIZATION = "PLACEHOLDER_AUTHORIZATION",
PDF_AUTHORIZATION = "PDF_AUTHORIZATION",
TEXTAREA = "TEXTAREA",
// Option unused as we have not automated this proces
UPLOAD_QUARTER_HOURLY_VALUES = "UPLOAD_QUARTER_HOURLY_VALUES",
// Option removed as per feedback
// ANNUAL_VALUES = "ANNUAL_VALUES",
Expand All @@ -12,6 +14,7 @@ export enum ConsumptionSpec {
const labels = {
[ConsumptionSpec.PLACEHOLDER_AUTHORIZATION]: "Ik wil jullie machtigen voor het ophalen van de meetdata",
[ConsumptionSpec.PDF_AUTHORIZATION]: "Ik wil jullie machtigen voor het ophalen van de meetdata",
[ConsumptionSpec.TEXTAREA]: "Kwartierwaarden plakken",
[ConsumptionSpec.UPLOAD_QUARTER_HOURLY_VALUES]: "Kwartierwaarden uploaden",
// [ConsumptionSpec.ANNUAL_VALUES]: "Jaarverbruik invullen",
}
Expand All @@ -32,9 +35,9 @@ export const ElectricityConsumptionRadios = ({onChange, consumptionSpec, project
Ik wil jullie machtigen voor het ophalen van de meetdata
</Radio>
}
<Radio value={ConsumptionSpec.UPLOAD_QUARTER_HOURLY_VALUES}>
Kwartierwaarden uploaden
<Radio value={ConsumptionSpec.TEXTAREA}>
Ik wil kwartierwaarden kopiëren en plakken
</Radio>
</Radio.Group>
)
}
}
18 changes: 11 additions & 7 deletions frontend/src/components/company-survey-v2/electricity-data.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {useState} from 'react'
import {UseFormReturn} from 'react-hook-form'
import {ConsumptionSpec, ElectricityConsumptionRadios} from './electricity-consumption-radios'
import {LabelRow} from './generic/label-row'
import {Purpose, Upload} from './generic/upload'
import {ProjectConfiguration} from './project'
import {useState} from "react"
import {UseFormReturn} from "react-hook-form"
import {ConsumptionSpec, ElectricityConsumptionRadios} from "./electricity-consumption-radios"
import {LabelRow} from "./generic/label-row"
import {Purpose, Upload} from "./generic/upload"
import {ProjectConfiguration} from "./project"
import {TimeSeriesElectricity} from "./time-series/time-series-electricity"

export const ElectricityData = ({form, prefix, project}: {
form: UseFormReturn,
Expand Down Expand Up @@ -62,6 +63,9 @@ export const ElectricityData = ({form, prefix, project}: {
purpose={Purpose.ELECTRICITY_AUTHORIZATION} />
</LabelRow>
)}
{consumptionSpec === ConsumptionSpec.TEXTAREA && (
<TimeSeriesElectricity form={form} prefix={prefix} />
)}
{/*{consumptionSpec === ConsumptionSpec.ANNUAL_VALUES && (*/}
{/* <>*/}
{/* <NumberRow*/}
Expand All @@ -80,4 +84,4 @@ export const ElectricityData = ({form, prefix, project}: {
{/*)}*/}
</>
)
}
}
54 changes: 26 additions & 28 deletions frontend/src/components/company-survey-v2/generic/label-row.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
import {css} from '@emotion/react'
import {PropsWithChildren} from 'react'
import {FunctionComponent, PropsWithChildren} from "react"
import {flash} from '../flash'

export const LabelRow = ({label, children}: PropsWithChildren<{label: any}>) => {
return (
<label css={[css`
display: flex;
`, flash]}>
<div css={css`
text-align: right;
width: 50%;
padding: 0.3rem;
export const LabelRow: FunctionComponent<PropsWithChildren<{ label: any }>> = ({label, children}) => (
<label css={[css`
display: flex;
`, flash]}>
<div css={css`
text-align: right;
width: 50%;
padding: 0.3rem;
display: flex;
flex-direction: column;
justify-content: center;
`}>
{label}
</div>
<div css={css`
width: 50%;
padding: 0.3rem;
display: flex;
flex-direction: column;
justify-content: center;
`}>
{label}
</div>
<div css={css`
width: 50%;
padding: 0.3rem;
display: flex;
flex-direction: column;
justify-content: center;
`}>
{children}
</div>
</label>
)
}
display: flex;
flex-direction: column;
justify-content: center;
`}>
{children}
</div>
</label>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {targetYear} from "./time-series-util"
import {TimeSeriesTextareaAdapter} from "./time-series-textarea-adapter"
import {FunctionComponent} from "react"
import {UseFormReturn} from "react-hook-form"
import {TimeSeriesType} from "zero-zummon"

export const TimeSeriesElectricity: FunctionComponent<{form: UseFormReturn, prefix: string}> = ({form, prefix}) => {
return (
<>
<h2>2. Kwartierwaarden electriciteit</h2>

<p>Richtlijnen</p>

<ul>
<li>Geef waarden op van het gehele jaar {targetYear}.</li>
<li>De eerste waarde betreft het verbruik in het kwartier van 1 januari {targetYear} van 00:00
tot 00:15 CET.
</li>
<li>De laatste waarde betreft het verbruik in het kwartier van 31 december {targetYear} 23:45
tot 1 januari {targetYear + 1} om 00:00 CET.
</li>
<li>Een langere periode mag.</li>
</ul>
<h3>Kwartierwaarden levering</h3>
<TimeSeriesTextareaAdapter
timeSeries={form.watch(`${prefix}.quarterHourlyDelivery_kWh`)}
timeSeriesType={TimeSeriesType.ELECTRICITY_DELIVERY}
setTimeSeries={timeSeries => form.setValue(`${prefix}.quarterHourlyDelivery_kWh`, timeSeries)} />
<h3>Kwartierwaarden teruglevering</h3>
<TimeSeriesTextareaAdapter
timeSeries={form.watch(`${prefix}.quarterHourlyFeedIn_kWh`)}
timeSeriesType={TimeSeriesType.ELECTRICITY_FEED_IN}
setTimeSeries={timeSeries => form.setValue(`${prefix}.quarterHourlyFeedIn_kWh`, timeSeries)} />
<h3>Kwartierwaarden brutoproductiemeter</h3>
<TimeSeriesTextareaAdapter
timeSeries={form.watch(`${prefix}.quarterHourlyProduction_kWh`)}
timeSeriesType={TimeSeriesType.ELECTRICITY_PRODUCTION}
setTimeSeries={timeSeries => form.setValue(`${prefix}.quarterHourlyProduction_kWh`, timeSeries)} />
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {FunctionComponent} from "react"
import {targetYear} from "./time-series-util"
import {TimeSeries, TimeSeriesType, timeSeriesFromJson, createEmptyTimeSeriesForYear} from "zero-zummon"
import {TimeSeriesTextarea} from "./time-series-textarea"

/**
* Has a plain JS object as input and output.
* Converts that objects to a {@link TimeSeries} domain object for use in {@link TimeSeriesTextarea}
*/
export const TimeSeriesTextareaAdapter: FunctionComponent<{
timeSeries?: any,
timeSeriesType?: TimeSeriesType,
setTimeSeries?: (obj: any) => void
}> = ({
timeSeries,
timeSeriesType = TimeSeriesType.ELECTRICITY_DELIVERY,
setTimeSeries = console.log,
}) => {
const timeSeriesDomainObject = timeSeries ? timeSeriesFromJson(JSON.stringify(timeSeries)) : createEmptyTimeSeriesForYear(timeSeriesType, targetYear)

return (
<TimeSeriesTextarea
timeSeries={timeSeriesDomainObject} setTimeSeries={(timeSeries: TimeSeries) => {
setTimeSeries(JSON.parse(timeSeries.toJson()))
}} />
)
}
Loading

0 comments on commit 42d07af

Please sign in to comment.