Skip to content

Commit

Permalink
Refactor water sampling card (#901)
Browse files Browse the repository at this point in the history
  • Loading branch information
echaidemenos authored Aug 4, 2023
1 parent b920308 commit 88bb66e
Show file tree
Hide file tree
Showing 11 changed files with 602 additions and 505 deletions.
1 change: 1 addition & 0 deletions packages/api/src/data-uploads/data-uploads.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ export class DataUploadsService {

async deleteDataUploads({ ids }: DataUploadsDeleteDto) {
await this.dataUploadsRepository.delete({ id: In(ids) });
this.dataUploadsRepository.query('REFRESH MATERIALIZED VIEW latest_data');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ const MultipleSensorsCharts = ({
...huiRanges.map((x) => x.metric),
];

const uniqueMetrics = [...new Map(allMetrics.map((x) => [x, x])).keys()];

setAvailableSources(
[
spotterRanges.length > 0 && 'spotter',
Expand All @@ -297,8 +299,6 @@ const MultipleSensorsCharts = ({
].filter((x): x is Sources => x !== false),
);

const uniqueMetrics = [...new Map(allMetrics.map((x) => [x, x])).keys()];

const siteLocalStartDate = setTimeZone(
new Date(pickerStartDate),
site.timezone,
Expand Down
228 changes: 0 additions & 228 deletions packages/website/src/common/SiteDetails/HUICard/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ exports[`Sensor Card should render with given state from Redux store 1`] = `
classname="Sensor-content-10"
>
<div
style="display: grid; gap: 1rem; grid-template-areas: 'value0 image' 'spacer image' 'value1 image'; padding: 1rem;"
style="display: grid; gap: 1rem; grid-template-areas: 'value0 image' 'spacer1 image' 'value1 image'; padding: 1rem;"
>
<div
style="grid-area: value0;"
Expand Down Expand Up @@ -73,7 +73,10 @@ exports[`Sensor Card should render with given state from Redux store 1`] = `
</mock-typography>
</div>
<div
style="grid-area: spacer; display: inherit; min-height: 2em;"
style="grid-area: spacer1; display: inherit; min-height: 2em;"
/>
<div
style="grid-area: spacer2; display: inherit;"
/>
<div
style="grid-area: image; position: relative;"
Expand Down
26 changes: 16 additions & 10 deletions packages/website/src/common/SiteDetails/Sensor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ const Sensor = ({ depth, id, data, classes }: SensorProps) => {
if (surfaceTemperature)
return "'value3 image' 'value0 image' 'value1 image'";
if (barometricPressureTop)
return "'value0 image' 'value1 image' 'value2 value4'";
return "'value0 image' 'spacer image' 'value1 image'";
return "'value0 image' 'spacer1 image' 'value1 image' 'spacer2 image' 'value2 value4'";
return "'value0 image' 'spacer1 image' 'value1 image'";
};

const getImageHeight = () => {
Expand All @@ -119,11 +119,11 @@ const Sensor = ({ depth, id, data, classes }: SensorProps) => {
return '150';
};

const getSpaceDisplay = () => {
if (barometricPressureTop && surfaceTemperature) return 'none';
if (surfaceTemperature) return 'none';
if (barometricPressureTop) return 'none';
return 'inherit';
const getSpace1Height = () => {
if (barometricPressureTop && surfaceTemperature) return 'inherit';
if (surfaceTemperature) return 'inherit';
if (barometricPressureTop) return 'inherit';
return '2em';
};

return (
Expand Down Expand Up @@ -188,9 +188,15 @@ const Sensor = ({ depth, id, data, classes }: SensorProps) => {
)}
<div
style={{
gridArea: 'spacer',
display: getSpaceDisplay(),
minHeight: '2em',
gridArea: 'spacer1',
display: 'inherit',
minHeight: getSpace1Height(),
}}
/>
<div
style={{
gridArea: 'spacer2',
display: 'inherit',
}}
/>
{surfaceTemperature && (
Expand Down
Loading

0 comments on commit 88bb66e

Please sign in to comment.