Skip to content

Commit 5ec7b27

Browse files
authored
Merge pull request #521 from openclimatefix/development
Quartz Energy Forecast Horizon Select [Development -> Staging]
2 parents f9dec18 + e776bae commit 5ec7b27

File tree

25 files changed

+784
-186
lines changed

25 files changed

+784
-186
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
# Solar Electricity Nowcasting
1+
# Quartz Energy
2+
### A set of forecasting products driven by the exciting modelling work in Open Climate Fix and the community
3+
4+
The code is as open source as we can possibly make it (safely) and is powered by various forecast APIs, which are also available as services under the same Quartz umbrella.
5+
26
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
37
[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-)
48
<!-- ALL-CONTRIBUTORS-BADGE:END -->
59

6-
This is a "meta-repository" for [Open Climate Fix](https://openclimatefix.org/)'s solar electricity nowcasting project. See [this great Wired article about OCF's solar electricity forecasting work](https://www.wired.co.uk/article/solar-weather-forecasting) for a good intro to solar electricity nowcasting.
10+
Head to [quartz.solar](https://quartz.solar) to find out more or to get in touch about using our Production services.
11+
12+
13+
14+
## Solar Electricity Nowcasting UI
15+
16+
The `nowcasting-app` is the repository for [Open Climate Fix](https://openclimatefix.org/)'s solar electricity nowcasting project. See [this great Wired article about OCF's solar electricity forecasting work](https://www.wired.co.uk/article/solar-weather-forecasting) for a good intro to solar electricity nowcasting.
717

818
The plan is to enable the community to build the world's best near-term forecasting system for solar electricity generation, and then let anyone use it! :) We'll do this by using state-of-the-art machine learning and 5-minutely satellite imagery to predict the movement of clouds over the next few hours, and then use this to predict solar electricity generation.
919

apps/nowcasting-app/components/map/deltaMap.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import mapboxgl, { Expression } from "mapbox-gl";
66
import { FailedStateMap, LoadStateMap, Map, MeasuringUnit } from "./";
77
import { ActiveUnit, SelectedData } from "./types";
88
import { DELTA_BUCKET, VIEWS } from "../../constant";
9-
import ButtonGroup from "../../components/button-group";
109
import gspShapeData from "../../data/gsp_regions_20220314.json";
1110
import useGlobalState from "../helpers/globalState";
1211
import { formatISODateString, formatISODateStringHuman } from "../helpers/utils";
@@ -28,7 +27,9 @@ import DeltaColorGuideBar from "./delta-color-guide-bar";
2827
import { safelyUpdateMapData } from "../helpers/mapUtils";
2928
import { generateGeoJsonForecastData } from "../helpers/data";
3029
import { components } from "../../types/quartz-api";
30+
import dynamic from "next/dynamic";
3131
const yellow = theme.extend.colors["ocf-yellow"].DEFAULT;
32+
const ButtonGroup = dynamic(() => import("../../components/button-group"), { ssr: false });
3233

3334
const getRoundedPv = (pv: number, round: boolean = true) => {
3435
if (!round) return Math.round(pv);

apps/nowcasting-app/components/map/pvLatestMap.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import mapboxgl, { Expression } from "mapbox-gl";
66
import { FailedStateMap, LoadStateMap, Map, MeasuringUnit } from "./";
77
import { ActiveUnit, SelectedData } from "./types";
88
import { MAX_POWER_GENERATED, VIEWS } from "../../constant";
9-
import ButtonGroup from "../../components/button-group";
109
import gspShapeData from "../../data/gsp_regions_20220314.json";
1110
import useGlobalState from "../helpers/globalState";
1211
import { formatISODateString, formatISODateStringHuman } from "../helpers/utils";
@@ -17,8 +16,11 @@ import { FeatureCollection } from "geojson";
1716
import { safelyUpdateMapData } from "../helpers/mapUtils";
1817
import { components } from "../../types/quartz-api";
1918
import { generateGeoJsonForecastData } from "../helpers/data";
19+
import dynamic from "next/dynamic";
2020
const yellow = theme.extend.colors["ocf-yellow"].DEFAULT;
2121

22+
const ButtonGroup = dynamic(() => import("../../components/button-group"), { ssr: false });
23+
2224
type PvLatestMapProps = {
2325
className?: string;
2426
combinedData: CombinedData;

apps/nowcasting-app/components/map/sitesMap.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
MAX_POWER_GENERATED,
1111
VIEWS
1212
} from "../../constant";
13-
import ButtonGroup from "../../components/button-group";
1413
import gspShapeData from "../../data/gsp_regions_20220314.json";
1514
import dnoShapeData from "../../data/dno_regions_lat_long_converted.json";
1615
import useGlobalState from "../helpers/globalState";
@@ -26,8 +25,10 @@ import { Feature, FeatureCollection } from "geojson";
2625
import Slider from "./sitesMapFeatures/sitesZoomSlider";
2726
import SitesLegend from "./sitesMapFeatures/sitesLegend";
2827
import { safelyUpdateMapData } from "../helpers/mapUtils";
28+
import dynamic from "next/dynamic";
2929

3030
const yellow = theme.extend.colors["ocf-yellow"].DEFAULT;
31+
const ButtonGroup = dynamic(() => import("../../components/button-group"), { ssr: false });
3132

3233
const getRoundedPv = (pv: number, round: boolean = true) => {
3334
if (!round) return Math.round(pv);

apps/quartz-app/.env.preview

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AUTH0_BASE_URL=https://$VERCEL_URL

apps/quartz-app/.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AUTH0_BASE_URL=https://$VERCEL_URL
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { handleAuth, handleLogout, HandleAuth } from "@auth0/nextjs-auth0";
2+
3+
/**
4+
* This is a GET endpoint that automatically handles authentication using Auth0.
5+
* We're using a logout option override to redirect to "/logout" after logout.
6+
*
7+
* @function GET
8+
* @returns {HandleAuth} A function that handles authentication.
9+
*/
10+
export const GET = handleAuth({
11+
logout: handleLogout({
12+
returnTo: "/logout",
13+
}),
14+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { NextRequest, NextResponse } from "next/server";
2+
import { getAccessToken, withApiAuthRequired } from "@auth0/nextjs-auth0";
3+
4+
/**
5+
* This is a secured GET endpoint that requires API authentication.
6+
* It retrieves the access token for the authenticated user.
7+
*
8+
* @async
9+
* @function GET
10+
* @param {NextRequest} req - The Next.js API request object.
11+
* @returns {NextResponse} A JSON response containing the access token.
12+
*/
13+
const GET = withApiAuthRequired(async function GET(req: NextRequest) {
14+
const res = new NextResponse();
15+
const { accessToken } = await getAccessToken(req, res);
16+
return NextResponse.json({ accessToken }, res);
17+
});
18+
19+
export { GET };

apps/quartz-app/app/globals.css

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,24 @@
1818

1919
body {
2020
color: rgb(var(--foreground-rgb));
21-
background: linear-gradient(
22-
to bottom,
23-
transparent,
24-
rgb(var(--background-end-rgb))
25-
)
26-
rgb(var(--background-start-rgb));
2721
}
2822

2923
@layer utilities {
3024
.text-balance {
3125
text-wrap: balance;
3226
}
3327
}
28+
29+
.fade-out {
30+
opacity: 1;
31+
animation: fade-out 2s ease-in-out forwards;
32+
}
33+
34+
@keyframes fade-out {
35+
from {
36+
opacity: 1;
37+
}
38+
to {
39+
opacity: 0;
40+
}
41+
}

apps/quartz-app/app/layout.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { Metadata } from "next";
22
import { Inter } from "next/font/google";
33
import "./globals.css";
4-
import Header from "../src/components/layout/Header";
5-
import Providers from "@/app/providers";
64
import { ReactNode } from "react";
5+
import { UserProvider } from "@auth0/nextjs-auth0/client";
6+
import LayoutWrapper from "@/src/components/layout/LayoutWrapper";
77

88
const inter = Inter({ subsets: ["latin"] });
99

@@ -19,12 +19,11 @@ export default function RootLayout({
1919
}>) {
2020
return (
2121
<html lang="en">
22-
<body className={inter.className}>
23-
<Providers>
24-
<Header />
25-
{children}
26-
</Providers>
27-
</body>
22+
<UserProvider>
23+
<body className={inter.className}>
24+
<LayoutWrapper>{children}</LayoutWrapper>
25+
</body>
26+
</UserProvider>
2827
</html>
2928
);
3029
}

0 commit comments

Comments
 (0)