Skip to content

Commit

Permalink
Merge pull request #306 from GNS-Science/deploy-test
Browse files Browse the repository at this point in the history
Deploy test
  • Loading branch information
benjamineac authored Dec 7, 2022
2 parents 2990ad0 + f341350 commit bc576e4
Show file tree
Hide file tree
Showing 18 changed files with 5,624 additions and 2,177 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kororaa",
"version": "1.0.4",
"version": "1.0.5",
"private": true,
"dependencies": {
"@emotion/react": "^11.9.0",
Expand Down
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import TechInfoPage from './views/techinfo/TechInfoPage';
import ChangelogPage from './views/changelog/ChangelogPage';
import OtherDocumentsPage from './views/info/OtherDocumentsPage';
import ModelComponentsPage from './views/info/ModelComponentsPage';
import ModelVersionsPage from './views/info/ModelVersionsPage';

// The Home component needs to know how to access the Relay environment, and we
// need to specify a fallback in case it suspends:
Expand Down Expand Up @@ -71,6 +72,7 @@ function App(props: { environment?: Environment }) {
<Route path="/Resources/ScienceReports" element={<ScienceReportsPage />} />
<Route path="/Resources/OtherDocuments" element={<OtherDocumentsPage />} />
<Route path="/Resources/ModelComponents" element={<ModelComponentsPage />} />
<Route path="/Resources/ModelVersions" element={<ModelVersionsPage />} />
<Route path="/" element={<Home />} />
</Routes>
</DisclaimerLayer>
Expand Down
20 changes: 17 additions & 3 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

## [v1.0.4](https://github.com/GNS-Science/kororaa/compare/v1.0.3...v1.0.4)
## [v1.0.5](https://github.com/GNS-Science/kororaa/compare/v1.0.4...v1.0.5)

### Merged

- Feature/287 Nested Hamburger, Update nest (Adds map overlays) [`#295`](https://github.com/GNS-Science/kororaa/pull/295)
- Fix/Cypress MSW [`#307`](https://github.com/GNS-Science/kororaa/pull/307)
- Feature/301 disagg csv [`#305`](https://github.com/GNS-Science/kororaa/pull/305)
- update tech info text; [`#304`](https://github.com/GNS-Science/kororaa/pull/304)
- Feature/290 model versioning [`#298`](https://github.com/GNS-Science/kororaa/pull/298)
- Deploy test [`#296`](https://github.com/GNS-Science/kororaa/pull/296)

### Commits

- update hazard curve MSW mocks; [`3d91e53`](https://github.com/GNS-Science/kororaa/commit/3d91e534a8142158a342b967a12e76c952f797eb)

## [v1.0.4](https://github.com/GNS-Science/kororaa/compare/v1.0.3...v1.0.4) - 2022-11-16

### Merged

- Feature/287 Nested Hamburger [`#295`](https://github.com/GNS-Science/kororaa/pull/295)
- Feature/289_hazard_controls_errors [`#291`](https://github.com/GNS-Science/kororaa/pull/291)
- Deploy test [`#286`](https://github.com/GNS-Science/kororaa/pull/286)

Expand Down Expand Up @@ -42,7 +56,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### Merged

- Fix/120 webpack warnings (#257) [`#266`](https://github.com/GNS-Science/kororaa/pull/266)
- - Fix/120 webpack warnings (#257) [`#266`](https://github.com/GNS-Science/kororaa/pull/266)
- new GA4 code for GNS Science org; [`#265`](https://github.com/GNS-Science/kororaa/pull/265)

### Commits
Expand Down
3 changes: 3 additions & 0 deletions src/components/common/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { styled } from '@mui/material/styles';
import { Link, Grid, Typography } from '@mui/material';
import { Link as RouterLink } from 'react-router-dom';
import { HAZARD_MODEL_VERSION } from '../../utils/environmentVariables';

const FooterContainer = styled('footer')(({ theme }) => ({
width: '100%',
Expand Down Expand Up @@ -48,6 +49,8 @@ const Footer: React.FC = () => {
<Link underline="hover" color="inherit" target="_blank" rel="noopener" href="https://www.building.govt.nz/getting-started/seismic-work-programme/national-seismic-hazard-model">
MBIE for information related to engineering design and the NSHM.
</Link>
<br />
You are viewing version {HAZARD_MODEL_VERSION} of the NSHM.
</em>
</Typography>
</FooterLinkItems>
Expand Down
1 change: 1 addition & 0 deletions src/components/common/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ const NavBar: React.FC = () => {
{ name: 'Science reports', path: '/Resources/ScienceReports' },
{ name: 'Other Documents', path: '/Resources/OtherDocuments' },
{ name: 'Model Components', path: '/Resources/ModelComponents' },
{ name: 'Model Versions', path: '/Resources/ModelVersions' },
],
},
{
Expand Down
7,436 changes: 5,318 additions & 2,118 deletions src/mocks/mockData/HazardChartsPlotsViewMockData.ts

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/services/spectralAccel/spectralAccel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { hazardPageOptions } from '../../views/hazardCharts/constants/hazardPage
import { HazardChartsPlotsViewQuery$data } from '../../views/hazardCharts/__generated__/HazardChartsPlotsViewQuery.graphql';
import { getLatLonFromLocationKey, roundLatLon } from '../latLon/latLon.service';
import { getColor } from '../../utils/colorUtils';
import { SA_LOG_PGA_SUBSTITUTE, HAZARD_IMTS, MEAN, LOWER1, LOWER2, UPPER1, UPPER2 } from '../../utils/environmentVariables';
import { SA_LOG_PGA_SUBSTITUTE, HAZARD_IMTS, MEAN, LOWER1, LOWER2, UPPER1, UPPER2, HAZARD_MODEL_VERSION } from '../../utils/environmentVariables';

export interface UncertaintyCurve {
strokeSize?: number;
Expand Down Expand Up @@ -136,6 +136,7 @@ export const tryParseLatLon = (loc: string): string[] => {
};

export const getSpectralCSVData = (curves: UncertaintyChartData, poe: number | undefined): string[][] => {
const datetimeAndVersion = [`date-time: ${new Date().toLocaleString('en-GB', { timeZone: 'UTC' })}, (UTC)`, `NSHM model version: ${HAZARD_MODEL_VERSION}`];
const saHeaderArray = ['lat', 'lon', 'vs30', 'PoE (% in 50 years)', 'statistic', ...HAZARD_IMTS];
const csvData: string[][] = [];
Object.fromEntries(
Expand All @@ -157,6 +158,7 @@ export const getSpectralCSVData = (curves: UncertaintyChartData, poe: number | u
}),
);
csvData.unshift(saHeaderArray);
csvData.unshift(datetimeAndVersion);
return csvData;
};

Expand Down
1 change: 1 addition & 0 deletions src/utils/environmentVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ export const LOWER2: string = process.env.REACT_APP_LOWER2 || '0.05';

export const GA_ID: string | undefined = process.env.REACT_APP_GA_ID;
export const GA_DEBUG_MODE: boolean = process.env.REACT_APP_GA_DEBUG_MODE === 'true';
export const HAZARD_MODEL_VERSION = 'NSHM_v1.0.0';
6 changes: 5 additions & 1 deletion src/views/changelog/ChangelogPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import { Typography, Grid } from '@mui/material';
import { styled } from '@mui/material/styles';
import CHANGELOG from '../../CHANGELOG.md';
Expand Down Expand Up @@ -46,7 +47,10 @@ const ChangelogPage: React.FC = () => {
<TitleContainer>
<Typography variant="h2">Releases</Typography>
<Typography variant="body1">
<strong>This is a changelog for the NSHM webapp service. The changelog tracks updates only to the web interface and not to the model itself.</strong>
<strong>
This is a changelog for the NSHM webapp service. The changelog tracks updates only to the web interface and not to the model itself. Updates to the model can be found on the{' '}
<Link to={'/Resources/ModelVersions'}>Model Versions page.</Link>
</strong>
</Typography>
</TitleContainer>
</Grid>
Expand Down
14 changes: 13 additions & 1 deletion src/views/disaggregations/DisaggregationsControls.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, { useState, useMemo, useEffect } from 'react';
import { SelectControl } from '@gns-science/toshi-nest';
import { Button } from '@mui/material';

import { DisaggregationsPageQuery$data } from './__generated__/DisaggregationsPageQuery.graphql';
import { DisaggregationsPageState } from './DisaggregationsPageReducer';
import { getVs30Options, getImtOptions, getLocationOptions, getPoeOptions } from './disaggregationPage.service';
import { getVs30Options, getImtOptions, getLocationOptions, getPoeOptions, getReportUrl } from './disaggregationPage.service';
import { readablePoe, readablePoeArray, parsePoeString } from '../hazardMaps/hazardMaps.service';
import CustomControlsBar from '../../components/common/CustomControlsBar';
import { vs30Tooltip, imtTooltip, poeTooltip } from '../../constants/tooltips';
Expand All @@ -29,6 +30,14 @@ export const DisaggregationsControls: React.FC<DisaggregationsControlsProps> = (
dispatch({ vs30, poe, location, imt });
}, [vs30, poe, location, imt, dispatch]);

const handleDownloadCsv = () => {
const csvLink = getReportUrl(data, state);
const link = document.createElement('a');
link.download = `disagg.csv`;
link.href = `https://${csvLink}/data/disagg.csv`;
link.click();
};

return (
<CustomControlsBar direction="column">
<SelectControl name="Location" options={locationOptions.sort()} selection={location} setSelection={setLocation} tooltip={locationTooltip} />
Expand All @@ -41,6 +50,9 @@ export const DisaggregationsControls: React.FC<DisaggregationsControlsProps> = (
setSelection={(newValue: string) => setPoe(parsePoeString(newValue))}
tooltip={poeTooltip}
/>
<Button variant="contained" onClick={handleDownloadCsv}>
Download CSV
</Button>
</CustomControlsBar>
);
};
Expand Down
3 changes: 2 additions & 1 deletion src/views/hazardCharts/HazardChartsSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getSpectralCSVData } from '../../services/spectralAccel/spectralAccel.s
import { getSpectralAccelUncertaintyCurves } from '../../services/spectralAccel/spectralAccel.service';
import { HazardPageState } from './hazardPageReducer';
import { HazardChartsPlotsViewQuery$data } from './__generated__/HazardChartsPlotsViewQuery.graphql';
import { HAZARD_MODEL_VERSION } from '../../utils/environmentVariables';

interface HazardChartsSettingsProps {
data: HazardChartsPlotsViewQuery$data;
Expand Down Expand Up @@ -48,7 +49,7 @@ const HazardChartsSettings: React.FC<HazardChartsSettingsProps> = ({ data, spect
}
toPng(element, { quality: 0.95 }).then((dataUrl: string) => {
const link = document.createElement('a');
link.download = spectral ? `UHS_${state.poe}_in_50yr.png` : 'hazard_chart.png';
link.download = spectral ? `UHS_${state.poe}_in_50yr-${HAZARD_MODEL_VERSION}.png` : `hazard_chart-${HAZARD_MODEL_VERSION}.png`;
link.href = dataUrl;
link.click();
});
Expand Down
4 changes: 3 additions & 1 deletion src/views/hazardCharts/hazardPage.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { roundLatLon } from '../../services/latLon/latLon.service';
import { HAZARD_COLOR_LIMIT } from '../../utils/environmentVariables';
import { HAZARD_COLOR_LIMIT, HAZARD_MODEL_VERSION } from '../../utils/environmentVariables';

import { tooManyCurves, noLocations, noImts, noVs30s } from './constants/hazardCharts';
import { hazardPageLocations } from './constants/hazardPageOptions';
Expand Down Expand Up @@ -74,6 +74,7 @@ export const getFilteredCurveGroups = (curveGroups: HazardUncertaintyChartData,
};

export const getHazardCSVData = (data: HazardChartsPlotsViewQuery$data): string[][] => {
const datetimeAndVersion = [`date-time: ${new Date().toLocaleString('en-GB', { timeZone: 'UTC' })}, (UTC)`, `NSHM model version: ${HAZARD_MODEL_VERSION}`];
const CSVData = data.hazard_curves?.curves?.map((curve) => {
const latLonArray = curve?.loc?.split('~');
if (latLonArray && curve?.curve?.values && curve?.vs30) {
Expand All @@ -96,6 +97,7 @@ export const getHazardCSVData = (data: HazardChartsPlotsViewQuery$data): string[
});
}
CSVData.unshift(headings);
CSVData.unshift(datetimeAndVersion);
}
return CSVData as string[][];
};
Expand Down
4 changes: 2 additions & 2 deletions src/views/hazardMaps/HazardMapsControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { flexParentCenter } from '../../utils/styleUtils';
import { getHazardMapCSVData } from './hazardMaps.service';
import { HazardMapsState } from './hazardMapReducer';
import CustomControlsBar from '../../components/common/CustomControlsBar';
import { MAP_IMTS, MAP_POES, MAP_STATISTICS, MAP_VS30S, MAP_GRID_STYLE_DEFAULT, MAP_GRID_VMAX, MAP_GRID_STROKE_WIDTH } from '../../utils/environmentVariables';
import { MAP_IMTS, MAP_POES, MAP_STATISTICS, MAP_VS30S, MAP_GRID_STYLE_DEFAULT, MAP_GRID_VMAX, MAP_GRID_STROKE_WIDTH, HAZARD_MODEL_VERSION } from '../../utils/environmentVariables';

import StyledCSVLink from '../../components/common/StyledCSVLink';
import { parsePoeString, readablePoe, readablePoeArray } from './hazardMaps.service';
Expand Down Expand Up @@ -69,7 +69,7 @@ const HazardMapsControls: React.FC<HazardMapsControlsProps> = ({ startTransition
}
toPng(element, { quality: 0.95 }).then((dataUrl: string) => {
const link = document.createElement('a');
link.download = `hazard map.png`;
link.download = `hazard map-${HAZARD_MODEL_VERSION}.png`;
link.href = dataUrl;
link.click();
});
Expand Down
3 changes: 3 additions & 0 deletions src/views/hazardMaps/hazardMaps.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { HAZARD_MODEL_VERSION } from '../../utils/environmentVariables';
export interface ColorScale {
levels: number[];
hexrgbs: (string | undefined)[];
}

export const getHazardMapCSVData = (data: string[], vs30: number, imt: string, poe: string, statistic: string) => {
const datetimeAndVersion = [`date-time: ${new Date().toLocaleString('en-GB', { timeZone: 'UTC' })}, (UTC)`, `NSHM model version: ${HAZARD_MODEL_VERSION}`];
const csvData: (number | string)[][] = [
[`vs30=${vs30}`, `spectral period=${imt}`, `Poe=${poe}`, `Statistic=${statistic}`],
['lon', 'lat', 'shaking intensity(g)'],
Expand All @@ -20,6 +22,7 @@ export const getHazardMapCSVData = (data: string[], vs30: number, imt: string, p
csvData.push([feature.properties.loc[0], feature.properties.loc[1], feature.properties.value.toFixed(2)]);
});
});
csvData.unshift(datetimeAndVersion);
return csvData;
};

Expand Down
79 changes: 79 additions & 0 deletions src/views/info/ModelVersionsPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React, { useMemo } from 'react';
import { styled } from '@mui/material/styles';
import Grid from '@mui/material/Grid';
import ReactMarkdown from 'react-markdown';
import { graphql } from 'babel-plugin-relay/macro';
import { useLazyLoadQuery } from 'react-relay';
import { ModelVersionsPageQuery } from './__generated__/ModelVersionsPageQuery.graphql';
import SimpleBackdrop from '../../components/common/SimpleBackdrop';

import { Typography } from '@mui/material';

const PageContainer = styled('div')({
justifyContent: 'center',
alignItems: 'center',
padding: '2rem',
marginBottom: '2rem',
});

const TitleContainer = styled('div')({
justifyContent: 'left',
textAlign: 'left',
width: '100%',
paddingBottom: '1rem',
});

const ModelVersionsComponent: React.FC = () => {
const data = useLazyLoadQuery<ModelVersionsPageQuery>(modelVersionsPageQuery, {});
const markdown = useMemo(() => data?.textual_content?.content && data?.textual_content?.content[0]?.text, [data]);

return (
<PageContainer>
<Grid container columns={{ sm: 6, md: 8, lg: 12 }}>
<Grid item xs={2} />
<Grid item xs={8}>
<Grid container spacing={2} columns={{ sm: 6, md: 8, lg: 12 }}>
<Grid item xs={12}>
<TitleContainer>
<Typography variant="h2">Model Versions</Typography>
<Typography variant="body1">
<strong>This is a log of the NSHM versions. Updates to the model are recorded here.</strong>
</Typography>
</TitleContainer>
</Grid>
<Grid item xs={12}>
<ReactMarkdown>{markdown?.replace('Changelog', '') || ''}</ReactMarkdown>
</Grid>
</Grid>
</Grid>
<Grid item xs={2} />
</Grid>
</PageContainer>
);
};

const ModelVersionsPage: React.FC = () => {
return (
<React.Suspense fallback={<SimpleBackdrop />}>
<ModelVersionsComponent />
</React.Suspense>
);
};

export const modelVersionsPageQuery = graphql`
query ModelVersionsPageQuery {
textual_content(index: "CHANGELOG.md") {
ok
content {
index
content_type
text
created
author
tags
status
}
}
}
`;
export default ModelVersionsPage;
Loading

0 comments on commit bc576e4

Please sign in to comment.