Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quartz Solar v0.5.2 – Staging #536

Merged
merged 35 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
21c594c
format dno name + tests
peterdudfield Feb 6, 2024
5d75a81
run prettier
peterdudfield Feb 6, 2024
5d7302e
lint
peterdudfield Feb 6, 2024
358bd89
Merge branch 'main' into issue/466-swap-gsp-name
peterdudfield May 14, 2024
90c7e31
update formatDNORegionName, add test
peterdudfield May 14, 2024
75b1f9e
lint
peterdudfield May 14, 2024
cb73d0d
lint
peterdudfield May 14, 2024
1b8177e
Hide Sites map ring legend
braddf Jul 24, 2024
30477e5
Add message for user with no sites
braddf Jul 24, 2024
c2e5933
Merge pull request #467 from openclimatefix/issue/466-swap-gsp-name
braddf Jul 26, 2024
964d8b2
Add legend toggles and N-hr forecast setting
braddf Aug 5, 2024
36dab90
Merge remote-tracking branch 'origin/development' into development
braddf Aug 5, 2024
cb5d5ff
Fix Legend prop mismatch
braddf Aug 6, 2024
7801d03
Change 4hr data/labels to reflect Nhr value
braddf Aug 6, 2024
ba1c550
Toggle p-levels on chart with FORECAST
braddf Aug 6, 2024
71ce217
N-hour forecast loading status message
braddf Aug 7, 2024
231bbaa
Amend Toggle input func to onChange handler
braddf Aug 7, 2024
7d37a43
Update chart when zoomed on nHour change
braddf Aug 7, 2024
bd3f0e1
Update GSP nHour data on nHour change
braddf Aug 7, 2024
5f189da
fix chart resizing issues
braddf Aug 7, 2024
dd65630
delta styling clean-up
braddf Aug 8, 2024
4bc7ca1
disable chart animations
braddf Aug 8, 2024
16683c5
reverse legend dash style
braddf Aug 8, 2024
0967631
Fix sites loading status position
braddf Aug 8, 2024
1cc66e8
Vercel comments: legend label & dropdown bg
braddf Aug 9, 2024
4252912
fix map loading bug + add PV map tooltip
braddf Aug 22, 2024
2778c51
fix %/MW & general duplication bug in popup
braddf Aug 29, 2024
461bc2d
fix missing actuals in PV popup
braddf Aug 29, 2024
8b0cb5d
fix legend/general responsiveness
braddf Aug 30, 2024
eeb5678
update page title
braddf Aug 30, 2024
2f07d89
update page title again
braddf Aug 30, 2024
01adf62
fix loading state issues
braddf Aug 30, 2024
70f4d72
fix map unit change bug
braddf Aug 30, 2024
7098aac
Refactor all 4hr refs to N Hour
braddf Sep 4, 2024
5e0e61f
Update sentry project name
braddf Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/nowcasting-app/components/Toggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { FC } from "react";
braddf marked this conversation as resolved.
Show resolved Hide resolved

const Toggle: FC<{
onClick: () => void;
visible: boolean;
}> = ({ onClick, visible }) => {
return (
<label className="inline-flex items-center cursor-pointer px-1 ml-2">
<input type="checkbox" checked={visible} onChange={onClick} className={`toggle`}></input>
</label>
);
};

export default Toggle;
158 changes: 64 additions & 94 deletions apps/nowcasting-app/components/charts/ChartLegend.tsx
Original file line number Diff line number Diff line change
@@ -1,115 +1,85 @@
import Tooltip from "../tooltip";
import { ChartInfo } from "../../ChartInfo";
import { InfoIcon, LegendLineGraphIcon } from "../icons/icons";
import { FC } from "react";
import { FC, useEffect } from "react";
import useGlobalState from "../helpers/globalState";
import { getRounded4HoursAgoString } from "../helpers/utils";

const LegendItem: FC<{
braddf marked this conversation as resolved.
Show resolved Hide resolved
iconClasses: string;
label: string;
dashed?: boolean;
dataKey: string;
}> = ({ iconClasses, label, dashed, dataKey }) => {
const [visibleLines, setVisibleLines] = useGlobalState("visibleLines");
const isVisible = visibleLines.includes(dataKey);

const toggleLineVisibility = () => {
if (isVisible) {
setVisibleLines(visibleLines.filter((line) => line !== dataKey));
} else {
setVisibleLines([...visibleLines, dataKey]);
}
};

return (
<div className="flex items-center flex-1">
<LegendLineGraphIcon className={iconClasses} dashed={dashed} />
<button
className="inline-flex flex-1 text-left pl-1 max-w-full w-44 dash:w-auto text-xs dash:text-base dash:tracking-wider dash:pb-1"
onClick={toggleLineVisibility}
>
<span
className={`block w-auto uppercase pl-1${
isVisible ? " font-extrabold dash:font-semibold" : ""
}`}
>
{label}
</span>
</button>
</div>
);
};
import LegendItem from "./LegendItem";
import { N_HOUR_FORECAST_OPTIONS } from "../../constant";

type ChartLegendProps = {
className?: string;
};
export const ChartLegend: React.FC<ChartLegendProps> = ({ className }) => {
const [show4hView] = useGlobalState("show4hView");
export const ChartLegend: FC<ChartLegendProps> = ({ className }) => {
const [showNHourView] = useGlobalState("showNHourView");
const [nHourForecast, setNHourForecast] = useGlobalState("nHourForecast");

const fourHoursAgo = getRounded4HoursAgoString();
const legendItemContainerClasses = `flex flex-initial flex-col lg:flex-row 3xl:flex-col justify-between${
const legendItemContainerClasses = `flex flex-initial flex-col @sm:gap-1 @6xl:gap-6 @6xl:flex-row ${
className ? ` ${className}` : ""
}`;
return (
<div className="absolute bottom-0 left-0 right-0 flex flex-none justify-between align-items:baseline px-4 text-xs tracking-wider text-ocf-gray-300 pt-3 bg-mapbox-black-500 overflow-y-visible">
<div className={`flex flex-1 justify-around flex-col 3xl:flex-row pb-3 overflow-x-auto`}>
<div className={legendItemContainerClasses}>
<LegendItem
iconClasses={"text-ocf-black"}
dashed
label={"PV live initial estimate"}
dataKey={`GENERATION`}
/>
<LegendItem
iconClasses={"text-ocf-black"}
label={"PV live updated"}
dataKey={`GENERATION_UPDATED`}
/>
</div>
<div className={legendItemContainerClasses}>
<LegendItem
iconClasses={"text-ocf-yellow"}
dashed
label={"OCF Forecast"}
dataKey={`FORECAST`}
/>
<LegendItem
iconClasses={"text-ocf-yellow"}
label={"OCF Final Forecast"}
dataKey={`PAST_FORECAST`}
/>
</div>
{show4hView && (
<div className="@container flex flex-initial">
<div className="flex flex-1 flex-col justify-between align-items:baseline px-4 text-xs tracking-wider text-ocf-gray-300 py-3 gap-3 bg-mapbox-black-500 overflow-y-visible @sm:flex-row @xl:gap-6">
<div
className={`flex flex-initial pr-2 justify-between flex-col overflow-x-auto @sm:gap-1 @md:pr-0 @md:flex-col @md:gap-1 @lg:flex-row @lg:gap-8 @3xl:gap-12 @6xl:gap-6`}
>
<div className={legendItemContainerClasses}>
<LegendItem
iconClasses={"text-ocf-orange"}
dashed
// label={`OCF ${fourHoursAgo} Forecast`}
label={`OCF 4hr+ Forecast`}
dataKey={`4HR_FORECAST`}
iconClasses={"text-ocf-black"}
dashStyle={"dashed"}
label={"PV live initial estimate"}
dataKey={`GENERATION`}
/>
<LegendItem
iconClasses={"text-ocf-orange"}
label={"OCF 4hr Forecast"}
dataKey={`4HR_PAST_FORECAST`}
iconClasses={"text-ocf-black"}
label={"PV live updated"}
dataKey={`GENERATION_UPDATED`}
/>
</div>
)}
</div>
<div className="flex-initial flex items-center pb-3">
<Tooltip
tip={
<div className="w-64 rounded-md">
<ChartInfo />
</div>
}
position="top"
className={"text-right"}
fullWidth
>
<InfoIcon />
</Tooltip>
<div className={legendItemContainerClasses}>
<LegendItem
iconClasses={"text-ocf-yellow"}
dashStyle={"both"}
label={"OCF Latest Forecast"}
dataKey={`FORECAST`}
/>
{/*<LegendItem*/}
{/* iconClasses={"text-ocf-yellow"}*/}
{/* label={"OCF Final Forecast"}*/}
{/* dataKey={`PAST_FORECAST`}*/}
{/*/>*/}
{showNHourView && (
<LegendItem
iconClasses={"text-ocf-orange"}
dashStyle={"both"}
label={`OCF ${nHourForecast}hr Forecast`}
dataKey={`N_HOUR_FORECAST`}
/>
)}
</div>
</div>
<div className="flex flex-1 w-full justify-end items-end gap-3 pr-3 @md:flex-col @lg:gap-4 @2xl:flex-row @3xl:gap-12">
<div className="flex">
<div className="h-8 w-10 mr-2 custom-select bg-mapbox-black-600 rounded-md">
<select
value={nHourForecast}
onChange={(e) => setNHourForecast(Number(e.target.value))}
className="text-sm px-2 py-0 rounded-md"
>
{N_HOUR_FORECAST_OPTIONS.map((option) => (
<option
key={`N-hour-select-option-${option}`}
className="text-black bg-white"
value={option}
>
{option}
</option>
))}
</select>
</div>{" "}
hour <br />
forecast
</div>
</div>
</div>
</div>
);
Expand Down
14 changes: 7 additions & 7 deletions apps/nowcasting-app/components/charts/DataLoadingChartStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const DataLoadingChartStatus = <
const isLoadingData =
!loadingState.initialLoadComplete ||
(loadingState.showMessage && !!loadingState.message.length);
const [show4hView] = useGlobalState("show4hView");
const [showNHourView] = useGlobalState("showNHourView");

if (!loadingState || !loadingState.endpointStates || !loadingState.endpointStates.type)
return null;
Expand All @@ -42,7 +42,7 @@ const DataLoadingChartStatus = <
isLoadingData={isLoadingData}
message={loadingState.message}
endpointStates={loadingState.endpointStates}
show4hView={show4hView}
showNHourView={showNHourView}
/>
);
} else if (isEndpointStateType<SitesEndpointStates>(loadingState.endpointStates, "sites")) {
Expand All @@ -51,7 +51,7 @@ const DataLoadingChartStatus = <
message={loadingState.message}
endpointStates={loadingState.endpointStates}
isLoadingData={isLoadingData}
show4hView={show4hView}
showNHourView={showNHourView}
/>
);
}
Expand All @@ -63,18 +63,18 @@ type EndpointStatusListProps<K> = {
isLoadingData: boolean;
message: string;
endpointStates: K;
show4hView: boolean | undefined;
showNHourView: boolean | undefined;
};
const EndpointStatusList = <K extends NationalEndpointStates | SitesEndpointStates>({
isLoadingData,
message,
endpointStates,
show4hView = false
showNHourView = false
}: EndpointStatusListProps<K>) => {
const endpointsArray = Array.from(Object.entries(endpointStates));
return (
<div
className={`absolute -top-4 right-4 flex items-center h-9 ${isLoadingData ? "z-40" : "z-0"}`}
className={`absolute -top-4 right-2 flex items-center h-9 ${isLoadingData ? "z-40" : "z-0"}`}
>
<div
className={`chart-data-loading-message flex flex-row relative h-6 cursor-default justify-between items-center rounded-sm bg-mapbox-black ${
Expand All @@ -92,7 +92,7 @@ const EndpointStatusList = <K extends NationalEndpointStates | SitesEndpointStat
{!!endpointsArray.length &&
endpointsArray.map(([key, val]) => {
if (!endpointStates) return null;
if (key === "national4Hour" && !show4hView) return null;
if (key === "nationalNHour" && !showNHourView) return null;
// Filter out "type" key with string state value
if (typeof val === "string") return null;
const state = endpointStates[key as keyof typeof endpointStates];
Expand Down
44 changes: 44 additions & 0 deletions apps/nowcasting-app/components/charts/LegendItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { FC } from "react";
import useGlobalState from "../helpers/globalState";
import { LegendLineGraphIcon } from "../icons/icons";
import Toggle from "../Toggle";

const LegendItem: FC<{
iconClasses: string;
label: string;
dashStyle?: "both" | "dashed" | "solid";
dataKey: string;
}> = ({ iconClasses, label, dashStyle, dataKey }) => {
const [visibleLines, setVisibleLines] = useGlobalState("visibleLines");
const isVisible = visibleLines.includes(dataKey);

const toggleLineVisibility = () => {
if (isVisible) {
setVisibleLines(visibleLines.filter((line) => line !== dataKey));
} else {
setVisibleLines([...visibleLines, dataKey]);
}
};

return (
<div className="flex items-center flex-initial">
<LegendLineGraphIcon className={iconClasses} dashStyle={dashStyle} />
<button
className="inline-flex flex-1 text-left pl-1 max-w-full w-auto leading-tight text-2xs @lg:pr-1 @xl:pr-0 @2xl:text-xs dash:text-base dash:tracking-wider dash:pb-1"
onClick={toggleLineVisibility}
>
<span
className={`block sometimes-bold w-auto uppercase pl-1${
isVisible ? " font-extrabold dash:font-semibold" : " text-ocf-gray-700"
}`}
title={label}
>
{label}
</span>
</button>
<Toggle onClick={toggleLineVisibility} visible={isVisible} />
</div>
);
};

export default LegendItem;
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ const BucketItem: React.FC<Bucket> = ({
flex-col items-center rounded`}
>
<button
className={`flex flex-col flex-1 w-full h-16 items-center p-1 pt-2 rounded-md justify-center border-2 ${bucketColor} ${
className={`flex flex-col flex-1 w-full items-center p-1 rounded-md justify-center border-2 ${bucketColor} ${
isSelected ? selectedClass : unselectedClass
}`}
onClick={toggleBucketSelection}
>
<span className="text-2xl font-semibold">{quantity}</span>
<span className="flex text-xs pb-2">
<span className="text-xl font-semibold leading-tight">{quantity}</span>
<span className="flex text-xs">
{text === DELTA_BUCKET.ZERO.toString() ? `-/+` : `${text} MW`}
</span>
</button>
Expand Down Expand Up @@ -86,7 +86,7 @@ const DeltaBuckets: React.FC<{

return (
<>
<div className="flex justify-center mx-3 pb-10 gap-1 lg:gap-3">
<div className="sticky top-0 bg-mapbox-black-500 z-10 mx-3 pb-1 flex justify-center gap-1 lg:gap-3">
{buckets.map((bucket) => {
return <BucketItem key={`Bucket-${bucket.dataKey}`} {...bucket}></BucketItem>;
})}
Expand Down
Loading
Loading