From c372167afe43f9099f7911ee6a9d53562a790f99 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jul 2023 12:23:37 +0000 Subject: [PATCH 01/98] Bump semver from 5.7.1 to 5.7.2 Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/yarn.lock b/yarn.lock index 608f86d3..64fba829 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9791,33 +9791,19 @@ schema-utils@^4.0.0: ajv-keywords "^5.1.0" "semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - -semver@^7.0.0, semver@^7.3.4, semver@^7.3.7, semver@^7.5.3: - version "7.5.3" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e" - integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ== - dependencies: - lru-cache "^6.0.0" - -semver@^7.3.2: - version "7.5.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.2.tgz#5b851e66d1be07c1cdaf37dfc856f543325a2beb" - integrity sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ== - dependencies: - lru-cache "^6.0.0" - -semver@^7.3.5, semver@^7.3.8: - version "7.3.8" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" - integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== + +semver@^7.0.0, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== dependencies: lru-cache "^6.0.0" From e4706dddb47d9b48030bf9668d1d8852eb9fbae7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jul 2023 07:28:43 +0000 Subject: [PATCH 02/98] Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 64fba829..3a177d29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11199,9 +11199,9 @@ widest-line@^3.1.0: string-width "^4.0.0" word-wrap@^1.2.3, word-wrap@~1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" - integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== + version "1.2.4" + resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.4.tgz#cb4b50ec9aca570abd1f52f33cd45b6c61739a9f" + integrity sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA== wordwrap@^1.0.0: version "1.0.0" From 6b36118c443d1e5bf08ef326cc056612fa50a9eb Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Thu, 3 Aug 2023 09:51:09 -0700 Subject: [PATCH 03/98] [C] Github workflows have NOIRLab releases endpoint env vars --- .github/workflows/dev-pull-request.yaml | 4 ++-- .github/workflows/dev-push.yaml | 4 ++-- .github/workflows/master-pr.yaml | 10 +++++----- .github/workflows/master-push.yaml | 10 +++++----- .github/workflows/prod-push.yaml | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/dev-pull-request.yaml b/.github/workflows/dev-pull-request.yaml index 9b74d15a..c8406448 100644 --- a/.github/workflows/dev-pull-request.yaml +++ b/.github/workflows/dev-pull-request.yaml @@ -42,8 +42,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-dev.rubinobs.com/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/json \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/json \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/api/v2/releases/{{ID}} \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/api/v2/releases/{{ID}} \ . - name: Configure Docker Auth diff --git a/.github/workflows/dev-push.yaml b/.github/workflows/dev-push.yaml index 7eb601a8..d1781abc 100644 --- a/.github/workflows/dev-push.yaml +++ b/.github/workflows/dev-push.yaml @@ -36,8 +36,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-dev.rubinobs.com/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/json \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/json \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/api/v2/releases/{{ID}} \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/api/v2/releases/{{ID}} \ . - name: Configure Docker Auth diff --git a/.github/workflows/master-pr.yaml b/.github/workflows/master-pr.yaml index 2bf8e805..39cdd296 100644 --- a/.github/workflows/master-pr.yaml +++ b/.github/workflows/master-pr.yaml @@ -33,17 +33,17 @@ jobs: run: |- docker build \ -t "gcr.io/edc-int-6c5e/rubin-obs-client:${{ github.sha }}" \ - --build-arg NEXT_PUBLIC_API_URL=https://api-int.rubinobs.dev/api \ + --build-arg NEXT_PUBLIC_API_URL=https://api-int.rubinobs.org/api \ --build-arg EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger \ --build-arg NEXT_DEBUG_LOGGING=false \ --build-arg CLOUD_ENV=INT \ - --build-arg NEXT_PUBLIC_BASE_URL=https://int.rubinobs.dev \ + --build-arg NEXT_PUBLIC_BASE_URL=https://int.rubinobs.org \ --build-arg NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps.googleusercontent.com \ - --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.dev/actions/contact-form/send \ + --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.org/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/json \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/json \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/api/v2/releases/{{ID}} \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/api/v2/releases/{{ID}} \ . - name: Configure Docker Auth diff --git a/.github/workflows/master-push.yaml b/.github/workflows/master-push.yaml index 70d7147f..a2262588 100644 --- a/.github/workflows/master-push.yaml +++ b/.github/workflows/master-push.yaml @@ -27,17 +27,17 @@ jobs: run: |- docker build \ -t "gcr.io/edc-int-6c5e/skyviewer-client:${{ github.sha }}" \ - --build-arg NEXT_PUBLIC_API_URL=https://api-int.rubinobs.dev/api \ - --build-arg NEXT_PUBLIC_BASE_URL=https://int.rubinobs.dev \ + --build-arg NEXT_PUBLIC_API_URL=https://api-int.rubinobs.org/api \ + --build-arg NEXT_PUBLIC_BASE_URL=https://int.rubinobs.org \ --build-arg EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger \ --build-arg NEXT_DEBUG_LOGGING=false \ --build-arg CLOUD_ENV=INT \ --build-arg NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps.googleusercontent.com \ - --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.dev/actions/contact-form/send \ + --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.org/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/json \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/json \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/api/v2/releases/{{ID}} \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/api/v2/releases/{{ID}} \ . - name: Configure Docker Auth diff --git a/.github/workflows/prod-push.yaml b/.github/workflows/prod-push.yaml index 789d1971..e0f0b036 100644 --- a/.github/workflows/prod-push.yaml +++ b/.github/workflows/prod-push.yaml @@ -42,8 +42,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api.rubinobs.org/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN=rubinobservatory.org \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/json \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/json \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/api/v2/releases/{{ID}} \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/api/v2/releases/{{ID}} \ . - name: Configure Docker Auth run: gcloud --quiet auth configure-docker From 4a0dfd42328e58cd9dc0405868a0a7d965274921 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Thu, 3 Aug 2023 10:52:27 -0700 Subject: [PATCH 04/98] [B] Revert to v1 NOIRLab releases endpoint --- .github/workflows/dev-pull-request.yaml | 4 ++-- .github/workflows/dev-push.yaml | 4 ++-- .github/workflows/master-pr.yaml | 4 ++-- .github/workflows/master-push.yaml | 4 ++-- .github/workflows/prod-push.yaml | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/dev-pull-request.yaml b/.github/workflows/dev-pull-request.yaml index c8406448..40cf232d 100644 --- a/.github/workflows/dev-pull-request.yaml +++ b/.github/workflows/dev-pull-request.yaml @@ -42,8 +42,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-dev.rubinobs.com/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/api/v2/releases/{{ID}} \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/api/v2/releases/{{ID}} \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ . - name: Configure Docker Auth diff --git a/.github/workflows/dev-push.yaml b/.github/workflows/dev-push.yaml index d1781abc..2685435b 100644 --- a/.github/workflows/dev-push.yaml +++ b/.github/workflows/dev-push.yaml @@ -36,8 +36,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-dev.rubinobs.com/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/api/v2/releases/{{ID}} \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/api/v2/releases/{{ID}} \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ . - name: Configure Docker Auth diff --git a/.github/workflows/master-pr.yaml b/.github/workflows/master-pr.yaml index 39cdd296..171e90f4 100644 --- a/.github/workflows/master-pr.yaml +++ b/.github/workflows/master-pr.yaml @@ -42,8 +42,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.org/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/api/v2/releases/{{ID}} \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/api/v2/releases/{{ID}} \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ . - name: Configure Docker Auth diff --git a/.github/workflows/master-push.yaml b/.github/workflows/master-push.yaml index a2262588..69691eca 100644 --- a/.github/workflows/master-push.yaml +++ b/.github/workflows/master-push.yaml @@ -36,8 +36,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.org/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/api/v2/releases/{{ID}} \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/api/v2/releases/{{ID}} \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ . - name: Configure Docker Auth diff --git a/.github/workflows/prod-push.yaml b/.github/workflows/prod-push.yaml index e0f0b036..cd2b175b 100644 --- a/.github/workflows/prod-push.yaml +++ b/.github/workflows/prod-push.yaml @@ -42,8 +42,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api.rubinobs.org/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN=rubinobservatory.org \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/api/v2/releases/{{ID}} \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/api/v2/releases/{{ID}} \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ + --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ . - name: Configure Docker Auth run: gcloud --quiet auth configure-docker From cc76f0e01f8efee23954f5036d634a21dd956ecc Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 30 May 2023 15:24:27 -0700 Subject: [PATCH 05/98] [F] Basic EFD fetch POC in SummitStatus component --- .github/workflows/dev-pull-request.yaml | 2 +- .github/workflows/dev-push.yaml | 2 +- .github/workflows/master-pr.yaml | 2 +- .github/workflows/master-push.yaml | 2 +- .github/workflows/prod-push.yaml | 2 +- .../content-blocks/SummitStatus/index.js | 4 ++ lib/api/efd.js | 58 +++++++++++++++++++ lib/edc-log.js | 2 +- package.json | 1 + pages/[[...uriSegments]].js | 2 +- yarn.lock | 5 ++ 11 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 lib/api/efd.js diff --git a/.github/workflows/dev-pull-request.yaml b/.github/workflows/dev-pull-request.yaml index 40cf232d..a65df197 100644 --- a/.github/workflows/dev-pull-request.yaml +++ b/.github/workflows/dev-pull-request.yaml @@ -35,7 +35,7 @@ jobs: -t "gcr.io/${{ secrets.SV_PROJ_NAME }}/rubin-obs-client:${{ github.sha }}" \ --build-arg NEXT_PUBLIC_API_URL=https://api-dev.rubinobs.com/api \ --build-arg EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger \ - --build-arg NEXT_DEBUG_LOGGING=false \ + --build-arg NEXT_PUBLIC_DEBUG_LOGGING=false \ --build-arg CLOUD_ENV=DEV \ --build-arg NEXT_PUBLIC_BASE_URL=https://dev.rubinobs.com \ --build-arg NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps.googleusercontent.com \ diff --git a/.github/workflows/dev-push.yaml b/.github/workflows/dev-push.yaml index 2685435b..bab8c459 100644 --- a/.github/workflows/dev-push.yaml +++ b/.github/workflows/dev-push.yaml @@ -29,7 +29,7 @@ jobs: -t "gcr.io/${{ secrets.SV_PROJ_NAME }}/rubin-obs-client:${{ github.sha }}" \ --build-arg NEXT_PUBLIC_API_URL=https://api-dev.rubinobs.com/api \ --build-arg EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger \ - --build-arg NEXT_DEBUG_LOGGING=true \ + --build-arg NEXT_PUBLIC_DEBUG_LOGGING=true \ --build-arg CLOUD_ENV=DEV \ --build-arg NEXT_PUBLIC_BASE_URL=https://dev.rubinobs.com \ --build-arg NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps.googleusercontent.com \ diff --git a/.github/workflows/master-pr.yaml b/.github/workflows/master-pr.yaml index 171e90f4..708dc92f 100644 --- a/.github/workflows/master-pr.yaml +++ b/.github/workflows/master-pr.yaml @@ -35,7 +35,7 @@ jobs: -t "gcr.io/edc-int-6c5e/rubin-obs-client:${{ github.sha }}" \ --build-arg NEXT_PUBLIC_API_URL=https://api-int.rubinobs.org/api \ --build-arg EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger \ - --build-arg NEXT_DEBUG_LOGGING=false \ + --build-arg NEXT_PUBLIC_DEBUG_LOGGING=false \ --build-arg CLOUD_ENV=INT \ --build-arg NEXT_PUBLIC_BASE_URL=https://int.rubinobs.org \ --build-arg NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps.googleusercontent.com \ diff --git a/.github/workflows/master-push.yaml b/.github/workflows/master-push.yaml index 69691eca..857a738d 100644 --- a/.github/workflows/master-push.yaml +++ b/.github/workflows/master-push.yaml @@ -30,7 +30,7 @@ jobs: --build-arg NEXT_PUBLIC_API_URL=https://api-int.rubinobs.org/api \ --build-arg NEXT_PUBLIC_BASE_URL=https://int.rubinobs.org \ --build-arg EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger \ - --build-arg NEXT_DEBUG_LOGGING=false \ + --build-arg NEXT_PUBLIC_DEBUG_LOGGING=false \ --build-arg CLOUD_ENV=INT \ --build-arg NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps.googleusercontent.com \ --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.org/actions/contact-form/send \ diff --git a/.github/workflows/prod-push.yaml b/.github/workflows/prod-push.yaml index cd2b175b..859b9464 100644 --- a/.github/workflows/prod-push.yaml +++ b/.github/workflows/prod-push.yaml @@ -36,7 +36,7 @@ jobs: --build-arg NEXT_PUBLIC_API_URL=https://api.rubinobs.org/api \ --build-arg NEXT_PUBLIC_BASE_URL=https://rubinobservatory.org \ --build-arg EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger \ - --build-arg NEXT_DEBUG_LOGGING=false \ + --build-arg NEXT_PUBLIC_DEBUG_LOGGING=false \ --build-arg CLOUD_ENV=PROD \ --build-arg NEXT_PUBLIC_GOOGLE_APP_ID=596747551410-vcqlrp7erg5c5gm0dkvc0k21mgi0ilg0.apps.googleusercontent.com \ --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api.rubinobs.org/actions/contact-form/send \ diff --git a/components/content-blocks/SummitStatus/index.js b/components/content-blocks/SummitStatus/index.js index 888900fd..ccc2f929 100644 --- a/components/content-blocks/SummitStatus/index.js +++ b/components/content-blocks/SummitStatus/index.js @@ -11,6 +11,7 @@ import TemperatureHistoric from "@/components/widgets/TemperatureHistoric"; import WindspeedHourly from "@/components/widgets/HourlyData/patterns/Windspeed"; import PrecipitationHourly from "@/components/widgets/HourlyData/patterns/Precipitation"; import WindspeedCurrent from "@/components/widgets/CurrentData/patterns/Windspeed"; +import { useEfd } from "@/api/efd"; const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { /** this logic should be changed to useRouter after i18n refactor */ @@ -90,6 +91,9 @@ const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { } ); + const [data, loading] = useEfd(); + // eslint-disable-next-line no-console + console.log({ data, loading }); return ( diff --git a/lib/api/efd.js b/lib/api/efd.js new file mode 100644 index 00000000..6c5ddd1c --- /dev/null +++ b/lib/api/efd.js @@ -0,0 +1,58 @@ +import { InfluxDB, flux } from "@influxdata/influxdb-client"; +import { useEffect, useState } from "react"; + +export function useEfd(fluxQuery) { + const [loading, setLoading] = useState(false); + const [result, setResult] = useState([]); + + const url = process.env.NEXT_PUBLIC_EFD_URL; + const bucket = process.env.NEXT_PUBLIC_EFD_BUCKET; + const token = process.env.NEXT_PUBLIC_EFD_TOKEN; + + const influxDB = new InfluxDB({ url, token }); + const queryApi = influxDB.getQueryApi(""); + + useEffect(() => { + async function fetchQuery() { + try { + setLoading(true); + const response = new Promise((resolve, reject) => { + const data = []; + queryApi.queryRows( + flux`from(bucket: "${bucket}") + |> range(start: -1s) + |> last() + |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.temperature") + |> filter(fn: (r) => r["_field"] == "temperature0")`, + { + next(row, tableMeta) { + const o = tableMeta.toObject(row); + data.push(o); + }, + error(error) { + reject(error); + }, + complete() { + resolve(data); + }, + } + ); + }); + + await response + .then((res) => { + setResult(res); + }) + .finally(() => { + setLoading(false); + }); + } catch (error) { + setLoading(false); + } + } + + fetchQuery(); + }, [fluxQuery]); + + return [result, loading]; +} diff --git a/lib/edc-log.js b/lib/edc-log.js index 76c1f097..471bdd48 100644 --- a/lib/edc-log.js +++ b/lib/edc-log.js @@ -8,7 +8,7 @@ export async function setEdcLog( ) { const API_URL = process.env.EDC_LOGGER_API_URL; - if (!API_URL || !process.env.NEXT_DEBUG_LOGGING) return; + if (!API_URL || !process.env.NEXT_PUBLIC_DEBUG_LOGGING) return; const env = process.env.CLOUD_ENV ? process.env.CLOUD_ENV : "UNKNOWN"; diff --git a/package.json b/package.json index 0ae28c40..4a6a1786 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "@castiron/components-breadcrumbs": "^1.1.0", "@castiron/style-mixins": "^1.0.6", "@headlessui/react": "^1.6.6", + "@influxdata/influxdb-client": "^1.33.2", "@popperjs/core": "^2.11.5", "@rubin-epo/epo-react-lib": "^1.2.9", "add": "^2.0.6", diff --git a/pages/[[...uriSegments]].js b/pages/[[...uriSegments]].js index dd9d3ee3..e49badeb 100644 --- a/pages/[[...uriSegments]].js +++ b/pages/[[...uriSegments]].js @@ -105,7 +105,7 @@ export async function getStaticPaths() { export async function getStaticProps({ params: { uriSegments }, previewData }) { const PREVIEW_SLUG = process.env.NEXT_PREVIEW_SLUG; - if (process.env.NEXT_DEBUG_LOGGING) { + if (process.env.NEXT_DEBUG_LOGGING === "true") { logNextDir(); } diff --git a/yarn.lock b/yarn.lock index 3a177d29..b85d0284 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1693,6 +1693,11 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== +"@influxdata/influxdb-client@^1.33.2": + version "1.33.2" + resolved "https://registry.yarnpkg.com/@influxdata/influxdb-client/-/influxdb-client-1.33.2.tgz#c68cfcf592e4e042361003143fbab99461410172" + integrity sha512-RT5SxH+grHAazo/YK3UTuWK/frPWRM0N7vkrCUyqVprDgQzlLP+bSK4ak2Jv3QVF/pazTnsxWjvtKZdwskV5Xw== + "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" From d33d9e2ee66618192c1108c5dc8e88ba07fd03e6 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 6 Jun 2023 15:18:02 -0700 Subject: [PATCH 06/98] [C] Proxy for USDF CORS issue from local --- package.json | 5 +- yarn.lock | 152 +++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 146 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 4a6a1786..9efdc915 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "test:e2e": "cypress run --e2e --headless", "cypress": "CYPRESS_BASE_URL=http://localhost:3000 cypress open", "storybook": "storybook dev -p 6006", - "build-storybook": "storybook build" + "build-storybook": "storybook build", + "proxy": "env-cmd -x lcp --proxyUrl \\$EFD_URL_PROXY" }, "browserslist": [ "defaults", @@ -86,6 +87,7 @@ "@storybook/react": "^7.0.6", "browserslist": "^4.21.2", "cypress": "^12.15.0", + "env-cmd": "^10.1.0", "eslint": "^8.26.0", "eslint-config-next": "^13.0.1", "eslint-config-prettier": "^8.5.0", @@ -100,6 +102,7 @@ "i18next-http-backend": "^2.2.0", "jsconfig-paths-jest-mapper": "^1.0.0", "lint-staged": "^13.0.3", + "local-cors-proxy": "^1.1.0", "postcss": "^8.4.14", "postcss-normalize": "^10.0.1", "postcss-preset-env": "^7.7.2", diff --git a/yarn.lock b/yarn.lock index b85d0284..56a78405 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2989,6 +2989,11 @@ dependencies: tslib "^2.4.0" +"@tootallnate/once@2": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" + integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== + "@types/babel__core@^7.0.0": version "7.20.0" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.0.tgz#61bc5a4cae505ce98e1e36c5445e4bee060d8891" @@ -3622,7 +3627,7 @@ ajv-keywords@^5.1.0: dependencies: fast-deep-equal "^3.1.3" -ajv@^6.10.0, ajv@^6.12.4, ajv@^6.12.5: +ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -3755,6 +3760,11 @@ aria-query@^5.1.3: dependencies: dequal "^2.0.3" +array-back@^3.0.1, array-back@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" + integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== + array-buffer-byte-length@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz#fabe8bc193fea865f317fe7807085ee0dee5aead" @@ -4334,7 +4344,7 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== -chalk@^2.0.0, chalk@^2.4.1, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.3.2, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -4535,11 +4545,26 @@ combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" +command-line-args@^5.0.2: + version "5.2.1" + resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-5.2.1.tgz#c44c32e437a57d7c51157696893c5909e9cec42e" + integrity sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg== + dependencies: + array-back "^3.1.0" + find-replace "^3.0.0" + lodash.camelcase "^4.3.0" + typical "^4.0.0" + commander@^2.19.0, commander@^2.20.0: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== +commander@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" + integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== + commander@^6.2.1: version "6.2.1" resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" @@ -4669,6 +4694,14 @@ core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== +cors@^2.8.4: + version "2.8.5" + resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" + integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== + dependencies: + object-assign "^4" + vary "^1" + cosmiconfig-typescript-loader@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/cosmiconfig-typescript-loader/-/cosmiconfig-typescript-loader-4.3.0.tgz#c4259ce474c9df0f32274ed162c0447c951ef073" @@ -5227,6 +5260,14 @@ entities@^2.0.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== +env-cmd@^10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/env-cmd/-/env-cmd-10.1.0.tgz#c7f5d3b550c9519f137fdac4dd8fb6866a8c8c4b" + integrity sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA== + dependencies: + commander "^4.0.0" + cross-spawn "^7.0.0" + envinfo@^7.7.3: version "7.8.1" resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" @@ -5788,7 +5829,7 @@ executable@^4.1.1: dependencies: pify "^2.2.0" -express@^4.17.3: +express@^4.16.3, express@^4.17.3: version "4.18.2" resolved "https://registry.yarnpkg.com/express/-/express-4.18.2.tgz#3fabe08296e930c796c19e3c516979386ba9fd59" integrity sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ== @@ -6002,6 +6043,13 @@ find-cache-dir@^3.0.0, find-cache-dir@^3.3.1, find-cache-dir@^3.3.2: make-dir "^3.0.2" pkg-dir "^4.1.0" +find-replace@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-3.0.0.tgz#3e7e23d3b05167a76f770c9fbd5258b0def68c38" + integrity sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ== + dependencies: + array-back "^3.0.1" + find-up@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" @@ -6530,6 +6578,19 @@ handlebars@^4.7.7: optionalDependencies: uglify-js "^3.1.4" +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + integrity sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q== + +har-validator@~5.1.3: + version "5.1.5" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" + integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== + dependencies: + ajv "^6.12.3" + har-schema "^2.0.0" + hard-rejection@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883" @@ -6677,6 +6738,15 @@ http-errors@2.0.0: statuses "2.0.1" toidentifier "1.0.1" +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + integrity sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ== + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + http-signature@~1.3.6: version "1.3.6" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.3.6.tgz#cb6fbfdf86d1c974f343be94e87f7fc128662cf9" @@ -7425,10 +7495,10 @@ jsonp@^0.2.1: dependencies: debug "^2.1.3" -jsprim@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-2.0.2.tgz#77ca23dbcd4135cd364800d22ff82c2185803d4d" - integrity sha512-gqXddjPqQ6G40VdnI6T6yObEC+pDNvyP95wdQhkWkg7crHH3km5qP1FsOXEkzEQwnz6gz5qGTn1c2Y52wP3OyQ== +jsprim@^1.2.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb" + integrity sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw== dependencies: assert-plus "1.0.0" extsprintf "1.3.0" @@ -7606,6 +7676,17 @@ loader-utils@^3.2.0: resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-3.2.1.tgz#4fb104b599daafd82ef3e1a41fb9265f87e1f576" integrity sha512-ZvFw1KWS3GVyYBYb7qkmRM/WwL2TQQBxgCK62rlvm4WpVQ23Nb4tYjApUlfjrEGvOs7KHEsmyUn75OHZrJMWPw== +local-cors-proxy@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/local-cors-proxy/-/local-cors-proxy-1.1.0.tgz#570a0abb19ba102ddccd3113e92fbf44cb075756" + integrity sha512-1UVrdG10HAT58TNZBhYSeMPkwQANuJunFsWBgEYOd1RChLDHGhvNPjUT8JsOlcqoJyr0QOH9cLx9IOLATf4j5w== + dependencies: + chalk "^2.3.2" + command-line-args "^5.0.2" + cors "^2.8.4" + express "^4.16.3" + request "^2.85.0" + locate-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" @@ -7628,6 +7709,11 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" +lodash.camelcase@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== + lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" @@ -8173,7 +8259,12 @@ nth-check@^2.0.1: dependencies: boolbase "^1.0.0" -object-assign@^4.1.1: +oauth-sign@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" + integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== + +object-assign@^4, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== @@ -9149,6 +9240,11 @@ qs@~6.10.3: dependencies: side-channel "^1.0.4" +qs@~6.5.2: + version "6.5.3" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" + integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== + queue-microtask@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" @@ -9557,6 +9653,32 @@ request-progress@^3.0.0: dependencies: throttleit "^1.0.0" +request@^2.85.0: + version "2.88.2" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" + integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.8.0" + caseless "~0.12.0" + combined-stream "~1.0.6" + extend "~3.0.2" + forever-agent "~0.6.1" + form-data "~2.3.2" + har-validator "~5.1.3" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.19" + oauth-sign "~0.9.0" + performance-now "^2.1.0" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.5.0" + tunnel-agent "^0.6.0" + uuid "^3.3.2" + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -10050,7 +10172,7 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== -sshpk@^1.14.1: +sshpk@^1.7.0: version "1.17.0" resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.17.0.tgz#578082d92d4fe612b13007496e543fa0fbcbe4c5" integrity sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ== @@ -10835,6 +10957,11 @@ typescript@5.0.4: resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== +typical@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" + integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== + uglify-js@^3.1.4: version "3.17.4" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" @@ -11011,6 +11138,11 @@ uuid-browser@^3.1.0: resolved "https://registry.yarnpkg.com/uuid-browser/-/uuid-browser-3.1.0.tgz#0f05a40aef74f9e5951e20efbf44b11871e56410" integrity sha512-dsNgbLaTrd6l3MMxTtouOCFw4CBFc/3a+GgYA2YyrJvyQ1u6q4pcu3ktLoUZ/VN/Aw9WsauazbgsgdfVWgAKQg== +uuid@^3.3.2: + version "3.4.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" + integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== + uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" @@ -11033,7 +11165,7 @@ validate-npm-package-license@^3.0.1: spdx-correct "^3.0.0" spdx-expression-parse "^3.0.0" -vary@~1.1.2: +vary@^1, vary@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== From d44dea1143e3d8e8a3adb1eceef35ae6e854605b Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 13 Jun 2023 14:25:22 -0700 Subject: [PATCH 07/98] [C] Change range to queryable timeframe --- lib/api/efd.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api/efd.js b/lib/api/efd.js index 6c5ddd1c..181ac31f 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -20,10 +20,10 @@ export function useEfd(fluxQuery) { const data = []; queryApi.queryRows( flux`from(bucket: "${bucket}") - |> range(start: -1s) - |> last() + |> range(start: 2023-05-31T19:00:00Z, stop: 2023-05-31T20:00:00Z) |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.temperature") - |> filter(fn: (r) => r["_field"] == "temperature0")`, + |> filter(fn: (r) => r["_field"] == "temperature0") + |> last()`, { next(row, tableMeta) { const o = tableMeta.toObject(row); From d95b55b4a883506db5a3aeb13595380a44ca43cb Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 14 Jun 2023 12:18:31 -0700 Subject: [PATCH 08/98] [F] SummitData provider --- .../content-blocks/SummitStatus/index.js | 74 ++++++++++--------- .../dynamic/SummitData/Weather/index.js | 42 +++++++++++ contexts/SummitData.js | 41 ++++++++++ contexts/WeatherUnit.js | 6 +- lib/api/efd.js | 33 +++++++++ 5 files changed, 159 insertions(+), 37 deletions(-) create mode 100644 components/dynamic/SummitData/Weather/index.js create mode 100644 contexts/SummitData.js diff --git a/components/content-blocks/SummitStatus/index.js b/components/content-blocks/SummitStatus/index.js index ccc2f929..fe2b346f 100644 --- a/components/content-blocks/SummitStatus/index.js +++ b/components/content-blocks/SummitStatus/index.js @@ -1,5 +1,5 @@ import PropTypes from "prop-types"; -import { useState } from "react"; +import { useState, Suspense } from "react"; import { Container } from "@rubin-epo/epo-react-lib"; import { useTranslation } from "react-i18next"; import WeatherUnitContext from "@/contexts/WeatherUnit"; @@ -10,8 +10,8 @@ import TemperatureCurrent from "@/components/widgets/CurrentData/patterns/Temper import TemperatureHistoric from "@/components/widgets/TemperatureHistoric"; import WindspeedHourly from "@/components/widgets/HourlyData/patterns/Windspeed"; import PrecipitationHourly from "@/components/widgets/HourlyData/patterns/Precipitation"; -import WindspeedCurrent from "@/components/widgets/CurrentData/patterns/Windspeed"; -import { useEfd } from "@/api/efd"; +import { SummitDataProvider } from "@/contexts/SummitData"; +import Weather from "@/components/dynamic/SummitData/Weather"; const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { /** this logic should be changed to useRouter after i18n refactor */ @@ -91,9 +91,9 @@ const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { } ); - const [data, loading] = useEfd(); + // const [data, loading] = useEfd(); // eslint-disable-next-line no-console - console.log({ data, loading }); + // console.log({ data, loading }); return ( @@ -102,35 +102,41 @@ const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { onTempChangeCallback={(value) => setTempUnit(value)} onWindChangeCallback={(value) => setWindspeedUnit(value)} /> - - - - - - - - - - - - - - - + + + + {/* + + + + + + + + + + + + */} + + ); diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js new file mode 100644 index 00000000..13bf57cb --- /dev/null +++ b/components/dynamic/SummitData/Weather/index.js @@ -0,0 +1,42 @@ +import WidgetPreview from "@/components/layout/WidgetPreview"; +import TemperatureCurrent from "@/components/widgets/TemperatureCurrent"; +import { useSummitData } from "@/contexts/SummitData"; +import { defaultUnits, useWeatherUnit } from "@/contexts/WeatherUnit"; +import convert from "convert"; + +const Weather = () => { + const { tempUnit, windspeedUnit } = useWeatherUnit(); + const { data, loading } = useSummitData(); + + if (loading || !data) return null; + + console.log({ data }); + + const { + temperature0: { _value: currentTemperature }, + } = data; + + const temperatureData = { currentTemperature }; + + if ({ tempUnit, windspeedUnit } !== defaultUnits) { + Object.entries(temperatureData).forEach(([key, value]) => { + temperatureData[key] = convert(value, defaultUnits.tempUnit).to(tempUnit); + }); + } + + return ( + + + + ); +}; + +Weather.displayName = "Dynamic.Weather"; + +export default Weather; diff --git a/contexts/SummitData.js b/contexts/SummitData.js new file mode 100644 index 00000000..ebc88635 --- /dev/null +++ b/contexts/SummitData.js @@ -0,0 +1,41 @@ +import getEfd from "@/lib/api/efd"; +import { createContext, useContext, useEffect, useMemo, useState } from "react"; + +export const SummitDataContext = createContext({}); + +export const SummitDataProvider = ({ children }) => { + const [data, setData] = useState(); + const [error, setError] = useState(false); + const [loading, setLoading] = useState(false); + + useEffect(() => { + setLoading(true); + getEfd() + .then((value) => { + setData(value); + }) + .catch(() => { + setError(true); + }) + .finally(() => { + setLoading(false); + }); + }, []); + + const value = useMemo( + () => ({ + data, + loading, + error, + }), + [data, loading, error] + ); + + return ( + + {children} + + ); +}; + +export const useSummitData = () => useContext(SummitDataContext); diff --git a/contexts/WeatherUnit.js b/contexts/WeatherUnit.js index e05c08ff..f87c1d8b 100644 --- a/contexts/WeatherUnit.js +++ b/contexts/WeatherUnit.js @@ -1,13 +1,13 @@ import { createContext, useContext } from "react"; -const defaultUnits = { +export const defaultUnits = { tempUnit: "C", windSpeedUnit: "m", }; -const WeatherUnitContext = createContext(); +const WeatherUnitContext = createContext(defaultUnits); -export function useWeatherUnitContext() { +export function useWeatherUnit() { return useContext(WeatherUnitContext); } diff --git a/lib/api/efd.js b/lib/api/efd.js index 181ac31f..35f1d2df 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -1,6 +1,39 @@ import { InfluxDB, flux } from "@influxdata/influxdb-client"; import { useEffect, useState } from "react"; +export default function getEfd() { + const url = process.env.NEXT_PUBLIC_EFD_URL; + const bucket = process.env.NEXT_PUBLIC_EFD_BUCKET; + const token = process.env.NEXT_PUBLIC_EFD_TOKEN; + + const influxDB = new InfluxDB({ url, token }); + const queryApi = influxDB.getQueryApi(""); + + return new Promise((resolve, reject) => { + const data = {}; + queryApi.queryRows( + flux`from(bucket: "${bucket}") + |> range(start: -60s) + |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.pressure" or r["_measurement"] == "lsst.sal.ESS.dewPoint" or r["_measurement"] == "lsst.sal.ESS.temperature" or r["_measurement"] == "lsst.sal.ESS.relativeHumidity" or r["_measurement"] == "lsst.sal.ESS.airFlow") + |> filter(fn: (r) => r["_field"] == "temperature0" or r["_field"] == "speed" or r["_field"] == "pressure0" or r["_field"] == "direction") + |> last()`, + { + next(row, tableMeta) { + const o = tableMeta.toObject(row); + const { _field } = o; + data[_field] = o; + }, + error(error) { + reject(error); + }, + complete() { + resolve(data); + }, + } + ); + }); +} + export function useEfd(fluxQuery) { const [loading, setLoading] = useState(false); const [result, setResult] = useState([]); From 47aad98506b6c68bb7ab9dbad153f02556806cac Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 14 Jun 2023 14:51:48 -0700 Subject: [PATCH 09/98] [F] SummitData provider --- .../content-blocks/SummitStatus/index.js | 10 +-- .../dynamic/SummitData/Weather/index.js | 26 +++++-- contexts/SummitData.js | 5 +- contexts/WeatherUnit.js | 2 +- lib/api/efd.js | 74 +++---------------- 5 files changed, 35 insertions(+), 82 deletions(-) diff --git a/components/content-blocks/SummitStatus/index.js b/components/content-blocks/SummitStatus/index.js index fe2b346f..ceffd81d 100644 --- a/components/content-blocks/SummitStatus/index.js +++ b/components/content-blocks/SummitStatus/index.js @@ -1,15 +1,10 @@ import PropTypes from "prop-types"; -import { useState, Suspense } from "react"; +import { useState } from "react"; import { Container } from "@rubin-epo/epo-react-lib"; import { useTranslation } from "react-i18next"; import WeatherUnitContext from "@/contexts/WeatherUnit"; import UnitLocalization from "@/components/layout/UnitLocalization"; import WidgetGrid from "@/components/layout/WidgetGrid"; -import WidgetPreview from "@/components/layout/WidgetPreview"; -import TemperatureCurrent from "@/components/widgets/CurrentData/patterns/Temperature"; -import TemperatureHistoric from "@/components/widgets/TemperatureHistoric"; -import WindspeedHourly from "@/components/widgets/HourlyData/patterns/Windspeed"; -import PrecipitationHourly from "@/components/widgets/HourlyData/patterns/Precipitation"; import { SummitDataProvider } from "@/contexts/SummitData"; import Weather from "@/components/dynamic/SummitData/Weather"; @@ -91,9 +86,6 @@ const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { } ); - // const [data, loading] = useEfd(); - // eslint-disable-next-line no-console - // console.log({ data, loading }); return ( diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 13bf57cb..69f5e535 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -1,4 +1,5 @@ import WidgetPreview from "@/components/layout/WidgetPreview"; +import PrecipitationCurrent from "@/components/widgets/PrecipitationCurrent"; import TemperatureCurrent from "@/components/widgets/TemperatureCurrent"; import { useSummitData } from "@/contexts/SummitData"; import { defaultUnits, useWeatherUnit } from "@/contexts/WeatherUnit"; @@ -10,20 +11,30 @@ const Weather = () => { if (loading || !data) return null; - console.log({ data }); + const { temperature0: temperature, relativeHumidity, windSpeed } = data; - const { - temperature0: { _value: currentTemperature }, - } = data; + const temperatureData = { + temperature, + }; - const temperatureData = { currentTemperature }; + const windspeedData = { + windSpeed, + }; - if ({ tempUnit, windspeedUnit } !== defaultUnits) { + if (tempUnit !== defaultUnits.tempUnit) { Object.entries(temperatureData).forEach(([key, value]) => { temperatureData[key] = convert(value, defaultUnits.tempUnit).to(tempUnit); }); } + if (windspeedUnit !== defaultUnits.windspeedUnit) { + Object.entries(windspeedData).forEach(([key, value]) => { + windspeedData[key] = convert(value, defaultUnits.windspeedUnit).to( + windspeedUnit + ); + }); + } + return ( { > + ); }; diff --git a/contexts/SummitData.js b/contexts/SummitData.js index ebc88635..679ef6a4 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -1,5 +1,6 @@ -import getEfd from "@/lib/api/efd"; import { createContext, useContext, useEffect, useMemo, useState } from "react"; +import PropTypes from "prop-types"; +import getEfd from "@/lib/api/efd"; export const SummitDataContext = createContext({}); @@ -38,4 +39,6 @@ export const SummitDataProvider = ({ children }) => { ); }; +SummitDataProvider.propTypes = { children: PropTypes.node }; + export const useSummitData = () => useContext(SummitDataContext); diff --git a/contexts/WeatherUnit.js b/contexts/WeatherUnit.js index f87c1d8b..53abeca3 100644 --- a/contexts/WeatherUnit.js +++ b/contexts/WeatherUnit.js @@ -2,7 +2,7 @@ import { createContext, useContext } from "react"; export const defaultUnits = { tempUnit: "C", - windSpeedUnit: "m", + windspeedUnit: "m", }; const WeatherUnitContext = createContext(defaultUnits); diff --git a/lib/api/efd.js b/lib/api/efd.js index 35f1d2df..91beb1b7 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -1,5 +1,4 @@ import { InfluxDB, flux } from "@influxdata/influxdb-client"; -import { useEffect, useState } from "react"; export default function getEfd() { const url = process.env.NEXT_PUBLIC_EFD_URL; @@ -10,18 +9,21 @@ export default function getEfd() { const queryApi = influxDB.getQueryApi(""); return new Promise((resolve, reject) => { - const data = {}; + let data = {}; queryApi.queryRows( flux`from(bucket: "${bucket}") |> range(start: -60s) - |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.pressure" or r["_measurement"] == "lsst.sal.ESS.dewPoint" or r["_measurement"] == "lsst.sal.ESS.temperature" or r["_measurement"] == "lsst.sal.ESS.relativeHumidity" or r["_measurement"] == "lsst.sal.ESS.airFlow") - |> filter(fn: (r) => r["_field"] == "temperature0" or r["_field"] == "speed" or r["_field"] == "pressure0" or r["_field"] == "direction") - |> last()`, + |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.temperature" or r["_measurement"] == "lsst.sal.ESS.relativeHumidity" or r["_measurement"] == "lsst.sal.ESS.airFlow") + |> filter(fn: (r) => r["_field"] == "relativeHumidity" or r["_field"] == "temperature0" or r["_field"] == "speed" or r["_field"] == "pressure0") + |> last() + |> set(key: "_pivoter", value: "stuff") + |> group() + |> pivot(rowKey:["_pivoter"], columnKey: ["_field"], valueColumn: "_value") + |> drop(columns: ["_pivoter"]) + |> rename(columns: {speed: "windSpeed"})`, { next(row, tableMeta) { - const o = tableMeta.toObject(row); - const { _field } = o; - data[_field] = o; + data = tableMeta.toObject(row); }, error(error) { reject(error); @@ -33,59 +35,3 @@ export default function getEfd() { ); }); } - -export function useEfd(fluxQuery) { - const [loading, setLoading] = useState(false); - const [result, setResult] = useState([]); - - const url = process.env.NEXT_PUBLIC_EFD_URL; - const bucket = process.env.NEXT_PUBLIC_EFD_BUCKET; - const token = process.env.NEXT_PUBLIC_EFD_TOKEN; - - const influxDB = new InfluxDB({ url, token }); - const queryApi = influxDB.getQueryApi(""); - - useEffect(() => { - async function fetchQuery() { - try { - setLoading(true); - const response = new Promise((resolve, reject) => { - const data = []; - queryApi.queryRows( - flux`from(bucket: "${bucket}") - |> range(start: 2023-05-31T19:00:00Z, stop: 2023-05-31T20:00:00Z) - |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.temperature") - |> filter(fn: (r) => r["_field"] == "temperature0") - |> last()`, - { - next(row, tableMeta) { - const o = tableMeta.toObject(row); - data.push(o); - }, - error(error) { - reject(error); - }, - complete() { - resolve(data); - }, - } - ); - }); - - await response - .then((res) => { - setResult(res); - }) - .finally(() => { - setLoading(false); - }); - } catch (error) { - setLoading(false); - } - } - - fetchQuery(); - }, [fluxQuery]); - - return [result, loading]; -} From 107746de0a3448257fa33887fdfedfde9e5dc925 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 15 Jun 2023 15:46:35 -0700 Subject: [PATCH 10/98] [C] set up individual queries --- contexts/SummitData.js | 8 +++-- lib/api/efd.js | 38 +++++++------------- lib/api/queries/weather.js | 71 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 27 deletions(-) create mode 100644 lib/api/queries/weather.js diff --git a/contexts/SummitData.js b/contexts/SummitData.js index 679ef6a4..72ed4b15 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -1,6 +1,7 @@ import { createContext, useContext, useEffect, useMemo, useState } from "react"; +import { currentWeather, dailyWeather } from "@/lib/api/queries/weather"; import PropTypes from "prop-types"; -import getEfd from "@/lib/api/efd"; +import queryEfd from "@/lib/api/efd"; export const SummitDataContext = createContext({}); @@ -11,8 +12,11 @@ export const SummitDataProvider = ({ children }) => { useEffect(() => { setLoading(true); - getEfd() + + // Promise.all(queryEfd(currentWeather), queryEfd(dailyWeather)) + queryEfd(dailyWeather) .then((value) => { + console.log({ value }); setData(value); }) .catch(() => { diff --git a/lib/api/efd.js b/lib/api/efd.js index 91beb1b7..ea342958 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -1,6 +1,6 @@ -import { InfluxDB, flux } from "@influxdata/influxdb-client"; +import { InfluxDB } from "@influxdata/influxdb-client"; -export default function getEfd() { +export default function queryEfd(query) { const url = process.env.NEXT_PUBLIC_EFD_URL; const bucket = process.env.NEXT_PUBLIC_EFD_BUCKET; const token = process.env.NEXT_PUBLIC_EFD_TOKEN; @@ -10,28 +10,16 @@ export default function getEfd() { return new Promise((resolve, reject) => { let data = {}; - queryApi.queryRows( - flux`from(bucket: "${bucket}") - |> range(start: -60s) - |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.temperature" or r["_measurement"] == "lsst.sal.ESS.relativeHumidity" or r["_measurement"] == "lsst.sal.ESS.airFlow") - |> filter(fn: (r) => r["_field"] == "relativeHumidity" or r["_field"] == "temperature0" or r["_field"] == "speed" or r["_field"] == "pressure0") - |> last() - |> set(key: "_pivoter", value: "stuff") - |> group() - |> pivot(rowKey:["_pivoter"], columnKey: ["_field"], valueColumn: "_value") - |> drop(columns: ["_pivoter"]) - |> rename(columns: {speed: "windSpeed"})`, - { - next(row, tableMeta) { - data = tableMeta.toObject(row); - }, - error(error) { - reject(error); - }, - complete() { - resolve(data); - }, - } - ); + queryApi.queryRows(query(bucket), { + next(row, tableMeta) { + data = tableMeta.toObject(row); + }, + error(error) { + reject(error); + }, + complete() { + resolve(data); + }, + }); }); } diff --git a/lib/api/queries/weather.js b/lib/api/queries/weather.js new file mode 100644 index 00000000..443c9d4d --- /dev/null +++ b/lib/api/queries/weather.js @@ -0,0 +1,71 @@ +import { flux } from "@influxdata/influxdb-client"; + +export const currentWeather = (bucket) => flux`from(bucket: "${bucket}") + |> range(start: -60s) + |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.pressure" or r["_measurement"] == "lsst.sal.ESS.dewPoint" or r["_measurement"] == "lsst.sal.ESS.temperature" or r["_measurement"] == "lsst.sal.ESS.relativeHumidity" or r["_measurement"] == "lsst.sal.ESS.airFlow") + |> filter(fn: (r) => r["_field"] == "relativeHumidity" or r["_field"] == "dewPoint" or r["_field"] == "temperature0" or r["_field"] == "speed" or r["_field"] == "pressure0" or r["_field"] == "direction") + |> last() + |> set(key: "_pivoter", value: "stuff") + |> group() + |> pivot(rowKey:["_pivoter"], columnKey: ["_field"], valueColumn: "_value") + |> drop(columns: ["_pivoter"]) + |> rename(columns: {direction: "windDirection", speed: "windSpeed"}) + |> yield(name: "realtime")`; + +export const hourlyWeather = (bucket) => { + const date = new Date().setUTCHours(0, 0, 0, 0); + return flux` + import "date" +data = from(bucket: "${bucket}") + |> range(start: date.truncate(t: now(), unit: 1d), stop: now()) + |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.pressure" or r["_measurement"] == "lsst.sal.ESS.dewPoint" or r["_measurement"] == "lsst.sal.ESS.temperature" or r["_measurement"] == "lsst.sal.ESS.relativeHumidity" or r["_measurement"] == "lsst.sal.ESS.airFlow") + |> filter(fn: (r) => r["_field"] == "relativeHumidity" or r["_field"] == "dewPoint" or r["_field"] == "temperature0" or r["_field"] == "speed" or r["_field"] == "pressure0" or r["_field"] == "direction") + |> drop(columns: ["_measurement"]) + +min = data + |> aggregateWindow(every: 1h, fn: min) + |> map(fn: (r) => ({r with _field: r._field + "_min"})) + +mean = data + |> aggregateWindow(every: 1h, fn: mean) + |> map(fn: (r) => ({r with _field: r._field + "_mean"})) + +max = data + |> aggregateWindow(every: 1h, fn: max) + |> map(fn: (r) => ({r with _field: r._field + "_max"})) + +union(tables: [min, mean, max]) + |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") + |> yield(name: "historical")`; +}; + +export const dailyWeather = (bucket) => { + const target = 1; // Monday + const today = new Date(); + const date = new Date().setDate( + today.getDate() - + (today.getDay() == target ? 7 : (today.getDay() + (7 - target)) % 7) + ); + + return flux`data = from(bucket: "${bucket}") + |> range(start: time(v: ${new Date(date).toISOString()}), stop: now()) + |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.pressure" or r["_measurement"] == "lsst.sal.ESS.dewPoint" or r["_measurement"] == "lsst.sal.ESS.temperature" or r["_measurement"] == "lsst.sal.ESS.relativeHumidity" or r["_measurement"] == "lsst.sal.ESS.airFlow") + |> filter(fn: (r) => r["_field"] == "relativeHumidity" or r["_field"] == "dewPoint" or r["_field"] == "temperature0" or r["_field"] == "speed" or r["_field"] == "pressure0" or r["_field"] == "direction") + |> drop(columns: ["_measurement"]) + + min = data + |> aggregateWindow(every: 1d, fn: min, createEmpty: true) + |> map(fn: (r) => ({r with _field: r._field + "_min"})) + + mean = data + |> aggregateWindow(every: 1d, fn: mean, createEmpty: true) + |> map(fn: (r) => ({r with _field: r._field + "_mean"})) + + max = data + |> aggregateWindow(every: 1d, fn: max, createEmpty: true) + |> map(fn: (r) => ({r with _field: r._field + "_max"})) + + union(tables: [min, mean, max]) + |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") + |> yield(name: "historical")`; +}; From e184449ac9b9d81437b79520367a4ce49a27e821 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Fri, 16 Jun 2023 13:42:16 -0700 Subject: [PATCH 11/98] [C] parallel data query requests --- .../content-blocks/SummitStatus/index.js | 8 ++- .../dynamic/SummitData/Weather/index.js | 12 ++-- contexts/SummitData.js | 68 +++++++++++++++---- lib/api/efd.js | 4 +- lib/api/queries/weather.js | 14 ++-- 5 files changed, 75 insertions(+), 31 deletions(-) diff --git a/components/content-blocks/SummitStatus/index.js b/components/content-blocks/SummitStatus/index.js index ceffd81d..0b2cf93e 100644 --- a/components/content-blocks/SummitStatus/index.js +++ b/components/content-blocks/SummitStatus/index.js @@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next"; import WeatherUnitContext from "@/contexts/WeatherUnit"; import UnitLocalization from "@/components/layout/UnitLocalization"; import WidgetGrid from "@/components/layout/WidgetGrid"; +import WidgetPreview from "@/components/layout/WidgetPreview"; import { SummitDataProvider } from "@/contexts/SummitData"; import Weather from "@/components/dynamic/SummitData/Weather"; @@ -96,7 +97,12 @@ const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { /> - + + + {/* { const { tempUnit, windspeedUnit } = useWeatherUnit(); - const { data, loading } = useSummitData(); + const { currentData: data, loading = true } = useSummitData(); - if (loading || !data) return null; + if (loading && !data) return ; const { temperature0: temperature, relativeHumidity, windSpeed } = data; @@ -36,16 +37,13 @@ const Weather = () => { } return ( - + <> - + ); }; diff --git a/contexts/SummitData.js b/contexts/SummitData.js index 72ed4b15..11ad5e82 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -1,25 +1,67 @@ import { createContext, useContext, useEffect, useMemo, useState } from "react"; -import { currentWeather, dailyWeather } from "@/lib/api/queries/weather"; +import { + currentWeather, + dailyWeather, + hourlyWeather, +} from "@/lib/api/queries/weather"; import PropTypes from "prop-types"; import queryEfd from "@/lib/api/efd"; export const SummitDataContext = createContext({}); export const SummitDataProvider = ({ children }) => { - const [data, setData] = useState(); + const [currentData, setCurrentData] = useState(); + const [hourlyData, setHourlyData] = useState(); + const [dailyData, setDailyData] = useState(); const [error, setError] = useState(false); - const [loading, setLoading] = useState(false); + const [loading, setLoading] = useState(true); + + const fetchCurrentWeather = () => + new Promise((resolve, reject) => { + queryEfd(currentWeather) + .then((value) => { + setCurrentData(...value); + resolve(...value); + }) + .catch((e) => { + reject(e); + }); + }); + + const fetchHourlyWeather = () => + new Promise((resolve, reject) => { + queryEfd(hourlyWeather) + .then((value) => { + setHourlyData(value); + resolve(value); + }) + .catch((e) => { + reject(e); + }); + }); + + const fetchDailyWeather = () => + new Promise((resolve, reject) => { + queryEfd(dailyWeather) + .then((value) => { + setDailyData(value); + resolve(value); + }) + .catch((e) => { + reject(e); + }); + }); useEffect(() => { setLoading(true); - // Promise.all(queryEfd(currentWeather), queryEfd(dailyWeather)) - queryEfd(dailyWeather) - .then((value) => { - console.log({ value }); - setData(value); - }) - .catch(() => { + Promise.allSettled([ + fetchCurrentWeather(), + fetchHourlyWeather(), + fetchDailyWeather(), + ]) + .catch((e) => { + console.error(e); setError(true); }) .finally(() => { @@ -29,11 +71,13 @@ export const SummitDataProvider = ({ children }) => { const value = useMemo( () => ({ - data, + currentData, + hourlyData, + dailyData, loading, error, }), - [data, loading, error] + [currentData, hourlyData, dailyData, loading, error] ); return ( diff --git a/lib/api/efd.js b/lib/api/efd.js index ea342958..5e034b09 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -9,10 +9,10 @@ export default function queryEfd(query) { const queryApi = influxDB.getQueryApi(""); return new Promise((resolve, reject) => { - let data = {}; + let data = []; queryApi.queryRows(query(bucket), { next(row, tableMeta) { - data = tableMeta.toObject(row); + data.push(tableMeta.toObject(row)); }, error(error) { reject(error); diff --git a/lib/api/queries/weather.js b/lib/api/queries/weather.js index 443c9d4d..7c0835e9 100644 --- a/lib/api/queries/weather.js +++ b/lib/api/queries/weather.js @@ -13,7 +13,6 @@ export const currentWeather = (bucket) => flux`from(bucket: "${bucket}") |> yield(name: "realtime")`; export const hourlyWeather = (bucket) => { - const date = new Date().setUTCHours(0, 0, 0, 0); return flux` import "date" data = from(bucket: "${bucket}") @@ -40,15 +39,11 @@ union(tables: [min, mean, max]) }; export const dailyWeather = (bucket) => { - const target = 1; // Monday - const today = new Date(); - const date = new Date().setDate( - today.getDate() - - (today.getDay() == target ? 7 : (today.getDay() + (7 - target)) % 7) - ); - + const date = new Date(); + date.setDate(date.getDate() - 7); + date.setHours(0, 0, 0, 0); return flux`data = from(bucket: "${bucket}") - |> range(start: time(v: ${new Date(date).toISOString()}), stop: now()) + |> range(start: ${date}, stop: now()) |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.pressure" or r["_measurement"] == "lsst.sal.ESS.dewPoint" or r["_measurement"] == "lsst.sal.ESS.temperature" or r["_measurement"] == "lsst.sal.ESS.relativeHumidity" or r["_measurement"] == "lsst.sal.ESS.airFlow") |> filter(fn: (r) => r["_field"] == "relativeHumidity" or r["_field"] == "dewPoint" or r["_field"] == "temperature0" or r["_field"] == "speed" or r["_field"] == "pressure0" or r["_field"] == "direction") |> drop(columns: ["_measurement"]) @@ -67,5 +62,6 @@ export const dailyWeather = (bucket) => { union(tables: [min, mean, max]) |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") + |> sort(columns: ["_time"]) |> yield(name: "historical")`; }; From bb2101010cf66df239780eb09b3f0dc4e7337e38 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Tue, 20 Jun 2023 10:28:18 -0700 Subject: [PATCH 12/98] [C] linting --- components/dynamic/SummitData/Weather/index.js | 1 - lib/api/efd.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 83df3448..00f0bdb7 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -1,5 +1,4 @@ import Loader from "@/components/atomic/Loader"; -import WidgetPreview from "@/components/layout/WidgetPreview"; import PrecipitationCurrent from "@/components/widgets/PrecipitationCurrent"; import TemperatureCurrent from "@/components/widgets/TemperatureCurrent"; import { useSummitData } from "@/contexts/SummitData"; diff --git a/lib/api/efd.js b/lib/api/efd.js index 5e034b09..5a1a32e4 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -9,7 +9,7 @@ export default function queryEfd(query) { const queryApi = influxDB.getQueryApi(""); return new Promise((resolve, reject) => { - let data = []; + const data = []; queryApi.queryRows(query(bucket), { next(row, tableMeta) { data.push(tableMeta.toObject(row)); From f68cd60e5ab6bb045ca8e8e60abb7ffea7385956 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Tue, 20 Jun 2023 10:43:08 -0700 Subject: [PATCH 13/98] [C] remove commented code --- .../content-blocks/SummitStatus/index.js | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/components/content-blocks/SummitStatus/index.js b/components/content-blocks/SummitStatus/index.js index 0b2cf93e..fb8f462c 100644 --- a/components/content-blocks/SummitStatus/index.js +++ b/components/content-blocks/SummitStatus/index.js @@ -103,36 +103,6 @@ const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { > - {/* - - - - - - - - - - - - */} From 8f9723db949034179c0c3e40cc12a8cbbae0687f Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 21 Jun 2023 13:20:51 -0700 Subject: [PATCH 14/98] [C] update path --- components/dynamic/SummitData/Weather/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 00f0bdb7..4f1853a9 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -1,6 +1,6 @@ import Loader from "@/components/atomic/Loader"; -import PrecipitationCurrent from "@/components/widgets/PrecipitationCurrent"; -import TemperatureCurrent from "@/components/widgets/TemperatureCurrent"; +import PrecipitationCurrent from "@/components/widgets/CurrentData/patterns/Precipitation"; +import TemperatureCurrent from "@/components/widgets/CurrentData/patterns/Temperature"; import { useSummitData } from "@/contexts/SummitData"; import { defaultUnits, useWeatherUnit } from "@/contexts/WeatherUnit"; import convert from "convert"; From 2a4da5a59fcda7ee27822c964dfc7b043166e180 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 30 May 2023 15:24:27 -0700 Subject: [PATCH 15/98] [F] Basic EFD fetch POC in SummitStatus component --- components/content-blocks/SummitStatus/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/content-blocks/SummitStatus/index.js b/components/content-blocks/SummitStatus/index.js index fb8f462c..f40a49f6 100644 --- a/components/content-blocks/SummitStatus/index.js +++ b/components/content-blocks/SummitStatus/index.js @@ -87,6 +87,9 @@ const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { } ); + const [data, loading] = useEfd(); + // eslint-disable-next-line no-console + console.log({ data, loading }); return ( From b837a96243dbe53e43a48bba3b3885e94ebbf690 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 14 Jun 2023 12:18:31 -0700 Subject: [PATCH 16/98] [F] SummitData provider --- .../content-blocks/SummitStatus/index.js | 47 +++++++++++++++++-- .../dynamic/SummitData/Weather/index.js | 34 ++++++++++++++ contexts/SummitData.js | 30 ++++++++++++ 3 files changed, 108 insertions(+), 3 deletions(-) diff --git a/components/content-blocks/SummitStatus/index.js b/components/content-blocks/SummitStatus/index.js index f40a49f6..85bf2f34 100644 --- a/components/content-blocks/SummitStatus/index.js +++ b/components/content-blocks/SummitStatus/index.js @@ -1,11 +1,18 @@ import PropTypes from "prop-types"; -import { useState } from "react"; +import { useState, Suspense } from "react"; import { Container } from "@rubin-epo/epo-react-lib"; import { useTranslation } from "react-i18next"; import WeatherUnitContext from "@/contexts/WeatherUnit"; import UnitLocalization from "@/components/layout/UnitLocalization"; import WidgetGrid from "@/components/layout/WidgetGrid"; import WidgetPreview from "@/components/layout/WidgetPreview"; +<<<<<<< HEAD +======= +import TemperatureCurrent from "@/components/widgets/CurrentData/patterns/Temperature"; +import TemperatureHistoric from "@/components/widgets/TemperatureHistoric"; +import WindspeedHourly from "@/components/widgets/HourlyData/patterns/Windspeed"; +import PrecipitationHourly from "@/components/widgets/HourlyData/patterns/Precipitation"; +>>>>>>> ebb054c ([F] SummitData provider) import { SummitDataProvider } from "@/contexts/SummitData"; import Weather from "@/components/dynamic/SummitData/Weather"; @@ -87,9 +94,9 @@ const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { } ); - const [data, loading] = useEfd(); + // const [data, loading] = useEfd(); // eslint-disable-next-line no-console - console.log({ data, loading }); + // console.log({ data, loading }); return ( @@ -100,12 +107,46 @@ const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { /> +<<<<<<< HEAD +======= + + {/* + + + + + + + + + + + + */} +>>>>>>> ebb054c ([F] SummitData provider) diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 4f1853a9..502bb62b 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -1,12 +1,18 @@ +<<<<<<< HEAD import Loader from "@/components/atomic/Loader"; import PrecipitationCurrent from "@/components/widgets/CurrentData/patterns/Precipitation"; import TemperatureCurrent from "@/components/widgets/CurrentData/patterns/Temperature"; +======= +import WidgetPreview from "@/components/layout/WidgetPreview"; +import TemperatureCurrent from "@/components/widgets/TemperatureCurrent"; +>>>>>>> ebb054c ([F] SummitData provider) import { useSummitData } from "@/contexts/SummitData"; import { defaultUnits, useWeatherUnit } from "@/contexts/WeatherUnit"; import convert from "convert"; const Weather = () => { const { tempUnit, windspeedUnit } = useWeatherUnit(); +<<<<<<< HEAD const { currentData: data, loading = true } = useSummitData(); if (loading && !data) return ; @@ -22,11 +28,27 @@ const Weather = () => { }; if (tempUnit !== defaultUnits.tempUnit) { +======= + const { data, loading } = useSummitData(); + + if (loading || !data) return null; + + console.log({ data }); + + const { + temperature0: { _value: currentTemperature }, + } = data; + + const temperatureData = { currentTemperature }; + + if ({ tempUnit, windspeedUnit } !== defaultUnits) { +>>>>>>> ebb054c ([F] SummitData provider) Object.entries(temperatureData).forEach(([key, value]) => { temperatureData[key] = convert(value, defaultUnits.tempUnit).to(tempUnit); }); } +<<<<<<< HEAD if (windspeedUnit !== defaultUnits.windspeedUnit) { Object.entries(windspeedData).forEach(([key, value]) => { windspeedData[key] = convert(value, defaultUnits.windspeedUnit).to( @@ -43,6 +65,18 @@ const Weather = () => { /> +======= + return ( + + + +>>>>>>> ebb054c ([F] SummitData provider) ); }; diff --git a/contexts/SummitData.js b/contexts/SummitData.js index 11ad5e82..225d6b93 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -1,3 +1,4 @@ +<<<<<<< HEAD import { createContext, useContext, useEffect, useMemo, useState } from "react"; import { currentWeather, @@ -6,10 +7,15 @@ import { } from "@/lib/api/queries/weather"; import PropTypes from "prop-types"; import queryEfd from "@/lib/api/efd"; +======= +import getEfd from "@/lib/api/efd"; +import { createContext, useContext, useEffect, useMemo, useState } from "react"; +>>>>>>> ebb054c ([F] SummitData provider) export const SummitDataContext = createContext({}); export const SummitDataProvider = ({ children }) => { +<<<<<<< HEAD const [currentData, setCurrentData] = useState(); const [hourlyData, setHourlyData] = useState(); const [dailyData, setDailyData] = useState(); @@ -62,6 +68,19 @@ export const SummitDataProvider = ({ children }) => { ]) .catch((e) => { console.error(e); +======= + const [data, setData] = useState(); + const [error, setError] = useState(false); + const [loading, setLoading] = useState(false); + + useEffect(() => { + setLoading(true); + getEfd() + .then((value) => { + setData(value); + }) + .catch(() => { +>>>>>>> ebb054c ([F] SummitData provider) setError(true); }) .finally(() => { @@ -71,6 +90,7 @@ export const SummitDataProvider = ({ children }) => { const value = useMemo( () => ({ +<<<<<<< HEAD currentData, hourlyData, dailyData, @@ -78,6 +98,13 @@ export const SummitDataProvider = ({ children }) => { error, }), [currentData, hourlyData, dailyData, loading, error] +======= + data, + loading, + error, + }), + [data, loading, error] +>>>>>>> ebb054c ([F] SummitData provider) ); return ( @@ -87,6 +114,9 @@ export const SummitDataProvider = ({ children }) => { ); }; +<<<<<<< HEAD SummitDataProvider.propTypes = { children: PropTypes.node }; +======= +>>>>>>> ebb054c ([F] SummitData provider) export const useSummitData = () => useContext(SummitDataContext); From 66f4f12d9c24cb36fc4fdbc16180d56a10bc99f3 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 21 Jun 2023 13:17:30 -0700 Subject: [PATCH 17/98] [F] SummitStatusModal --- components/atomic/Loader/styles.js | 1 + .../content-blocks/SummitStatus/index.js | 141 +----------------- .../dynamic/SummitData/Weather/Daily/index.js | 49 ++++++ .../SummitData/Weather/Hourly/index.js | 47 ++++++ .../dynamic/SummitData/Weather/index.js | 105 +++++-------- components/layout/UnitLocalization/index.js | 19 +-- components/layout/WidgetSection/index.js | 2 +- components/modal/SummitStatusModal/index.js | 34 +++++ components/modal/SummitStatusModal/styles.js | 53 +++++++ components/widgets/HourlyData/styles.js | 1 + contexts/WeatherUnit.js | 56 ++++++- helpers/converters.js | 11 ++ lib/api/queries/weather.js | 12 +- lib/localeStrings/en.json | 5 + 14 files changed, 308 insertions(+), 228 deletions(-) create mode 100644 components/dynamic/SummitData/Weather/Daily/index.js create mode 100644 components/dynamic/SummitData/Weather/Hourly/index.js create mode 100644 components/modal/SummitStatusModal/index.js create mode 100644 components/modal/SummitStatusModal/styles.js create mode 100644 helpers/converters.js diff --git a/components/atomic/Loader/styles.js b/components/atomic/Loader/styles.js index 27e82454..da8dd54a 100644 --- a/components/atomic/Loader/styles.js +++ b/components/atomic/Loader/styles.js @@ -5,4 +5,5 @@ export const Loader = styled(CircularLoader)` display: flex; align-items: center; justify-content: center; + grid-column: 1/-1; `; diff --git a/components/content-blocks/SummitStatus/index.js b/components/content-blocks/SummitStatus/index.js index 85bf2f34..60f35231 100644 --- a/components/content-blocks/SummitStatus/index.js +++ b/components/content-blocks/SummitStatus/index.js @@ -1,155 +1,22 @@ import PropTypes from "prop-types"; -import { useState, Suspense } from "react"; import { Container } from "@rubin-epo/epo-react-lib"; -import { useTranslation } from "react-i18next"; -import WeatherUnitContext from "@/contexts/WeatherUnit"; +import { WeatherUnitProvider } from "@/contexts/WeatherUnit"; import UnitLocalization from "@/components/layout/UnitLocalization"; import WidgetGrid from "@/components/layout/WidgetGrid"; -import WidgetPreview from "@/components/layout/WidgetPreview"; -<<<<<<< HEAD -======= -import TemperatureCurrent from "@/components/widgets/CurrentData/patterns/Temperature"; -import TemperatureHistoric from "@/components/widgets/TemperatureHistoric"; -import WindspeedHourly from "@/components/widgets/HourlyData/patterns/Windspeed"; -import PrecipitationHourly from "@/components/widgets/HourlyData/patterns/Precipitation"; ->>>>>>> ebb054c ([F] SummitData provider) import { SummitDataProvider } from "@/contexts/SummitData"; import Weather from "@/components/dynamic/SummitData/Weather"; const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { - /** this logic should be changed to useRouter after i18n refactor */ - const { - i18n: { language = "en" }, - } = useTranslation(); - const [windspeedUnit, setWindspeedUnit] = useState( - language === "en" ? "NM" : "m" - ); - const [tempUnit, setTempUnit] = useState( - language === "en" ? "fahrenheit" : "celsius" - ); - - const mockWindspeedData = [ - { windspeed: 5.2342342, direction: 120 }, - { windspeed: 4.7, direction: 112 }, - { windspeed: 6.1, direction: 98 }, - { windspeed: 3.8, direction: 105 }, - { windspeed: 5.5, direction: 117 }, - { windspeed: 7.2, direction: 125 }, - { windspeed: 4.3, direction: 103 }, - { windspeed: 6.8, direction: 108 }, - { windspeed: 5.14343, direction: 115 }, - { windspeed: 4.9, direction: 98 }, - { windspeed: 5.7, direction: 105 }, - { windspeed: 6.5, direction: 114 }, - { windspeed: 3.9, direction: 99 }, - { windspeed: 4.1, direction: 102 }, - { windspeed: 5.3, direction: 108 }, - { windspeed: 6.3, direction: 116 }, - {}, - {}, - {}, - {}, - {}, - {}, - {}, - {}, - ]; - - const mockPrecipitationData = [ - { probability: 0.0 }, - { probability: 0.0 }, - { probability: 0.0 }, - { probability: 0.0 }, - { probability: 0.0 }, - { probability: 0.0 }, - { probability: 0.0 }, - { probability: 0.0 }, - { probability: 0.01 }, - { probability: 0.02 }, - { probability: 0.03 }, - { probability: 0.04 }, - { probability: 0.05 }, - { probability: 0.03 }, - { probability: 0.02 }, - { probability: 0.1 }, - { probability: 0.04 }, - { probability: 0.03 }, - { probability: 0.0 }, - { probability: 0.02 }, - { probability: 0.01 }, - { probability: 0.02 }, - { probability: 0.03 }, - { probability: 0.02 }, - ]; - - const timedWindpeedData = mockWindspeedData.map( - ({ windspeed, direction }, i) => { - return { windspeed, direction, time: new Date().setHours(i, 0, 0, 0) }; - } - ); - - const timedPrecipitationData = mockPrecipitationData.map( - ({ probability }, i) => { - return { probability, time: new Date().setHours(i, 0, 0, 0) }; - } - ); - - // const [data, loading] = useEfd(); - // eslint-disable-next-line no-console - // console.log({ data, loading }); return ( - - setTempUnit(value)} - onWindChangeCallback={(value) => setWindspeedUnit(value)} - /> + + -<<<<<<< HEAD - - - -======= - {/* - - - - - - - - - - - - */} ->>>>>>> ebb054c ([F] SummitData provider) - + ); }; diff --git a/components/dynamic/SummitData/Weather/Daily/index.js b/components/dynamic/SummitData/Weather/Daily/index.js new file mode 100644 index 00000000..d22a25b4 --- /dev/null +++ b/components/dynamic/SummitData/Weather/Daily/index.js @@ -0,0 +1,49 @@ +import { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { useWeatherUnit } from "@/contexts/WeatherUnit"; +import { useSummitData } from "@/contexts/SummitData"; +import Loader from "@/components/atomic/Loader"; +import WidgetSection from "@/components/layout/WidgetSection"; +import TemperatureHistoric from "@/components/widgets/TemperatureHistoric"; +import { convertTemperature } from "@/helpers/converters"; + +const DailyWeather = () => { + const { t } = useTranslation(); + const [isOpen, setOpen] = useState(true); + const [{ tempUnit }] = useWeatherUnit(); + const { dailyData, loading = true } = useSummitData(); + const sectionProps = { + title: t("summit_dashboard.sections.daily", { + unit: t(`summit_dashboard.unit_localization.${tempUnit}`), + }), + onToggleCallback: (value) => setOpen(value), + isOpen, + }; + + if (loading && !dailyData) + return ( + + + + ); + + const temperatureData = dailyData + .slice(0, -1) + .map(({ _time, temperature0_max, temperature0_min }) => { + return { + weekday: new Date(_time).getDay(), + low: convertTemperature(temperature0_min, tempUnit), + high: convertTemperature(temperature0_max, tempUnit), + }; + }); + + return ( + + + + ); +}; + +DailyWeather.displayName = "Dynamic.Weather.Daily"; + +export default DailyWeather; diff --git a/components/dynamic/SummitData/Weather/Hourly/index.js b/components/dynamic/SummitData/Weather/Hourly/index.js new file mode 100644 index 00000000..89697e4c --- /dev/null +++ b/components/dynamic/SummitData/Weather/Hourly/index.js @@ -0,0 +1,47 @@ +import { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { useWeatherUnit } from "@/contexts/WeatherUnit"; +import { useSummitData } from "@/contexts/SummitData"; +import Loader from "@/components/atomic/Loader"; +import WidgetSection from "@/components/layout/WidgetSection"; +import Windspeed from "@/components/widgets/HourlyData/patterns/Windspeed"; +import { convertWindspeed } from "@/helpers/converters"; + +const HourlyWeather = () => { + const { t } = useTranslation(); + const [isOpen, setOpen] = useState(true); + const [{ windspeedUnit }] = useWeatherUnit(); + const { hourlyData, loading = true } = useSummitData(); + const sectionProps = { + title: t("summit_dashboard.sections.hourly"), + onToggleCallback: (value) => setOpen(value), + isOpen, + }; + + if (loading && !hourlyData) + return ( + + + + ); + + const windspeedData = hourlyData + .slice(0, -1) + .map(({ _time, direction_mean: direction, speed_mean }) => { + return { + direction, + time: new Date(_time), + windspeed: convertWindspeed(speed_mean, windspeedUnit), + }; + }); + + return ( + + + + ); +}; + +HourlyWeather.displayName = "Dynamic.Weather.Hourly"; + +export default HourlyWeather; diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 502bb62b..9e2d9b06 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -1,82 +1,59 @@ +import { useState } from "react"; <<<<<<< HEAD import Loader from "@/components/atomic/Loader"; -import PrecipitationCurrent from "@/components/widgets/CurrentData/patterns/Precipitation"; -import TemperatureCurrent from "@/components/widgets/CurrentData/patterns/Temperature"; -======= import WidgetPreview from "@/components/layout/WidgetPreview"; +import WidgetSection from "@/components/layout/WidgetSection"; +import SummitStatusModal from "@/components/modal/SummitStatusModal"; +import PrecipitationCurrent from "@/components/widgets/PrecipitationCurrent"; import TemperatureCurrent from "@/components/widgets/TemperatureCurrent"; >>>>>>> ebb054c ([F] SummitData provider) import { useSummitData } from "@/contexts/SummitData"; -import { defaultUnits, useWeatherUnit } from "@/contexts/WeatherUnit"; -import convert from "convert"; +import { useWeatherUnit } from "@/contexts/WeatherUnit"; +import { convertTemperature } from "@/helpers/converters"; +import DailyWeather from "./Daily"; +import HourlyWeather from "./Hourly"; const Weather = () => { - const { tempUnit, windspeedUnit } = useWeatherUnit(); -<<<<<<< HEAD - const { currentData: data, loading = true } = useSummitData(); - - if (loading && !data) return ; - - const { temperature0: temperature, relativeHumidity, windSpeed } = data; - - const temperatureData = { - temperature, - }; - - const windspeedData = { - windSpeed, - }; - - if (tempUnit !== defaultUnits.tempUnit) { -======= - const { data, loading } = useSummitData(); - - if (loading || !data) return null; - - console.log({ data }); - - const { - temperature0: { _value: currentTemperature }, - } = data; - - const temperatureData = { currentTemperature }; - - if ({ tempUnit, windspeedUnit } !== defaultUnits) { ->>>>>>> ebb054c ([F] SummitData provider) - Object.entries(temperatureData).forEach(([key, value]) => { - temperatureData[key] = convert(value, defaultUnits.tempUnit).to(tempUnit); - }); - } - -<<<<<<< HEAD - if (windspeedUnit !== defaultUnits.windspeedUnit) { - Object.entries(windspeedData).forEach(([key, value]) => { - windspeedData[key] = convert(value, defaultUnits.windspeedUnit).to( - windspeedUnit - ); - }); - } + const [isModalOpen, setModalOpen] = useState(false); + const [{ tempUnit, windspeedUnit }] = useWeatherUnit(); + const { currentData, loading = true } = useSummitData(); + + if (loading && !currentData) + return ( + + + + ); + + const { temperature0, relativeHumidity } = currentData; + const temperature = convertTemperature(temperature0, tempUnit); - return ( - <> - - - -======= return ( { + setModalOpen(true); + }} > - + + + setModalOpen(false)} + {...{ tempUnit, windspeedUnit }} + > + + + + + + + ->>>>>>> ebb054c ([F] SummitData provider) ); }; diff --git a/components/layout/UnitLocalization/index.js b/components/layout/UnitLocalization/index.js index af66470b..bb65e42e 100644 --- a/components/layout/UnitLocalization/index.js +++ b/components/layout/UnitLocalization/index.js @@ -6,14 +6,11 @@ import { temperatureUnitType, windspeedUnitType, } from "@/components/shapes/units"; +import { useWeatherUnit } from "@/contexts/WeatherUnit"; -const UnitLocalization = ({ - tempUnit, - windspeedUnit, - onTempChangeCallback, - onWindChangeCallback, -}) => { - const { t, i18n } = useTranslation(); +const UnitLocalization = () => { + const [{ tempUnit, windspeedUnit }, dispatch] = useWeatherUnit(); + const { t } = useTranslation(); const heading = "unitLocalizationHeading"; const temperatureLabel = "temperatureLabel"; const windspeedLabel = "windspeedLabel"; @@ -50,9 +47,7 @@ const UnitLocalization = ({ - onTempChangeCallback && onTempChangeCallback(value) - } + onChange={(value) => dispatch({ type: value })} > {t("summit_dashboard.unit_localization.label_temp")} @@ -66,9 +61,7 @@ const UnitLocalization = ({ - onWindChangeCallback && onWindChangeCallback(value) - } + onChange={(value) => dispatch({ type: value })} > {t("summit_dashboard.unit_localization.label_windspeed")} diff --git a/components/layout/WidgetSection/index.js b/components/layout/WidgetSection/index.js index d5bfb6cd..10ec8be1 100644 --- a/components/layout/WidgetSection/index.js +++ b/components/layout/WidgetSection/index.js @@ -9,7 +9,7 @@ const WidgetSection = ({ onToggleCallback, }) => { const handleToggle = () => { - onToggleCallback(!isOpen); + onToggleCallback && onToggleCallback(!isOpen); }; return ( diff --git a/components/modal/SummitStatusModal/index.js b/components/modal/SummitStatusModal/index.js new file mode 100644 index 00000000..63297e6c --- /dev/null +++ b/components/modal/SummitStatusModal/index.js @@ -0,0 +1,34 @@ +import PropTypes from "prop-types"; +import * as Styled from "./styles"; +import UnitLocalization from "@/components/layout/UnitLocalization"; + +const SummitStatusModal = ({ open, onClose, children }) => { + return ( + + + + + + onClose && onClose()} + icon="close" + /> + + + {children} + + + ); +}; + +SummitStatusModal.displayName = "Modal.SummitStatus"; + +SummitStatusModal.propTypes = { + open: PropTypes.bool, + onClose: PropTypes.func.isRequired, + children: PropTypes.node.isRequired, +}; + +export default SummitStatusModal; diff --git a/components/modal/SummitStatusModal/styles.js b/components/modal/SummitStatusModal/styles.js new file mode 100644 index 00000000..cfaa247f --- /dev/null +++ b/components/modal/SummitStatusModal/styles.js @@ -0,0 +1,53 @@ +import styled from "styled-components"; +import { zStack } from "@/styles/globalStyles"; +import { Dialog as BaseDialog } from "@headlessui/react"; +import IconButton from "@/components/atomic/Button/IconButton"; + +export const Overlay = styled(BaseDialog.Overlay)` + background-color: rgba(0, 0, 0, 80%); + position: fixed; + top: 0; + width: 100%; + height: 100%; +`; + +export const Dialog = styled(BaseDialog)` + position: fixed; + inset: 0; + z-index: ${zStack.dialog}; + overflow: auto; + padding: 1rem; + display: flex; + align-items: start; + justify-content: center; +`; + +export const Content = styled.div` + position: relative; + display: flex; + flex-direction: column; + gap: var(--PADDING_SMALL, 20px); + max-width: 100vw; + color: var(--white, #fff); + width: calc(100vw - 1rem); + max-width: var(--BREAK_LARGE_TABLET, 850px); +`; + +export const Toolbar = styled.div` + display: flex; + align-items: center; +`; + +export const CloseButton = styled(IconButton)` + position: absolute; + top: 0; + right: 0; + width: 1rem; + height: 1rem; + + &:hover { + svg { + stroke-width: 10px; + } + } +`; diff --git a/components/widgets/HourlyData/styles.js b/components/widgets/HourlyData/styles.js index 19a36b37..9b66b4ff 100644 --- a/components/widgets/HourlyData/styles.js +++ b/components/widgets/HourlyData/styles.js @@ -21,6 +21,7 @@ export const HourlyDataItem = styled.li` display: flex; flex-direction: column-reverse; justify-content: center; + align-items: center; text-align: center; `; diff --git a/contexts/WeatherUnit.js b/contexts/WeatherUnit.js index 53abeca3..2f540bea 100644 --- a/contexts/WeatherUnit.js +++ b/contexts/WeatherUnit.js @@ -1,14 +1,60 @@ -import { createContext, useContext } from "react"; +import { createContext, useContext, useReducer } from "react"; +import { useTranslation } from "react-i18next"; + +export const defaultTempUnit = "celsius"; +export const defaultWindspeedUnit = "m"; export const defaultUnits = { - tempUnit: "C", - windspeedUnit: "m", + tempUnit: defaultTempUnit, + windspeedUnit: defaultWindspeedUnit, +}; + +const WeatherUnitContext = createContext(); + +const unitReducer = (state, action) => { + console.log(state, action); + const { type } = action; + + switch (type) { + case "fahrenheit": + return { ...state, tempUnit: "fahrenheit" }; + case "celsius": + return { ...state, tempUnit: "celsius" }; + case "NM": + return { ...state, windspeedUnit: "NM" }; + case "mi": + return { ...state, windspeedUnit: "mi" }; + case "m": + return { ...state, windspeedUnit: "m" }; + default: + throw new Error(`Unhandled action type: ${type}`); + } }; -const WeatherUnitContext = createContext(defaultUnits); +export const WeatherUnitProvider = ({ children }) => { + const { + i18n: { language = "en" }, + } = useTranslation(); + const [state, dispatch] = useReducer(unitReducer, { + tempUnit: language === "en" ? "fahrenheit" : defaultUnits.tempUnit, + windspeedUnit: language === "en" ? "NM" : defaultUnits.windspeedUnit, + }); + + return ( + + {children} + + ); +}; export function useWeatherUnit() { - return useContext(WeatherUnitContext); + const context = useContext(WeatherUnitContext); + + if (context === undefined) { + throw new Error("useWeatherUnit must be used within a WeatherUnitProvider"); + } + + return context; } export default WeatherUnitContext; diff --git a/helpers/converters.js b/helpers/converters.js new file mode 100644 index 00000000..5e2cb0a3 --- /dev/null +++ b/helpers/converters.js @@ -0,0 +1,11 @@ +import convert from "convert"; +import { defaultTempUnit, defaultWindspeedUnit } from "@/contexts/WeatherUnit"; + +export const convertTemperature = (value, toUnit = defaultTempUnit) => + convert(value, defaultTempUnit).to(toUnit); + +export const convertWindspeed = (value, toUnit = defaultWindspeedUnit) => { + const adjustedValue = toUnit !== "m" ? value * 60 * 60 : value; + + return convert(adjustedValue, defaultWindspeedUnit).to(toUnit); +}; diff --git a/lib/api/queries/weather.js b/lib/api/queries/weather.js index 7c0835e9..c108ab7d 100644 --- a/lib/api/queries/weather.js +++ b/lib/api/queries/weather.js @@ -9,7 +9,7 @@ export const currentWeather = (bucket) => flux`from(bucket: "${bucket}") |> group() |> pivot(rowKey:["_pivoter"], columnKey: ["_field"], valueColumn: "_value") |> drop(columns: ["_pivoter"]) - |> rename(columns: {direction: "windDirection", speed: "windSpeed"}) + |> rename(columns: {direction: "windDirection", speed: "windspeed"}) |> yield(name: "realtime")`; export const hourlyWeather = (bucket) => { @@ -44,23 +44,19 @@ export const dailyWeather = (bucket) => { date.setHours(0, 0, 0, 0); return flux`data = from(bucket: "${bucket}") |> range(start: ${date}, stop: now()) - |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.pressure" or r["_measurement"] == "lsst.sal.ESS.dewPoint" or r["_measurement"] == "lsst.sal.ESS.temperature" or r["_measurement"] == "lsst.sal.ESS.relativeHumidity" or r["_measurement"] == "lsst.sal.ESS.airFlow") - |> filter(fn: (r) => r["_field"] == "relativeHumidity" or r["_field"] == "dewPoint" or r["_field"] == "temperature0" or r["_field"] == "speed" or r["_field"] == "pressure0" or r["_field"] == "direction") + |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.temperature") + |> filter(fn: (r) => r["_field"] == "temperature0") |> drop(columns: ["_measurement"]) min = data |> aggregateWindow(every: 1d, fn: min, createEmpty: true) |> map(fn: (r) => ({r with _field: r._field + "_min"})) - - mean = data - |> aggregateWindow(every: 1d, fn: mean, createEmpty: true) - |> map(fn: (r) => ({r with _field: r._field + "_mean"})) max = data |> aggregateWindow(every: 1d, fn: max, createEmpty: true) |> map(fn: (r) => ({r with _field: r._field + "_max"})) - union(tables: [min, mean, max]) + union(tables: [min, max]) |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") |> sort(columns: ["_time"]) |> yield(name: "historical")`; diff --git a/lib/localeStrings/en.json b/lib/localeStrings/en.json index 44579c16..8f713ada 100644 --- a/lib/localeStrings/en.json +++ b/lib/localeStrings/en.json @@ -349,6 +349,11 @@ "mi_full": "Miles per hour", "m_full": "Meters per second" }, + "sections": { + "current": "Weather at the summit now", + "hourly": "Hourly weather stats", + "daily": "Daily temperature variations - {{unit}} degrees (last week)" + }, "weather": { "temp_daily_max": "High", "temp_daily_min": "Low", From 2dfe729907b0f7a52e1dbbe778460b6c589568a5 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 21 Jun 2023 15:43:34 -0700 Subject: [PATCH 18/98] [C] finish widget sections --- .../SummitData/Weather/Current/index.js | 47 +++++++++++++++++++ .../dynamic/SummitData/Weather/Daily/index.js | 2 +- .../SummitData/Weather/Hourly/index.js | 2 +- .../dynamic/SummitData/Weather/index.js | 26 +++++----- .../CurrentData/patterns/Windspeed/index.js | 7 +-- lib/localeStrings/en.json | 9 ++-- 6 files changed, 70 insertions(+), 23 deletions(-) create mode 100644 components/dynamic/SummitData/Weather/Current/index.js diff --git a/components/dynamic/SummitData/Weather/Current/index.js b/components/dynamic/SummitData/Weather/Current/index.js new file mode 100644 index 00000000..4d4c13bb --- /dev/null +++ b/components/dynamic/SummitData/Weather/Current/index.js @@ -0,0 +1,47 @@ +import { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { useWeatherUnit } from "@/contexts/WeatherUnit"; +import { useSummitData } from "@/contexts/SummitData"; +import Loader from "@/components/atomic/Loader"; +import WidgetSection from "@/components/layout/WidgetSection"; +import TemperatureCurrent from "@/components/widgets/CurrentData/patterns/Temperature"; +import WindspeedCurrent from "@/components/widgets/CurrentData/patterns/Windspeed"; +import PrecipitationCurrent from "@/components/widgets/CurrentData/patterns/Precipitation"; +import { convertTemperature, convertWindspeed } from "@/helpers/converters"; + +const CurrentWeather = () => { + const { t } = useTranslation(); + const [isOpen, setOpen] = useState(true); + const [{ tempUnit, windspeedUnit }] = useWeatherUnit(); + const { currentData, loading = true } = useSummitData(); + const sectionProps = { + title: t("summit_dashboard.sections.weather.current"), + onToggleCallback: (value) => setOpen(value), + isOpen, + }; + + if (loading && !currentData) + return ( + + + + ); + + const { temperature0, windspeed, relativeHumidity } = currentData; + const temperature = convertTemperature(temperature0, tempUnit); + + return ( + + + + + + ); +}; + +CurrentWeather.displayName = "Dynamic.Weather.Current"; + +export default CurrentWeather; diff --git a/components/dynamic/SummitData/Weather/Daily/index.js b/components/dynamic/SummitData/Weather/Daily/index.js index d22a25b4..f754fbf1 100644 --- a/components/dynamic/SummitData/Weather/Daily/index.js +++ b/components/dynamic/SummitData/Weather/Daily/index.js @@ -13,7 +13,7 @@ const DailyWeather = () => { const [{ tempUnit }] = useWeatherUnit(); const { dailyData, loading = true } = useSummitData(); const sectionProps = { - title: t("summit_dashboard.sections.daily", { + title: t("summit_dashboard.sections.weather.daily", { unit: t(`summit_dashboard.unit_localization.${tempUnit}`), }), onToggleCallback: (value) => setOpen(value), diff --git a/components/dynamic/SummitData/Weather/Hourly/index.js b/components/dynamic/SummitData/Weather/Hourly/index.js index 89697e4c..6777e238 100644 --- a/components/dynamic/SummitData/Weather/Hourly/index.js +++ b/components/dynamic/SummitData/Weather/Hourly/index.js @@ -13,7 +13,7 @@ const HourlyWeather = () => { const [{ windspeedUnit }] = useWeatherUnit(); const { hourlyData, loading = true } = useSummitData(); const sectionProps = { - title: t("summit_dashboard.sections.hourly"), + title: t("summit_dashboard.sections.weather.hourly"), onToggleCallback: (value) => setOpen(value), isOpen, }; diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 9e2d9b06..b6c88fd5 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -1,29 +1,29 @@ import { useState } from "react"; -<<<<<<< HEAD import Loader from "@/components/atomic/Loader"; import WidgetPreview from "@/components/layout/WidgetPreview"; -import WidgetSection from "@/components/layout/WidgetSection"; import SummitStatusModal from "@/components/modal/SummitStatusModal"; -import PrecipitationCurrent from "@/components/widgets/PrecipitationCurrent"; -import TemperatureCurrent from "@/components/widgets/TemperatureCurrent"; ->>>>>>> ebb054c ([F] SummitData provider) +import PrecipitationCurrent from "@/components/widgets/CurrentData/patterns/Precipitation"; +import TemperatureCurrent from "@/components/widgets/CurrentData/patterns/Temperature"; import { useSummitData } from "@/contexts/SummitData"; import { useWeatherUnit } from "@/contexts/WeatherUnit"; import { convertTemperature } from "@/helpers/converters"; import DailyWeather from "./Daily"; import HourlyWeather from "./Hourly"; +import CurrentWeather from "./Current"; const Weather = () => { + const { t } = useTranslation(); const [isModalOpen, setModalOpen] = useState(false); const [{ tempUnit, windspeedUnit }] = useWeatherUnit(); const { currentData, loading = true } = useSummitData(); + const previewProps = { + title: t("summit_dashboard.sections.weather.preview"), + }; + if (loading && !currentData) return ( - + ); @@ -33,8 +33,7 @@ const Weather = () => { return ( { setModalOpen(true); }} @@ -46,10 +45,7 @@ const Weather = () => { onClose={() => setModalOpen(false)} {...{ tempUnit, windspeedUnit }} > - - - - + diff --git a/components/widgets/CurrentData/patterns/Windspeed/index.js b/components/widgets/CurrentData/patterns/Windspeed/index.js index d0f40aba..007ed5fd 100644 --- a/components/widgets/CurrentData/patterns/Windspeed/index.js +++ b/components/widgets/CurrentData/patterns/Windspeed/index.js @@ -1,10 +1,11 @@ import PropTypes from "prop-types"; -import { windspeedUnitType } from "@/components/shapes/units"; import { useTranslation } from "react-i18next"; +import { windspeedUnitType } from "@/components/shapes/units"; +import { defaultWindspeedUnit } from "@/contexts/WeatherUnit"; import WidgetBackground from "@/components/atomic/WidgetBackground"; import * as Styled from "../../styles"; -const WindspeedCurrent = ({ windspeed = 0, unit = "m" }) => { +const WindspeedCurrent = ({ windspeed = 0, unit = defaultWindspeedUnit }) => { const { t, i18n: { language = "en" }, @@ -18,7 +19,7 @@ const WindspeedCurrent = ({ windspeed = 0, unit = "m" }) => { {new Intl.NumberFormat(language, { style: "decimal", - maximumFractionDigits: 0, + maximumFractionDigits: unit === defaultWindspeedUnit ? 1 : 0, }).format(windspeed)} diff --git a/lib/localeStrings/en.json b/lib/localeStrings/en.json index 8f713ada..1c4d2699 100644 --- a/lib/localeStrings/en.json +++ b/lib/localeStrings/en.json @@ -350,9 +350,12 @@ "m_full": "Meters per second" }, "sections": { - "current": "Weather at the summit now", - "hourly": "Hourly weather stats", - "daily": "Daily temperature variations - {{unit}} degrees (last week)" + "weather": { + "preview": "Weather at the summit", + "current": "Weather at the summit now", + "hourly": "Hourly weather stats", + "daily": "Daily temperature variations - {{unit}} degrees (last week)" + } }, "weather": { "temp_daily_max": "High", From 43123e6d15e4b9e837a12e433ae8def2797eae34 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 21 Jun 2023 15:54:14 -0700 Subject: [PATCH 19/98] [C] mergey merge --- .../dynamic/SummitData/Weather/index.js | 1 + contexts/SummitData.js | 30 ------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index b6c88fd5..e2acb264 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -1,4 +1,5 @@ import { useState } from "react"; +import { useTranslation } from "react-i18next"; import Loader from "@/components/atomic/Loader"; import WidgetPreview from "@/components/layout/WidgetPreview"; import SummitStatusModal from "@/components/modal/SummitStatusModal"; diff --git a/contexts/SummitData.js b/contexts/SummitData.js index 225d6b93..11ad5e82 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -1,4 +1,3 @@ -<<<<<<< HEAD import { createContext, useContext, useEffect, useMemo, useState } from "react"; import { currentWeather, @@ -7,15 +6,10 @@ import { } from "@/lib/api/queries/weather"; import PropTypes from "prop-types"; import queryEfd from "@/lib/api/efd"; -======= -import getEfd from "@/lib/api/efd"; -import { createContext, useContext, useEffect, useMemo, useState } from "react"; ->>>>>>> ebb054c ([F] SummitData provider) export const SummitDataContext = createContext({}); export const SummitDataProvider = ({ children }) => { -<<<<<<< HEAD const [currentData, setCurrentData] = useState(); const [hourlyData, setHourlyData] = useState(); const [dailyData, setDailyData] = useState(); @@ -68,19 +62,6 @@ export const SummitDataProvider = ({ children }) => { ]) .catch((e) => { console.error(e); -======= - const [data, setData] = useState(); - const [error, setError] = useState(false); - const [loading, setLoading] = useState(false); - - useEffect(() => { - setLoading(true); - getEfd() - .then((value) => { - setData(value); - }) - .catch(() => { ->>>>>>> ebb054c ([F] SummitData provider) setError(true); }) .finally(() => { @@ -90,7 +71,6 @@ export const SummitDataProvider = ({ children }) => { const value = useMemo( () => ({ -<<<<<<< HEAD currentData, hourlyData, dailyData, @@ -98,13 +78,6 @@ export const SummitDataProvider = ({ children }) => { error, }), [currentData, hourlyData, dailyData, loading, error] -======= - data, - loading, - error, - }), - [data, loading, error] ->>>>>>> ebb054c ([F] SummitData provider) ); return ( @@ -114,9 +87,6 @@ export const SummitDataProvider = ({ children }) => { ); }; -<<<<<<< HEAD SummitDataProvider.propTypes = { children: PropTypes.node }; -======= ->>>>>>> ebb054c ([F] SummitData provider) export const useSummitData = () => useContext(SummitDataContext); From bf85e83156ce52b118a68305ecfa04306ad0afc6 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 21 Jun 2023 15:56:46 -0700 Subject: [PATCH 20/98] [C] lint --- components/dynamic/SummitData/Weather/Daily/index.js | 6 +++--- components/dynamic/SummitData/Weather/Hourly/index.js | 4 ++-- contexts/WeatherUnit.js | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/components/dynamic/SummitData/Weather/Daily/index.js b/components/dynamic/SummitData/Weather/Daily/index.js index f754fbf1..413f9a3e 100644 --- a/components/dynamic/SummitData/Weather/Daily/index.js +++ b/components/dynamic/SummitData/Weather/Daily/index.js @@ -29,11 +29,11 @@ const DailyWeather = () => { const temperatureData = dailyData .slice(0, -1) - .map(({ _time, temperature0_max, temperature0_min }) => { + .map(({ _time, temperature0_max: max, temperature0_min: min }) => { return { weekday: new Date(_time).getDay(), - low: convertTemperature(temperature0_min, tempUnit), - high: convertTemperature(temperature0_max, tempUnit), + low: convertTemperature(min, tempUnit), + high: convertTemperature(max, tempUnit), }; }); diff --git a/components/dynamic/SummitData/Weather/Hourly/index.js b/components/dynamic/SummitData/Weather/Hourly/index.js index 6777e238..edb665eb 100644 --- a/components/dynamic/SummitData/Weather/Hourly/index.js +++ b/components/dynamic/SummitData/Weather/Hourly/index.js @@ -27,11 +27,11 @@ const HourlyWeather = () => { const windspeedData = hourlyData .slice(0, -1) - .map(({ _time, direction_mean: direction, speed_mean }) => { + .map(({ _time, direction_mean: direction, speed_mean: windspeed }) => { return { direction, time: new Date(_time), - windspeed: convertWindspeed(speed_mean, windspeedUnit), + windspeed: convertWindspeed(windspeed, windspeedUnit), }; }); diff --git a/contexts/WeatherUnit.js b/contexts/WeatherUnit.js index 2f540bea..806899ed 100644 --- a/contexts/WeatherUnit.js +++ b/contexts/WeatherUnit.js @@ -1,4 +1,5 @@ import { createContext, useContext, useReducer } from "react"; +import PropTypes from "prop-types"; import { useTranslation } from "react-i18next"; export const defaultTempUnit = "celsius"; @@ -12,7 +13,6 @@ export const defaultUnits = { const WeatherUnitContext = createContext(); const unitReducer = (state, action) => { - console.log(state, action); const { type } = action; switch (type) { @@ -47,6 +47,10 @@ export const WeatherUnitProvider = ({ children }) => { ); }; +WeatherUnitProvider.propTypes = { + children: PropTypes.node, +}; + export function useWeatherUnit() { const context = useContext(WeatherUnitContext); From d5311a0b4dd6deb51ab2c5a59cdb4b926f7a13a9 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 21 Jun 2023 16:20:51 -0700 Subject: [PATCH 21/98] [C] add some undefined resiliency --- components/dynamic/SummitData/Weather/Current/index.js | 2 +- components/dynamic/SummitData/Weather/Daily/index.js | 2 +- components/dynamic/SummitData/Weather/Hourly/index.js | 2 +- components/dynamic/SummitData/Weather/index.js | 4 +++- contexts/WeatherUnit.js | 9 ++------- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/components/dynamic/SummitData/Weather/Current/index.js b/components/dynamic/SummitData/Weather/Current/index.js index 4d4c13bb..a41bedfc 100644 --- a/components/dynamic/SummitData/Weather/Current/index.js +++ b/components/dynamic/SummitData/Weather/Current/index.js @@ -20,7 +20,7 @@ const CurrentWeather = () => { isOpen, }; - if (loading && !currentData) + if (loading || !currentData) return ( diff --git a/components/dynamic/SummitData/Weather/Daily/index.js b/components/dynamic/SummitData/Weather/Daily/index.js index 413f9a3e..c847b57b 100644 --- a/components/dynamic/SummitData/Weather/Daily/index.js +++ b/components/dynamic/SummitData/Weather/Daily/index.js @@ -20,7 +20,7 @@ const DailyWeather = () => { isOpen, }; - if (loading && !dailyData) + if (loading || !dailyData) return ( diff --git a/components/dynamic/SummitData/Weather/Hourly/index.js b/components/dynamic/SummitData/Weather/Hourly/index.js index edb665eb..53ba1618 100644 --- a/components/dynamic/SummitData/Weather/Hourly/index.js +++ b/components/dynamic/SummitData/Weather/Hourly/index.js @@ -18,7 +18,7 @@ const HourlyWeather = () => { isOpen, }; - if (loading && !hourlyData) + if (loading || !hourlyData) return ( diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index e2acb264..733f841f 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -22,13 +22,15 @@ const Weather = () => { title: t("summit_dashboard.sections.weather.preview"), }; - if (loading && !currentData) + if (loading || !currentData) return ( ); + console.log({ currentData }); + const { temperature0, relativeHumidity } = currentData; const temperature = convertTemperature(temperature0, tempUnit); diff --git a/contexts/WeatherUnit.js b/contexts/WeatherUnit.js index 806899ed..a7790a31 100644 --- a/contexts/WeatherUnit.js +++ b/contexts/WeatherUnit.js @@ -5,11 +5,6 @@ import { useTranslation } from "react-i18next"; export const defaultTempUnit = "celsius"; export const defaultWindspeedUnit = "m"; -export const defaultUnits = { - tempUnit: defaultTempUnit, - windspeedUnit: defaultWindspeedUnit, -}; - const WeatherUnitContext = createContext(); const unitReducer = (state, action) => { @@ -36,8 +31,8 @@ export const WeatherUnitProvider = ({ children }) => { i18n: { language = "en" }, } = useTranslation(); const [state, dispatch] = useReducer(unitReducer, { - tempUnit: language === "en" ? "fahrenheit" : defaultUnits.tempUnit, - windspeedUnit: language === "en" ? "NM" : defaultUnits.windspeedUnit, + tempUnit: language === "en" ? "fahrenheit" : defaultTempUnit, + windspeedUnit: language === "en" ? "NM" : defaultWindspeedUnit, }); return ( From 5bbadf90b7dce2e057815a8db15cf335cc81949e Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 22 Jun 2023 09:28:47 -0700 Subject: [PATCH 22/98] [C] track individual loading states --- .../SummitData/Weather/Current/index.js | 5 +- .../dynamic/SummitData/Weather/Daily/index.js | 5 +- .../SummitData/Weather/Hourly/index.js | 5 +- .../dynamic/SummitData/Weather/index.js | 7 +-- .../patterns/Precipitation/index.js | 4 +- .../HourlyData/patterns/Windspeed/index.js | 4 +- contexts/SummitData.js | 53 ++++++++++++++----- 7 files changed, 61 insertions(+), 22 deletions(-) diff --git a/components/dynamic/SummitData/Weather/Current/index.js b/components/dynamic/SummitData/Weather/Current/index.js index a41bedfc..92ddc0a7 100644 --- a/components/dynamic/SummitData/Weather/Current/index.js +++ b/components/dynamic/SummitData/Weather/Current/index.js @@ -13,7 +13,10 @@ const CurrentWeather = () => { const { t } = useTranslation(); const [isOpen, setOpen] = useState(true); const [{ tempUnit, windspeedUnit }] = useWeatherUnit(); - const { currentData, loading = true } = useSummitData(); + const { + currentData, + loading: { currentData: loading }, + } = useSummitData(); const sectionProps = { title: t("summit_dashboard.sections.weather.current"), onToggleCallback: (value) => setOpen(value), diff --git a/components/dynamic/SummitData/Weather/Daily/index.js b/components/dynamic/SummitData/Weather/Daily/index.js index c847b57b..b50db36b 100644 --- a/components/dynamic/SummitData/Weather/Daily/index.js +++ b/components/dynamic/SummitData/Weather/Daily/index.js @@ -11,7 +11,10 @@ const DailyWeather = () => { const { t } = useTranslation(); const [isOpen, setOpen] = useState(true); const [{ tempUnit }] = useWeatherUnit(); - const { dailyData, loading = true } = useSummitData(); + const { + dailyData, + loading: { dailyData: loading }, + } = useSummitData(); const sectionProps = { title: t("summit_dashboard.sections.weather.daily", { unit: t(`summit_dashboard.unit_localization.${tempUnit}`), diff --git a/components/dynamic/SummitData/Weather/Hourly/index.js b/components/dynamic/SummitData/Weather/Hourly/index.js index 53ba1618..be243285 100644 --- a/components/dynamic/SummitData/Weather/Hourly/index.js +++ b/components/dynamic/SummitData/Weather/Hourly/index.js @@ -11,7 +11,10 @@ const HourlyWeather = () => { const { t } = useTranslation(); const [isOpen, setOpen] = useState(true); const [{ windspeedUnit }] = useWeatherUnit(); - const { hourlyData, loading = true } = useSummitData(); + const { + hourlyData, + loading: { hourlyData: loading }, + } = useSummitData(); const sectionProps = { title: t("summit_dashboard.sections.weather.hourly"), onToggleCallback: (value) => setOpen(value), diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 733f841f..933f5a9b 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -16,7 +16,10 @@ const Weather = () => { const { t } = useTranslation(); const [isModalOpen, setModalOpen] = useState(false); const [{ tempUnit, windspeedUnit }] = useWeatherUnit(); - const { currentData, loading = true } = useSummitData(); + const { + currentData, + loading: { currentData: loading }, + } = useSummitData(); const previewProps = { title: t("summit_dashboard.sections.weather.preview"), @@ -29,8 +32,6 @@ const Weather = () => { ); - console.log({ currentData }); - const { temperature0, relativeHumidity } = currentData; const temperature = convertTemperature(temperature0, tempUnit); diff --git a/components/widgets/HourlyData/patterns/Precipitation/index.js b/components/widgets/HourlyData/patterns/Precipitation/index.js index a8b6e2e4..66a784e6 100644 --- a/components/widgets/HourlyData/patterns/Precipitation/index.js +++ b/components/widgets/HourlyData/patterns/Precipitation/index.js @@ -18,7 +18,7 @@ const PrecipitationHourly = ({ precipitationData = [] }) => { {precipitationData.map(({ probability, time }) => ( - {new Date(time).getHours() === new Date().getHours() ? ( + {time.getHours() === new Date().getHours() ? ( {t( "summit_dashboard.weather.condition_now" @@ -46,7 +46,7 @@ PrecipitationHourly.propTypes = { precipitationData: PropTypes.arrayOf( PropTypes.shape({ probability: PropTypes.number, - time: PropTypes.number, + time: PropTypes.instanceOf(Date), }) ).isRequired, }; diff --git a/components/widgets/HourlyData/patterns/Windspeed/index.js b/components/widgets/HourlyData/patterns/Windspeed/index.js index ced45be7..3445a672 100644 --- a/components/widgets/HourlyData/patterns/Windspeed/index.js +++ b/components/widgets/HourlyData/patterns/Windspeed/index.js @@ -54,7 +54,7 @@ const Windspeed = ({ unit, windspeedData = [], labelledById }) => { windspeedData.map(({ windspeed, direction, time }) => ( - {new Date(time).getHours() === new Date().getHours() ? ( + {time.getHours() === new Date().getHours() ? ( {t( "summit_dashboard.weather.condition_now" @@ -98,7 +98,7 @@ Windspeed.propTypes = { PropTypes.shape({ windspeed: PropTypes.number, direction: PropTypes.number, - time: PropTypes.number, + time: PropTypes.instanceOf(Date), }) ), labelledById: PropTypes.string, diff --git a/contexts/SummitData.js b/contexts/SummitData.js index 11ad5e82..ff75176e 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -1,4 +1,11 @@ -import { createContext, useContext, useEffect, useMemo, useState } from "react"; +import { + createContext, + useContext, + useEffect, + useMemo, + useState, + useReducer, +} from "react"; import { currentWeather, dailyWeather, @@ -9,12 +16,31 @@ import queryEfd from "@/lib/api/efd"; export const SummitDataContext = createContext({}); +const loadingReducer = (state, action) => { + const { type, dataSet } = action; + + switch (type) { + case "complete": + return { ...state, [dataSet]: false }; + case "loading": + return { ...state, [dataSet]: true }; + default: + throw new Error(`Unhandled action type: ${type}`); + } +}; + +const defaultLoadState = { + currentData: true, + hourlyData: true, + dailyData: true, +}; + export const SummitDataProvider = ({ children }) => { const [currentData, setCurrentData] = useState(); const [hourlyData, setHourlyData] = useState(); const [dailyData, setDailyData] = useState(); const [error, setError] = useState(false); - const [loading, setLoading] = useState(true); + const [loading, dispatch] = useReducer(loadingReducer, defaultLoadState); const fetchCurrentWeather = () => new Promise((resolve, reject) => { @@ -25,6 +51,9 @@ export const SummitDataProvider = ({ children }) => { }) .catch((e) => { reject(e); + }) + .finally(() => { + dispatch({ type: "complete", dataSet: "currentData" }); }); }); @@ -37,6 +66,9 @@ export const SummitDataProvider = ({ children }) => { }) .catch((e) => { reject(e); + }) + .finally(() => { + dispatch({ type: "complete", dataSet: "hourlyData" }); }); }); @@ -49,24 +81,21 @@ export const SummitDataProvider = ({ children }) => { }) .catch((e) => { reject(e); + }) + .finally(() => { + dispatch({ type: "complete", dataSet: "dailyData" }); }); }); useEffect(() => { - setLoading(true); - Promise.allSettled([ fetchCurrentWeather(), fetchHourlyWeather(), fetchDailyWeather(), - ]) - .catch((e) => { - console.error(e); - setError(true); - }) - .finally(() => { - setLoading(false); - }); + ]).catch((e) => { + console.error(e); + setError(true); + }); }, []); const value = useMemo( From 7e78ddbdcd6c54a250e5514a64e2babd6cf12c7f Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 22 Jun 2023 15:04:14 -0700 Subject: [PATCH 23/98] [C] fixes and local time --- components/layout/WidgetSection/styles.js | 14 +++- components/modal/SummitStatusModal/index.js | 13 ++- components/modal/SummitStatusModal/styles.js | 27 +++++- .../HourlyData/patterns/Windspeed/index.js | 83 +++++++++++-------- helpers/formatters.js | 5 +- lib/api/queries/weather.js | 18 +++- 6 files changed, 111 insertions(+), 49 deletions(-) diff --git a/components/layout/WidgetSection/styles.js b/components/layout/WidgetSection/styles.js index 9a86d069..57872766 100644 --- a/components/layout/WidgetSection/styles.js +++ b/components/layout/WidgetSection/styles.js @@ -1,4 +1,5 @@ import IconButton from "@/components/atomic/Button/IconButton"; +import { BREAK_PHABLET_MIN } from "@/styles/globalStyles"; import styled from "styled-components"; export const WidgetSection = styled.section` @@ -20,7 +21,10 @@ export const WidgetSection = styled.section` `; export const SectionIconButton = styled(IconButton)` + text-align: left; + > svg { + flex-shrink: 0; padding: 7px; border: 1px solid var(--section-color); border-radius: 50%; @@ -42,12 +46,18 @@ export const SectionHeader = styled.h2` `; export const SectionContent = styled.div` - grid-template-columns: 1fr; - grid-auto-rows: min-content; + --grid-columns: repeat(2, 1fr); + grid-gap: var(--PADDING_SMALL, 20px); + grid-template-columns: var(--grid-columns); + grid-auto-rows: 10rem; margin-block-start: var(--PADDING_SMALL, 20px); &:not([hidden]) { display: grid; } + + @media screen and (min-width: ${BREAK_PHABLET_MIN}) { + --grid-columns: repeat(4, 1fr); + } `; diff --git a/components/modal/SummitStatusModal/index.js b/components/modal/SummitStatusModal/index.js index 63297e6c..a1015b0c 100644 --- a/components/modal/SummitStatusModal/index.js +++ b/components/modal/SummitStatusModal/index.js @@ -2,13 +2,18 @@ import PropTypes from "prop-types"; import * as Styled from "./styles"; import UnitLocalization from "@/components/layout/UnitLocalization"; -const SummitStatusModal = ({ open, onClose, children }) => { +const SummitStatusModal = ({ + open, + onClose, + children, + showLocalization = true, +}) => { return ( - + {showLocalization && } { icon="close" /> - - {children} + {children} ); @@ -29,6 +33,7 @@ SummitStatusModal.propTypes = { open: PropTypes.bool, onClose: PropTypes.func.isRequired, children: PropTypes.node.isRequired, + showLocalization: PropTypes.bool, }; export default SummitStatusModal; diff --git a/components/modal/SummitStatusModal/styles.js b/components/modal/SummitStatusModal/styles.js index cfaa247f..e04fa354 100644 --- a/components/modal/SummitStatusModal/styles.js +++ b/components/modal/SummitStatusModal/styles.js @@ -27,21 +27,40 @@ export const Content = styled.div` display: flex; flex-direction: column; gap: var(--PADDING_SMALL, 20px); - max-width: 100vw; color: var(--white, #fff); width: calc(100vw - 1rem); max-width: var(--BREAK_LARGE_TABLET, 850px); + max-height: 100%; +`; + +export const ScrollableContent = styled.div` + overflow-x: hidden; + overflow-y: auto; + scrollbar-width: thin; + scrollbar-color: var(--white, #fff) rgba(255, 255, 255, 20%); + + &::-webkit-scrollbar { + width: 8px; + background-color: rgba(255, 255, 255, 50%); /* or add it to the track */ + background-clip: padding-box; + border-top: 3px solid transparent; + border-bottom: 3px solid transparent; + } + + &::-webkit-scrollbar-thumb { + background-color: var(--white, #fff); + border-radius: 4px; + } `; export const Toolbar = styled.div` display: flex; align-items: center; + justify-content: flex-end; + height: min-content; `; export const CloseButton = styled(IconButton)` - position: absolute; - top: 0; - right: 0; width: 1rem; height: 1rem; diff --git a/components/widgets/HourlyData/patterns/Windspeed/index.js b/components/widgets/HourlyData/patterns/Windspeed/index.js index 3445a672..bed898fa 100644 --- a/components/widgets/HourlyData/patterns/Windspeed/index.js +++ b/components/widgets/HourlyData/patterns/Windspeed/index.js @@ -1,3 +1,4 @@ +import { useEffect, useRef } from "react"; import PropTypes from "prop-types"; import { windspeedUnitType } from "@/components/shapes/units"; import { useTranslation } from "react-i18next"; @@ -7,6 +8,7 @@ import UniqueIconComposer from "@/components/svg/UniqueIconComposer"; import { ScreenreaderText } from "@rubin-epo/epo-react-lib"; const Windspeed = ({ unit, windspeedData = [], labelledById }) => { + const currentTimeRef = useRef(); const { t, i18n: { language = "en" }, @@ -40,6 +42,12 @@ const Windspeed = ({ unit, windspeedData = [], labelledById }) => { }).toLocaleLowerCase(language)}`, }; + useEffect(() => { + if (currentTimeRef.current) { + currentTimeRef.current.scrollIntoView(); + } + }, []); + return ( @@ -51,40 +59,47 @@ const Windspeed = ({ unit, windspeedData = [], labelledById }) => { {windspeedData && - windspeedData.map(({ windspeed, direction, time }) => ( - - - {time.getHours() === new Date().getHours() ? ( - - {t( - "summit_dashboard.weather.condition_now" - ).toLocaleUpperCase(language)} - - ) : ( - formatTime(time, language) - )} - - - {direction ? ( - <> - - - {t("summit_dashboard.weather.windspeed_direction", { - direction: directionFormatter.format(direction), - })} - - - ) : ( - - {t("summit_dashboard.weather.no_data_yet")} - - )} - - - {windspeed ? speedFormatters[unit](windspeed) : "\u00A0"} - - - ))} + windspeedData.map(({ windspeed, direction, time }) => { + const isNow = time.getHours() === new Date().getHours(); + return ( + + + {isNow ? ( + + {t( + "summit_dashboard.weather.condition_now" + ).toLocaleUpperCase(language)} + + ) : ( + formatTime(time, language) + )} + + + {direction ? ( + <> + + + {t("summit_dashboard.weather.windspeed_direction", { + direction: directionFormatter.format(direction), + })} + + + ) : ( + + {t("summit_dashboard.weather.no_data_yet")} + + )} + + + {windspeed ? speedFormatters[unit](windspeed) : "\u00A0"} + + + ); + })} ); diff --git a/helpers/formatters.js b/helpers/formatters.js index 836da1d3..e892228c 100644 --- a/helpers/formatters.js +++ b/helpers/formatters.js @@ -1,3 +1,5 @@ +const observatoryTZ = "America/Santiago"; + export const formatTemperature = (value, locale = "en", unit = "celsius") => { const formatter = new Intl.NumberFormat(locale, { style: "unit", @@ -31,8 +33,9 @@ export const formatPercent = (value, locale = "en") => { return parts.join(""); }; -export const formatTime = (value, locale = "en") => { +export const formatTime = (value, locale = "en", observatoryTime = "true") => { return new Intl.DateTimeFormat(locale, { timeStyle: "short", + ...(observatoryTime && { timeZone: observatoryTZ }), }).format(value); }; diff --git a/lib/api/queries/weather.js b/lib/api/queries/weather.js index c108ab7d..aed7ae4e 100644 --- a/lib/api/queries/weather.js +++ b/lib/api/queries/weather.js @@ -39,11 +39,21 @@ union(tables: [min, mean, max]) }; export const dailyWeather = (bucket) => { - const date = new Date(); - date.setDate(date.getDate() - 7); - date.setHours(0, 0, 0, 0); + const start = new Date(); + const end = new Date(); + + start.setUTCDate(start.getUTCDate() - 7); + start.setUTCHours(0, 0, 0, 0); + const observatoryDate = new Date( + start.toLocaleString("en-US", { timeZone: "America/Santiago" }) + ); + const diff = 24 - observatoryDate.getHours(); + + start.setUTCHours(diff, 0, 0, 0); + end.setUTCHours(diff, 0, 0, 0); + return flux`data = from(bucket: "${bucket}") - |> range(start: ${date}, stop: now()) + |> range(start: ${start}, stop: ${end}) |> filter(fn: (r) => r["_measurement"] == "lsst.sal.ESS.temperature") |> filter(fn: (r) => r["_field"] == "temperature0") |> drop(columns: ["_measurement"]) From debca18c163c585c9c82dd11a803ecd6e2665697 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 22 Jun 2023 16:27:10 -0700 Subject: [PATCH 24/98] [C] remove extra prop --- components/dynamic/SummitData/Weather/index.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 933f5a9b..5c3f8c4a 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -15,7 +15,7 @@ import CurrentWeather from "./Current"; const Weather = () => { const { t } = useTranslation(); const [isModalOpen, setModalOpen] = useState(false); - const [{ tempUnit, windspeedUnit }] = useWeatherUnit(); + const [{ tempUnit }] = useWeatherUnit(); const { currentData, loading: { currentData: loading }, @@ -44,11 +44,7 @@ const Weather = () => { > - setModalOpen(false)} - {...{ tempUnit, windspeedUnit }} - > + setModalOpen(false)}> From 87fbd3b17aed6ee67c29e6969c4810589b911dc4 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 22 Jun 2023 16:26:20 -0700 Subject: [PATCH 25/98] [C] set up astroweather --- .../dynamic/SummitData/Astroweather/index.js | 27 +++++++++++++++++++ .../CurrentData/patterns/MoonPhase/index.js | 20 ++++++++++++++ helpers/formatters.js | 4 +-- lib/api/queries/weather.js | 3 ++- lib/observatory.js | 3 +++ package.json | 1 + yarn.lock | 5 ++++ 7 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 components/dynamic/SummitData/Astroweather/index.js create mode 100644 components/widgets/CurrentData/patterns/MoonPhase/index.js create mode 100644 lib/observatory.js diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js new file mode 100644 index 00000000..06b7ab30 --- /dev/null +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -0,0 +1,27 @@ +import { useState } from "react"; +import { useTranslation } from "react-i18next"; +import WidgetPreview from "@/components/layout/WidgetPreview"; +import SummitStatusModal from "@/components/modal/SummitStatusModal"; + +const Astroweather = () => { + const { t } = useTranslation(); + const [isModalOpen, setModalOpen] = useState(false); + + return ( + { + setModalOpen(true); + }} + > + setModalOpen(false)} + > + + ); +}; + +Astroweather.displayName = "Dynamic.Astroweather"; + +export default Astroweather; diff --git a/components/widgets/CurrentData/patterns/MoonPhase/index.js b/components/widgets/CurrentData/patterns/MoonPhase/index.js new file mode 100644 index 00000000..f38c9c44 --- /dev/null +++ b/components/widgets/CurrentData/patterns/MoonPhase/index.js @@ -0,0 +1,20 @@ +import PropTypes from "prop-types"; +import { useTranslation } from "react-i18next"; +import { formatPercent } from "helpers/formatters"; +import WidgetBackground from "@/components/atomic/WidgetBackground"; +import * as Styled from "../../styles"; + +const MoonPhase = ({ phase = 0 }) => { + const { t, i18n } = useTranslation(); + const { language = "en" } = i18n; + + return ; +}; + +MoonPhase.displayName = "Widgets.Current.MoonPhase"; + +MoonPhase.propTypes = { + phase: PropTypes.number, +}; + +export default MoonPhase; diff --git a/helpers/formatters.js b/helpers/formatters.js index e892228c..896ade94 100644 --- a/helpers/formatters.js +++ b/helpers/formatters.js @@ -1,4 +1,4 @@ -const observatoryTZ = "America/Santiago"; +import { timezone } from "@/lib/observatory"; export const formatTemperature = (value, locale = "en", unit = "celsius") => { const formatter = new Intl.NumberFormat(locale, { @@ -36,6 +36,6 @@ export const formatPercent = (value, locale = "en") => { export const formatTime = (value, locale = "en", observatoryTime = "true") => { return new Intl.DateTimeFormat(locale, { timeStyle: "short", - ...(observatoryTime && { timeZone: observatoryTZ }), + ...(observatoryTime && { timeZone: timezone }), }).format(value); }; diff --git a/lib/api/queries/weather.js b/lib/api/queries/weather.js index aed7ae4e..2786861f 100644 --- a/lib/api/queries/weather.js +++ b/lib/api/queries/weather.js @@ -1,4 +1,5 @@ import { flux } from "@influxdata/influxdb-client"; +import { timezone } from "@/lib/observatory"; export const currentWeather = (bucket) => flux`from(bucket: "${bucket}") |> range(start: -60s) @@ -45,7 +46,7 @@ export const dailyWeather = (bucket) => { start.setUTCDate(start.getUTCDate() - 7); start.setUTCHours(0, 0, 0, 0); const observatoryDate = new Date( - start.toLocaleString("en-US", { timeZone: "America/Santiago" }) + start.toLocaleString("en-US", { timeZone: timezone }) ); const diff = 24 - observatoryDate.getHours(); diff --git a/lib/observatory.js b/lib/observatory.js new file mode 100644 index 00000000..52834a49 --- /dev/null +++ b/lib/observatory.js @@ -0,0 +1,3 @@ +export const lat = -30.244639; +export const long = -70.749417; +export const timezone = "America/Santiago"; diff --git a/package.json b/package.json index 9efdc915..861ef72f 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "react-uid": "^2.3.2", "striptags": "^3.2.0", "styled-components": "5.3.11", + "suncalc": "^1.9.0", "swr": "^1.3.0", "use-resize-observer": "^9.0.2" }, diff --git a/yarn.lock b/yarn.lock index 56a78405..5361f52c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10536,6 +10536,11 @@ stylelint@^15.6.1: table "^6.8.1" write-file-atomic "^5.0.1" +suncalc@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/suncalc/-/suncalc-1.9.0.tgz#26212353fae61edb287c2d558fc4932ecf0e1532" + integrity sha512-vMJ8Byp1uIPoj+wb9c1AdK4jpkSKVAywgHX0lqY7zt6+EWRRC3Z+0Ucfjy/0yxTVO1hwwchZe4uoFNqrIC24+A== + supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" From 18a2059317ceaa72a864d822ebded927fbfdbcdd Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Fri, 23 Jun 2023 11:13:03 -0700 Subject: [PATCH 26/98] [F] lunar phase setup --- .../content-blocks/SummitStatus/index.js | 2 + .../dynamic/SummitData/Astroweather/index.js | 6 +- components/svg/unique/index.js | 40 ----- components/svg/unique/moon/Moon.stories.js | 19 +++ .../svg/unique/moon/MoonCrescentWaning1.jsx | 45 ------ .../svg/unique/moon/MoonCrescentWaning2.jsx | 44 ------ .../svg/unique/moon/MoonCrescentWaning3.jsx | 44 ------ .../svg/unique/moon/MoonCrescentWaning4.jsx | 44 ------ .../svg/unique/moon/MoonCrescentWaxing1.jsx | 44 ------ .../svg/unique/moon/MoonCrescentWaxing2.jsx | 44 ------ .../svg/unique/moon/MoonCrescentWaxing3.jsx | 44 ------ .../svg/unique/moon/MoonCrescentWaxing4.jsx | 44 ------ components/svg/unique/moon/MoonFull.jsx | 35 ----- .../svg/unique/moon/MoonGibbousWaning1.jsx | 44 ------ .../svg/unique/moon/MoonGibbousWaning2.jsx | 44 ------ .../svg/unique/moon/MoonGibbousWaning3.jsx | 44 ------ .../svg/unique/moon/MoonGibbousWaning4.jsx | 44 ------ .../svg/unique/moon/MoonGibbousWaxing1.jsx | 44 ------ .../svg/unique/moon/MoonGibbousWaxing2.jsx | 44 ------ .../svg/unique/moon/MoonGibbousWaxing3.jsx | 44 ------ .../svg/unique/moon/MoonGibbousWaxing4.jsx | 44 ------ components/svg/unique/moon/MoonNew.jsx | 43 ------ .../svg/unique/moon/MoonQuarterFirst.jsx | 40 ----- .../svg/unique/moon/MoonQuarterLast.jsx | 40 ----- components/svg/unique/moon/index.js | 75 ++++++++++ components/svg/unique/moon/parts/index.js | 140 ++++++++++++++++++ .../CurrentData/patterns/MoonPhase/index.js | 39 ++++- lib/localeStrings/en.json | 18 ++- 28 files changed, 292 insertions(+), 910 deletions(-) create mode 100644 components/svg/unique/moon/Moon.stories.js delete mode 100644 components/svg/unique/moon/MoonCrescentWaning1.jsx delete mode 100644 components/svg/unique/moon/MoonCrescentWaning2.jsx delete mode 100644 components/svg/unique/moon/MoonCrescentWaning3.jsx delete mode 100644 components/svg/unique/moon/MoonCrescentWaning4.jsx delete mode 100644 components/svg/unique/moon/MoonCrescentWaxing1.jsx delete mode 100644 components/svg/unique/moon/MoonCrescentWaxing2.jsx delete mode 100644 components/svg/unique/moon/MoonCrescentWaxing3.jsx delete mode 100644 components/svg/unique/moon/MoonCrescentWaxing4.jsx delete mode 100644 components/svg/unique/moon/MoonFull.jsx delete mode 100644 components/svg/unique/moon/MoonGibbousWaning1.jsx delete mode 100644 components/svg/unique/moon/MoonGibbousWaning2.jsx delete mode 100644 components/svg/unique/moon/MoonGibbousWaning3.jsx delete mode 100644 components/svg/unique/moon/MoonGibbousWaning4.jsx delete mode 100644 components/svg/unique/moon/MoonGibbousWaxing1.jsx delete mode 100644 components/svg/unique/moon/MoonGibbousWaxing2.jsx delete mode 100644 components/svg/unique/moon/MoonGibbousWaxing3.jsx delete mode 100644 components/svg/unique/moon/MoonGibbousWaxing4.jsx delete mode 100644 components/svg/unique/moon/MoonNew.jsx delete mode 100644 components/svg/unique/moon/MoonQuarterFirst.jsx delete mode 100644 components/svg/unique/moon/MoonQuarterLast.jsx create mode 100644 components/svg/unique/moon/index.js create mode 100644 components/svg/unique/moon/parts/index.js diff --git a/components/content-blocks/SummitStatus/index.js b/components/content-blocks/SummitStatus/index.js index 60f35231..01c0c570 100644 --- a/components/content-blocks/SummitStatus/index.js +++ b/components/content-blocks/SummitStatus/index.js @@ -5,6 +5,7 @@ import UnitLocalization from "@/components/layout/UnitLocalization"; import WidgetGrid from "@/components/layout/WidgetGrid"; import { SummitDataProvider } from "@/contexts/SummitData"; import Weather from "@/components/dynamic/SummitData/Weather"; +import Astroweather from "@/components/dynamic/SummitData/Astroweather"; const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { return ( @@ -14,6 +15,7 @@ const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { + diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index 06b7ab30..9bbc7ec2 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -1,19 +1,23 @@ import { useState } from "react"; import { useTranslation } from "react-i18next"; +import SunCalc from "suncalc"; import WidgetPreview from "@/components/layout/WidgetPreview"; import SummitStatusModal from "@/components/modal/SummitStatusModal"; +import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; const Astroweather = () => { const { t } = useTranslation(); const [isModalOpen, setModalOpen] = useState(false); + const { phase } = SunCalc.getMoonIllumination(new Date()); return ( { setModalOpen(true); }} > + setModalOpen(false)} diff --git a/components/svg/unique/index.js b/components/svg/unique/index.js index e1994cf7..e5b9f0dd 100644 --- a/components/svg/unique/index.js +++ b/components/svg/unique/index.js @@ -4,26 +4,6 @@ import CloudyPartial from "./weather/CloudyPartial"; import Gear from "./Gear"; import Logo from "./site/Logo"; import LogoFullSize from "./site/LogoFullSize"; -import MoonCrescentWaning1 from "./moon/MoonCrescentWaning1"; -import MoonCrescentWaning2 from "./moon/MoonCrescentWaning2"; -import MoonCrescentWaning3 from "./moon/MoonCrescentWaning3"; -import MoonCrescentWaning4 from "./moon/MoonCrescentWaning4"; -import MoonCrescentWaxing1 from "./moon/MoonCrescentWaxing1"; -import MoonCrescentWaxing2 from "./moon/MoonCrescentWaxing2"; -import MoonCrescentWaxing3 from "./moon/MoonCrescentWaxing3"; -import MoonCrescentWaxing4 from "./moon/MoonCrescentWaxing4"; -import MoonFull from "./moon/MoonFull"; -import MoonGibbousWaning1 from "./moon/MoonGibbousWaning1"; -import MoonGibbousWaning2 from "./moon/MoonGibbousWaning2"; -import MoonGibbousWaning3 from "./moon/MoonGibbousWaning3"; -import MoonGibbousWaning4 from "./moon/MoonGibbousWaning4"; -import MoonGibbousWaxing1 from "./moon/MoonGibbousWaxing1"; -import MoonGibbousWaxing2 from "./moon/MoonGibbousWaxing2"; -import MoonGibbousWaxing3 from "./moon/MoonGibbousWaxing3"; -import MoonGibbousWaxing4 from "./moon/MoonGibbousWaxing4"; -import MoonNew from "./moon/MoonNew"; -import MoonQuarterFirst from "./moon/MoonQuarterFirst"; -import MoonQuarterLast from "./moon/MoonQuarterLast"; import Rain from "./weather/Rain"; import RainHeavy from "./weather/RainHeavy"; import RainLight from "./weather/RainLight"; @@ -39,26 +19,6 @@ export default { Gear, Logo, LogoFullSize, - MoonCrescentWaning1, - MoonCrescentWaning2, - MoonCrescentWaning3, - MoonCrescentWaning4, - MoonCrescentWaxing1, - MoonCrescentWaxing2, - MoonCrescentWaxing3, - MoonCrescentWaxing4, - MoonFull, - MoonGibbousWaning1, - MoonGibbousWaning2, - MoonGibbousWaning3, - MoonGibbousWaning4, - MoonGibbousWaxing1, - MoonGibbousWaxing2, - MoonGibbousWaxing3, - MoonGibbousWaxing4, - MoonNew, - MoonQuarterFirst, - MoonQuarterLast, Rain, RainHeavy, RainLight, diff --git a/components/svg/unique/moon/Moon.stories.js b/components/svg/unique/moon/Moon.stories.js new file mode 100644 index 00000000..c1173d71 --- /dev/null +++ b/components/svg/unique/moon/Moon.stories.js @@ -0,0 +1,19 @@ +import Moon from "."; + +const meta = { + component: Moon, + argTypes: { + phase: { + control: { type: "number", min: 0, max: 1, step: 0.05 }, + }, + size: { + control: { type: "number", min: 0 }, + }, + fill: { control: { type: "text" } }, + }, +}; +export default meta; + +export const Primary = { + args: { phase: 0.5 }, +}; diff --git a/components/svg/unique/moon/MoonCrescentWaning1.jsx b/components/svg/unique/moon/MoonCrescentWaning1.jsx deleted file mode 100644 index 7c5a49a3..00000000 --- a/components/svg/unique/moon/MoonCrescentWaning1.jsx +++ /dev/null @@ -1,45 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonCrescentWaning1 = ({ - className, - size = 24, - fill = "currentColor", - ...props -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waning crescent moon icon - - - - - - ); -}; - -MoonCrescentWaning1.displayName = "SVG.MoonCrescentWaning1"; - -MoonCrescentWaning1.propTypes = svgShape; - -export default MoonCrescentWaning1; diff --git a/components/svg/unique/moon/MoonCrescentWaning2.jsx b/components/svg/unique/moon/MoonCrescentWaning2.jsx deleted file mode 100644 index 363f9860..00000000 --- a/components/svg/unique/moon/MoonCrescentWaning2.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonCrescentWaning2 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waning crescent moon icon - - - - - - ); -}; - -MoonCrescentWaning2.displayName = "SVG.MoonCrescentWaning2"; - -MoonCrescentWaning2.propTypes = svgShape; - -export default MoonCrescentWaning2; diff --git a/components/svg/unique/moon/MoonCrescentWaning3.jsx b/components/svg/unique/moon/MoonCrescentWaning3.jsx deleted file mode 100644 index 748d386c..00000000 --- a/components/svg/unique/moon/MoonCrescentWaning3.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonCrescentWaning3 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waning crescent moon icon - - - - - - ); -}; - -MoonCrescentWaning3.displayName = "SVG.MoonCrescentWaning3"; - -MoonCrescentWaning3.propTypes = svgShape; - -export default MoonCrescentWaning3; diff --git a/components/svg/unique/moon/MoonCrescentWaning4.jsx b/components/svg/unique/moon/MoonCrescentWaning4.jsx deleted file mode 100644 index 6a4e2e1b..00000000 --- a/components/svg/unique/moon/MoonCrescentWaning4.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonCrescentWaning4 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waning crescent moon icon - - - - - - ); -}; - -MoonCrescentWaning4.displayName = "SVG.MoonCrescentWaning4"; - -MoonCrescentWaning4.propTypes = svgShape; - -export default MoonCrescentWaning4; diff --git a/components/svg/unique/moon/MoonCrescentWaxing1.jsx b/components/svg/unique/moon/MoonCrescentWaxing1.jsx deleted file mode 100644 index aaea1029..00000000 --- a/components/svg/unique/moon/MoonCrescentWaxing1.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonCrescentWaxing1 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waxing crescent moon icon - - - - - - ); -}; - -MoonCrescentWaxing1.displayName = "SVG.MoonCrescentWaxing1"; - -MoonCrescentWaxing1.propTypes = svgShape; - -export default MoonCrescentWaxing1; diff --git a/components/svg/unique/moon/MoonCrescentWaxing2.jsx b/components/svg/unique/moon/MoonCrescentWaxing2.jsx deleted file mode 100644 index bc4716ea..00000000 --- a/components/svg/unique/moon/MoonCrescentWaxing2.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonCrescentWaxing2 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waxing crescent moon icon - - - - - - ); -}; - -MoonCrescentWaxing2.displayName = "SVG.MoonCrescentWaxing2"; - -MoonCrescentWaxing2.propTypes = svgShape; - -export default MoonCrescentWaxing2; diff --git a/components/svg/unique/moon/MoonCrescentWaxing3.jsx b/components/svg/unique/moon/MoonCrescentWaxing3.jsx deleted file mode 100644 index 856ce409..00000000 --- a/components/svg/unique/moon/MoonCrescentWaxing3.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonCrescentWaxing3 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waxing crescent moon icon - - - - - - ); -}; - -MoonCrescentWaxing3.displayName = "SVG.MoonCrescentWaxing3"; - -MoonCrescentWaxing3.propTypes = svgShape; - -export default MoonCrescentWaxing3; diff --git a/components/svg/unique/moon/MoonCrescentWaxing4.jsx b/components/svg/unique/moon/MoonCrescentWaxing4.jsx deleted file mode 100644 index 60f0638b..00000000 --- a/components/svg/unique/moon/MoonCrescentWaxing4.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonCrescentWaxing4 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waxing crescent moon icon - - - - - - ); -}; - -MoonCrescentWaxing4.displayName = "SVG.MoonCrescentWaxing4"; - -MoonCrescentWaxing4.propTypes = svgShape; - -export default MoonCrescentWaxing4; diff --git a/components/svg/unique/moon/MoonFull.jsx b/components/svg/unique/moon/MoonFull.jsx deleted file mode 100644 index 14cef7df..00000000 --- a/components/svg/unique/moon/MoonFull.jsx +++ /dev/null @@ -1,35 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonFull = ({ className, size = 24, fill = "currentColor" }) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Full moon icon - - - - - ); -}; - -MoonFull.displayName = "SVG.MoonFull"; - -MoonFull.propTypes = svgShape; - -export default MoonFull; diff --git a/components/svg/unique/moon/MoonGibbousWaning1.jsx b/components/svg/unique/moon/MoonGibbousWaning1.jsx deleted file mode 100644 index f466dff5..00000000 --- a/components/svg/unique/moon/MoonGibbousWaning1.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonGibbousWaning1 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waning gibbous moon icon - - - - - - ); -}; - -MoonGibbousWaning1.displayName = "SVG.MoonGibbousWaning1"; - -MoonGibbousWaning1.propTypes = svgShape; - -export default MoonGibbousWaning1; diff --git a/components/svg/unique/moon/MoonGibbousWaning2.jsx b/components/svg/unique/moon/MoonGibbousWaning2.jsx deleted file mode 100644 index 216c34a8..00000000 --- a/components/svg/unique/moon/MoonGibbousWaning2.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonGibbousWaning2 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waning gibbous moon icon - - - - - - ); -}; - -MoonGibbousWaning2.displayName = "SVG.MoonGibbousWaning2"; - -MoonGibbousWaning2.propTypes = svgShape; - -export default MoonGibbousWaning2; diff --git a/components/svg/unique/moon/MoonGibbousWaning3.jsx b/components/svg/unique/moon/MoonGibbousWaning3.jsx deleted file mode 100644 index 2058692e..00000000 --- a/components/svg/unique/moon/MoonGibbousWaning3.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonGibbousWaning3 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waning gibbous moon icon - - - - - - ); -}; - -MoonGibbousWaning3.displayName = "SVG.MoonGibbousWaning3"; - -MoonGibbousWaning3.propTypes = svgShape; - -export default MoonGibbousWaning3; diff --git a/components/svg/unique/moon/MoonGibbousWaning4.jsx b/components/svg/unique/moon/MoonGibbousWaning4.jsx deleted file mode 100644 index 39ca3f43..00000000 --- a/components/svg/unique/moon/MoonGibbousWaning4.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonGibbousWaning4 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waning gibbous moon icon - - - - - - ); -}; - -MoonGibbousWaning4.displayName = "SVG.MoonGibbousWaning4"; - -MoonGibbousWaning4.propTypes = svgShape; - -export default MoonGibbousWaning4; diff --git a/components/svg/unique/moon/MoonGibbousWaxing1.jsx b/components/svg/unique/moon/MoonGibbousWaxing1.jsx deleted file mode 100644 index 14ddb45c..00000000 --- a/components/svg/unique/moon/MoonGibbousWaxing1.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonGibbousWaxing1 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waxing gibbous moon icon - - - - - - ); -}; - -MoonGibbousWaxing1.displayName = "SVG.MoonGibbousWaxing1"; - -MoonGibbousWaxing1.propTypes = svgShape; - -export default MoonGibbousWaxing1; diff --git a/components/svg/unique/moon/MoonGibbousWaxing2.jsx b/components/svg/unique/moon/MoonGibbousWaxing2.jsx deleted file mode 100644 index a6e5b94c..00000000 --- a/components/svg/unique/moon/MoonGibbousWaxing2.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonGibbousWaxing2 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waxing gibbous moon icon - - - - - - ); -}; - -MoonGibbousWaxing2.displayName = "SVG.MoonGibbousWaxing2"; - -MoonGibbousWaxing2.propTypes = svgShape; - -export default MoonGibbousWaxing2; diff --git a/components/svg/unique/moon/MoonGibbousWaxing3.jsx b/components/svg/unique/moon/MoonGibbousWaxing3.jsx deleted file mode 100644 index 77714022..00000000 --- a/components/svg/unique/moon/MoonGibbousWaxing3.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonGibbousWaxing3 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waxing gibbous moon icon - - - - - - ); -}; - -MoonGibbousWaxing3.displayName = "SVG.MoonGibbousWaxing3"; - -MoonGibbousWaxing3.propTypes = svgShape; - -export default MoonGibbousWaxing3; diff --git a/components/svg/unique/moon/MoonGibbousWaxing4.jsx b/components/svg/unique/moon/MoonGibbousWaxing4.jsx deleted file mode 100644 index 90ed45d5..00000000 --- a/components/svg/unique/moon/MoonGibbousWaxing4.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonGibbousWaxing4 = ({ - className, - size = 24, - fill = "currentColor", -}) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Waxing gibbous moon icon - - - - - - ); -}; - -MoonGibbousWaxing4.displayName = "SVG.MoonGibbousWaxing4"; - -MoonGibbousWaxing4.propTypes = svgShape; - -export default MoonGibbousWaxing4; diff --git a/components/svg/unique/moon/MoonNew.jsx b/components/svg/unique/moon/MoonNew.jsx deleted file mode 100644 index f15c8b50..00000000 --- a/components/svg/unique/moon/MoonNew.jsx +++ /dev/null @@ -1,43 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonNew = ({ className, size = 24, fill = "currentColor" }) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - New moon icon - - - - - - ); -}; - -MoonNew.displayName = "SVG.MoonNew"; - -MoonNew.propTypes = svgShape; - -export default MoonNew; diff --git a/components/svg/unique/moon/MoonQuarterFirst.jsx b/components/svg/unique/moon/MoonQuarterFirst.jsx deleted file mode 100644 index 9b480e45..00000000 --- a/components/svg/unique/moon/MoonQuarterFirst.jsx +++ /dev/null @@ -1,40 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonQuarterFirst = ({ className, size = 24, fill = "currentColor" }) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - First quarter moon icon - - - - - - ); -}; - -MoonQuarterFirst.displayName = "SVG.MoonQuarterFirst"; - -MoonQuarterFirst.propTypes = svgShape; - -export default MoonQuarterFirst; diff --git a/components/svg/unique/moon/MoonQuarterLast.jsx b/components/svg/unique/moon/MoonQuarterLast.jsx deleted file mode 100644 index 0e6bb53f..00000000 --- a/components/svg/unique/moon/MoonQuarterLast.jsx +++ /dev/null @@ -1,40 +0,0 @@ -import defaultProps from "../defaultProps"; -import svgShape from "@/shapes/svg"; - -const MoonQuarterLast = ({ className, size = 24, fill = "currentColor" }) => { - const uniqueProps = { - viewBox: "0 0 46 46", - width: size, - height: size, - fill, - className, - }; - - const mergedSvgProps = Object.assign(defaultProps, uniqueProps); - return ( - - Last quarter moon icon - - - - - - ); -}; - -MoonQuarterLast.displayName = "SVG.MoonQuarterLast"; - -MoonQuarterLast.propTypes = svgShape; - -export default MoonQuarterLast; diff --git a/components/svg/unique/moon/index.js b/components/svg/unique/moon/index.js new file mode 100644 index 00000000..1414ed36 --- /dev/null +++ b/components/svg/unique/moon/index.js @@ -0,0 +1,75 @@ +import PropTypes from "prop-types"; +import svgShape from "@/shapes/svg"; +import defaultProps from "../defaultProps"; + +import phaseParts from "./parts"; +import { useTranslation } from "react-i18next"; + +const Moon = ({ phase = 0, className, size = 46, fill = "currentColor" }) => { + const { t } = useTranslation(); + const uniqueProps = { + viewBox: "0 0 46 46", + width: size, + height: size, + fill, + className, + }; + + const labels = [ + t("summit_dashboard.astro.moon.new"), + t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), + t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), + t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), + t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), + t("summit_dashboard.astro.moon.quarter", { context: "first" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), + t("summit_dashboard.astro.moon.full"), + t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), + t("summit_dashboard.astro.moon.quarter", { context: "last" }), + t("summit_dashboard.astro.moon.crescent", { context: "waning" }), + t("summit_dashboard.astro.moon.crescent", { context: "waning" }), + t("summit_dashboard.astro.moon.crescent", { context: "waning" }), + t("summit_dashboard.astro.moon.crescent", { context: "waning" }), + ]; + + const pathProps = + phaseParts[ + Math.min(Math.floor(phase * phaseParts.length), phaseParts.length - 1) + ]; + + const label = + labels[Math.min(Math.floor(phase * labels.length), labels.length - 1)]; + + const mergedSvgProps = Object.assign(defaultProps, uniqueProps); + return ( + + {label} + + + + + + ); +}; + +Moon.propTypes = { + phase: PropTypes.number, + ...svgShape, +}; + +Moon.displayName = "SVG.Moon"; + +export default Moon; diff --git a/components/svg/unique/moon/parts/index.js b/components/svg/unique/moon/parts/index.js new file mode 100644 index 00000000..1cb09c78 --- /dev/null +++ b/components/svg/unique/moon/parts/index.js @@ -0,0 +1,140 @@ +const CrescentWaning1 = { + d: "M2087.8-3685.221a138.389,138.389,0,0,1-1.8-22.279,138.339,138.339,0,0,1,1.966-23.3,23.209,23.209,0,0,1,3.034-.2,23,23,0,0,1,23,23,23,23,0,0,1-23,23A23.2,23.2,0,0,1,2087.8-3685.221Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const CrescentWaning2 = { + d: "M2086.256-3685.49A31.9,31.9,0,0,1,2077-3708a31.9,31.9,0,0,1,9.256-22.51A23.106,23.106,0,0,1,2091-3731a23,23,0,0,1,23,23,23,23,0,0,1-23,23A23.106,23.106,0,0,1,2086.256-3685.49Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const CrescentWaning3 = { + d: "M2085.2-3685.737A25.486,25.486,0,0,1,2073-3707.5a25.507,25.507,0,0,1,15.19-23.33,23.255,23.255,0,0,1,2.81-.17,23,23,0,0,1,23,23,23,23,0,0,1-23,23A23.049,23.049,0,0,1,2085.2-3685.737Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const CrescentWaning4 = { + d: "M2070-3708a23,23,0,0,1,22-22.979A23,23,0,0,1,2114-3708a23,23,0,0,1-22,22.978A23,23,0,0,1,2070-3708Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const CrescentWaxing1 = { + d: "M2068-3708a23,23,0,0,1,22-22.979A23,23,0,0,1,2112-3708a23,23,0,0,1-22,22.978A23,23,0,0,1,2068-3708Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const CrescentWaxing2 = { + d: "M2068-3708a23,23,0,0,1,23-23,23.116,23.116,0,0,1,4.329.407A25.5,25.5,0,0,1,2110-3707.5a25.473,25.473,0,0,1-11.288,21.175A22.957,22.957,0,0,1,2091-3685,23,23,0,0,1,2068-3708Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const CrescentWaxing3 = { + d: "M2068-3708a23,23,0,0,1,23-23,23.1,23.1,0,0,1,4.742.49A31.9,31.9,0,0,1,2105-3708a31.894,31.894,0,0,1-9.255,22.509,23.1,23.1,0,0,1-4.743.49A23,23,0,0,1,2068-3708Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const CrescentWaxing4 = { + d: "M2068-3708a23,23,0,0,1,23-23,23.2,23.2,0,0,1,3.034.2,138.33,138.33,0,0,1,1.966,23.3,138.4,138.4,0,0,1-1.8,22.279,23.114,23.114,0,0,1-3.2.222A23,23,0,0,1,2068-3708Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const Full = { + opacity: "0", +}; + +const GibbousWaning1 = { + d: "M23,0a23.006,23.006,0,0,0-8.953,44.193A22.853,22.853,0,0,0,23,46c.335,0,.671-.007,1-.021A23,23,0,0,1,8.41,7.069,22.882,22.882,0,0,1,24,.021C23.645.007,23.309,0,23,0Z", + transform: "translate(46 46) rotate(180)", + opacity: "0.5", +}; + +const GibbousWaning2 = { + d: "M17.2,0a22.845,22.845,0,0,0-6.857,3.056A23,23,0,0,0,20.19,45.092,25.505,25.505,0,0,1,17.2,0Z", + transform: "translate(46 45.262) rotate(180)", + opacity: "0.5", +}; + +const GibbousWaning3 = { + d: "M18.256,0h0a23.006,23.006,0,0,0,0,45.02A31.972,31.972,0,0,1,18.254,0Z", + transform: "translate(46 45.51) rotate(180)", + opacity: "0.5", +}; + +const GibbousWaning4 = { + d: "M19.965,45.58h0A23,23,0,0,1,19.795,0a139.077,139.077,0,0,0,.17,45.579Z", + transform: "translate(46 45.779) rotate(180)", + opacity: "0.5", +}; + +const GibbousWaxing1 = { + d: "M2087.8-3685.221h0a22.981,22.981,0,0,1-14.091-7.618A22.979,22.979,0,0,1,2068-3708a22.972,22.972,0,0,1,5.757-15.221,22.976,22.976,0,0,1,14.208-7.58,138.863,138.863,0,0,0-1.966,23.3,138.9,138.9,0,0,0,1.8,22.277Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const GibbousWaxing2 = { + d: "M2086.256-3685.49h0a23.068,23.068,0,0,1-13.035-7.92,22.919,22.919,0,0,1-3.832-6.707A22.925,22.925,0,0,1,2068-3708a22.925,22.925,0,0,1,1.386-7.883,22.918,22.918,0,0,1,3.832-6.707,23.067,23.067,0,0,1,13.038-7.921,31.885,31.885,0,0,0-6.774,10.132A31.8,31.8,0,0,0,2077-3708a31.8,31.8,0,0,0,2.482,12.378,31.893,31.893,0,0,0,6.771,10.129Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const GibbousWaxing3 = { + d: "M2085.2-3685.738a22.845,22.845,0,0,1-6.857-3.056,23.076,23.076,0,0,1-5.45-5.024,22.908,22.908,0,0,1-3.594-6.55A22.948,22.948,0,0,1,2068-3708a23.007,23.007,0,0,1,20.19-22.83,25.53,25.53,0,0,0-10.95,9.245A25.388,25.388,0,0,0,2073-3707.5a25.494,25.494,0,0,0,3.357,12.655,25.673,25.673,0,0,0,8.841,9.1Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const GibbousWaxing4 = { + d: "M2091-3685a22.859,22.859,0,0,1-8.953-1.807,22.922,22.922,0,0,1-7.311-4.929,22.922,22.922,0,0,1-4.929-7.311A22.859,22.859,0,0,1,2068-3708a22.861,22.861,0,0,1,1.807-8.953,22.93,22.93,0,0,1,4.929-7.311,22.923,22.923,0,0,1,7.311-4.929A22.853,22.853,0,0,1,2091-3731c.335,0,.671.007,1,.021a22.882,22.882,0,0,0-15.59,7.048A22.892,22.892,0,0,0,2070-3708a22.891,22.891,0,0,0,6.41,15.931,22.882,22.882,0,0,0,15.59,7.048C2091.645-3685.006,2091.309-3685,2091-3685Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const New = { + d: "M0,23a23,23 0 1,0 46,0a23,23 0 1,0 -46,0", + transform: "translate(0)", + opacity: "0.5", +}; + +const QuarterFirst = { + d: "M2091-3685h-.008a22.838,22.838,0,0,1-8.945-1.806,22.922,22.922,0,0,1-7.311-4.929,22.922,22.922,0,0,1-4.929-7.311A22.859,22.859,0,0,1,2068-3708a22.861,22.861,0,0,1,1.807-8.953,22.93,22.93,0,0,1,4.929-7.311,22.927,22.927,0,0,1,7.311-4.929A22.853,22.853,0,0,1,2091-3731Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +const QuarterLast = { + d: "M2091-3731a23,23,0,0,1,23,23,23,23,0,0,1-23,23Z", + transform: "translate(-2068 3731)", + opacity: "0.5", +}; + +export default [ + New, + CrescentWaxing1, + CrescentWaxing2, + CrescentWaxing3, + CrescentWaxing4, + QuarterFirst, + GibbousWaxing1, + GibbousWaxing2, + GibbousWaxing3, + GibbousWaxing4, + Full, + GibbousWaning1, + GibbousWaning2, + GibbousWaning3, + GibbousWaning4, + QuarterLast, + CrescentWaning1, + CrescentWaning2, + CrescentWaning3, + CrescentWaning4, +]; diff --git a/components/widgets/CurrentData/patterns/MoonPhase/index.js b/components/widgets/CurrentData/patterns/MoonPhase/index.js index f38c9c44..a4f035ce 100644 --- a/components/widgets/CurrentData/patterns/MoonPhase/index.js +++ b/components/widgets/CurrentData/patterns/MoonPhase/index.js @@ -1,14 +1,45 @@ import PropTypes from "prop-types"; import { useTranslation } from "react-i18next"; -import { formatPercent } from "helpers/formatters"; import WidgetBackground from "@/components/atomic/WidgetBackground"; import * as Styled from "../../styles"; +import Moon from "@/components/svg/unique/moon"; const MoonPhase = ({ phase = 0 }) => { - const { t, i18n } = useTranslation(); - const { language = "en" } = i18n; + const { t } = useTranslation(); - return ; + const labels = [ + t("summit_dashboard.astro.moon.new"), + t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), + t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), + t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), + t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), + t("summit_dashboard.astro.moon.quarter", { context: "first" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), + t("summit_dashboard.astro.moon.full"), + t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), + t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), + t("summit_dashboard.astro.moon.quarter", { context: "last" }), + t("summit_dashboard.astro.moon.crescent", { context: "waning" }), + t("summit_dashboard.astro.moon.crescent", { context: "waning" }), + t("summit_dashboard.astro.moon.crescent", { context: "waning" }), + t("summit_dashboard.astro.moon.crescent", { context: "waning" }), + ]; + + const label = + labels[Math.min(Math.floor(phase * labels.length), labels.length - 1)]; + + return ( + + {t("summit_dashboard.widgets.current.moon")} + + {label} + + ); }; MoonPhase.displayName = "Widgets.Current.MoonPhase"; diff --git a/lib/localeStrings/en.json b/lib/localeStrings/en.json index 1c4d2699..716f73c8 100644 --- a/lib/localeStrings/en.json +++ b/lib/localeStrings/en.json @@ -333,7 +333,6 @@ }, "summit_dashboard": { "open_modal": "Expand content", - "unit_localization": { "settings": "Settings", "label_temp": "Temperature", @@ -364,12 +363,27 @@ "condition_now": "Now", "no_data_yet": "No data yet" }, + "astro": { + "moon": { + "new": "New Moon", + "full": "Full Moon", + "crescent_waxing": "Waxing Crescent", + "crescent_waning": "Waning Crescent", + "gibbous_waxing": "Waxing Gibbous", + "gibbous_waning": "Waning Gibbous", + "quarter_first": "First Quarter", + "quarter_last": "Last Quarter" + } + }, "widgets": { "hourly": { "windspeed": "Hourly wind speed report - {{unit}}", "precipitation": "Hourly precipitation probability report - Probability percentage" }, - "current": { "windspeed": "Average windspeed" } + "current": { + "windspeed": "Average windspeed", + "moon": "Tonight we will have a" + } } } } From 8e02ca370a19c95b3aa18f6edc6c561dbbb3fa87 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Fri, 23 Jun 2023 12:13:23 -0700 Subject: [PATCH 27/98] [C] condense props and labels --- components/svg/unique/moon/index.js | 38 +---- components/svg/unique/moon/parts/index.js | 153 +++++++++++++++--- .../CurrentData/patterns/MoonPhase/index.js | 42 ++--- 3 files changed, 150 insertions(+), 83 deletions(-) diff --git a/components/svg/unique/moon/index.js b/components/svg/unique/moon/index.js index 1414ed36..4774318f 100644 --- a/components/svg/unique/moon/index.js +++ b/components/svg/unique/moon/index.js @@ -2,7 +2,7 @@ import PropTypes from "prop-types"; import svgShape from "@/shapes/svg"; import defaultProps from "../defaultProps"; -import phaseParts from "./parts"; +import phases from "./parts"; import { useTranslation } from "react-i18next"; const Moon = ({ phase = 0, className, size = 46, fill = "currentColor" }) => { @@ -15,41 +15,15 @@ const Moon = ({ phase = 0, className, size = 46, fill = "currentColor" }) => { className, }; - const labels = [ - t("summit_dashboard.astro.moon.new"), - t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), - t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), - t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), - t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), - t("summit_dashboard.astro.moon.quarter", { context: "first" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), - t("summit_dashboard.astro.moon.full"), - t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), - t("summit_dashboard.astro.moon.quarter", { context: "last" }), - t("summit_dashboard.astro.moon.crescent", { context: "waning" }), - t("summit_dashboard.astro.moon.crescent", { context: "waning" }), - t("summit_dashboard.astro.moon.crescent", { context: "waning" }), - t("summit_dashboard.astro.moon.crescent", { context: "waning" }), - ]; - - const pathProps = - phaseParts[ - Math.min(Math.floor(phase * phaseParts.length), phaseParts.length - 1) - ]; - - const label = - labels[Math.min(Math.floor(phase * labels.length), labels.length - 1)]; + const { + pathProps, + label: { i18nKey, context }, + } = phases[Math.min(Math.floor(phase * phases.length), phases.length - 1)]; const mergedSvgProps = Object.assign(defaultProps, uniqueProps); return ( - {label} + {t(i18nKey, { context })} { - const { t } = useTranslation(); - - const labels = [ - t("summit_dashboard.astro.moon.new"), - t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), - t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), - t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), - t("summit_dashboard.astro.moon.crescent", { context: "waxing" }), - t("summit_dashboard.astro.moon.quarter", { context: "first" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waxing" }), - t("summit_dashboard.astro.moon.full"), - t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), - t("summit_dashboard.astro.moon.gibbous", { context: "waning" }), - t("summit_dashboard.astro.moon.quarter", { context: "last" }), - t("summit_dashboard.astro.moon.crescent", { context: "waning" }), - t("summit_dashboard.astro.moon.crescent", { context: "waning" }), - t("summit_dashboard.astro.moon.crescent", { context: "waning" }), - t("summit_dashboard.astro.moon.crescent", { context: "waning" }), - ]; - - const label = - labels[Math.min(Math.floor(phase * labels.length), labels.length - 1)]; + const { label } = + phases[Math.min(Math.floor(phase * phases.length), phases.length - 1)]; return ( - {t("summit_dashboard.widgets.current.moon")} + + summit_dashboard.widgets.current.moon + - {label} + + + ); }; From 27b28a6f1855aa2f6add0627e19f4a59346a723b Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 26 Jun 2023 16:29:35 -0700 Subject: [PATCH 28/98] [F] daylight widget --- components/charts/ChartBase/index.js | 3 +- components/charts/ChartFigure/index.js | 5 +- components/charts/ChartFigure/styles.js | 15 +- components/charts/Legend/index.js | 5 +- components/charts/XAxis/index.js | 4 +- .../dynamic/SummitData/Astroweather/index.js | 31 ++- .../CurrentData/patterns/Daylight/index.js | 205 ++++++++++++++++++ .../CurrentData/patterns/Daylight/styles.js | 23 ++ helpers/formatters.js | 2 +- helpers/index.js | 14 +- lib/localeStrings/en.json | 7 + lib/observatory.js | 1 + 12 files changed, 292 insertions(+), 23 deletions(-) create mode 100644 components/widgets/CurrentData/patterns/Daylight/index.js create mode 100644 components/widgets/CurrentData/patterns/Daylight/styles.js diff --git a/components/charts/ChartBase/index.js b/components/charts/ChartBase/index.js index e4d93d6f..b594d7b8 100644 --- a/components/charts/ChartBase/index.js +++ b/components/charts/ChartBase/index.js @@ -6,7 +6,8 @@ const ChartBase = ({ children, className, width = 900, height = 300 }) => { preserveAspectRatio="xMidYMid meet" viewBox={`0 0 ${width} ${height}`} className={className} - style={{ minHeight: height, height: "100%" }} + style={{ minHeight: height, aspectRatio: `${width} / ${height}` }} + role="group" > {children} diff --git a/components/charts/ChartFigure/index.js b/components/charts/ChartFigure/index.js index d450e21d..073b9d4e 100644 --- a/components/charts/ChartFigure/index.js +++ b/components/charts/ChartFigure/index.js @@ -1,9 +1,9 @@ import PropTypes from "prop-types"; import * as Styled from "./styles"; -const ChartFigure = ({ caption, children, legend }) => { +const ChartFigure = ({ caption, children, legend, className }) => { return ( - + {caption} {children} {legend} @@ -17,6 +17,7 @@ ChartFigure.propTypes = { caption: PropTypes.string, children: PropTypes.node, legend: PropTypes.node, + className: PropTypes.string, }; export default ChartFigure; diff --git a/components/charts/ChartFigure/styles.js b/components/charts/ChartFigure/styles.js index a862fda7..7fe95054 100644 --- a/components/charts/ChartFigure/styles.js +++ b/components/charts/ChartFigure/styles.js @@ -1,19 +1,14 @@ import styled from "styled-components"; +import WidgetBackground from "@/components/atomic/WidgetBackground"; -export const Figure = styled.figure` - padding: var(--PADDING_SMALL, 20px); - color: var(--white, #fff); - background-color: var(--turquoise85, #12726c); - border-radius: 10px; - - & > * + * { - margin-block-start: var(--PADDING_SMALL, 20px); - } -`; +export const Figure = styled(WidgetBackground)``; export const Caption = styled.figcaption` text-align: center; `; export const Content = styled.div` + width: 100%; + overflow-x: auto; + overflow-y: hidden; position: relative; overflow-x: auto; scrollbar-color: var(--white, #fff) rgba(255, 255, 255, 20%); diff --git a/components/charts/Legend/index.js b/components/charts/Legend/index.js index 51f74337..e83100f9 100644 --- a/components/charts/Legend/index.js +++ b/components/charts/Legend/index.js @@ -9,9 +9,9 @@ const colors = { const ChartLegend = ({ legends = [] }) => { return ( - {legends.map(({ title, type, id }) => ( + {legends.map(({ title, type, id, color }) => ( - + {title} ))} @@ -26,6 +26,7 @@ ChartLegend.propTypes = { PropTypes.shape({ title: PropTypes.string, type: PropTypes.oneOf("line", "bar"), + color: PropTypes.string, id: PropTypes.string, }) ), diff --git a/components/charts/XAxis/index.js b/components/charts/XAxis/index.js index 1a9fe614..37264aac 100644 --- a/components/charts/XAxis/index.js +++ b/components/charts/XAxis/index.js @@ -5,7 +5,7 @@ const XAxis = ({ xDomain, xScale, y = 0, - padding, + padding = 0, ticks, labelFormatter, labelledById, @@ -48,7 +48,7 @@ XAxis.propTypes = { xDomain: PropTypes.arrayOf(PropTypes.number).isRequired, xScale: PropTypes.func.isRequired, y: PropTypes.number, - padding: PropTypes.number.isRequired, + padding: PropTypes.number, ticks: PropTypes.number.isRequired, labelFormatter: PropTypes.func, labelledById: PropTypes.string, diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index 9bbc7ec2..72468e2d 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -1,23 +1,48 @@ import { useState } from "react"; -import { useTranslation } from "react-i18next"; import SunCalc from "suncalc"; import WidgetPreview from "@/components/layout/WidgetPreview"; import SummitStatusModal from "@/components/modal/SummitStatusModal"; import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; +import Daylight from "@/components/widgets/CurrentData/patterns/Daylight"; +import { altitude, lat, long, timezone } from "@/lib/observatory"; +import { timezoneOffset } from "@/helpers"; const Astroweather = () => { - const { t } = useTranslation(); const [isModalOpen, setModalOpen] = useState(false); - const { phase } = SunCalc.getMoonIllumination(new Date()); + const now = new Date(); + const offset = timezoneOffset(timezone); + + const { phase } = SunCalc.getMoonIllumination(now); + + const observatoryDate = new Date( + now.toLocaleString("en-US", { timeZone: timezone }) + ); + + observatoryDate.setUTCHours(12 - offset, 0, 0, 0); + + const { nightEnd, sunrise, sunset, night } = SunCalc.getTimes( + observatoryDate, + lat, + long, + altitude + ); + return ( { setModalOpen(true); }} > + setModalOpen(false)} diff --git a/components/widgets/CurrentData/patterns/Daylight/index.js b/components/widgets/CurrentData/patterns/Daylight/index.js new file mode 100644 index 00000000..eae2dd3a --- /dev/null +++ b/components/widgets/CurrentData/patterns/Daylight/index.js @@ -0,0 +1,205 @@ +import PropTypes from "prop-types"; +import { ChartBase } from "@/components/charts"; +import * as Styled from "./styles"; +import { getLinearScale } from "@/lib/utils"; +import { formatTime } from "@/helpers/formatters"; +import XAxis from "@/components/charts/XAxis"; +import { capitalize, timezoneOffset } from "@/helpers"; +import { timezone } from "@/lib/observatory"; +import { useTranslation } from "react-i18next"; +import ChartLegend from "@/components/charts/Legend"; + +const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { + const { + t, + i18n: { language = "en-US" }, + } = useTranslation(); + const offset = timezoneOffset(timezone); + const minutes = 1500; + const width = 280; + const height = 70; + const xDomain = [0, minutes]; + const xScale = getLinearScale(xDomain, [0, width]); + + const midnight = new Date(); + midnight.setUTCHours(offset, 0, 0, 0); + + const getMinutes = (date) => + (date.getUTCHours() - offset) * 60 + date.getMinutes(); + + const dawnMinutes = getMinutes(dawn); + const sunriseMinutes = getMinutes(sunrise); + const sunsetMinutes = getMinutes(sunset); + const nightMinutes = getMinutes(night); + const now = getMinutes(new Date()); + + const nightFill = "#1f2121"; + const twilightFill = "#006DA8"; + const dayFill = "#55B9F0"; + + const nightId = "legendNight"; + const twilightId = "legendTwilight"; + const dayId = "legendDay"; + + const legends = [ + { title: "Night", color: nightFill, id: nightId }, + { title: "Twilight", color: twilightFill, id: twilightId }, + { title: "Day", color: dayFill, id: dayId }, + ]; + + return ( + } + > + + { + const hours = value / 60; + const date = new Date(); + date.setUTCHours(hours + offset, 0, 0, 0); + + const time = date.getUTCHours() - offset; + + if (time / 24 === 0) { + return ( + + {formatTime(date, language)} + + ); + } + + if (time === 12) { + const noon = date.toLocaleTimeString(language, { + dayPeriod: "short", + timeZone: timezone, + }); + + return ( + + {capitalize(noon, language)} + + ); + } + }, + }} + /> + + + + + + + + + + + + + + + + + + + nightMinutes || now < dawnMinutes ? "observable" : null, + })} + /> + + + + + ); +}; + +Daylight.propTypes = { + dawn: PropTypes.instanceOf(Date).isRequired, + sunrise: PropTypes.instanceOf(Date).isRequired, + sunset: PropTypes.instanceOf(Date).isRequired, + night: PropTypes.instanceOf(Date).isRequired, + variant: PropTypes.oneOf(["primary", "secondary"]), +}; + +Daylight.displayName = "Widgets.Current.Daylight"; + +export default Daylight; diff --git a/components/widgets/CurrentData/patterns/Daylight/styles.js b/components/widgets/CurrentData/patterns/Daylight/styles.js new file mode 100644 index 00000000..3c67c1fa --- /dev/null +++ b/components/widgets/CurrentData/patterns/Daylight/styles.js @@ -0,0 +1,23 @@ +import styled from "styled-components"; +import { ChartFigure } from "@/components/charts"; + +export const Figure = styled(ChartFigure)` + --widget-background-color: ${({ $variant }) => + $variant === "primary" ? "#313333" : "transparent"}; + grid-column: span 3; +`; + +export const BoundRect = styled.rect` + fill: var(--fill, var(--neutral95, #1f2121)); + stroke: var(--neutral20, #dce0e3); + stroke-width: 1; +`; + +export const Now = styled.line` + stroke: var(--white, #fff); + stroke-width: 5; +`; + +export const NowTip = styled.polygon` + fill: var(--neutral20, #dce0e3); +`; diff --git a/helpers/formatters.js b/helpers/formatters.js index 896ade94..aec84a3f 100644 --- a/helpers/formatters.js +++ b/helpers/formatters.js @@ -33,7 +33,7 @@ export const formatPercent = (value, locale = "en") => { return parts.join(""); }; -export const formatTime = (value, locale = "en", observatoryTime = "true") => { +export const formatTime = (value, locale = "en", observatoryTime = true) => { return new Intl.DateTimeFormat(locale, { timeStyle: "short", ...(observatoryTime && { timeZone: timezone }), diff --git a/helpers/index.js b/helpers/index.js index cd1fb80b..c48526da 100644 --- a/helpers/index.js +++ b/helpers/index.js @@ -1,6 +1,6 @@ -export const capitalize = (string) => { +export const capitalize = (string, locale = "en-US") => { if (typeof string !== "string") return ""; - return string.charAt(0).toUpperCase() + string.slice(1); + return string.charAt(0).toLocaleUpperCase(locale) + string.slice(1); }; export const hasImage = (imageArray) => @@ -36,3 +36,13 @@ export function wait(seconds) { setTimeout(resolve, seconds * 1000); }); } + +export const timezoneOffset = (timezone) => { + const now = new Date(); + now.setUTCHours(0, 0, 0, 0); + const localeDate = new Date( + now.toLocaleString("en-US", { timeZone: timezone }) + ); + + return 24 - localeDate.getHours(); +}; diff --git a/lib/localeStrings/en.json b/lib/localeStrings/en.json index 716f73c8..434fc34b 100644 --- a/lib/localeStrings/en.json +++ b/lib/localeStrings/en.json @@ -364,6 +364,13 @@ "no_data_yet": "No data yet" }, "astro": { + "daylight": { + "observing": "Dark enough to observe from {{from}} to {{to}}", + "twilight": "Twilight from {{from}} to {{to}}", + "daylight": "Daylight from {{from}} to {{to}}", + "current": "Current local time {{time}}. It is too light to observe right now.", + "current_observable": "Current local time {{time}}. It is dark enough to observe right now." + }, "moon": { "new": "New Moon", "full": "Full Moon", diff --git a/lib/observatory.js b/lib/observatory.js index 52834a49..01428698 100644 --- a/lib/observatory.js +++ b/lib/observatory.js @@ -1,3 +1,4 @@ export const lat = -30.244639; export const long = -70.749417; export const timezone = "America/Santiago"; +export const altitude = 2663; From d431d04c6c2670ac30b3bcf79f3d2fb2ec2cf000 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Tue, 27 Jun 2023 10:59:23 -0700 Subject: [PATCH 29/98] [C] finish up daylight widget --- components/charts/ChartFigure/index.js | 7 +- components/charts/ChartFigure/styles.js | 2 - components/charts/Legend/index.js | 2 +- .../SummitData/Astroweather/Current/index.js | 49 +++++ .../dynamic/SummitData/Astroweather/index.js | 8 +- .../CurrentData/patterns/Daylight/index.js | 170 ++++++++++-------- .../CurrentData/patterns/Daylight/styles.js | 7 +- lib/localeStrings/en.json | 18 +- 8 files changed, 168 insertions(+), 95 deletions(-) create mode 100644 components/dynamic/SummitData/Astroweather/Current/index.js diff --git a/components/charts/ChartFigure/index.js b/components/charts/ChartFigure/index.js index 073b9d4e..c9ff7adf 100644 --- a/components/charts/ChartFigure/index.js +++ b/components/charts/ChartFigure/index.js @@ -1,13 +1,14 @@ import PropTypes from "prop-types"; import * as Styled from "./styles"; +import WidgetBackground from "@/components/atomic/WidgetBackground"; const ChartFigure = ({ caption, children, legend, className }) => { return ( - - {caption} + + {caption && {caption}} {children} {legend} - + ); }; diff --git a/components/charts/ChartFigure/styles.js b/components/charts/ChartFigure/styles.js index 7fe95054..e5a2c0b5 100644 --- a/components/charts/ChartFigure/styles.js +++ b/components/charts/ChartFigure/styles.js @@ -1,7 +1,5 @@ import styled from "styled-components"; -import WidgetBackground from "@/components/atomic/WidgetBackground"; -export const Figure = styled(WidgetBackground)``; export const Caption = styled.figcaption` text-align: center; `; diff --git a/components/charts/Legend/index.js b/components/charts/Legend/index.js index e83100f9..9513a861 100644 --- a/components/charts/Legend/index.js +++ b/components/charts/Legend/index.js @@ -25,7 +25,7 @@ ChartLegend.propTypes = { legends: PropTypes.arrayOf( PropTypes.shape({ title: PropTypes.string, - type: PropTypes.oneOf("line", "bar"), + type: PropTypes.oneOf(["line", "bar"]), color: PropTypes.string, id: PropTypes.string, }) diff --git a/components/dynamic/SummitData/Astroweather/Current/index.js b/components/dynamic/SummitData/Astroweather/Current/index.js new file mode 100644 index 00000000..7378f056 --- /dev/null +++ b/components/dynamic/SummitData/Astroweather/Current/index.js @@ -0,0 +1,49 @@ +import { useState } from "react"; +import SunCalc from "suncalc"; +import { useTranslation } from "react-i18next"; +import { altitude, lat, long, timezone } from "@/lib/observatory"; +import { timezoneOffset } from "@/helpers"; +import WidgetSection from "@/components/layout/WidgetSection"; +import Daylight from "@/components/widgets/CurrentData/patterns/Daylight"; + +const CurrentAstroweather = () => { + const { t } = useTranslation(); + const [isOpen, setOpen] = useState(true); + const sectionProps = { + title: t("summit_dashboard.sections.astro.daylight.title"), + onToggleCallback: (value) => setOpen(value), + isOpen, + }; + + const now = new Date(); + const offset = timezoneOffset(timezone); + + const observatoryDate = new Date( + now.toLocaleString("en-US", { timeZone: timezone }) + ); + + observatoryDate.setUTCHours(12 - offset, 0, 0, 0); + + const { nightEnd, sunrise, sunset, night } = SunCalc.getTimes( + observatoryDate, + lat, + long, + altitude + ); + + return ( + + + + ); +}; + +CurrentAstroweather.displayName = "Dynamic.Astroweather.Current"; + +export default CurrentAstroweather; diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index 72468e2d..4ef43b2b 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -6,6 +6,7 @@ import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; import Daylight from "@/components/widgets/CurrentData/patterns/Daylight"; import { altitude, lat, long, timezone } from "@/lib/observatory"; import { timezoneOffset } from "@/helpers"; +import CurrentAstroweather from "./Current"; const Astroweather = () => { const [isModalOpen, setModalOpen] = useState(false); @@ -43,10 +44,9 @@ const Astroweather = () => { sunset={sunset} night={night} /> - setModalOpen(false)} - > + setModalOpen(false)}> + + ); }; diff --git a/components/widgets/CurrentData/patterns/Daylight/index.js b/components/widgets/CurrentData/patterns/Daylight/index.js index eae2dd3a..5bcbaaa6 100644 --- a/components/widgets/CurrentData/patterns/Daylight/index.js +++ b/components/widgets/CurrentData/patterns/Daylight/index.js @@ -16,10 +16,12 @@ const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { } = useTranslation(); const offset = timezoneOffset(timezone); const minutes = 1500; - const width = 280; + const width = variant === "primary" ? 280 : 640; const height = 70; const xDomain = [0, minutes]; const xScale = getLinearScale(xDomain, [0, width]); + const xHeight = 25; + const xPos = height - xHeight; const midnight = new Date(); midnight.setUTCHours(offset, 0, 0, 0); @@ -42,15 +44,31 @@ const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { const dayId = "legendDay"; const legends = [ - { title: "Night", color: nightFill, id: nightId }, - { title: "Twilight", color: twilightFill, id: twilightId }, - { title: "Day", color: dayFill, id: dayId }, + { + title: t("summit_dashboard.astro.daylight.night"), + color: nightFill, + id: nightId, + }, + { + title: t("summit_dashboard.astro.daylight.twilight"), + color: twilightFill, + id: twilightId, + }, + { + title: t("summit_dashboard.astro.daylight.day"), + color: dayFill, + id: dayId, + }, ]; return ( } > @@ -58,7 +76,7 @@ const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { {...{ xDomain, xScale, - y: height - 25, + y: xPos, ticks: 25, labelFormatter: (value) => { const hours = value / 60; @@ -72,7 +90,7 @@ const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { {formatTime(date, language)} @@ -89,7 +107,7 @@ const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { return ( {capitalize(noon, language)} @@ -100,91 +118,87 @@ const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { }} /> - - - - - - - - - - - - - - + + + + - + } + )} + /> - + nightMinutes || now < dawnMinutes ? "observable" : null, })} /> diff --git a/components/widgets/CurrentData/patterns/Daylight/styles.js b/components/widgets/CurrentData/patterns/Daylight/styles.js index 3c67c1fa..b4f7ef1b 100644 --- a/components/widgets/CurrentData/patterns/Daylight/styles.js +++ b/components/widgets/CurrentData/patterns/Daylight/styles.js @@ -3,8 +3,11 @@ import { ChartFigure } from "@/components/charts"; export const Figure = styled(ChartFigure)` --widget-background-color: ${({ $variant }) => - $variant === "primary" ? "#313333" : "transparent"}; - grid-column: span 3; + `--widget-background-color: ${ + $variant === "primary" ? "#313333" : "transparent" + }; --widget-columns: ${$variant === "primary" ? "span 3" : "1 / -1"}`}; + + grid-column: var(--widget-columns, span 3); `; export const BoundRect = styled.rect` diff --git a/lib/localeStrings/en.json b/lib/localeStrings/en.json index 434fc34b..a7bccd8a 100644 --- a/lib/localeStrings/en.json +++ b/lib/localeStrings/en.json @@ -354,6 +354,16 @@ "current": "Weather at the summit now", "hourly": "Hourly weather stats", "daily": "Daily temperature variations - {{unit}} degrees (last week)" + }, + "astro": { + "daylight": { + "title": "Twilight, day, and night times", + "observing": "Dark enough to observe from {{from}} to {{to}}", + "twilight": "Twilight from {{from}} to {{to}}", + "daylight": "Daylight from {{from}} to {{to}}", + "current": "Current local time {{time}}. It is too light to observe right now.", + "current_observable": "Current local time {{time}}. It is dark enough to observe right now." + } } }, "weather": { @@ -365,11 +375,9 @@ }, "astro": { "daylight": { - "observing": "Dark enough to observe from {{from}} to {{to}}", - "twilight": "Twilight from {{from}} to {{to}}", - "daylight": "Daylight from {{from}} to {{to}}", - "current": "Current local time {{time}}. It is too light to observe right now.", - "current_observable": "Current local time {{time}}. It is dark enough to observe right now." + "night": "Night", + "twilight": "Twilight", + "day": "Day" }, "moon": { "new": "New Moon", From 80088c4b96b8ca20ced8368565b8bbfea728bb91 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 29 Jun 2023 09:22:14 -0700 Subject: [PATCH 30/98] [C] responsive styling fixes --- components/atomic/WidgetBackground/styles.js | 10 +++--- components/charts/ChartBase/index.js | 7 +++-- components/charts/ChartBase/styles.js | 7 +++++ components/charts/ChartFigure/styles.js | 2 ++ components/layout/WidgetGrid/styles.js | 2 +- components/layout/WidgetPreview/styles.js | 31 ++++++++++++++++--- components/svg/unique/moon/index.js | 2 +- .../CurrentData/patterns/Daylight/styles.js | 11 +++++-- .../CurrentData/patterns/MoonPhase/index.js | 2 +- components/widgets/CurrentData/styles.js | 2 +- 10 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 components/charts/ChartBase/styles.js diff --git a/components/atomic/WidgetBackground/styles.js b/components/atomic/WidgetBackground/styles.js index fe65e7d5..11862c16 100644 --- a/components/atomic/WidgetBackground/styles.js +++ b/components/atomic/WidgetBackground/styles.js @@ -1,4 +1,5 @@ import styled from "styled-components"; +import { fluidScale } from "@/styles/globalStyles"; const variants = { primary: "var(--turquoise85, #12726d)", @@ -8,13 +9,14 @@ const variants = { export const WidgetBackground = styled.div` --widget-background-color: ${({ $variant = "primary" }) => variants[$variant]}; + --widget-padding: ${fluidScale("20px", "10px")}; + background-color: var(--widget-background-color); + border-radius: calc(var(--widget-padding) / 2); + font-size: 0.75rem; display: flex; flex-direction: column; align-items: center; justify-content: space-between; - padding: var(--PADDING_SMALL, 20px); - font-size: 0.75rem; - background-color: var(--widget-background-color); - border-radius: calc(var(--PADDING_SMALL, 20px) / 2); + padding: var(--widget-padding); `; diff --git a/components/charts/ChartBase/index.js b/components/charts/ChartBase/index.js index b594d7b8..0544557f 100644 --- a/components/charts/ChartBase/index.js +++ b/components/charts/ChartBase/index.js @@ -1,16 +1,17 @@ import PropTypes from "prop-types"; +import * as Styled from "./styles"; const ChartBase = ({ children, className, width = 900, height = 300 }) => { return ( - {children} - + ); }; diff --git a/components/charts/ChartBase/styles.js b/components/charts/ChartBase/styles.js new file mode 100644 index 00000000..a8bb187b --- /dev/null +++ b/components/charts/ChartBase/styles.js @@ -0,0 +1,7 @@ +import styled from "styled-components"; + +export const SVG = styled.svg` + aspect-ratio: var(--aspect-ratio); + max-height: 100%; + max-width: 100%; +`; diff --git a/components/charts/ChartFigure/styles.js b/components/charts/ChartFigure/styles.js index e5a2c0b5..41b14b8f 100644 --- a/components/charts/ChartFigure/styles.js +++ b/components/charts/ChartFigure/styles.js @@ -4,6 +4,8 @@ export const Caption = styled.figcaption` text-align: center; `; export const Content = styled.div` + display: flex; + justify-content: center; width: 100%; overflow-x: auto; overflow-y: hidden; diff --git a/components/layout/WidgetGrid/styles.js b/components/layout/WidgetGrid/styles.js index 8450e63d..99819d34 100644 --- a/components/layout/WidgetGrid/styles.js +++ b/components/layout/WidgetGrid/styles.js @@ -3,7 +3,7 @@ import styled from "styled-components"; export const WidgetGrid = styled.div` --widget-row-gap: var(--PADDING_SMALL, 20px); - --widget-columns: 2; + --widget-columns: 1; display: grid; grid-template-columns: repeat(var(--widget-columns), 1fr); diff --git a/components/layout/WidgetPreview/styles.js b/components/layout/WidgetPreview/styles.js index b422d26e..ebea5e54 100644 --- a/components/layout/WidgetPreview/styles.js +++ b/components/layout/WidgetPreview/styles.js @@ -1,7 +1,20 @@ import IconButton from "@/components/atomic/Button/IconButton"; import styled from "styled-components"; +import { token } from "@/styles/globalStyles"; -const columns = { +const mobileColumns = { + small: 1, + medium: 1, + large: 1, + full: 1, +}; +const tabletColumns = { + small: 1, + medium: 1, + large: 2, + full: 3, +}; +const desktopColumns = { small: 1, medium: 2, large: 4, @@ -10,15 +23,24 @@ const columns = { export const PreviewPanel = styled.section` --widget-grid-gap: var(--PADDING_SMALL, 20px); - --panel-columns: ${({ $size }) => columns[$size]}; + --panel-columns: ${({ $size }) => mobileColumns[$size]}; display: grid; - grid-template: "header" 2rem "content" 10rem "callout" 2rem / 1fr; + grid-template: "header" 2rem "content" auto "callout" 2rem / 1fr; + grid-gap: var(--widget-grid-gap); grid-column: span min(var(--panel-columns), var(--widget-columns)); grid-gap: var(--widget-grid-gap); background-color: var(--black, #000); border-bottom-right-radius: 0.75rem; border-bottom-left-radius: 0.75rem; + + @media screen and (min-width: ${token("BREAK_TABLET_MIN")}) { + --panel-columns: ${({ $size }) => tabletColumns[$size]}; + } + + @media screen and (min-width: ${token("BREAK_DESKTOP_SMALL")}) { + --panel-columns: ${({ $size }) => desktopColumns[$size]}; + } `; export const PreviewHeader = styled.h2` @@ -48,8 +70,7 @@ export const PreviewIconButton = styled(IconButton)` export const PreviewContent = styled.div` display: grid; - grid-area: content; - grid-template-rows: 1fr; + grid-auto-rows: 10rem; grid-template-columns: repeat(var(--panel-columns), 1fr); grid-gap: var(--widget-grid-gap); padding-inline: var(--widget-grid-gap); diff --git a/components/svg/unique/moon/index.js b/components/svg/unique/moon/index.js index 4774318f..159e6b8d 100644 --- a/components/svg/unique/moon/index.js +++ b/components/svg/unique/moon/index.js @@ -34,7 +34,7 @@ const Moon = ({ phase = 0, className, size = 46, fill = "currentColor" }) => { d="M11.088,42.679a6.714,6.714,0,1,1,12.969,3.3Q23.531,46,23,46A22.891,22.891,0,0,1,11.088,42.679Zm23.666-2.514a5.166,5.166,0,0,1,7.514-4.6,23.124,23.124,0,0,1-6.983,6.883A5.144,5.144,0,0,1,34.754,40.164Z" fill="#e9edf0" /> - + ); }; diff --git a/components/widgets/CurrentData/patterns/Daylight/styles.js b/components/widgets/CurrentData/patterns/Daylight/styles.js index b4f7ef1b..6e9be3e9 100644 --- a/components/widgets/CurrentData/patterns/Daylight/styles.js +++ b/components/widgets/CurrentData/patterns/Daylight/styles.js @@ -1,13 +1,20 @@ import styled from "styled-components"; +import { token } from "@/styles/globalStyles"; import { ChartFigure } from "@/components/charts"; export const Figure = styled(ChartFigure)` - --widget-background-color: ${({ $variant }) => + --widget-columns: 1 / -1; + ${({ $variant }) => `--widget-background-color: ${ $variant === "primary" ? "#313333" : "transparent" - }; --widget-columns: ${$variant === "primary" ? "span 3" : "1 / -1"}`}; + }`}; grid-column: var(--widget-columns, span 3); + + @media screen and (min-width: ${token("BREAK_TABLET_MIN")}) { + --widget-columns: ${({ $variant }) => + $variant === "primary" ? "span 3" : "1 / -1"}; + } `; export const BoundRect = styled.rect` diff --git a/components/widgets/CurrentData/patterns/MoonPhase/index.js b/components/widgets/CurrentData/patterns/MoonPhase/index.js index 82b45f13..c873a626 100644 --- a/components/widgets/CurrentData/patterns/MoonPhase/index.js +++ b/components/widgets/CurrentData/patterns/MoonPhase/index.js @@ -14,7 +14,7 @@ const MoonPhase = ({ phase = 0 }) => { summit_dashboard.widgets.current.moon - + diff --git a/components/widgets/CurrentData/styles.js b/components/widgets/CurrentData/styles.js index 678b5ab8..3f53ba98 100644 --- a/components/widgets/CurrentData/styles.js +++ b/components/widgets/CurrentData/styles.js @@ -17,7 +17,7 @@ export const Separator = styled.hr` `; export const Unit = styled.span` - line-height: 0.75; + text-align: center; `; export const Label = styled.h3` From 80d691250e8b99b1eac6ed8acf905e51b6c35168 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 29 Jun 2023 09:26:22 -0700 Subject: [PATCH 31/98] [C] remove max-width --- components/charts/ChartBase/styles.js | 1 - 1 file changed, 1 deletion(-) diff --git a/components/charts/ChartBase/styles.js b/components/charts/ChartBase/styles.js index a8bb187b..3ef01415 100644 --- a/components/charts/ChartBase/styles.js +++ b/components/charts/ChartBase/styles.js @@ -3,5 +3,4 @@ import styled from "styled-components"; export const SVG = styled.svg` aspect-ratio: var(--aspect-ratio); max-height: 100%; - max-width: 100%; `; From 347d63808c4b66d97547e910df5e5aa94f1b2c3f Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 29 Jun 2023 09:33:26 -0700 Subject: [PATCH 32/98] [C] more responsive work --- components/charts/ChartBase/index.js | 5 ++++- components/charts/ChartBase/styles.js | 3 +++ components/charts/ChartFigure/styles.js | 2 -- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/charts/ChartBase/index.js b/components/charts/ChartBase/index.js index 0544557f..59421df2 100644 --- a/components/charts/ChartBase/index.js +++ b/components/charts/ChartBase/index.js @@ -7,7 +7,10 @@ const ChartBase = ({ children, className, width = 900, height = 300 }) => { preserveAspectRatio="xMidYMid meet" viewBox={`0 0 ${width} ${height}`} className={className} - style={{ "--aspect-ratio": `${width} / ${height}` }} + style={{ + "--aspect-ratio": `${width} / ${height}`, + "--min-width": `${width}px`, + }} role="group" > {children} diff --git a/components/charts/ChartBase/styles.js b/components/charts/ChartBase/styles.js index 3ef01415..0e555ced 100644 --- a/components/charts/ChartBase/styles.js +++ b/components/charts/ChartBase/styles.js @@ -2,5 +2,8 @@ import styled from "styled-components"; export const SVG = styled.svg` aspect-ratio: var(--aspect-ratio); + min-width: var(--min-width); + width: 100%; max-height: 100%; + margin-inline: auto; `; diff --git a/components/charts/ChartFigure/styles.js b/components/charts/ChartFigure/styles.js index 41b14b8f..e5a2c0b5 100644 --- a/components/charts/ChartFigure/styles.js +++ b/components/charts/ChartFigure/styles.js @@ -4,8 +4,6 @@ export const Caption = styled.figcaption` text-align: center; `; export const Content = styled.div` - display: flex; - justify-content: center; width: 100%; overflow-x: auto; overflow-y: hidden; From 963b0d2fb3f2a0439eee8b2afb6ff1ca615626cc Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Mon, 26 Jun 2023 10:35:04 -0700 Subject: [PATCH 33/98] [F] efd internal API enpoint + hooks fetching --- contexts/SummitData.js | 125 +++++++++++----------------------------- lib/api/efd.js | 30 +++------- pages/api/efd/[type].js | 40 +++++++++++++ 3 files changed, 82 insertions(+), 113 deletions(-) create mode 100644 pages/api/efd/[type].js diff --git a/contexts/SummitData.js b/contexts/SummitData.js index ff75176e..890e7fae 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -1,112 +1,53 @@ import { createContext, useContext, - useEffect, useMemo, - useState, - useReducer, } from "react"; -import { - currentWeather, - dailyWeather, - hourlyWeather, -} from "@/lib/api/queries/weather"; import PropTypes from "prop-types"; -import queryEfd from "@/lib/api/efd"; +import useEfd from "@/lib/api/efd"; export const SummitDataContext = createContext({}); -const loadingReducer = (state, action) => { - const { type, dataSet } = action; - - switch (type) { - case "complete": - return { ...state, [dataSet]: false }; - case "loading": - return { ...state, [dataSet]: true }; - default: - throw new Error(`Unhandled action type: ${type}`); - } -}; - -const defaultLoadState = { - currentData: true, - hourlyData: true, - dailyData: true, -}; - export const SummitDataProvider = ({ children }) => { - const [currentData, setCurrentData] = useState(); - const [hourlyData, setHourlyData] = useState(); - const [dailyData, setDailyData] = useState(); - const [error, setError] = useState(false); - const [loading, dispatch] = useReducer(loadingReducer, defaultLoadState); - - const fetchCurrentWeather = () => - new Promise((resolve, reject) => { - queryEfd(currentWeather) - .then((value) => { - setCurrentData(...value); - resolve(...value); - }) - .catch((e) => { - reject(e); - }) - .finally(() => { - dispatch({ type: "complete", dataSet: "currentData" }); - }); - }); - - const fetchHourlyWeather = () => - new Promise((resolve, reject) => { - queryEfd(hourlyWeather) - .then((value) => { - setHourlyData(value); - resolve(value); - }) - .catch((e) => { - reject(e); - }) - .finally(() => { - dispatch({ type: "complete", dataSet: "hourlyData" }); - }); - }); - - const fetchDailyWeather = () => - new Promise((resolve, reject) => { - queryEfd(dailyWeather) - .then((value) => { - setDailyData(value); - resolve(value); - }) - .catch((e) => { - reject(e); - }) - .finally(() => { - dispatch({ type: "complete", dataSet: "dailyData" }); - }); - }); - - useEffect(() => { - Promise.allSettled([ - fetchCurrentWeather(), - fetchHourlyWeather(), - fetchDailyWeather(), - ]).catch((e) => { - console.error(e); - setError(true); - }); - }, []); + const { + data: currentData, + isLoading: currentIsLoading, + isError: currentIsError, + } = useEfd("current"); + const { + data: hourlyData, + isLoading: hourlyIsLoading, + isError: hourlyIsError, + } = useEfd("hourly"); + const { + data: dailyData, + isLoading: dailyIsLoading, + isError: dailyIsError, + } = useEfd("daily"); const value = useMemo( () => ({ currentData, hourlyData, dailyData, - loading, - error, + error: currentIsError || hourlyIsError || dailyIsError, + loading: { + currentData: currentIsLoading, + hourlyData: hourlyIsLoading, + dailyData: dailyIsLoading, + }, }), - [currentData, hourlyData, dailyData, loading, error] + [ + currentData, + hourlyData, + dailyData, + currentIsLoading, + hourlyIsLoading, + dailyIsLoading, + currentIsError, + hourlyIsError, + dailyIsError, + ] ); return ( diff --git a/lib/api/efd.js b/lib/api/efd.js index 5a1a32e4..71d61597 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -1,25 +1,13 @@ -import { InfluxDB } from "@influxdata/influxdb-client"; +import useSWR from "swr"; -export default function queryEfd(query) { - const url = process.env.NEXT_PUBLIC_EFD_URL; - const bucket = process.env.NEXT_PUBLIC_EFD_BUCKET; - const token = process.env.NEXT_PUBLIC_EFD_TOKEN; +const fetcher = (url) => fetch(url).then((res) => res.json()); - const influxDB = new InfluxDB({ url, token }); - const queryApi = influxDB.getQueryApi(""); +export default async function useEfd(type) { + const { data, error } = useSWR(`/api/efd/${type}`, fetcher); - return new Promise((resolve, reject) => { - const data = []; - queryApi.queryRows(query(bucket), { - next(row, tableMeta) { - data.push(tableMeta.toObject(row)); - }, - error(error) { - reject(error); - }, - complete() { - resolve(data); - }, - }); - }); + return { + data, + isLoading: !error && !data, + isError: error, + }; } diff --git a/pages/api/efd/[type].js b/pages/api/efd/[type].js new file mode 100644 index 00000000..aa66d6e4 --- /dev/null +++ b/pages/api/efd/[type].js @@ -0,0 +1,40 @@ +import { InfluxDB } from "@influxdata/influxdb-client"; +import { + currentWeather, + dailyWeather, + hourlyWeather, +} from "@/lib/api/queries/weather"; + +const types = { + current: currentWeather, + hourly: hourlyWeather, + daily: dailyWeather, +}; + +export default function handler(req, res) { + const url = process.env.EFD_URL; + const bucket = process.env.EFD_BUCKET; + const token = process.env.EFD_TOKEN; + + const influxDB = new InfluxDB({ url, token }); + const queryApi = influxDB.getQueryApi(""); + + const { type } = req.query; + const query = types[type]; + + const data = []; + + queryApi.queryRows(query(bucket), { + next(row, tableMeta) { + data.push(tableMeta.toObject(row)); + }, + error(error) { + // reject(error); + res.status(200).json({ error }) + }, + complete() { + // resolve(data); + res.status(200).json({ data }) + }, + }); +} \ No newline at end of file From 873cf803f7daf4521a6fb80ac7c3397bfa88f9a1 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 11 Jul 2023 12:26:41 -0700 Subject: [PATCH 34/98] [B] Correct EFD response format + useEfd no longer async --- lib/api/efd.js | 2 +- pages/api/efd/[type].js | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/api/efd.js b/lib/api/efd.js index 71d61597..37f203bb 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -2,7 +2,7 @@ import useSWR from "swr"; const fetcher = (url) => fetch(url).then((res) => res.json()); -export default async function useEfd(type) { +export default function useEfd(type) { const { data, error } = useSWR(`/api/efd/${type}`, fetcher); return { diff --git a/pages/api/efd/[type].js b/pages/api/efd/[type].js index aa66d6e4..c400ef29 100644 --- a/pages/api/efd/[type].js +++ b/pages/api/efd/[type].js @@ -6,7 +6,7 @@ import { } from "@/lib/api/queries/weather"; const types = { - current: currentWeather, + current: currentWeather, hourly: hourlyWeather, daily: dailyWeather, }; @@ -29,12 +29,10 @@ export default function handler(req, res) { data.push(tableMeta.toObject(row)); }, error(error) { - // reject(error); - res.status(200).json({ error }) + return res.status(405).json(error); }, complete() { - // resolve(data); - res.status(200).json({ data }) + return res.status(200).json(type === "current" ? data[0] : data); }, }); -} \ No newline at end of file +} From f9a77a6d6ee30fde18068c55172f04d48041e807 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 6 Jun 2023 15:18:02 -0700 Subject: [PATCH 35/98] [C] Proxy for USDF CORS issue from local --- package.json | 14 +++ yarn.lock | 247 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 261 insertions(+) diff --git a/package.json b/package.json index 861ef72f..407a1683 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,20 @@ "build-storybook": "storybook build", "proxy": "env-cmd -x lcp --proxyUrl \\$EFD_URL_PROXY" }, + "babel": { + "presets": [ + "next/babel" + ], + "plugins": [ + [ + "styled-components", + { + "ssr": true, + "displayName": true + } + ] + ] + }, "browserslist": [ "defaults", "not IE 11" diff --git a/yarn.lock b/yarn.lock index 5361f52c..b4ee60e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3765,7 +3765,16 @@ array-back@^3.0.1, array-back@^3.1.0: resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== +<<<<<<< HEAD array-buffer-byte-length@^1.0.0: +======= +array-back@^3.0.1, array-back@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" + integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== + +array-find@^1.0.0: +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "1.0.0" resolved "https://registry.yarnpkg.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz#fabe8bc193fea865f317fe7807085ee0dee5aead" integrity sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A== @@ -3853,6 +3862,18 @@ assert-plus@1.0.0, assert-plus@^1.0.0: resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== +asn1@~0.2.3: + version "0.2.6" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.6.tgz#0d3a7bb6e64e02a90c0303b31f292868ea09a08d" + integrity sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ== + dependencies: + safer-buffer "~2.1.0" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== + assert@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32" @@ -4343,8 +4364,25 @@ caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== +<<<<<<< HEAD chalk@^2.0.0, chalk@^2.3.2, chalk@^2.4.1, chalk@^2.4.2: +======= + +chai@4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.4.tgz#b55e655b31e1eac7099be4c08c21964fce2e6c49" + integrity sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA== + dependencies: + assertion-error "^1.1.0" + check-error "^1.0.2" + deep-eql "^3.0.1" + get-func-name "^2.0.0" + pathval "^1.1.1" + type-detect "^4.0.5" + +chalk@^2.0.0, chalk@^2.3.0, chalk@^2.3.2, chalk@^2.4.0, chalk@^2.4.1, chalk@^2.4.2: +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -4554,6 +4592,14 @@ command-line-args@^5.0.2: find-replace "^3.0.0" lodash.camelcase "^4.3.0" typical "^4.0.0" +<<<<<<< HEAD +======= + +commander@2.11.x: + version "2.11.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" + integrity sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ== +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) commander@^2.19.0, commander@^2.20.0: version "2.20.3" @@ -4689,6 +4735,11 @@ core-util-is@1.0.2: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== +core-util-is@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== + core-util-is@~1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" @@ -4908,6 +4959,16 @@ dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" integrity sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g== +<<<<<<< HEAD +======= + dependencies: + assert-plus "^1.0.0" + +data-urls@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-3.0.2.tgz#9cf24a477ae22bcef5cd5f6f0bfbc1d2d3be9143" + integrity sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ== +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) dependencies: assert-plus "^1.0.0" @@ -5165,6 +5226,17 @@ ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" integrity sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw== +<<<<<<< HEAD +======= + dependencies: + jsbn "~0.1.0" + safer-buffer "^2.1.0" + +ecdsa-sig-formatter@1.0.11: + version "1.0.11" + resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz#ae0f0fa2d85045ef14a817daa3ce9acd0489e5bf" + integrity sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ== +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) dependencies: jsbn "~0.1.0" safer-buffer "^2.1.0" @@ -5268,6 +5340,14 @@ env-cmd@^10.1.0: commander "^4.0.0" cross-spawn "^7.0.0" +env-cmd@^10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/env-cmd/-/env-cmd-10.1.0.tgz#c7f5d3b550c9519f137fdac4dd8fb6866a8c8c4b" + integrity sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA== + dependencies: + commander "^4.0.0" + cross-spawn "^7.0.0" + envinfo@^7.7.3: version "7.8.1" resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" @@ -6182,6 +6262,15 @@ form-data@~2.3.2: combined-stream "^1.0.6" mime-types "^2.1.12" +form-data@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" + integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.6" + mime-types "^2.1.12" + forwarded@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" @@ -6747,6 +6836,7 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" +<<<<<<< HEAD http-signature@~1.3.6: version "1.3.6" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.3.6.tgz#cb6fbfdf86d1c974f343be94e87f7fc128662cf9" @@ -6755,6 +6845,21 @@ http-signature@~1.3.6: assert-plus "^1.0.0" jsprim "^2.0.2" sshpk "^1.14.1" +======= +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + integrity sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ== + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +http-status-codes@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/http-status-codes/-/http-status-codes-2.2.0.tgz#bb2efe63d941dfc2be18e15f703da525169622be" + integrity sha512-feERVo9iWxvnejp3SEfm/+oNG517npqL2/PIA8ORjyOZjGC7TwCRQsZylciLS64i6pJ0wRYz3rkXLRwbtFa8Ng== +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) https-proxy-agent@^4.0.0: version "4.0.0" @@ -7198,6 +7303,14 @@ is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== +<<<<<<< HEAD +======= + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + integrity sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q== +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) is-unicode-supported@^0.1.0: version "0.1.0" @@ -7505,7 +7618,21 @@ jsprim@^1.2.2: json-schema "0.4.0" verror "1.10.0" +<<<<<<< HEAD "jsx-ast-utils@^2.4.1 || ^3.0.0", jsx-ast-utils@^3.3.3: +======= +jsprim@^1.2.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb" + integrity sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw== + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.4.0" + verror "1.10.0" + +"jsx-ast-utils@^2.4.1 || ^3.0.0", jsx-ast-utils@^3.3.2: +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "3.3.3" resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz#76b3e6e6cece5c69d49a5792c3d01bd1a0cdc7ea" integrity sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw== @@ -8264,7 +8391,16 @@ oauth-sign@~0.9.0: resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== +<<<<<<< HEAD object-assign@^4, object-assign@^4.1.1: +======= +oauth-sign@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" + integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== + +object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.1: +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== @@ -9163,7 +9299,11 @@ proxy-from-env@^1.0.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== +<<<<<<< HEAD psl@^1.1.28: +======= +psl@^1.1.28, psl@^1.1.33: +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== @@ -9233,6 +9373,7 @@ qs@^6.10.0: dependencies: side-channel "^1.0.4" +<<<<<<< HEAD qs@~6.10.3: version "6.10.5" resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.5.tgz#974715920a80ff6a262264acd2c7e6c2a53282b4" @@ -9240,10 +9381,20 @@ qs@~6.10.3: dependencies: side-channel "^1.0.4" +======= +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) qs@~6.5.2: version "6.5.3" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== +<<<<<<< HEAD +======= + +querystringify@^2.1.1: + version "2.2.0" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6" + integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ== +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) queue-microtask@^1.2.2: version "1.2.3" @@ -9679,6 +9830,32 @@ request@^2.85.0: tunnel-agent "^0.6.0" uuid "^3.3.2" +request@^2.85.0: + version "2.88.2" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" + integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.8.0" + caseless "~0.12.0" + combined-stream "~1.0.6" + extend "~3.0.2" + forever-agent "~0.6.1" + form-data "~2.3.2" + har-validator "~5.1.3" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.19" + oauth-sign "~0.9.0" + performance-now "^2.1.0" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.5.0" + tunnel-agent "^0.6.0" + uuid "^3.3.2" + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -9851,7 +10028,11 @@ safe-regex-test@^1.0.0: get-intrinsic "^1.1.3" is-regex "^1.1.4" +<<<<<<< HEAD "safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: +======= +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== @@ -10187,7 +10368,23 @@ sshpk@^1.7.0: safer-buffer "^2.0.2" tweetnacl "~0.14.0" +<<<<<<< HEAD stackframe@^1.3.4: +======= +stack-utils@^2.0.3: + version "2.0.5" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.5.tgz#d25265fca995154659dbbfba3b49254778d2fdd5" + integrity sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA== + dependencies: + escape-string-regexp "^2.0.0" + +stackframe@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-0.3.1.tgz#33aa84f1177a5548c8935533cbfeb3420975f5a4" + integrity sha512-XmoiF4T5nuWEp2x2w92WdGjdHGY/cZa6LIbRsDRQR/Xlk4uW0PAUlH1zJYVffocwKpCdwyuypIp25xsSXEtZHw== + +stackframe@^1.1.1, stackframe@^1.3.4: +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "1.3.4" resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.3.4.tgz#b881a004c8c149a5e8efef37d51b16e412943310" integrity sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw== @@ -10782,10 +10979,43 @@ toidentifier@1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== +<<<<<<< HEAD +======= +tough-cookie@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.0.0.tgz#d822234eeca882f991f0f908824ad2622ddbece4" + integrity sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg== + dependencies: + psl "^1.1.33" + punycode "^2.1.1" + universalify "^0.1.2" + +tough-cookie@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.2.tgz#e53e84b85f24e0b65dd526f46628db6c85f6b874" + integrity sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ== + dependencies: + psl "^1.1.33" + punycode "^2.1.1" + universalify "^0.2.0" + url-parse "^1.5.3" + +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) tough-cookie@~2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== +<<<<<<< HEAD +======= + dependencies: + psl "^1.1.28" + punycode "^2.1.1" + +tr46@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-3.0.0.tgz#555c4e297a950617e8eeddef633c87d4d9d6cbf9" + integrity sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA== +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) dependencies: psl "^1.1.28" punycode "^2.1.1" @@ -10874,7 +11104,11 @@ tsutils@^3.21.0: dependencies: tslib "^1.8.1" +<<<<<<< HEAD tunnel-agent@^0.6.0: +======= +tunnel-agent@0.6.0, tunnel-agent@^0.6.0: +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" integrity sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w== @@ -10967,6 +11201,11 @@ typical@^4.0.0: resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== +typical@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" + integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== + uglify-js@^3.1.4: version "3.17.4" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" @@ -11147,6 +11386,14 @@ uuid@^3.3.2: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== +<<<<<<< HEAD +======= + +uuid@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" + integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== +>>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) uuid@^8.3.2: version "8.3.2" From 503659b0b53155c8dd6e9e905dc65794a11300a4 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 26 Jun 2023 16:29:35 -0700 Subject: [PATCH 36/98] [F] daylight widget --- components/charts/ChartFigure/styles.js | 1 + 1 file changed, 1 insertion(+) diff --git a/components/charts/ChartFigure/styles.js b/components/charts/ChartFigure/styles.js index e5a2c0b5..2c0c1de1 100644 --- a/components/charts/ChartFigure/styles.js +++ b/components/charts/ChartFigure/styles.js @@ -1,4 +1,5 @@ import styled from "styled-components"; +import WidgetBackground from "@/components/atomic/WidgetBackground"; export const Caption = styled.figcaption` text-align: center; From 0796b4a94986e24ac04bb749b0acf8c6ee42f7f5 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 29 Jun 2023 09:22:14 -0700 Subject: [PATCH 37/98] [C] responsive styling fixes --- components/charts/ChartFigure/styles.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/charts/ChartFigure/styles.js b/components/charts/ChartFigure/styles.js index 2c0c1de1..351f7d6f 100644 --- a/components/charts/ChartFigure/styles.js +++ b/components/charts/ChartFigure/styles.js @@ -5,6 +5,8 @@ export const Caption = styled.figcaption` text-align: center; `; export const Content = styled.div` + display: flex; + justify-content: center; width: 100%; overflow-x: auto; overflow-y: hidden; From 9ed0a7e2456be01cc2fef5afa08deddc6561f27f Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 5 Jul 2023 15:34:03 -0700 Subject: [PATCH 38/98] [F] Moonrise widget For JIRA: "EPO-8245 #IN-REVIEW #comment Moonrise widget" --- .../SummitData/Astroweather/Forecast/index.js | 41 +++++++++++++ .../dynamic/SummitData/Astroweather/index.js | 6 +- components/modal/SummitStatusModal/styles.js | 3 + .../CurrentData/patterns/MoonRise/index.js | 58 +++++++++++++++++++ .../CurrentData/patterns/MoonRise/styles.js | 28 +++++++++ helpers/formatters.js | 7 ++- lib/localeStrings/en.json | 5 ++ 7 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 components/dynamic/SummitData/Astroweather/Forecast/index.js create mode 100644 components/widgets/CurrentData/patterns/MoonRise/index.js create mode 100644 components/widgets/CurrentData/patterns/MoonRise/styles.js diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js new file mode 100644 index 00000000..ada8e411 --- /dev/null +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -0,0 +1,41 @@ +import { useState } from "react"; +import SunCalc from "suncalc"; +import { useTranslation } from "react-i18next"; +import { lat, long, timezone } from "@/lib/observatory"; +import { timezoneOffset } from "@/helpers"; +import WidgetSection from "@/components/layout/WidgetSection"; +import MoonRise from "@/components/widgets/CurrentData/patterns/MoonRise"; +import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; + +const ForecastAstroweather = () => { + const { t } = useTranslation(); + const [isOpen, setOpen] = useState(true); + const sectionProps = { + title: t("summit_dashboard.sections.astro.title"), + onToggleCallback: (value) => setOpen(value), + isOpen, + }; + + const now = new Date(); + const offset = timezoneOffset(timezone); + + const observatoryDate = new Date( + now.toLocaleString("en-US", { timeZone: timezone }) + ); + + observatoryDate.setUTCHours(12 - offset, 0, 0, 0); + + const { phase } = SunCalc.getMoonIllumination(now); + const { rise, set } = SunCalc.getMoonTimes(observatoryDate, lat, long, true); + + return ( + + + + + ); +}; + +ForecastAstroweather.displayName = "Dynamic.Astroweather.Forecast"; + +export default ForecastAstroweather; diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index 4ef43b2b..f4898cd4 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -1,5 +1,6 @@ import { useState } from "react"; import SunCalc from "suncalc"; +import { useTranslation } from "react-i18next"; import WidgetPreview from "@/components/layout/WidgetPreview"; import SummitStatusModal from "@/components/modal/SummitStatusModal"; import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; @@ -7,8 +8,10 @@ import Daylight from "@/components/widgets/CurrentData/patterns/Daylight"; import { altitude, lat, long, timezone } from "@/lib/observatory"; import { timezoneOffset } from "@/helpers"; import CurrentAstroweather from "./Current"; +import ForecastAstroweather from "./Forecast"; const Astroweather = () => { + const { t } = useTranslation(); const [isModalOpen, setModalOpen] = useState(false); const now = new Date(); @@ -31,7 +34,7 @@ const Astroweather = () => { return ( { setModalOpen(true); @@ -45,6 +48,7 @@ const Astroweather = () => { night={night} /> setModalOpen(false)}> + diff --git a/components/modal/SummitStatusModal/styles.js b/components/modal/SummitStatusModal/styles.js index e04fa354..2ab55081 100644 --- a/components/modal/SummitStatusModal/styles.js +++ b/components/modal/SummitStatusModal/styles.js @@ -34,6 +34,9 @@ export const Content = styled.div` `; export const ScrollableContent = styled.div` + display: flex; + flex-direction: column; + gap: var(--PADDING_SMALL, 20px); overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; diff --git a/components/widgets/CurrentData/patterns/MoonRise/index.js b/components/widgets/CurrentData/patterns/MoonRise/index.js new file mode 100644 index 00000000..8e144c8f --- /dev/null +++ b/components/widgets/CurrentData/patterns/MoonRise/index.js @@ -0,0 +1,58 @@ +import PropTypes from "prop-types"; +import { useTranslation } from "react-i18next"; +import { formatTime } from "@/helpers/formatters"; +import * as Styled from "./styles"; +import { capitalize } from "@/helpers"; + +const MoonRise = ({ rise, set }) => { + const { + t, + i18n: { language = "en" }, + } = useTranslation(); + const now = new Date(); + + const getHourDifference = (laterDate, earlierDate) => + Math.floor(Math.abs(laterDate - earlierDate) / 36e5); + + const getRelativeTime = (laterDate, earlierDate) => + capitalize( + new Intl.RelativeTimeFormat(language).format( + getHourDifference(laterDate, earlierDate), + "hour" + ), + language + ); + + return ( + + + + {t("summit_dashboard.sections.astro.moonrise.time_moonrise")} + + + {formatTime(rise, language, { hourCycle: "h24" })} + + {getRelativeTime(rise, now)} + + + + + {t("summit_dashboard.sections.astro.moonrise.time_moonset")} + + + {formatTime(set, language, { hourCycle: "h24" })} + + {getRelativeTime(set, now)} + + + ); +}; + +MoonRise.displayName = "Widgets.Current.MoonRise"; + +MoonRise.propTypes = { + rise: PropTypes.instanceOf(Date), + set: PropTypes.instanceOf(Date), +}; + +export default MoonRise; diff --git a/components/widgets/CurrentData/patterns/MoonRise/styles.js b/components/widgets/CurrentData/patterns/MoonRise/styles.js new file mode 100644 index 00000000..352ae440 --- /dev/null +++ b/components/widgets/CurrentData/patterns/MoonRise/styles.js @@ -0,0 +1,28 @@ +import styled from "styled-components"; +import WidgetBackground from "@/components/atomic/WidgetBackground"; +import { Value } from "../../styles"; +export * from "../../styles"; + +export const Background = styled(WidgetBackground)` + flex-direction: row; + grid-column: span 2; +`; + +export const Timecard = styled.div` + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + flex: 0 1 50%; + height: 100%; +`; + +export const Divider = styled.div` + background-color: var(--white, #fff); + width: 1px; + height: 4em; +`; + +export const Time = styled(Value)` + --font-size: 400%; +`; diff --git a/helpers/formatters.js b/helpers/formatters.js index aec84a3f..159d0b1e 100644 --- a/helpers/formatters.js +++ b/helpers/formatters.js @@ -33,9 +33,10 @@ export const formatPercent = (value, locale = "en") => { return parts.join(""); }; -export const formatTime = (value, locale = "en", observatoryTime = true) => { +export const formatTime = (value, locale = "en", options = {}) => { + const defaultOptions = { timeStyle: "short", timeZone: timezone }; return new Intl.DateTimeFormat(locale, { - timeStyle: "short", - ...(observatoryTime && { timeZone: timezone }), + ...defaultOptions, + ...options, }).format(value); }; diff --git a/lib/localeStrings/en.json b/lib/localeStrings/en.json index a7bccd8a..66e09db6 100644 --- a/lib/localeStrings/en.json +++ b/lib/localeStrings/en.json @@ -356,6 +356,7 @@ "daily": "Daily temperature variations - {{unit}} degrees (last week)" }, "astro": { + "title": "Astroweather", "daylight": { "title": "Twilight, day, and night times", "observing": "Dark enough to observe from {{from}} to {{to}}", @@ -363,6 +364,10 @@ "daylight": "Daylight from {{from}} to {{to}}", "current": "Current local time {{time}}. It is too light to observe right now.", "current_observable": "Current local time {{time}}. It is dark enough to observe right now." + }, + "moonrise": { + "time_moonrise": "Moonrise time", + "time_moonset": "Moonset time" } } }, From 1baf351698085b31a422651dba65bdc2b74b8f40 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 17 Jul 2023 13:30:20 -0700 Subject: [PATCH 39/98] [C] resolve merge --- yarn.lock | 266 ++++-------------------------------------------------- 1 file changed, 17 insertions(+), 249 deletions(-) diff --git a/yarn.lock b/yarn.lock index b4ee60e8..199c39f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2989,11 +2989,6 @@ dependencies: tslib "^2.4.0" -"@tootallnate/once@2": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" - integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== - "@types/babel__core@^7.0.0": version "7.20.0" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.0.tgz#61bc5a4cae505ce98e1e36c5445e4bee060d8891" @@ -3765,16 +3760,7 @@ array-back@^3.0.1, array-back@^3.1.0: resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== -<<<<<<< HEAD array-buffer-byte-length@^1.0.0: -======= -array-back@^3.0.1, array-back@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" - integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== - -array-find@^1.0.0: ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "1.0.0" resolved "https://registry.yarnpkg.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz#fabe8bc193fea865f317fe7807085ee0dee5aead" integrity sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A== @@ -3814,7 +3800,7 @@ array-union@^2.1.0: resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== -array.prototype.flat@^1.2.5: +array.prototype.flat@^1.2.5, array.prototype.flat@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz#ffc6576a7ca3efc2f46a143b9d1dda9b4b3cf5e2" integrity sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA== @@ -3862,18 +3848,6 @@ assert-plus@1.0.0, assert-plus@^1.0.0: resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== -asn1@~0.2.3: - version "0.2.6" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.6.tgz#0d3a7bb6e64e02a90c0303b31f292868ea09a08d" - integrity sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ== - dependencies: - safer-buffer "~2.1.0" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== - assert@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32" @@ -4364,25 +4338,8 @@ caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== -<<<<<<< HEAD chalk@^2.0.0, chalk@^2.3.2, chalk@^2.4.1, chalk@^2.4.2: -======= - -chai@4.3.4: - version "4.3.4" - resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.4.tgz#b55e655b31e1eac7099be4c08c21964fce2e6c49" - integrity sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA== - dependencies: - assertion-error "^1.1.0" - check-error "^1.0.2" - deep-eql "^3.0.1" - get-func-name "^2.0.0" - pathval "^1.1.1" - type-detect "^4.0.5" - -chalk@^2.0.0, chalk@^2.3.0, chalk@^2.3.2, chalk@^2.4.0, chalk@^2.4.1, chalk@^2.4.2: ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -4592,14 +4549,6 @@ command-line-args@^5.0.2: find-replace "^3.0.0" lodash.camelcase "^4.3.0" typical "^4.0.0" -<<<<<<< HEAD -======= - -commander@2.11.x: - version "2.11.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" - integrity sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ== ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) commander@^2.19.0, commander@^2.20.0: version "2.20.3" @@ -4735,11 +4684,6 @@ core-util-is@1.0.2: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== -core-util-is@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== - core-util-is@~1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" @@ -4959,16 +4903,6 @@ dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" integrity sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g== -<<<<<<< HEAD -======= - dependencies: - assert-plus "^1.0.0" - -data-urls@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-3.0.2.tgz#9cf24a477ae22bcef5cd5f6f0bfbc1d2d3be9143" - integrity sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ== ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) dependencies: assert-plus "^1.0.0" @@ -5226,17 +5160,6 @@ ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" integrity sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw== -<<<<<<< HEAD -======= - dependencies: - jsbn "~0.1.0" - safer-buffer "^2.1.0" - -ecdsa-sig-formatter@1.0.11: - version "1.0.11" - resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz#ae0f0fa2d85045ef14a817daa3ce9acd0489e5bf" - integrity sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ== ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) dependencies: jsbn "~0.1.0" safer-buffer "^2.1.0" @@ -5340,14 +5263,6 @@ env-cmd@^10.1.0: commander "^4.0.0" cross-spawn "^7.0.0" -env-cmd@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/env-cmd/-/env-cmd-10.1.0.tgz#c7f5d3b550c9519f137fdac4dd8fb6866a8c8c4b" - integrity sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA== - dependencies: - commander "^4.0.0" - cross-spawn "^7.0.0" - envinfo@^7.7.3: version "7.8.1" resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" @@ -6262,15 +6177,6 @@ form-data@~2.3.2: combined-stream "^1.0.6" mime-types "^2.1.12" -form-data@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" - integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.6" - mime-types "^2.1.12" - forwarded@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" @@ -6836,7 +6742,6 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" -<<<<<<< HEAD http-signature@~1.3.6: version "1.3.6" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.3.6.tgz#cb6fbfdf86d1c974f343be94e87f7fc128662cf9" @@ -6845,21 +6750,6 @@ http-signature@~1.3.6: assert-plus "^1.0.0" jsprim "^2.0.2" sshpk "^1.14.1" -======= -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" - integrity sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ== - dependencies: - assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -http-status-codes@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/http-status-codes/-/http-status-codes-2.2.0.tgz#bb2efe63d941dfc2be18e15f703da525169622be" - integrity sha512-feERVo9iWxvnejp3SEfm/+oNG517npqL2/PIA8ORjyOZjGC7TwCRQsZylciLS64i6pJ0wRYz3rkXLRwbtFa8Ng== ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) https-proxy-agent@^4.0.0: version "4.0.0" @@ -7303,14 +7193,6 @@ is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== -<<<<<<< HEAD -======= - -is-utf8@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" - integrity sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q== ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) is-unicode-supported@^0.1.0: version "0.1.0" @@ -7618,21 +7500,17 @@ jsprim@^1.2.2: json-schema "0.4.0" verror "1.10.0" -<<<<<<< HEAD -"jsx-ast-utils@^2.4.1 || ^3.0.0", jsx-ast-utils@^3.3.3: -======= -jsprim@^1.2.2: - version "1.4.2" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb" - integrity sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw== +jsprim@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-2.0.2.tgz#77ca23dbcd4135cd364800d22ff82c2185803d4d" + integrity sha512-gqXddjPqQ6G40VdnI6T6yObEC+pDNvyP95wdQhkWkg7crHH3km5qP1FsOXEkzEQwnz6gz5qGTn1c2Y52wP3OyQ== dependencies: assert-plus "1.0.0" extsprintf "1.3.0" json-schema "0.4.0" verror "1.10.0" -"jsx-ast-utils@^2.4.1 || ^3.0.0", jsx-ast-utils@^3.3.2: ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) +"jsx-ast-utils@^2.4.1 || ^3.0.0": version "3.3.3" resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz#76b3e6e6cece5c69d49a5792c3d01bd1a0cdc7ea" integrity sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw== @@ -7640,6 +7518,16 @@ jsprim@^1.2.2: array-includes "^3.1.5" object.assign "^4.1.3" +jsx-ast-utils@^3.3.3: + version "3.3.4" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.4.tgz#b896535fed5b867650acce5a9bd4135ffc7b3bf9" + integrity sha512-fX2TVdCViod6HwKEtSWGHs57oFhVfCMwieb9PuRDgjDPh5XeqJiHFFFJCHxU5cnTc3Bu/GRL+kPiFmw8XWOfKw== + dependencies: + array-includes "^3.1.6" + array.prototype.flat "^1.3.1" + object.assign "^4.1.4" + object.values "^1.1.6" + jwt-decode@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/jwt-decode/-/jwt-decode-3.1.2.tgz#3fb319f3675a2df0c2895c8f5e9fa4b67b04ed59" @@ -8391,16 +8279,7 @@ oauth-sign@~0.9.0: resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== -<<<<<<< HEAD object-assign@^4, object-assign@^4.1.1: -======= -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" - integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== - -object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.1: ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== @@ -9299,11 +9178,7 @@ proxy-from-env@^1.0.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== -<<<<<<< HEAD psl@^1.1.28: -======= -psl@^1.1.28, psl@^1.1.33: ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== @@ -9373,7 +9248,6 @@ qs@^6.10.0: dependencies: side-channel "^1.0.4" -<<<<<<< HEAD qs@~6.10.3: version "6.10.5" resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.5.tgz#974715920a80ff6a262264acd2c7e6c2a53282b4" @@ -9381,20 +9255,10 @@ qs@~6.10.3: dependencies: side-channel "^1.0.4" -======= ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) qs@~6.5.2: version "6.5.3" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== -<<<<<<< HEAD -======= - -querystringify@^2.1.1: - version "2.2.0" - resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6" - integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ== ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) queue-microtask@^1.2.2: version "1.2.3" @@ -9830,32 +9694,6 @@ request@^2.85.0: tunnel-agent "^0.6.0" uuid "^3.3.2" -request@^2.85.0: - version "2.88.2" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" - integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.3" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.5.0" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -10028,11 +9866,7 @@ safe-regex-test@^1.0.0: get-intrinsic "^1.1.3" is-regex "^1.1.4" -<<<<<<< HEAD "safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: -======= -"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== @@ -10353,7 +10187,7 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== -sshpk@^1.7.0: +sshpk@^1.14.1, sshpk@^1.7.0: version "1.17.0" resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.17.0.tgz#578082d92d4fe612b13007496e543fa0fbcbe4c5" integrity sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ== @@ -10368,23 +10202,7 @@ sshpk@^1.7.0: safer-buffer "^2.0.2" tweetnacl "~0.14.0" -<<<<<<< HEAD stackframe@^1.3.4: -======= -stack-utils@^2.0.3: - version "2.0.5" - resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.5.tgz#d25265fca995154659dbbfba3b49254778d2fdd5" - integrity sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA== - dependencies: - escape-string-regexp "^2.0.0" - -stackframe@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-0.3.1.tgz#33aa84f1177a5548c8935533cbfeb3420975f5a4" - integrity sha512-XmoiF4T5nuWEp2x2w92WdGjdHGY/cZa6LIbRsDRQR/Xlk4uW0PAUlH1zJYVffocwKpCdwyuypIp25xsSXEtZHw== - -stackframe@^1.1.1, stackframe@^1.3.4: ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "1.3.4" resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.3.4.tgz#b881a004c8c149a5e8efef37d51b16e412943310" integrity sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw== @@ -10979,43 +10797,10 @@ toidentifier@1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== -<<<<<<< HEAD -======= -tough-cookie@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.0.0.tgz#d822234eeca882f991f0f908824ad2622ddbece4" - integrity sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg== - dependencies: - psl "^1.1.33" - punycode "^2.1.1" - universalify "^0.1.2" - -tough-cookie@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.2.tgz#e53e84b85f24e0b65dd526f46628db6c85f6b874" - integrity sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ== - dependencies: - psl "^1.1.33" - punycode "^2.1.1" - universalify "^0.2.0" - url-parse "^1.5.3" - ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) tough-cookie@~2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== -<<<<<<< HEAD -======= - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - -tr46@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-3.0.0.tgz#555c4e297a950617e8eeddef633c87d4d9d6cbf9" - integrity sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA== ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) dependencies: psl "^1.1.28" punycode "^2.1.1" @@ -11104,11 +10889,7 @@ tsutils@^3.21.0: dependencies: tslib "^1.8.1" -<<<<<<< HEAD tunnel-agent@^0.6.0: -======= -tunnel-agent@0.6.0, tunnel-agent@^0.6.0: ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" integrity sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w== @@ -11201,11 +10982,6 @@ typical@^4.0.0: resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== -typical@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" - integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== - uglify-js@^3.1.4: version "3.17.4" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" @@ -11386,14 +11162,6 @@ uuid@^3.3.2: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== -<<<<<<< HEAD -======= - -uuid@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" - integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== ->>>>>>> 1449b1f ([C] Proxy for USDF CORS issue from local) uuid@^8.3.2: version "8.3.2" From 7f33e7d7c428d59f9fbbf075a1a4fed5e456a80d Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 6 Jun 2023 15:18:02 -0700 Subject: [PATCH 40/98] [C] Proxy for USDF CORS issue from local --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 199c39f8..6fbfab14 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11529,4 +11529,4 @@ yauzl@^2.10.0: yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" - integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== \ No newline at end of file From f9ac4ce895a8b09b153aa42b39f64afb6dd2dff0 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 26 Jun 2023 16:29:35 -0700 Subject: [PATCH 41/98] [F] daylight widget --- components/dynamic/SummitData/Astroweather/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index f4898cd4..0647019b 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -11,7 +11,6 @@ import CurrentAstroweather from "./Current"; import ForecastAstroweather from "./Forecast"; const Astroweather = () => { - const { t } = useTranslation(); const [isModalOpen, setModalOpen] = useState(false); const now = new Date(); From eba3b259d9dacf3600c7a0f46a682e54ee35ab9b Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 6 Jul 2023 16:45:10 -0700 Subject: [PATCH 42/98] [F] Moonrise widget --- components/atomic/DirectionalArrow/index.js | 26 +++++++ components/atomic/DirectionalArrow/styles.js | 13 ++++ .../SummitData/Astroweather/Current/index.js | 2 +- .../SummitData/Astroweather/Forecast/index.js | 38 ++++++--- .../dynamic/SummitData/Astroweather/index.js | 2 +- .../dynamic/SummitData/Weather/Daily/index.js | 2 +- components/layout/WidgetSection/styles.js | 6 +- .../DailyData/patterns/Moonrise/Time/index.js | 22 ++++++ .../patterns/Moonrise/Time/styles.js | 8 ++ .../DailyData/patterns/Moonrise/index.js | 78 +++++++++++++++++++ .../DailyData/patterns/Moonrise/styles.js | 29 +++++++ .../patterns/Temperature}/index.js | 16 +--- .../patterns/Temperature}/styles.js | 0 .../HourlyData/patterns/Windspeed/index.js | 10 +-- helpers/formatters.js | 18 +++++ helpers/index.js | 8 ++ lib/localeStrings/en.json | 5 ++ package.json | 2 +- yarn.lock | 8 +- 19 files changed, 252 insertions(+), 41 deletions(-) create mode 100644 components/atomic/DirectionalArrow/index.js create mode 100644 components/atomic/DirectionalArrow/styles.js create mode 100644 components/widgets/DailyData/patterns/Moonrise/Time/index.js create mode 100644 components/widgets/DailyData/patterns/Moonrise/Time/styles.js create mode 100644 components/widgets/DailyData/patterns/Moonrise/index.js create mode 100644 components/widgets/DailyData/patterns/Moonrise/styles.js rename components/widgets/{TemperatureHistoric => DailyData/patterns/Temperature}/index.js (85%) rename components/widgets/{TemperatureHistoric => DailyData/patterns/Temperature}/styles.js (100%) diff --git a/components/atomic/DirectionalArrow/index.js b/components/atomic/DirectionalArrow/index.js new file mode 100644 index 00000000..502f08fb --- /dev/null +++ b/components/atomic/DirectionalArrow/index.js @@ -0,0 +1,26 @@ +import PropTypes from "prop-types"; +import UniqueIconComposer from "@/components/svg/UniqueIconComposer"; +import { ScreenreaderText } from "@rubin-epo/epo-react-lib"; +import * as Styled from "./styles"; + +const DirectionalArrow = ({ angle, altText, className }) => { + return ( + + + {altText && {altText}} + + ); +}; + +DirectionalArrow.displayName = "Atomic.DirectionalArrow"; + +DirectionalArrow.propTypes = { + angle: PropTypes.number.isRequired, + altText: PropTypes.string, + className: PropTypes.string, +}; + +export default DirectionalArrow; diff --git a/components/atomic/DirectionalArrow/styles.js b/components/atomic/DirectionalArrow/styles.js new file mode 100644 index 00000000..b1533f37 --- /dev/null +++ b/components/atomic/DirectionalArrow/styles.js @@ -0,0 +1,13 @@ +import styled from "styled-components"; + +export const Container = styled.div` + background-color: var(--black, #000); + border-radius: 50%; + color: #30e0e3; + display: flex; + justify-content: center; + align-items: center; + transform: rotate(var(--angle, 0deg)); + aspect-ratio: 1; + width: 22px; +`; diff --git a/components/dynamic/SummitData/Astroweather/Current/index.js b/components/dynamic/SummitData/Astroweather/Current/index.js index 7378f056..91197cb0 100644 --- a/components/dynamic/SummitData/Astroweather/Current/index.js +++ b/components/dynamic/SummitData/Astroweather/Current/index.js @@ -1,5 +1,5 @@ import { useState } from "react"; -import SunCalc from "suncalc"; +import SunCalc from "suncalc-tz"; import { useTranslation } from "react-i18next"; import { altitude, lat, long, timezone } from "@/lib/observatory"; import { timezoneOffset } from "@/helpers"; diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js index ada8e411..ae22336b 100644 --- a/components/dynamic/SummitData/Astroweather/Forecast/index.js +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -1,11 +1,12 @@ import { useState } from "react"; -import SunCalc from "suncalc"; +import SunCalc from "suncalc-tz"; import { useTranslation } from "react-i18next"; -import { lat, long, timezone } from "@/lib/observatory"; -import { timezoneOffset } from "@/helpers"; +import { lat, long } from "@/lib/observatory"; import WidgetSection from "@/components/layout/WidgetSection"; import MoonRise from "@/components/widgets/CurrentData/patterns/MoonRise"; import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; +import DailyMoonrise from "@/components/widgets/DailyData/patterns/Moonrise"; +import { SectionSubHeader } from "@/components/layout/WidgetSection/styles"; const ForecastAstroweather = () => { const { t } = useTranslation(); @@ -16,22 +17,37 @@ const ForecastAstroweather = () => { isOpen, }; + const moonriseId = "moonriseTitle"; const now = new Date(); - const offset = timezoneOffset(timezone); - const observatoryDate = new Date( - now.toLocaleString("en-US", { timeZone: timezone }) - ); + const { phase } = SunCalc.getMoonIllumination(now); - observatoryDate.setUTCHours(12 - offset, 0, 0, 0); + const conversion = 180 / Math.PI; + const getAzimuth = (time) => + SunCalc.getMoonPosition(time, lat, long).azimuth * conversion + 180; - const { phase } = SunCalc.getMoonIllumination(now); - const { rise, set } = SunCalc.getMoonTimes(observatoryDate, lat, long, true); + const forecast = Array.apply(null, Array(14)).map((value, i) => { + const day = new Date(); + day.setDate(now.getDate() + i); + const { rise, set } = SunCalc.getMoonTimes(day, lat, long); + + return { + day: day.getDay(), + rise, + set, + azimuthRise: rise ? getAzimuth(rise) : null, + azimuthSet: set ? getAzimuth(set) : null, + }; + }); return ( - + + + {t("summit_dashboard.sections.astro.moonrise.forecast")} + + ); }; diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index 0647019b..ddca0d00 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -1,5 +1,5 @@ import { useState } from "react"; -import SunCalc from "suncalc"; +import SunCalc from "suncalc-tz"; import { useTranslation } from "react-i18next"; import WidgetPreview from "@/components/layout/WidgetPreview"; import SummitStatusModal from "@/components/modal/SummitStatusModal"; diff --git a/components/dynamic/SummitData/Weather/Daily/index.js b/components/dynamic/SummitData/Weather/Daily/index.js index b50db36b..0031e792 100644 --- a/components/dynamic/SummitData/Weather/Daily/index.js +++ b/components/dynamic/SummitData/Weather/Daily/index.js @@ -4,7 +4,7 @@ import { useWeatherUnit } from "@/contexts/WeatherUnit"; import { useSummitData } from "@/contexts/SummitData"; import Loader from "@/components/atomic/Loader"; import WidgetSection from "@/components/layout/WidgetSection"; -import TemperatureHistoric from "@/components/widgets/TemperatureHistoric"; +import TemperatureHistoric from "@/components/widgets/DailyData/patterns/Temperature"; import { convertTemperature } from "@/helpers/converters"; const DailyWeather = () => { diff --git a/components/layout/WidgetSection/styles.js b/components/layout/WidgetSection/styles.js index 57872766..aff836fe 100644 --- a/components/layout/WidgetSection/styles.js +++ b/components/layout/WidgetSection/styles.js @@ -50,7 +50,7 @@ export const SectionContent = styled.div` grid-gap: var(--PADDING_SMALL, 20px); grid-template-columns: var(--grid-columns); - grid-auto-rows: 10rem; + grid-auto-rows: fit-content(10rem); margin-block-start: var(--PADDING_SMALL, 20px); &:not([hidden]) { @@ -61,3 +61,7 @@ export const SectionContent = styled.div` --grid-columns: repeat(4, 1fr); } `; + +export const SectionSubHeader = styled.h3` + grid-column: 1/-1; +`; diff --git a/components/widgets/DailyData/patterns/Moonrise/Time/index.js b/components/widgets/DailyData/patterns/Moonrise/Time/index.js new file mode 100644 index 00000000..5b4490da --- /dev/null +++ b/components/widgets/DailyData/patterns/Moonrise/Time/index.js @@ -0,0 +1,22 @@ +import PropTypes from "prop-types"; +import { formatAngle, formatTime } from "@/helpers/formatters"; +import DirectionalArrow from "@/components/atomic/DirectionalArrow"; +import * as Styled from "./styles"; + +const MoonTime = ({ time, azimuth }) => { + return ( + + + ({formatAngle(azimuth)}) + + ); +}; + +MoonTime.displayName = "Widgets.Daily.MoonTime"; + +MoonTime.propTypes = { + time: PropTypes.instanceOf(Date), + azimuth: PropTypes.number, +}; + +export default MoonTime; diff --git a/components/widgets/DailyData/patterns/Moonrise/Time/styles.js b/components/widgets/DailyData/patterns/Moonrise/Time/styles.js new file mode 100644 index 00000000..96f54520 --- /dev/null +++ b/components/widgets/DailyData/patterns/Moonrise/Time/styles.js @@ -0,0 +1,8 @@ +import styled from "styled-components"; + +export const Container = styled.div` + display: flex; + justify-content: center; + align-items: center; + gap: 1ch; +`; diff --git a/components/widgets/DailyData/patterns/Moonrise/index.js b/components/widgets/DailyData/patterns/Moonrise/index.js new file mode 100644 index 00000000..4e656596 --- /dev/null +++ b/components/widgets/DailyData/patterns/Moonrise/index.js @@ -0,0 +1,78 @@ +import PropTypes from "prop-types"; +import { useTranslation } from "react-i18next"; +import { formatDayName } from "@/helpers/formatters"; +import * as Styled from "./styles"; +import MoonTime from "./Time"; + +const DailyMoonrise = ({ data, labelledById }) => { + const { + t, + i18n: { language = "en" }, + } = useTranslation(); + + return ( + + + + + {t("summit_dashboard.astro.daylight.day")} + + + {t("summit_dashboard.astro.moonlight.moonrise")} + + + {t("summit_dashboard.astro.moonlight.moonset")} + + + {t("summit_dashboard.astro.moonlight.moonrise")} + + + + + {data.map(({ day, rise, set, azimuthRise, azimuthSet }) => { + return ( + + + {formatDayName(day, language)} + + + {rise && rise < set ? ( + + ) : ( + "—" + )} + + + {set && } + + + {rise && rise > set ? ( + + ) : ( + "—" + )} + + + ); + })} + + + ); +}; + +DailyMoonrise.propTypes = { + data: PropTypes.arrayOf( + PropTypes.shape({ + day: PropTypes.number, + rise: PropTypes.instanceOf(Date), + set: PropTypes.instanceOf(Date), + azimuthRise: PropTypes.number, + azimuthSet: PropTypes.number, + }) + ).isRequired, + labelledById: PropTypes.string, +}; + +DailyMoonrise.displayName = "Widgets.Daily.Moonrise"; + +export default DailyMoonrise; diff --git a/components/widgets/DailyData/patterns/Moonrise/styles.js b/components/widgets/DailyData/patterns/Moonrise/styles.js new file mode 100644 index 00000000..b0623e52 --- /dev/null +++ b/components/widgets/DailyData/patterns/Moonrise/styles.js @@ -0,0 +1,29 @@ +import styled from "styled-components"; + +export const Table = styled.table` + grid-column: 1/-1; + border-collapse: collapse; + font-size: 0.75rem; +`; +export const Header = styled.thead``; +export const HeaderCell = styled.th` + background-color: #313333; + border-spacing: 0; + border: 5px solid var(--black, #000); + font-weight: normal; + height: 40px; + padding: 0; + + &[scope="row"] { + font-size: 0.75em; + } +`; +export const TableCell = styled.td` + background-color: #313333; + border-spacing: 0; + border: 5px solid var(--black, #000); + font-size: 0.75em; + height: 40px; + padding: 0; + text-align: center; +`; diff --git a/components/widgets/TemperatureHistoric/index.js b/components/widgets/DailyData/patterns/Temperature/index.js similarity index 85% rename from components/widgets/TemperatureHistoric/index.js rename to components/widgets/DailyData/patterns/Temperature/index.js index 1a1cc319..b195f3c5 100644 --- a/components/widgets/TemperatureHistoric/index.js +++ b/components/widgets/DailyData/patterns/Temperature/index.js @@ -2,7 +2,7 @@ import { useTranslation } from "react-i18next"; import PropTypes from "prop-types"; import ScrollableHorizontalWrapper from "@/components/atomic/ScrollableHorizontalWrapper"; import { temperatureUnitType } from "@/components/shapes/units"; -import { formatTemperature } from "@/helpers/formatters"; +import { formatDayName, formatTemperature } from "@/helpers/formatters"; import * as Styled from "./styles"; const TemperatureHistoric = ({ @@ -15,16 +15,6 @@ const TemperatureHistoric = ({ i18n: { language = "en" }, } = useTranslation(); - const getDayName = (day) => { - const today = new Date(); - const result = new Date(today); - const diff = day - today.getDay(); - - result.setDate(today.getDate() + diff); - - return result.toLocaleDateString(language, { weekday: "long" }); - }; - return ( @@ -35,7 +25,7 @@ const TemperatureHistoric = ({ {temperatureData.map(({ weekday }, i) => ( - {getDayName(weekday)} + {formatDayName(weekday, language)} ))} @@ -77,7 +67,7 @@ const TemperatureHistoric = ({ ); }; -TemperatureHistoric.displayName = "Widgets.TemperatureHistoric"; +TemperatureHistoric.displayName = "Widgets.Daily.Temperature"; TemperatureHistoric.propTypes = { unit: temperatureUnitType, diff --git a/components/widgets/TemperatureHistoric/styles.js b/components/widgets/DailyData/patterns/Temperature/styles.js similarity index 100% rename from components/widgets/TemperatureHistoric/styles.js rename to components/widgets/DailyData/patterns/Temperature/styles.js diff --git a/components/widgets/HourlyData/patterns/Windspeed/index.js b/components/widgets/HourlyData/patterns/Windspeed/index.js index bed898fa..01341ef5 100644 --- a/components/widgets/HourlyData/patterns/Windspeed/index.js +++ b/components/widgets/HourlyData/patterns/Windspeed/index.js @@ -2,7 +2,7 @@ import { useEffect, useRef } from "react"; import PropTypes from "prop-types"; import { windspeedUnitType } from "@/components/shapes/units"; import { useTranslation } from "react-i18next"; -import { formatTime } from "@/helpers/formatters"; +import { formatAngle, formatTime } from "@/helpers/formatters"; import * as Styled from "./styles"; import UniqueIconComposer from "@/components/svg/UniqueIconComposer"; import { ScreenreaderText } from "@rubin-epo/epo-react-lib"; @@ -14,12 +14,6 @@ const Windspeed = ({ unit, windspeedData = [], labelledById }) => { i18n: { language = "en" }, } = useTranslation(); - const directionFormatter = new Intl.NumberFormat(language, { - notation: "compact", - style: "unit", - unit: "degree", - }); - const speedFormatters = { mi: new Intl.NumberFormat(language, { style: "unit", @@ -84,7 +78,7 @@ const Windspeed = ({ unit, windspeedData = [], labelledById }) => { {t("summit_dashboard.weather.windspeed_direction", { - direction: directionFormatter.format(direction), + direction: formatAngle(direction, language), })} diff --git a/helpers/formatters.js b/helpers/formatters.js index 159d0b1e..0e8b9e2d 100644 --- a/helpers/formatters.js +++ b/helpers/formatters.js @@ -40,3 +40,21 @@ export const formatTime = (value, locale = "en", options = {}) => { ...options, }).format(value); }; + +export const formatDayName = (day = 0, locale = "en") => { + const today = new Date(); + const result = new Date(today); + const diff = day - today.getDay(); + + result.setDate(today.getDate() + diff); + + return result.toLocaleDateString(locale, { weekday: "long" }); +}; + +export const formatAngle = (angle = 0, locale = "en") => + new Intl.NumberFormat(locale, { + notation: "compact", + style: "unit", + unit: "degree", + unitDisplay: "narrow", + }).format(angle); diff --git a/helpers/index.js b/helpers/index.js index c48526da..6ecb85d9 100644 --- a/helpers/index.js +++ b/helpers/index.js @@ -46,3 +46,11 @@ export const timezoneOffset = (timezone) => { return 24 - localeDate.getHours(); }; + +export const timezoneOffsetLocal = (timezone) => { + const now = new Date(); + const localOffset = now.getTimezoneOffset() / 60; + const offset = timezoneOffset(timezone); + + return localOffset - offset; +}; diff --git a/lib/localeStrings/en.json b/lib/localeStrings/en.json index 66e09db6..b048c9f1 100644 --- a/lib/localeStrings/en.json +++ b/lib/localeStrings/en.json @@ -366,6 +366,7 @@ "current_observable": "Current local time {{time}}. It is dark enough to observe right now." }, "moonrise": { + "forecast": "Moonrise and moonset times forecast (next fourteen days)", "time_moonrise": "Moonrise time", "time_moonset": "Moonset time" } @@ -393,6 +394,10 @@ "gibbous_waning": "Waning Gibbous", "quarter_first": "First Quarter", "quarter_last": "Last Quarter" + }, + "moonlight": { + "moonrise": "Moonrise", + "moonset": "Moonset" } }, "widgets": { diff --git a/package.json b/package.json index 407a1683..1f5e716b 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "react-uid": "^2.3.2", "striptags": "^3.2.0", "styled-components": "5.3.11", - "suncalc": "^1.9.0", + "suncalc-tz": "^1.9.1", "swr": "^1.3.0", "use-resize-observer": "^9.0.2" }, diff --git a/yarn.lock b/yarn.lock index 6fbfab14..cdabdb9f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10551,10 +10551,10 @@ stylelint@^15.6.1: table "^6.8.1" write-file-atomic "^5.0.1" -suncalc@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/suncalc/-/suncalc-1.9.0.tgz#26212353fae61edb287c2d558fc4932ecf0e1532" - integrity sha512-vMJ8Byp1uIPoj+wb9c1AdK4jpkSKVAywgHX0lqY7zt6+EWRRC3Z+0Ucfjy/0yxTVO1hwwchZe4uoFNqrIC24+A== +suncalc-tz@^1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/suncalc-tz/-/suncalc-tz-1.9.1.tgz#c5d616c2e79cd684f3e7281a63a895cb39c7a922" + integrity sha512-4tL0XM54iE237XOM2ywgvlGQykDPOwWYcno+w9RIY3M7LGiaSxQwqkOGtYYMDvu/kRDf0tm/nTzjs0mlF0iNMQ== supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" From 5c779be0236e49168e31c53c0ef08022c6bb0d79 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 17 Jul 2023 15:37:29 -0700 Subject: [PATCH 43/98] [C] pull in suncalc --- components/charts/ChartFigure/styles.js | 4 +- .../SummitData/Astroweather/Current/index.js | 4 +- .../SummitData/Astroweather/Forecast/index.js | 22 +- .../dynamic/SummitData/Astroweather/index.js | 7 +- .../DailyData/patterns/Moonrise/index.js | 4 +- contexts/SummitData.js | 6 +- lib/suncalc.js | 353 ++++++++++++++++++ package.json | 2 +- yarn.lock | 12 +- 9 files changed, 386 insertions(+), 28 deletions(-) create mode 100644 lib/suncalc.js diff --git a/components/charts/ChartFigure/styles.js b/components/charts/ChartFigure/styles.js index 351f7d6f..f2f28287 100644 --- a/components/charts/ChartFigure/styles.js +++ b/components/charts/ChartFigure/styles.js @@ -1,17 +1,15 @@ import styled from "styled-components"; -import WidgetBackground from "@/components/atomic/WidgetBackground"; export const Caption = styled.figcaption` text-align: center; `; export const Content = styled.div` + position: relative; display: flex; justify-content: center; width: 100%; overflow-x: auto; overflow-y: hidden; - position: relative; - overflow-x: auto; scrollbar-color: var(--white, #fff) rgba(255, 255, 255, 20%); scrollbar-width: thin; diff --git a/components/dynamic/SummitData/Astroweather/Current/index.js b/components/dynamic/SummitData/Astroweather/Current/index.js index 91197cb0..fe85739c 100644 --- a/components/dynamic/SummitData/Astroweather/Current/index.js +++ b/components/dynamic/SummitData/Astroweather/Current/index.js @@ -1,6 +1,6 @@ import { useState } from "react"; -import SunCalc from "suncalc-tz"; import { useTranslation } from "react-i18next"; +import { getTimes } from "@/lib/suncalc"; import { altitude, lat, long, timezone } from "@/lib/observatory"; import { timezoneOffset } from "@/helpers"; import WidgetSection from "@/components/layout/WidgetSection"; @@ -24,7 +24,7 @@ const CurrentAstroweather = () => { observatoryDate.setUTCHours(12 - offset, 0, 0, 0); - const { nightEnd, sunrise, sunset, night } = SunCalc.getTimes( + const { nightEnd, sunrise, sunset, night } = getTimes( observatoryDate, lat, long, diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js index ae22336b..694887e0 100644 --- a/components/dynamic/SummitData/Astroweather/Forecast/index.js +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -1,12 +1,17 @@ import { useState } from "react"; -import SunCalc from "suncalc-tz"; import { useTranslation } from "react-i18next"; -import { lat, long } from "@/lib/observatory"; +import { + getMoonIllumination, + getMoonPosition, + getMoonTimes, +} from "@/lib/suncalc"; +import { lat, long, timezone } from "@/lib/observatory"; import WidgetSection from "@/components/layout/WidgetSection"; import MoonRise from "@/components/widgets/CurrentData/patterns/MoonRise"; import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; import DailyMoonrise from "@/components/widgets/DailyData/patterns/Moonrise"; import { SectionSubHeader } from "@/components/layout/WidgetSection/styles"; +import { timezoneOffset } from "@/helpers"; const ForecastAstroweather = () => { const { t } = useTranslation(); @@ -20,16 +25,18 @@ const ForecastAstroweather = () => { const moonriseId = "moonriseTitle"; const now = new Date(); - const { phase } = SunCalc.getMoonIllumination(now); + const { phase } = getMoonIllumination(now); const conversion = 180 / Math.PI; const getAzimuth = (time) => - SunCalc.getMoonPosition(time, lat, long).azimuth * conversion + 180; + getMoonPosition(time, lat, long).azimuth * conversion + 180; + const offset = timezoneOffset(timezone); const forecast = Array.apply(null, Array(14)).map((value, i) => { const day = new Date(); day.setDate(now.getDate() + i); - const { rise, set } = SunCalc.getMoonTimes(day, lat, long); + day.setUTCHours(offset, 0, 0, 0); + const { rise, set } = getMoonTimes(day.toUTCString(), lat, long); return { day: day.getDay(), @@ -43,7 +50,10 @@ const ForecastAstroweather = () => { return ( - + {t("summit_dashboard.sections.astro.moonrise.forecast")} diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index ddca0d00..cf8eea23 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -1,6 +1,6 @@ import { useState } from "react"; -import SunCalc from "suncalc-tz"; import { useTranslation } from "react-i18next"; +import { getMoonIllumination, getTimes } from "@/lib/suncalc"; import WidgetPreview from "@/components/layout/WidgetPreview"; import SummitStatusModal from "@/components/modal/SummitStatusModal"; import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; @@ -11,12 +11,13 @@ import CurrentAstroweather from "./Current"; import ForecastAstroweather from "./Forecast"; const Astroweather = () => { + const { t } = useTranslation(); const [isModalOpen, setModalOpen] = useState(false); const now = new Date(); const offset = timezoneOffset(timezone); - const { phase } = SunCalc.getMoonIllumination(now); + const { phase } = getMoonIllumination(now); const observatoryDate = new Date( now.toLocaleString("en-US", { timeZone: timezone }) @@ -24,7 +25,7 @@ const Astroweather = () => { observatoryDate.setUTCHours(12 - offset, 0, 0, 0); - const { nightEnd, sunrise, sunset, night } = SunCalc.getTimes( + const { nightEnd, sunrise, sunset, night } = getTimes( observatoryDate, lat, long, diff --git a/components/widgets/DailyData/patterns/Moonrise/index.js b/components/widgets/DailyData/patterns/Moonrise/index.js index 4e656596..e5b5bac3 100644 --- a/components/widgets/DailyData/patterns/Moonrise/index.js +++ b/components/widgets/DailyData/patterns/Moonrise/index.js @@ -36,14 +36,14 @@ const DailyMoonrise = ({ data, labelledById }) => { {formatDayName(day, language)} - {rise && rise < set ? ( + {rise && (rise < set || !set) ? ( ) : ( "—" )} - {set && } + {set ? : "—"} {rise && rise > set ? ( diff --git a/contexts/SummitData.js b/contexts/SummitData.js index 890e7fae..461889b4 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -1,8 +1,4 @@ -import { - createContext, - useContext, - useMemo, -} from "react"; +import { createContext, useContext, useMemo } from "react"; import PropTypes from "prop-types"; import useEfd from "@/lib/api/efd"; diff --git a/lib/suncalc.js b/lib/suncalc.js new file mode 100644 index 00000000..fc97987e --- /dev/null +++ b/lib/suncalc.js @@ -0,0 +1,353 @@ +import tzlookup from "tz-lookup"; + +/* + (c) 2011-2015, Vladimir Agafonkin + SunCalc is a JavaScript library for calculating sun/moon position and light phases. + https://github.com/mourner/suncalc +*/ + +// shortcuts for easier to read formulas + +const PI = Math.PI; +const sin = Math.sin; +const cos = Math.cos; +const tan = Math.tan; +const asin = Math.asin; +const atan = Math.atan2; +const acos = Math.acos; +const rad = PI / 180; + +// sun calculations are based on http://aa.quae.nl/en/reken/zonpositie.html formulas + +// date/time constants and conversions + +const dayMs = 1000 * 60 * 60 * 24; +const J1970 = 2440588; +const J2000 = 2451545; + +function toJulian(date) { + return date.valueOf() / dayMs - 0.5 + J1970; +} +function fromJulian(j) { + return new Date((j + 0.5 - J1970) * dayMs); +} +function toDays(date) { + return toJulian(date) - J2000; +} + +// general calculations for position + +const e = rad * 23.4397; // obliquity of the Earth + +function rightAscension(l, b) { + return atan(sin(l) * cos(e) - tan(b) * sin(e), cos(l)); +} +function declination(l, b) { + return asin(sin(b) * cos(e) + cos(b) * sin(e) * sin(l)); +} + +function azimuth(H, phi, dec) { + return atan(sin(H), cos(H) * sin(phi) - tan(dec) * cos(phi)); +} +function altitude(H, phi, dec) { + return asin(sin(phi) * sin(dec) + cos(phi) * cos(dec) * cos(H)); +} + +function siderealTime(d, lw) { + return rad * (280.16 + 360.9856235 * d) - lw; +} + +function astroRefraction(h) { + if (h < 0) + // the following formula works for positive altitudes only. + h = 0; // if h = -0.08901179 a div/0 would occur. + + // formula 16.4 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998. + // 1.02 / tan(h + 10.26 / (h + 5.10)) h in degrees, result in arc minutes -> converted to rad: + return 0.0002967 / Math.tan(h + 0.00312536 / (h + 0.08901179)); +} + +// general sun calculations + +function solarMeanAnomaly(d) { + return rad * (357.5291 + 0.98560028 * d); +} + +function eclipticLongitude(M) { + const C = rad * (1.9148 * sin(M) + 0.02 * sin(2 * M) + 0.0003 * sin(3 * M)); // equation of center + const P = rad * 102.9372; // perihelion of the Earth + + return M + C + P + PI; +} + +function sunCoords(d) { + const M = solarMeanAnomaly(d); + const L = eclipticLongitude(M); + + return { + dec: declination(L, 0), + ra: rightAscension(L, 0), + }; +} + +// calculates sun position for a given date and latitude/longitude + +export const getPosition = (date, lat, lng) => { + const lw = rad * -lng; + const phi = rad * lat; + const d = toDays(date); + const c = sunCoords(d); + const H = siderealTime(d, lw) - c.ra; + + return { + azimuth: azimuth(H, phi, c.dec), + altitude: altitude(H, phi, c.dec), + }; +}; + +// sun times configuration (angle, morning name, evening name) + +const times = [ + [-0.833, "sunrise", "sunset"], + [-0.3, "sunriseEnd", "sunsetStart"], + [-6, "dawn", "dusk"], + [-12, "nauticalDawn", "nauticalDusk"], + [-18, "nightEnd", "night"], + [6, "goldenHourEnd", "goldenHour"], +]; + +// adds a custom time to the times config + +export function addTime(angle, riseName, setName) { + times.push([angle, riseName, setName]); +} + +// calculations for sun times + +const J0 = 0.0009; + +function julianCycle(d, lw) { + return Math.round(d - J0 - lw / (2 * PI)); +} + +function approxTransit(Ht, lw, n) { + return J0 + (Ht + lw) / (2 * PI) + n; +} +function solarTransitJ(ds, M, L) { + return J2000 + ds + 0.0053 * sin(M) - 0.0069 * sin(2 * L); +} + +function hourAngle(h, phi, d) { + return acos((sin(h) - sin(phi) * sin(d)) / (cos(phi) * cos(d))); +} +function observerAngle(height) { + return (-2.076 * Math.sqrt(height)) / 60; +} + +// returns set time for the given sun altitude +function getSetJ(h, lw, phi, dec, n, M, L) { + const w = hourAngle(h, phi, dec); + const a = approxTransit(w, lw, n); + return solarTransitJ(a, M, L); +} + +// calculates sun times for a given date, latitude/longitude, and, optionally, +// the observer height (in meters) relative to the horizon + +export function getTimes(date, lat, lng, height) { + const tz = tzlookup(lat, lng); + + // console.log('before date:', date); + // var newDate = date.toLocaleString('en-GB', {timezone: tz}); + // const destOptions = {timeZone: tz, year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric'}; + // var newDate = /*new Date(Date.parse(*/new Intl.DateTimeFormat('default', destOptions).format(date); // )); + // console.log('after date:', newDate); + + height = height || 0; + + const lw = rad * -lng; + const phi = rad * lat; + const dh = observerAngle(height); + const d = toDays(date); + const n = julianCycle(d, lw); + const ds = approxTransit(0, lw, n); + const M = solarMeanAnomaly(ds); + const L = eclipticLongitude(M); + const dec = declination(L, 0); + const Jnoon = solarTransitJ(ds, M, L); + let i; + let len; + let time; + let h0; + let Jset; + let Jrise; + + const result = { + solarNoon: fromJulian(Jnoon), + nadir: fromJulian(Jnoon - 0.5), + }; + + for (i = 0, len = times.length; i < len; i += 1) { + time = times[i]; + h0 = (time[0] + dh) * rad; + + Jset = getSetJ(h0, lw, phi, dec, n, M, L); + Jrise = Jnoon - (Jset - Jnoon); + + result[time[1]] = fromJulian(Jrise); + result[time[2]] = fromJulian(Jset); + } + + // Convert dates to the time at lat/lng + for (const time in result) { + const options = { + timeZone: tz, + year: "numeric", + month: "numeric", + day: "numeric", + hour: "numeric", + minute: "numeric", + second: "numeric", + }; + result[time] = new Date( + Date.parse( + new Intl.DateTimeFormat("default", options).format(result[time]) + ) + ); + } + + return result; +} + +// moon calculations, based on http://aa.quae.nl/en/reken/hemelpositie.html formulas + +function moonCoords(d) { + // geocentric ecliptic coordinates of the moon + + const L = rad * (218.316 + 13.176396 * d); // ecliptic longitude + const M = rad * (134.963 + 13.064993 * d); // mean anomaly + const F = rad * (93.272 + 13.22935 * d); // mean distance + const l = L + rad * 6.289 * sin(M); // longitude + const b = rad * 5.128 * sin(F); // latitude + const dt = 385001 - 20905 * cos(M); // distance to the moon in km + + return { + ra: rightAscension(l, b), + dec: declination(l, b), + dist: dt, + }; +} +export function getMoonPosition(date, lat, lng) { + const lw = rad * -lng; + const phi = rad * lat; + const d = toDays(date); + const c = moonCoords(d); + const H = siderealTime(d, lw) - c.ra; + let h = altitude(H, phi, c.dec); + // formula 14.1 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998. + const pa = atan(sin(H), tan(phi) * cos(c.dec) - sin(c.dec) * cos(H)); + + h = h + astroRefraction(h); // altitude correction for refraction + + return { + azimuth: azimuth(H, phi, c.dec), + altitude: h, + distance: c.dist, + parallacticAngle: pa, + }; +} + +// calculations for illumination parameters of the moon, +// based on http://idlastro.gsfc.nasa.gov/ftp/pro/astro/mphase.pro formulas and +// Chapter 48 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998. + +export function getMoonIllumination(date) { + const d = toDays(date || new Date()(Date.now())); + const s = sunCoords(d); + const m = moonCoords(d); + const sdist = 149598000; // distance from Earth to Sun in km + const phi = acos( + sin(s.dec) * sin(m.dec) + cos(s.dec) * cos(m.dec) * cos(s.ra - m.ra) + ); + const inc = atan(sdist * sin(phi), m.dist - sdist * cos(phi)); + const angle = atan( + cos(s.dec) * sin(s.ra - m.ra), + sin(s.dec) * cos(m.dec) - cos(s.dec) * sin(m.dec) * cos(s.ra - m.ra) + ); + + return { + fraction: (1 + cos(inc)) / 2, + phase: 0.5 + (0.5 * inc * (angle < 0 ? -1 : 1)) / Math.PI, + angle, + }; +} + +function hoursLater(date, h) { + return new Date(date.valueOf() + (h * dayMs) / 24); +} + +// calculations for moon rise/set times are based on http://www.stargazing.net/kepler/moonrise.html article + +export function getMoonTimes(date, lat, lng, inUTC) { + const t = new Date(date); + if (inUTC) t.setUTCHours(0, 0, 0, 0); + + const hc = 0.133 * rad; + let h0 = getMoonPosition(t, lat, lng).altitude - hc; + let h1; + let h2; + let rise; + let set; + let a; + let b; + let xe; + let ye; + let d; + let roots; + let x1; + let x2; + let dx; + + // go in 2-hour chunks, each time seeing if a 3-point quadratic curve crosses zero (which means rise or set) + for (let i = 1; i <= 24; i += 2) { + h1 = getMoonPosition(hoursLater(t, i), lat, lng).altitude - hc; + h2 = getMoonPosition(hoursLater(t, i + 1), lat, lng).altitude - hc; + + a = (h0 + h2) / 2 - h1; + b = (h2 - h0) / 2; + xe = -b / (2 * a); + ye = (a * xe + b) * xe + h1; + d = b * b - 4 * a * h1; + roots = 0; + + if (d >= 0) { + dx = Math.sqrt(d) / (Math.abs(a) * 2); + x1 = xe - dx; + x2 = xe + dx; + if (Math.abs(x1) <= 1) roots++; + if (Math.abs(x2) <= 1) roots++; + if (x1 < -1) x1 = x2; + } + + if (roots === 1) { + if (h0 < 0) rise = i + x1; + else set = i + x1; + } else if (roots === 2) { + rise = i + (ye < 0 ? x2 : x1); + set = i + (ye < 0 ? x1 : x2); + } + + if (rise && set) break; + + h0 = h2; + } + + const result = {}; + + if (rise) result.rise = hoursLater(t, rise); + if (set) result.set = hoursLater(t, set); + + if (!rise && !set) result[ye > 0 ? "alwaysUp" : "alwaysDown"] = true; + + return result; +} diff --git a/package.json b/package.json index 1f5e716b..8f76feb6 100644 --- a/package.json +++ b/package.json @@ -87,8 +87,8 @@ "react-uid": "^2.3.2", "striptags": "^3.2.0", "styled-components": "5.3.11", - "suncalc-tz": "^1.9.1", "swr": "^1.3.0", + "tz-lookup": "^6.1.25", "use-resize-observer": "^9.0.2" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index cdabdb9f..6553cf5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10551,11 +10551,6 @@ stylelint@^15.6.1: table "^6.8.1" write-file-atomic "^5.0.1" -suncalc-tz@^1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/suncalc-tz/-/suncalc-tz-1.9.1.tgz#c5d616c2e79cd684f3e7281a63a895cb39c7a922" - integrity sha512-4tL0XM54iE237XOM2ywgvlGQykDPOwWYcno+w9RIY3M7LGiaSxQwqkOGtYYMDvu/kRDf0tm/nTzjs0mlF0iNMQ== - supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -10982,6 +10977,11 @@ typical@^4.0.0: resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== +tz-lookup@^6.1.25: + version "6.1.25" + resolved "https://registry.yarnpkg.com/tz-lookup/-/tz-lookup-6.1.25.tgz#34d68a7e1ccfcb51f29a9893d2d48e4118d873cd" + integrity sha512-fFewT9o1uDzsW1QnUU1ValqaihFnwiUiiHr1S79/fxOzKXYYvX+EHeRnpvQJ9B3Qg67wPXT6QF2Esc4pFOrvLg== + uglify-js@^3.1.4: version "3.17.4" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" @@ -11529,4 +11529,4 @@ yauzl@^2.10.0: yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" - integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== \ No newline at end of file + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== From 4909803f68d573c490fedd73cd27f947e7835f19 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 17 Jul 2023 15:52:31 -0700 Subject: [PATCH 44/98] [C] move timezone offset inside of lib --- components/atomic/DirectionalArrow/styles.js | 12 ++++++------ components/atomic/Loader/styles.js | 2 +- components/atomic/WidgetBackground/styles.js | 6 +++--- components/charts/ChartBase/styles.js | 4 ++-- .../SummitData/Astroweather/Forecast/index.js | 5 +---- components/layout/WidgetPreview/styles.js | 3 +-- components/layout/WidgetSection/styles.js | 2 +- components/modal/SummitStatusModal/styles.js | 8 ++++---- .../CurrentData/patterns/MoonRise/styles.js | 4 ++-- .../DailyData/patterns/Moonrise/Time/styles.js | 4 ++-- .../DailyData/patterns/Moonrise/styles.js | 18 +++++++++--------- components/widgets/HourlyData/styles.js | 2 +- helpers/index.js | 2 +- lib/suncalc.js | 9 +++++++-- 14 files changed, 41 insertions(+), 40 deletions(-) diff --git a/components/atomic/DirectionalArrow/styles.js b/components/atomic/DirectionalArrow/styles.js index b1533f37..a4fd9be8 100644 --- a/components/atomic/DirectionalArrow/styles.js +++ b/components/atomic/DirectionalArrow/styles.js @@ -1,13 +1,13 @@ import styled from "styled-components"; export const Container = styled.div` - background-color: var(--black, #000); - border-radius: 50%; - color: #30e0e3; display: flex; - justify-content: center; align-items: center; - transform: rotate(var(--angle, 0deg)); - aspect-ratio: 1; + justify-content: center; width: 22px; + aspect-ratio: 1; + color: #30e0e3; + background-color: var(--black, #000); + border-radius: 50%; + transform: rotate(var(--angle, 0deg)); `; diff --git a/components/atomic/Loader/styles.js b/components/atomic/Loader/styles.js index da8dd54a..9bdf4625 100644 --- a/components/atomic/Loader/styles.js +++ b/components/atomic/Loader/styles.js @@ -3,7 +3,7 @@ import { CircularLoader } from "@rubin-epo/epo-react-lib"; export const Loader = styled(CircularLoader)` display: flex; + grid-column: 1/-1; align-items: center; justify-content: center; - grid-column: 1/-1; `; diff --git a/components/atomic/WidgetBackground/styles.js b/components/atomic/WidgetBackground/styles.js index 11862c16..3c9ee5a2 100644 --- a/components/atomic/WidgetBackground/styles.js +++ b/components/atomic/WidgetBackground/styles.js @@ -11,12 +11,12 @@ export const WidgetBackground = styled.div` variants[$variant]}; --widget-padding: ${fluidScale("20px", "10px")}; - background-color: var(--widget-background-color); - border-radius: calc(var(--widget-padding) / 2); - font-size: 0.75rem; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: var(--widget-padding); + font-size: 0.75rem; + background-color: var(--widget-background-color); + border-radius: calc(var(--widget-padding) / 2); `; diff --git a/components/charts/ChartBase/styles.js b/components/charts/ChartBase/styles.js index 0e555ced..dc265010 100644 --- a/components/charts/ChartBase/styles.js +++ b/components/charts/ChartBase/styles.js @@ -1,9 +1,9 @@ import styled from "styled-components"; export const SVG = styled.svg` - aspect-ratio: var(--aspect-ratio); - min-width: var(--min-width); width: 100%; + min-width: var(--min-width); max-height: 100%; + aspect-ratio: var(--aspect-ratio); margin-inline: auto; `; diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js index 694887e0..6b13054a 100644 --- a/components/dynamic/SummitData/Astroweather/Forecast/index.js +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -5,13 +5,12 @@ import { getMoonPosition, getMoonTimes, } from "@/lib/suncalc"; -import { lat, long, timezone } from "@/lib/observatory"; +import { lat, long } from "@/lib/observatory"; import WidgetSection from "@/components/layout/WidgetSection"; import MoonRise from "@/components/widgets/CurrentData/patterns/MoonRise"; import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; import DailyMoonrise from "@/components/widgets/DailyData/patterns/Moonrise"; import { SectionSubHeader } from "@/components/layout/WidgetSection/styles"; -import { timezoneOffset } from "@/helpers"; const ForecastAstroweather = () => { const { t } = useTranslation(); @@ -30,12 +29,10 @@ const ForecastAstroweather = () => { const conversion = 180 / Math.PI; const getAzimuth = (time) => getMoonPosition(time, lat, long).azimuth * conversion + 180; - const offset = timezoneOffset(timezone); const forecast = Array.apply(null, Array(14)).map((value, i) => { const day = new Date(); day.setDate(now.getDate() + i); - day.setUTCHours(offset, 0, 0, 0); const { rise, set } = getMoonTimes(day.toUTCString(), lat, long); return { diff --git a/components/layout/WidgetPreview/styles.js b/components/layout/WidgetPreview/styles.js index ebea5e54..54db7ddc 100644 --- a/components/layout/WidgetPreview/styles.js +++ b/components/layout/WidgetPreview/styles.js @@ -27,7 +27,6 @@ export const PreviewPanel = styled.section` display: grid; grid-template: "header" 2rem "content" auto "callout" 2rem / 1fr; - grid-gap: var(--widget-grid-gap); grid-column: span min(var(--panel-columns), var(--widget-columns)); grid-gap: var(--widget-grid-gap); background-color: var(--black, #000); @@ -70,8 +69,8 @@ export const PreviewIconButton = styled(IconButton)` export const PreviewContent = styled.div` display: grid; - grid-auto-rows: 10rem; grid-template-columns: repeat(var(--panel-columns), 1fr); + grid-auto-rows: 10rem; grid-gap: var(--widget-grid-gap); padding-inline: var(--widget-grid-gap); color: var(--white, #fff); diff --git a/components/layout/WidgetSection/styles.js b/components/layout/WidgetSection/styles.js index aff836fe..aedb6c3f 100644 --- a/components/layout/WidgetSection/styles.js +++ b/components/layout/WidgetSection/styles.js @@ -48,9 +48,9 @@ export const SectionHeader = styled.h2` export const SectionContent = styled.div` --grid-columns: repeat(2, 1fr); - grid-gap: var(--PADDING_SMALL, 20px); grid-template-columns: var(--grid-columns); grid-auto-rows: fit-content(10rem); + grid-gap: var(--PADDING_SMALL, 20px); margin-block-start: var(--PADDING_SMALL, 20px); &:not([hidden]) { diff --git a/components/modal/SummitStatusModal/styles.js b/components/modal/SummitStatusModal/styles.js index 2ab55081..154e1d3e 100644 --- a/components/modal/SummitStatusModal/styles.js +++ b/components/modal/SummitStatusModal/styles.js @@ -4,22 +4,22 @@ import { Dialog as BaseDialog } from "@headlessui/react"; import IconButton from "@/components/atomic/Button/IconButton"; export const Overlay = styled(BaseDialog.Overlay)` - background-color: rgba(0, 0, 0, 80%); position: fixed; top: 0; width: 100%; height: 100%; + background-color: rgba(0, 0, 0, 80%); `; export const Dialog = styled(BaseDialog)` position: fixed; inset: 0; z-index: ${zStack.dialog}; - overflow: auto; - padding: 1rem; display: flex; align-items: start; justify-content: center; + padding: 1rem; + overflow: auto; `; export const Content = styled.div` @@ -27,10 +27,10 @@ export const Content = styled.div` display: flex; flex-direction: column; gap: var(--PADDING_SMALL, 20px); - color: var(--white, #fff); width: calc(100vw - 1rem); max-width: var(--BREAK_LARGE_TABLET, 850px); max-height: 100%; + color: var(--white, #fff); `; export const ScrollableContent = styled.div` diff --git a/components/widgets/CurrentData/patterns/MoonRise/styles.js b/components/widgets/CurrentData/patterns/MoonRise/styles.js index 352ae440..c1375612 100644 --- a/components/widgets/CurrentData/patterns/MoonRise/styles.js +++ b/components/widgets/CurrentData/patterns/MoonRise/styles.js @@ -10,17 +10,17 @@ export const Background = styled(WidgetBackground)` export const Timecard = styled.div` display: flex; + flex: 0 1 50%; flex-direction: column; align-items: center; justify-content: space-between; - flex: 0 1 50%; height: 100%; `; export const Divider = styled.div` - background-color: var(--white, #fff); width: 1px; height: 4em; + background-color: var(--white, #fff); `; export const Time = styled(Value)` diff --git a/components/widgets/DailyData/patterns/Moonrise/Time/styles.js b/components/widgets/DailyData/patterns/Moonrise/Time/styles.js index 96f54520..ca545774 100644 --- a/components/widgets/DailyData/patterns/Moonrise/Time/styles.js +++ b/components/widgets/DailyData/patterns/Moonrise/Time/styles.js @@ -2,7 +2,7 @@ import styled from "styled-components"; export const Container = styled.div` display: flex; - justify-content: center; - align-items: center; gap: 1ch; + align-items: center; + justify-content: center; `; diff --git a/components/widgets/DailyData/patterns/Moonrise/styles.js b/components/widgets/DailyData/patterns/Moonrise/styles.js index b0623e52..471ee279 100644 --- a/components/widgets/DailyData/patterns/Moonrise/styles.js +++ b/components/widgets/DailyData/patterns/Moonrise/styles.js @@ -2,28 +2,28 @@ import styled from "styled-components"; export const Table = styled.table` grid-column: 1/-1; - border-collapse: collapse; font-size: 0.75rem; + border-collapse: collapse; `; export const Header = styled.thead``; export const HeaderCell = styled.th` - background-color: #313333; - border-spacing: 0; - border: 5px solid var(--black, #000); - font-weight: normal; height: 40px; padding: 0; + font-weight: normal; + border-spacing: 0; + background-color: #313333; + border: 5px solid var(--black, #000); &[scope="row"] { font-size: 0.75em; } `; export const TableCell = styled.td` - background-color: #313333; - border-spacing: 0; - border: 5px solid var(--black, #000); - font-size: 0.75em; height: 40px; padding: 0; + font-size: 0.75em; text-align: center; + border-spacing: 0; + background-color: #313333; + border: 5px solid var(--black, #000); `; diff --git a/components/widgets/HourlyData/styles.js b/components/widgets/HourlyData/styles.js index 9b66b4ff..a34debc0 100644 --- a/components/widgets/HourlyData/styles.js +++ b/components/widgets/HourlyData/styles.js @@ -20,8 +20,8 @@ export const HourlyDataList = styled(ScrollableHorizontalWrapper)` export const HourlyDataItem = styled.li` display: flex; flex-direction: column-reverse; - justify-content: center; align-items: center; + justify-content: center; text-align: center; `; diff --git a/helpers/index.js b/helpers/index.js index 6ecb85d9..a97a3140 100644 --- a/helpers/index.js +++ b/helpers/index.js @@ -41,7 +41,7 @@ export const timezoneOffset = (timezone) => { const now = new Date(); now.setUTCHours(0, 0, 0, 0); const localeDate = new Date( - now.toLocaleString("en-US", { timeZone: timezone }) + now.toLocaleString("default", { timeZone: timezone }) ); return 24 - localeDate.getHours(); diff --git a/lib/suncalc.js b/lib/suncalc.js index fc97987e..cfb38d33 100644 --- a/lib/suncalc.js +++ b/lib/suncalc.js @@ -1,3 +1,4 @@ +import { timezoneOffset } from "@/helpers"; import tzlookup from "tz-lookup"; /* @@ -288,9 +289,13 @@ function hoursLater(date, h) { // calculations for moon rise/set times are based on http://www.stargazing.net/kepler/moonrise.html article -export function getMoonTimes(date, lat, lng, inUTC) { +export function getMoonTimes(date, lat, lng, inUTC = false) { const t = new Date(date); - if (inUTC) t.setUTCHours(0, 0, 0, 0); + const tz = tzlookup(lat, lng); + + const utcOffset = inUTC ? 0 : timezoneOffset(tz); + + t.setUTCHours(utcOffset, 0, 0, 0); const hc = 0.133 * rad; let h0 = getMoonPosition(t, lat, lng).altitude - hc; From 7f59ffc5a6acc6e7304f3c11227d071f34f3878b Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 17 Jul 2023 15:57:26 -0700 Subject: [PATCH 45/98] [C] remove extra method --- components/dynamic/SummitData/Astroweather/Forecast/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js index 6b13054a..a108413d 100644 --- a/components/dynamic/SummitData/Astroweather/Forecast/index.js +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -33,7 +33,7 @@ const ForecastAstroweather = () => { const forecast = Array.apply(null, Array(14)).map((value, i) => { const day = new Date(); day.setDate(now.getDate() + i); - const { rise, set } = getMoonTimes(day.toUTCString(), lat, long); + const { rise, set } = getMoonTimes(day, lat, long); return { day: day.getDay(), From dbc918caf87af48c4c029a07bb7bb3701801cc07 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 6 Jun 2023 15:18:02 -0700 Subject: [PATCH 46/98] [C] Proxy for USDF CORS issue from local --- yarn.lock | 213 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 191 insertions(+), 22 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6553cf5d..c137d441 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3760,7 +3760,12 @@ array-back@^3.0.1, array-back@^3.1.0: resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== -array-buffer-byte-length@^1.0.0: +array-back@^3.0.1, array-back@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" + integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== + +array-find@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz#fabe8bc193fea865f317fe7807085ee0dee5aead" integrity sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A== @@ -3848,6 +3853,18 @@ assert-plus@1.0.0, assert-plus@^1.0.0: resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== +asn1@~0.2.3: + version "0.2.6" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.6.tgz#0d3a7bb6e64e02a90c0303b31f292868ea09a08d" + integrity sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ== + dependencies: + safer-buffer "~2.1.0" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== + assert@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32" @@ -4339,7 +4356,19 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== -chalk@^2.0.0, chalk@^2.3.2, chalk@^2.4.1, chalk@^2.4.2: +chai@4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.4.tgz#b55e655b31e1eac7099be4c08c21964fce2e6c49" + integrity sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA== + dependencies: + assertion-error "^1.1.0" + check-error "^1.0.2" + deep-eql "^3.0.1" + get-func-name "^2.0.0" + pathval "^1.1.1" + type-detect "^4.0.5" + +chalk@^2.0.0, chalk@^2.3.0, chalk@^2.3.2, chalk@^2.4.0, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -4550,6 +4579,11 @@ command-line-args@^5.0.2: lodash.camelcase "^4.3.0" typical "^4.0.0" +commander@2.11.x: + version "2.11.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" + integrity sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ== + commander@^2.19.0, commander@^2.20.0: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" @@ -4684,6 +4718,11 @@ core-util-is@1.0.2: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== +core-util-is@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== + core-util-is@~1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" @@ -4906,6 +4945,13 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" +data-urls@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-3.0.2.tgz#9cf24a477ae22bcef5cd5f6f0bfbc1d2d3be9143" + integrity sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ== + dependencies: + assert-plus "^1.0.0" + dayjs@^1.10.4: version "1.11.8" resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.8.tgz#4282f139c8c19dd6d0c7bd571e30c2d0ba7698ea" @@ -5164,6 +5210,14 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" +ecdsa-sig-formatter@1.0.11: + version "1.0.11" + resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz#ae0f0fa2d85045ef14a817daa3ce9acd0489e5bf" + integrity sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ== + dependencies: + jsbn "~0.1.0" + safer-buffer "^2.1.0" + ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -5263,6 +5317,14 @@ env-cmd@^10.1.0: commander "^4.0.0" cross-spawn "^7.0.0" +env-cmd@^10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/env-cmd/-/env-cmd-10.1.0.tgz#c7f5d3b550c9519f137fdac4dd8fb6866a8c8c4b" + integrity sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA== + dependencies: + commander "^4.0.0" + cross-spawn "^7.0.0" + envinfo@^7.7.3: version "7.8.1" resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" @@ -6177,6 +6239,15 @@ form-data@~2.3.2: combined-stream "^1.0.6" mime-types "^2.1.12" +form-data@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" + integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.6" + mime-types "^2.1.12" + forwarded@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" @@ -6742,14 +6813,19 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" -http-signature@~1.3.6: - version "1.3.6" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.3.6.tgz#cb6fbfdf86d1c974f343be94e87f7fc128662cf9" - integrity sha512-3adrsD6zqo4GsTqtO7FyrejHNv+NgiIfAfv68+jVlFmSr9OGy7zrxONceFRLKvnnZA5jbxQBX1u9PpB6Wi32Gw== +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + integrity sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ== dependencies: assert-plus "^1.0.0" - jsprim "^2.0.2" - sshpk "^1.14.1" + jsprim "^1.2.2" + sshpk "^1.7.0" + +http-status-codes@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/http-status-codes/-/http-status-codes-2.2.0.tgz#bb2efe63d941dfc2be18e15f703da525169622be" + integrity sha512-feERVo9iWxvnejp3SEfm/+oNG517npqL2/PIA8ORjyOZjGC7TwCRQsZylciLS64i6pJ0wRYz3rkXLRwbtFa8Ng== https-proxy-agent@^4.0.0: version "4.0.0" @@ -7194,6 +7270,11 @@ is-typedarray@~1.0.0: resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + integrity sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q== + is-unicode-supported@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" @@ -7510,7 +7591,17 @@ jsprim@^2.0.2: json-schema "0.4.0" verror "1.10.0" -"jsx-ast-utils@^2.4.1 || ^3.0.0": +jsprim@^1.2.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb" + integrity sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw== + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.4.0" + verror "1.10.0" + +"jsx-ast-utils@^2.4.1 || ^3.0.0", jsx-ast-utils@^3.3.2: version "3.3.3" resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz#76b3e6e6cece5c69d49a5792c3d01bd1a0cdc7ea" integrity sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw== @@ -8279,7 +8370,12 @@ oauth-sign@~0.9.0: resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== -object-assign@^4, object-assign@^4.1.1: +oauth-sign@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" + integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== + +object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== @@ -9178,7 +9274,7 @@ proxy-from-env@^1.0.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== -psl@^1.1.28: +psl@^1.1.28, psl@^1.1.33: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== @@ -9248,18 +9344,16 @@ qs@^6.10.0: dependencies: side-channel "^1.0.4" -qs@~6.10.3: - version "6.10.5" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.5.tgz#974715920a80ff6a262264acd2c7e6c2a53282b4" - integrity sha512-O5RlPh0VFtR78y79rgcgKK4wbAI0C5zGVLztOIdpWX6ep368q5Hv6XRxDvXuZ9q3C6v+e3n8UfZZJw7IIG27eQ== - dependencies: - side-channel "^1.0.4" - qs@~6.5.2: version "6.5.3" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== +querystringify@^2.1.1: + version "2.2.0" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6" + integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ== + queue-microtask@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" @@ -9694,6 +9788,32 @@ request@^2.85.0: tunnel-agent "^0.6.0" uuid "^3.3.2" +request@^2.85.0: + version "2.88.2" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" + integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.8.0" + caseless "~0.12.0" + combined-stream "~1.0.6" + extend "~3.0.2" + forever-agent "~0.6.1" + form-data "~2.3.2" + har-validator "~5.1.3" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.19" + oauth-sign "~0.9.0" + performance-now "^2.1.0" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.5.0" + tunnel-agent "^0.6.0" + uuid "^3.3.2" + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -9866,7 +9986,7 @@ safe-regex-test@^1.0.0: get-intrinsic "^1.1.3" is-regex "^1.1.4" -"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== @@ -10187,7 +10307,7 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== -sshpk@^1.14.1, sshpk@^1.7.0: +sshpk@^1.7.0: version "1.17.0" resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.17.0.tgz#578082d92d4fe612b13007496e543fa0fbcbe4c5" integrity sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ== @@ -10202,7 +10322,19 @@ sshpk@^1.14.1, sshpk@^1.7.0: safer-buffer "^2.0.2" tweetnacl "~0.14.0" -stackframe@^1.3.4: +stack-utils@^2.0.3: + version "2.0.5" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.5.tgz#d25265fca995154659dbbfba3b49254778d2fdd5" + integrity sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA== + dependencies: + escape-string-regexp "^2.0.0" + +stackframe@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-0.3.1.tgz#33aa84f1177a5548c8935533cbfeb3420975f5a4" + integrity sha512-XmoiF4T5nuWEp2x2w92WdGjdHGY/cZa6LIbRsDRQR/Xlk4uW0PAUlH1zJYVffocwKpCdwyuypIp25xsSXEtZHw== + +stackframe@^1.1.1, stackframe@^1.3.4: version "1.3.4" resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.3.4.tgz#b881a004c8c149a5e8efef37d51b16e412943310" integrity sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw== @@ -10792,6 +10924,25 @@ toidentifier@1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== +tough-cookie@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.0.0.tgz#d822234eeca882f991f0f908824ad2622ddbece4" + integrity sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg== + dependencies: + psl "^1.1.33" + punycode "^2.1.1" + universalify "^0.1.2" + +tough-cookie@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.2.tgz#e53e84b85f24e0b65dd526f46628db6c85f6b874" + integrity sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ== + dependencies: + psl "^1.1.33" + punycode "^2.1.1" + universalify "^0.2.0" + url-parse "^1.5.3" + tough-cookie@~2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" @@ -10800,6 +10951,14 @@ tough-cookie@~2.5.0: psl "^1.1.28" punycode "^2.1.1" +tr46@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-3.0.0.tgz#555c4e297a950617e8eeddef633c87d4d9d6cbf9" + integrity sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA== + dependencies: + psl "^1.1.28" + punycode "^2.1.1" + tr46@~0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" @@ -10884,7 +11043,7 @@ tsutils@^3.21.0: dependencies: tslib "^1.8.1" -tunnel-agent@^0.6.0: +tunnel-agent@0.6.0, tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" integrity sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w== @@ -10982,6 +11141,11 @@ tz-lookup@^6.1.25: resolved "https://registry.yarnpkg.com/tz-lookup/-/tz-lookup-6.1.25.tgz#34d68a7e1ccfcb51f29a9893d2d48e4118d873cd" integrity sha512-fFewT9o1uDzsW1QnUU1ValqaihFnwiUiiHr1S79/fxOzKXYYvX+EHeRnpvQJ9B3Qg67wPXT6QF2Esc4pFOrvLg== +typical@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" + integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== + uglify-js@^3.1.4: version "3.17.4" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" @@ -11163,6 +11327,11 @@ uuid@^3.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== +uuid@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" + integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== + uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" From d291a70c3a0954aeac70d1b8d84c7bc02de89cfe Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 21 Jun 2023 13:17:30 -0700 Subject: [PATCH 47/98] [F] SummitStatusModal --- .../dynamic/SummitData/Weather/Daily/index.js | 22 +++++++++++++++++++ components/widgets/HourlyData/styles.js | 1 + 2 files changed, 23 insertions(+) diff --git a/components/dynamic/SummitData/Weather/Daily/index.js b/components/dynamic/SummitData/Weather/Daily/index.js index 0031e792..a99b4c77 100644 --- a/components/dynamic/SummitData/Weather/Daily/index.js +++ b/components/dynamic/SummitData/Weather/Daily/index.js @@ -4,26 +4,40 @@ import { useWeatherUnit } from "@/contexts/WeatherUnit"; import { useSummitData } from "@/contexts/SummitData"; import Loader from "@/components/atomic/Loader"; import WidgetSection from "@/components/layout/WidgetSection"; +<<<<<<< HEAD import TemperatureHistoric from "@/components/widgets/DailyData/patterns/Temperature"; +======= +import TemperatureHistoric from "@/components/widgets/TemperatureHistoric"; +>>>>>>> ea86e5c ([F] SummitStatusModal) import { convertTemperature } from "@/helpers/converters"; const DailyWeather = () => { const { t } = useTranslation(); const [isOpen, setOpen] = useState(true); const [{ tempUnit }] = useWeatherUnit(); +<<<<<<< HEAD const { dailyData, loading: { dailyData: loading }, } = useSummitData(); const sectionProps = { title: t("summit_dashboard.sections.weather.daily", { +======= + const { dailyData, loading = true } = useSummitData(); + const sectionProps = { + title: t("summit_dashboard.sections.daily", { +>>>>>>> ea86e5c ([F] SummitStatusModal) unit: t(`summit_dashboard.unit_localization.${tempUnit}`), }), onToggleCallback: (value) => setOpen(value), isOpen, }; +<<<<<<< HEAD if (loading || !dailyData) +======= + if (loading && !dailyData) +>>>>>>> ea86e5c ([F] SummitStatusModal) return ( @@ -32,11 +46,19 @@ const DailyWeather = () => { const temperatureData = dailyData .slice(0, -1) +<<<<<<< HEAD .map(({ _time, temperature0_max: max, temperature0_min: min }) => { return { weekday: new Date(_time).getDay(), low: convertTemperature(min, tempUnit), high: convertTemperature(max, tempUnit), +======= + .map(({ _time, temperature0_max, temperature0_min }) => { + return { + weekday: new Date(_time).getDay(), + low: convertTemperature(temperature0_min, tempUnit), + high: convertTemperature(temperature0_max, tempUnit), +>>>>>>> ea86e5c ([F] SummitStatusModal) }; }); diff --git a/components/widgets/HourlyData/styles.js b/components/widgets/HourlyData/styles.js index a34debc0..3cbc407a 100644 --- a/components/widgets/HourlyData/styles.js +++ b/components/widgets/HourlyData/styles.js @@ -22,6 +22,7 @@ export const HourlyDataItem = styled.li` flex-direction: column-reverse; align-items: center; justify-content: center; + align-items: center; text-align: center; `; From 8d7d107ab7eacb5fd24b439ca01b1808389360ab Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 22 Jun 2023 16:26:20 -0700 Subject: [PATCH 48/98] [C] set up astroweather --- package.json | 1 + yarn.lock | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/package.json b/package.json index 8f76feb6..0c3641d4 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "react-uid": "^2.3.2", "striptags": "^3.2.0", "styled-components": "5.3.11", + "suncalc": "^1.9.0", "swr": "^1.3.0", "tz-lookup": "^6.1.25", "use-resize-observer": "^9.0.2" diff --git a/yarn.lock b/yarn.lock index c137d441..d8126ba9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10683,6 +10683,11 @@ stylelint@^15.6.1: table "^6.8.1" write-file-atomic "^5.0.1" +suncalc@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/suncalc/-/suncalc-1.9.0.tgz#26212353fae61edb287c2d558fc4932ecf0e1532" + integrity sha512-vMJ8Byp1uIPoj+wb9c1AdK4jpkSKVAywgHX0lqY7zt6+EWRRC3Z+0Ucfjy/0yxTVO1hwwchZe4uoFNqrIC24+A== + supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" From 682307ddff250b07a25863ccba6f4e595d1a751e Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 26 Jun 2023 16:29:35 -0700 Subject: [PATCH 49/98] [F] daylight widget --- components/charts/ChartFigure/styles.js | 1 + components/dynamic/SummitData/Astroweather/index.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/components/charts/ChartFigure/styles.js b/components/charts/ChartFigure/styles.js index f2f28287..52563c28 100644 --- a/components/charts/ChartFigure/styles.js +++ b/components/charts/ChartFigure/styles.js @@ -1,4 +1,5 @@ import styled from "styled-components"; +import WidgetBackground from "@/components/atomic/WidgetBackground"; export const Caption = styled.figcaption` text-align: center; diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index cf8eea23..4d3f074f 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -11,7 +11,6 @@ import CurrentAstroweather from "./Current"; import ForecastAstroweather from "./Forecast"; const Astroweather = () => { - const { t } = useTranslation(); const [isModalOpen, setModalOpen] = useState(false); const now = new Date(); From c3ba25fe5322d789a2fba2c2b783fc1ccdb86c09 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 6 Jul 2023 16:45:10 -0700 Subject: [PATCH 50/98] [F] Moonrise widget --- .../SummitData/Astroweather/Forecast/index.js | 5 +++++ .../dynamic/SummitData/Weather/Daily/index.js | 22 ------------------- package.json | 2 +- yarn.lock | 8 +++---- 4 files changed, 10 insertions(+), 27 deletions(-) diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js index a108413d..c54e2f05 100644 --- a/components/dynamic/SummitData/Astroweather/Forecast/index.js +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -1,10 +1,15 @@ import { useState } from "react"; +<<<<<<< HEAD import { useTranslation } from "react-i18next"; import { getMoonIllumination, getMoonPosition, getMoonTimes, } from "@/lib/suncalc"; +======= +import SunCalc from "suncalc-tz"; +import { useTranslation } from "react-i18next"; +>>>>>>> 32d31dc ([F] Moonrise widget) import { lat, long } from "@/lib/observatory"; import WidgetSection from "@/components/layout/WidgetSection"; import MoonRise from "@/components/widgets/CurrentData/patterns/MoonRise"; diff --git a/components/dynamic/SummitData/Weather/Daily/index.js b/components/dynamic/SummitData/Weather/Daily/index.js index a99b4c77..0031e792 100644 --- a/components/dynamic/SummitData/Weather/Daily/index.js +++ b/components/dynamic/SummitData/Weather/Daily/index.js @@ -4,40 +4,26 @@ import { useWeatherUnit } from "@/contexts/WeatherUnit"; import { useSummitData } from "@/contexts/SummitData"; import Loader from "@/components/atomic/Loader"; import WidgetSection from "@/components/layout/WidgetSection"; -<<<<<<< HEAD import TemperatureHistoric from "@/components/widgets/DailyData/patterns/Temperature"; -======= -import TemperatureHistoric from "@/components/widgets/TemperatureHistoric"; ->>>>>>> ea86e5c ([F] SummitStatusModal) import { convertTemperature } from "@/helpers/converters"; const DailyWeather = () => { const { t } = useTranslation(); const [isOpen, setOpen] = useState(true); const [{ tempUnit }] = useWeatherUnit(); -<<<<<<< HEAD const { dailyData, loading: { dailyData: loading }, } = useSummitData(); const sectionProps = { title: t("summit_dashboard.sections.weather.daily", { -======= - const { dailyData, loading = true } = useSummitData(); - const sectionProps = { - title: t("summit_dashboard.sections.daily", { ->>>>>>> ea86e5c ([F] SummitStatusModal) unit: t(`summit_dashboard.unit_localization.${tempUnit}`), }), onToggleCallback: (value) => setOpen(value), isOpen, }; -<<<<<<< HEAD if (loading || !dailyData) -======= - if (loading && !dailyData) ->>>>>>> ea86e5c ([F] SummitStatusModal) return ( @@ -46,19 +32,11 @@ const DailyWeather = () => { const temperatureData = dailyData .slice(0, -1) -<<<<<<< HEAD .map(({ _time, temperature0_max: max, temperature0_min: min }) => { return { weekday: new Date(_time).getDay(), low: convertTemperature(min, tempUnit), high: convertTemperature(max, tempUnit), -======= - .map(({ _time, temperature0_max, temperature0_min }) => { - return { - weekday: new Date(_time).getDay(), - low: convertTemperature(temperature0_min, tempUnit), - high: convertTemperature(temperature0_max, tempUnit), ->>>>>>> ea86e5c ([F] SummitStatusModal) }; }); diff --git a/package.json b/package.json index 0c3641d4..213504fa 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "react-uid": "^2.3.2", "striptags": "^3.2.0", "styled-components": "5.3.11", - "suncalc": "^1.9.0", + "suncalc-tz": "^1.9.1", "swr": "^1.3.0", "tz-lookup": "^6.1.25", "use-resize-observer": "^9.0.2" diff --git a/yarn.lock b/yarn.lock index d8126ba9..1dea816d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10683,10 +10683,10 @@ stylelint@^15.6.1: table "^6.8.1" write-file-atomic "^5.0.1" -suncalc@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/suncalc/-/suncalc-1.9.0.tgz#26212353fae61edb287c2d558fc4932ecf0e1532" - integrity sha512-vMJ8Byp1uIPoj+wb9c1AdK4jpkSKVAywgHX0lqY7zt6+EWRRC3Z+0Ucfjy/0yxTVO1hwwchZe4uoFNqrIC24+A== +suncalc-tz@^1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/suncalc-tz/-/suncalc-tz-1.9.1.tgz#c5d616c2e79cd684f3e7281a63a895cb39c7a922" + integrity sha512-4tL0XM54iE237XOM2ywgvlGQykDPOwWYcno+w9RIY3M7LGiaSxQwqkOGtYYMDvu/kRDf0tm/nTzjs0mlF0iNMQ== supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" From 41d2d0b4bf186eecb0850713374ac96e936c37c9 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Fri, 7 Jul 2023 13:53:30 -0700 Subject: [PATCH 51/98] [C] invert Daylight widget to center night --- components/charts/XAxis/index.js | 12 +- .../SummitData/Astroweather/Current/index.js | 40 ++---- .../dynamic/SummitData/Astroweather/index.js | 39 +++--- .../CurrentData/patterns/Daylight/index.js | 132 +++++++++--------- lib/localeStrings/en.json | 3 +- lib/utils.js | 18 ++- 6 files changed, 119 insertions(+), 125 deletions(-) diff --git a/components/charts/XAxis/index.js b/components/charts/XAxis/index.js index 37264aac..2f6d0d25 100644 --- a/components/charts/XAxis/index.js +++ b/components/charts/XAxis/index.js @@ -11,13 +11,13 @@ const XAxis = ({ labelledById, }) => { const tickHeight = 5; - const valueInterval = (xDomain[1] - xDomain[0]) / ticks; - const positionInterval = (xDomain[1] - xDomain[0]) / (ticks - 1); - const tickMap = Array.from(Array(ticks)).map((tick, i) => { - const value = xDomain[0] + valueInterval * i; - const label = labelFormatter ? labelFormatter(value) : value; - const position = xScale(xDomain[0] + positionInterval * i); + const interval = (xDomain[1] - xDomain[0]) / ticks; + + const tickMap = Array.from(Array(ticks + 1)).map((tick, i) => { + const value = xDomain[0] + interval * i; + const label = labelFormatter ? labelFormatter(value, i) : value; + const position = xScale(xDomain[0] + interval * i); return { label, position }; }); diff --git a/components/dynamic/SummitData/Astroweather/Current/index.js b/components/dynamic/SummitData/Astroweather/Current/index.js index fe85739c..112b18d0 100644 --- a/components/dynamic/SummitData/Astroweather/Current/index.js +++ b/components/dynamic/SummitData/Astroweather/Current/index.js @@ -1,12 +1,12 @@ +import PropTypes from "prop-types"; import { useState } from "react"; import { useTranslation } from "react-i18next"; -import { getTimes } from "@/lib/suncalc"; -import { altitude, lat, long, timezone } from "@/lib/observatory"; -import { timezoneOffset } from "@/helpers"; import WidgetSection from "@/components/layout/WidgetSection"; -import Daylight from "@/components/widgets/CurrentData/patterns/Daylight"; +import Daylight, { + DaylightDataShape, +} from "@/components/widgets/CurrentData/patterns/Daylight"; -const CurrentAstroweather = () => { +const CurrentAstroweather = ({ data }) => { const { t } = useTranslation(); const [isOpen, setOpen] = useState(true); const sectionProps = { @@ -15,35 +15,21 @@ const CurrentAstroweather = () => { isOpen, }; - const now = new Date(); - const offset = timezoneOffset(timezone); - - const observatoryDate = new Date( - now.toLocaleString("en-US", { timeZone: timezone }) - ); - - observatoryDate.setUTCHours(12 - offset, 0, 0, 0); - - const { nightEnd, sunrise, sunset, night } = getTimes( - observatoryDate, - lat, - long, - altitude - ); + const { daylight } = data; return ( - + ); }; CurrentAstroweather.displayName = "Dynamic.Astroweather.Current"; +CurrentAstroweather.propTypes = { + data: PropTypes.shape({ + daylight: PropTypes.shape(DaylightDataShape), + }), +}; + export default CurrentAstroweather; diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index 4d3f074f..f5e62cc4 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -6,30 +6,34 @@ import SummitStatusModal from "@/components/modal/SummitStatusModal"; import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; import Daylight from "@/components/widgets/CurrentData/patterns/Daylight"; import { altitude, lat, long, timezone } from "@/lib/observatory"; -import { timezoneOffset } from "@/helpers"; +import { timezoneOffset, timezoneOffsetLocal } from "@/helpers"; import CurrentAstroweather from "./Current"; import ForecastAstroweather from "./Forecast"; const Astroweather = () => { + const { t } = useTranslation(); const [isModalOpen, setModalOpen] = useState(false); - const now = new Date(); const offset = timezoneOffset(timezone); + const localOffset = timezoneOffsetLocal(timezone); - const { phase } = getMoonIllumination(now); + const today = new Date(); + const tomorrow = new Date(today); + const yesterday = new Date(today); + tomorrow.setDate(tomorrow.getDate() + 1); + yesterday.setDate(yesterday.getDate() - 1); - const observatoryDate = new Date( - now.toLocaleString("en-US", { timeZone: timezone }) - ); + const isAfterNoon = today.getUTCHours() - offset > 12; + const dates = isAfterNoon ? [today, tomorrow] : [yesterday, today]; - observatoryDate.setUTCHours(12 - offset, 0, 0, 0); + const { phase } = getMoonIllumination(today); + const { sunset, night } = getTimes(dates[0], lat, long, altitude); + const { nightEnd: dawn, sunrise } = getTimes(dates[1], lat, long, altitude); - const { nightEnd, sunrise, sunset, night } = getTimes( - observatoryDate, - lat, - long, - altitude - ); + const times = { dawn, sunrise, sunset, night }; + Object.keys(times).forEach((key) => { + times[key].setHours(times[key].getHours() - localOffset); + }); return ( { }} > - + setModalOpen(false)}> - + ); diff --git a/components/widgets/CurrentData/patterns/Daylight/index.js b/components/widgets/CurrentData/patterns/Daylight/index.js index 5bcbaaa6..a7052b62 100644 --- a/components/widgets/CurrentData/patterns/Daylight/index.js +++ b/components/widgets/CurrentData/patterns/Daylight/index.js @@ -4,36 +4,38 @@ import * as Styled from "./styles"; import { getLinearScale } from "@/lib/utils"; import { formatTime } from "@/helpers/formatters"; import XAxis from "@/components/charts/XAxis"; -import { capitalize, timezoneOffset } from "@/helpers"; +import { timezoneOffset } from "@/helpers"; import { timezone } from "@/lib/observatory"; import { useTranslation } from "react-i18next"; import ChartLegend from "@/components/charts/Legend"; -const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { +const Daylight = ({ + dawn, + sunrise, + sunset, + night, + dates, + variant = "primary", +}) => { const { t, i18n: { language = "en-US" }, } = useTranslation(); + const offset = timezoneOffset(timezone); - const minutes = 1500; + const width = variant === "primary" ? 280 : 640; const height = 70; - const xDomain = [0, minutes]; + const xDomain = dates.map((date) => { + const hours = 12 + offset; + date.setUTCHours(hours, 0, 0, 0); + return date.getTime(); + }); const xScale = getLinearScale(xDomain, [0, width]); const xHeight = 25; const xPos = height - xHeight; - const midnight = new Date(); - midnight.setUTCHours(offset, 0, 0, 0); - - const getMinutes = (date) => - (date.getUTCHours() - offset) * 60 + date.getMinutes(); - - const dawnMinutes = getMinutes(dawn); - const sunriseMinutes = getMinutes(sunrise); - const sunsetMinutes = getMinutes(sunset); - const nightMinutes = getMinutes(night); - const now = getMinutes(new Date()); + const now = Date.now(); const nightFill = "#1f2121"; const twilightFill = "#006DA8"; @@ -77,19 +79,16 @@ const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { xDomain, xScale, y: xPos, - ticks: 25, - labelFormatter: (value) => { - const hours = value / 60; - const date = new Date(); - date.setUTCHours(hours + offset, 0, 0, 0); - - const time = date.getUTCHours() - offset; + ticks: 24, + labelFormatter: (value, i) => { + const date = new Date(value); + const hours = date.getUTCHours() - offset; - if (time / 24 === 0) { + if (hours === 12) { return ( @@ -97,20 +96,14 @@ const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { ); } - - if (time === 12) { - const noon = date.toLocaleTimeString(language, { - dayPeriod: "short", - timeZone: timezone, - }); - + if (hours === 0) { return ( - {capitalize(noon, language)} + {t("summit_dashboard.sections.astro.daylight.midnight")} ); } @@ -119,68 +112,66 @@ const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { /> @@ -192,7 +183,9 @@ const Daylight = ({ dawn, sunrise, sunset, night, variant = "primary" }) => { aria-label={t("summit_dashboard.sections.astro.daylight.current", { time: formatTime(new Date(), language), context: - now > nightMinutes || now < dawnMinutes ? "observable" : null, + now > night.getTime() && now < dawn.getTime() + ? "observable" + : null, })} /> { ); }; -Daylight.propTypes = { +export const DaylightDataShape = { dawn: PropTypes.instanceOf(Date).isRequired, sunrise: PropTypes.instanceOf(Date).isRequired, sunset: PropTypes.instanceOf(Date).isRequired, night: PropTypes.instanceOf(Date).isRequired, + dates: PropTypes.arrayOf(PropTypes.instanceOf(Date)).isRequired, +}; + +Daylight.propTypes = { + ...DaylightDataShape, variant: PropTypes.oneOf(["primary", "secondary"]), }; diff --git a/lib/localeStrings/en.json b/lib/localeStrings/en.json index b048c9f1..ddeee3c1 100644 --- a/lib/localeStrings/en.json +++ b/lib/localeStrings/en.json @@ -363,7 +363,8 @@ "twilight": "Twilight from {{from}} to {{to}}", "daylight": "Daylight from {{from}} to {{to}}", "current": "Current local time {{time}}. It is too light to observe right now.", - "current_observable": "Current local time {{time}}. It is dark enough to observe right now." + "current_observable": "Current local time {{time}}. It is dark enough to observe right now.", + "midnight": "Midnight" }, "moonrise": { "forecast": "Moonrise and moonset times forecast (next fourteen days)", diff --git a/lib/utils.js b/lib/utils.js index 996a8088..452e87af 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -5,11 +5,21 @@ import { useDataList } from "@/api/entries"; import { useReleases } from "@/lib/api/noirlabReleases"; import debounce from "lodash/debounce"; -export const getLinearScale = (domain, range) => { - const [dMin, dMax] = domain; - const [rMin, rMax] = range; +export const getLinearScale = (domain, range, clamp = false) => { + return (val) => { + const sub = domain[1] - domain[0]; - return (value) => (value / (dMax - dMin)) * (rMax - rMin) + rMin; + if (sub === 0) { + return (range[0] + range[1]) / 2; + } + let t = (val - domain[0]) / sub; + + if (clamp) { + t = Math.min(Math.max(t, 0), 1); + } + + return t * (range[1] - range[0]) + range[0]; + }; }; function nearestOdd(value) { From ee452630e9425a4568cccfd6764279d16ded6ac9 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 19 Jul 2023 10:03:17 -0700 Subject: [PATCH 52/98] rebase --- components/dynamic/SummitData/Astroweather/Forecast/index.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js index c54e2f05..a108413d 100644 --- a/components/dynamic/SummitData/Astroweather/Forecast/index.js +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -1,15 +1,10 @@ import { useState } from "react"; -<<<<<<< HEAD import { useTranslation } from "react-i18next"; import { getMoonIllumination, getMoonPosition, getMoonTimes, } from "@/lib/suncalc"; -======= -import SunCalc from "suncalc-tz"; -import { useTranslation } from "react-i18next"; ->>>>>>> 32d31dc ([F] Moonrise widget) import { lat, long } from "@/lib/observatory"; import WidgetSection from "@/components/layout/WidgetSection"; import MoonRise from "@/components/widgets/CurrentData/patterns/MoonRise"; From 072794a767779d1ce870d3996c0ac21c7804854a Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 19 Jul 2023 10:04:07 -0700 Subject: [PATCH 53/98] rebase --- components/charts/ChartFigure/styles.js | 1 - 1 file changed, 1 deletion(-) diff --git a/components/charts/ChartFigure/styles.js b/components/charts/ChartFigure/styles.js index 52563c28..f2f28287 100644 --- a/components/charts/ChartFigure/styles.js +++ b/components/charts/ChartFigure/styles.js @@ -1,5 +1,4 @@ import styled from "styled-components"; -import WidgetBackground from "@/components/atomic/WidgetBackground"; export const Caption = styled.figcaption` text-align: center; From 5ecd2248567589f73b764e4b6ecdcc3e6ff22a01 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 19 Jul 2023 10:04:42 -0700 Subject: [PATCH 54/98] lint --- components/widgets/HourlyData/styles.js | 1 - 1 file changed, 1 deletion(-) diff --git a/components/widgets/HourlyData/styles.js b/components/widgets/HourlyData/styles.js index 3cbc407a..a34debc0 100644 --- a/components/widgets/HourlyData/styles.js +++ b/components/widgets/HourlyData/styles.js @@ -22,7 +22,6 @@ export const HourlyDataItem = styled.li` flex-direction: column-reverse; align-items: center; justify-content: center; - align-items: center; text-align: center; `; From 8353f42d042ae12926ef542c8ccf331370e6a37e Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 19 Jul 2023 10:06:16 -0700 Subject: [PATCH 55/98] [C] remove suncalc again --- package.json | 1 - yarn.lock | 218 ++++++--------------------------------------------- 2 files changed, 22 insertions(+), 197 deletions(-) diff --git a/package.json b/package.json index 213504fa..8f76feb6 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,6 @@ "react-uid": "^2.3.2", "striptags": "^3.2.0", "styled-components": "5.3.11", - "suncalc-tz": "^1.9.1", "swr": "^1.3.0", "tz-lookup": "^6.1.25", "use-resize-observer": "^9.0.2" diff --git a/yarn.lock b/yarn.lock index 1dea816d..6553cf5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3760,12 +3760,7 @@ array-back@^3.0.1, array-back@^3.1.0: resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== -array-back@^3.0.1, array-back@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" - integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== - -array-find@^1.0.0: +array-buffer-byte-length@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz#fabe8bc193fea865f317fe7807085ee0dee5aead" integrity sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A== @@ -3853,18 +3848,6 @@ assert-plus@1.0.0, assert-plus@^1.0.0: resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== -asn1@~0.2.3: - version "0.2.6" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.6.tgz#0d3a7bb6e64e02a90c0303b31f292868ea09a08d" - integrity sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ== - dependencies: - safer-buffer "~2.1.0" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== - assert@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32" @@ -4356,19 +4339,7 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== -chai@4.3.4: - version "4.3.4" - resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.4.tgz#b55e655b31e1eac7099be4c08c21964fce2e6c49" - integrity sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA== - dependencies: - assertion-error "^1.1.0" - check-error "^1.0.2" - deep-eql "^3.0.1" - get-func-name "^2.0.0" - pathval "^1.1.1" - type-detect "^4.0.5" - -chalk@^2.0.0, chalk@^2.3.0, chalk@^2.3.2, chalk@^2.4.0, chalk@^2.4.1, chalk@^2.4.2: +chalk@^2.0.0, chalk@^2.3.2, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -4579,11 +4550,6 @@ command-line-args@^5.0.2: lodash.camelcase "^4.3.0" typical "^4.0.0" -commander@2.11.x: - version "2.11.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" - integrity sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ== - commander@^2.19.0, commander@^2.20.0: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" @@ -4718,11 +4684,6 @@ core-util-is@1.0.2: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== -core-util-is@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== - core-util-is@~1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" @@ -4945,13 +4906,6 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" -data-urls@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-3.0.2.tgz#9cf24a477ae22bcef5cd5f6f0bfbc1d2d3be9143" - integrity sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ== - dependencies: - assert-plus "^1.0.0" - dayjs@^1.10.4: version "1.11.8" resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.8.tgz#4282f139c8c19dd6d0c7bd571e30c2d0ba7698ea" @@ -5210,14 +5164,6 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" -ecdsa-sig-formatter@1.0.11: - version "1.0.11" - resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz#ae0f0fa2d85045ef14a817daa3ce9acd0489e5bf" - integrity sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ== - dependencies: - jsbn "~0.1.0" - safer-buffer "^2.1.0" - ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -5317,14 +5263,6 @@ env-cmd@^10.1.0: commander "^4.0.0" cross-spawn "^7.0.0" -env-cmd@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/env-cmd/-/env-cmd-10.1.0.tgz#c7f5d3b550c9519f137fdac4dd8fb6866a8c8c4b" - integrity sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA== - dependencies: - commander "^4.0.0" - cross-spawn "^7.0.0" - envinfo@^7.7.3: version "7.8.1" resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" @@ -6239,15 +6177,6 @@ form-data@~2.3.2: combined-stream "^1.0.6" mime-types "^2.1.12" -form-data@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" - integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.6" - mime-types "^2.1.12" - forwarded@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" @@ -6813,19 +6742,14 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" - integrity sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ== +http-signature@~1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.3.6.tgz#cb6fbfdf86d1c974f343be94e87f7fc128662cf9" + integrity sha512-3adrsD6zqo4GsTqtO7FyrejHNv+NgiIfAfv68+jVlFmSr9OGy7zrxONceFRLKvnnZA5jbxQBX1u9PpB6Wi32Gw== dependencies: assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -http-status-codes@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/http-status-codes/-/http-status-codes-2.2.0.tgz#bb2efe63d941dfc2be18e15f703da525169622be" - integrity sha512-feERVo9iWxvnejp3SEfm/+oNG517npqL2/PIA8ORjyOZjGC7TwCRQsZylciLS64i6pJ0wRYz3rkXLRwbtFa8Ng== + jsprim "^2.0.2" + sshpk "^1.14.1" https-proxy-agent@^4.0.0: version "4.0.0" @@ -7270,11 +7194,6 @@ is-typedarray@~1.0.0: resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== -is-utf8@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" - integrity sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q== - is-unicode-supported@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" @@ -7591,17 +7510,7 @@ jsprim@^2.0.2: json-schema "0.4.0" verror "1.10.0" -jsprim@^1.2.2: - version "1.4.2" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb" - integrity sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw== - dependencies: - assert-plus "1.0.0" - extsprintf "1.3.0" - json-schema "0.4.0" - verror "1.10.0" - -"jsx-ast-utils@^2.4.1 || ^3.0.0", jsx-ast-utils@^3.3.2: +"jsx-ast-utils@^2.4.1 || ^3.0.0": version "3.3.3" resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz#76b3e6e6cece5c69d49a5792c3d01bd1a0cdc7ea" integrity sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw== @@ -8370,12 +8279,7 @@ oauth-sign@~0.9.0: resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" - integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== - -object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.1: +object-assign@^4, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== @@ -9274,7 +9178,7 @@ proxy-from-env@^1.0.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== -psl@^1.1.28, psl@^1.1.33: +psl@^1.1.28: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== @@ -9344,16 +9248,18 @@ qs@^6.10.0: dependencies: side-channel "^1.0.4" +qs@~6.10.3: + version "6.10.5" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.5.tgz#974715920a80ff6a262264acd2c7e6c2a53282b4" + integrity sha512-O5RlPh0VFtR78y79rgcgKK4wbAI0C5zGVLztOIdpWX6ep368q5Hv6XRxDvXuZ9q3C6v+e3n8UfZZJw7IIG27eQ== + dependencies: + side-channel "^1.0.4" + qs@~6.5.2: version "6.5.3" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== -querystringify@^2.1.1: - version "2.2.0" - resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6" - integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ== - queue-microtask@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" @@ -9788,32 +9694,6 @@ request@^2.85.0: tunnel-agent "^0.6.0" uuid "^3.3.2" -request@^2.85.0: - version "2.88.2" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" - integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.3" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.5.0" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -9986,7 +9866,7 @@ safe-regex-test@^1.0.0: get-intrinsic "^1.1.3" is-regex "^1.1.4" -"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: +"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== @@ -10307,7 +10187,7 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== -sshpk@^1.7.0: +sshpk@^1.14.1, sshpk@^1.7.0: version "1.17.0" resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.17.0.tgz#578082d92d4fe612b13007496e543fa0fbcbe4c5" integrity sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ== @@ -10322,19 +10202,7 @@ sshpk@^1.7.0: safer-buffer "^2.0.2" tweetnacl "~0.14.0" -stack-utils@^2.0.3: - version "2.0.5" - resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.5.tgz#d25265fca995154659dbbfba3b49254778d2fdd5" - integrity sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA== - dependencies: - escape-string-regexp "^2.0.0" - -stackframe@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-0.3.1.tgz#33aa84f1177a5548c8935533cbfeb3420975f5a4" - integrity sha512-XmoiF4T5nuWEp2x2w92WdGjdHGY/cZa6LIbRsDRQR/Xlk4uW0PAUlH1zJYVffocwKpCdwyuypIp25xsSXEtZHw== - -stackframe@^1.1.1, stackframe@^1.3.4: +stackframe@^1.3.4: version "1.3.4" resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.3.4.tgz#b881a004c8c149a5e8efef37d51b16e412943310" integrity sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw== @@ -10683,11 +10551,6 @@ stylelint@^15.6.1: table "^6.8.1" write-file-atomic "^5.0.1" -suncalc-tz@^1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/suncalc-tz/-/suncalc-tz-1.9.1.tgz#c5d616c2e79cd684f3e7281a63a895cb39c7a922" - integrity sha512-4tL0XM54iE237XOM2ywgvlGQykDPOwWYcno+w9RIY3M7LGiaSxQwqkOGtYYMDvu/kRDf0tm/nTzjs0mlF0iNMQ== - supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -10929,25 +10792,6 @@ toidentifier@1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== -tough-cookie@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.0.0.tgz#d822234eeca882f991f0f908824ad2622ddbece4" - integrity sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg== - dependencies: - psl "^1.1.33" - punycode "^2.1.1" - universalify "^0.1.2" - -tough-cookie@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.2.tgz#e53e84b85f24e0b65dd526f46628db6c85f6b874" - integrity sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ== - dependencies: - psl "^1.1.33" - punycode "^2.1.1" - universalify "^0.2.0" - url-parse "^1.5.3" - tough-cookie@~2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" @@ -10956,14 +10800,6 @@ tough-cookie@~2.5.0: psl "^1.1.28" punycode "^2.1.1" -tr46@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-3.0.0.tgz#555c4e297a950617e8eeddef633c87d4d9d6cbf9" - integrity sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA== - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - tr46@~0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" @@ -11048,7 +10884,7 @@ tsutils@^3.21.0: dependencies: tslib "^1.8.1" -tunnel-agent@0.6.0, tunnel-agent@^0.6.0: +tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" integrity sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w== @@ -11146,11 +10982,6 @@ tz-lookup@^6.1.25: resolved "https://registry.yarnpkg.com/tz-lookup/-/tz-lookup-6.1.25.tgz#34d68a7e1ccfcb51f29a9893d2d48e4118d873cd" integrity sha512-fFewT9o1uDzsW1QnUU1ValqaihFnwiUiiHr1S79/fxOzKXYYvX+EHeRnpvQJ9B3Qg67wPXT6QF2Esc4pFOrvLg== -typical@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" - integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== - uglify-js@^3.1.4: version "3.17.4" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" @@ -11332,11 +11163,6 @@ uuid@^3.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== -uuid@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" - integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== - uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" From b44f9c702761152f3ab2d978b8b7bf094974338d Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Fri, 28 Jul 2023 10:52:00 -0700 Subject: [PATCH 56/98] [F] Zenith and Azimuth widgets --- .../content-blocks/SummitStatus/index.js | 2 + .../Observation/Instruments/index.js | 34 +++++ .../Observation/Instruments/styles.js | 31 +++++ .../dynamic/SummitData/Observation/index.js | 36 +++++ .../dynamic/SummitData/Observation/styles.js | 10 ++ .../CurrentData/patterns/Azimuth/index.js | 128 ++++++++++++++++++ .../CurrentData/patterns/Azimuth/styles.js | 17 +++ .../CurrentData/patterns/Zenith/index.js | 67 +++++++++ .../CurrentData/patterns/Zenith/styles.js | 17 +++ lib/localeStrings/en.json | 15 +- lib/localeStrings/es.json | 14 +- 11 files changed, 366 insertions(+), 5 deletions(-) create mode 100644 components/dynamic/SummitData/Observation/Instruments/index.js create mode 100644 components/dynamic/SummitData/Observation/Instruments/styles.js create mode 100644 components/dynamic/SummitData/Observation/index.js create mode 100644 components/dynamic/SummitData/Observation/styles.js create mode 100644 components/widgets/CurrentData/patterns/Azimuth/index.js create mode 100644 components/widgets/CurrentData/patterns/Azimuth/styles.js create mode 100644 components/widgets/CurrentData/patterns/Zenith/index.js create mode 100644 components/widgets/CurrentData/patterns/Zenith/styles.js diff --git a/components/content-blocks/SummitStatus/index.js b/components/content-blocks/SummitStatus/index.js index 01c0c570..1fc1e251 100644 --- a/components/content-blocks/SummitStatus/index.js +++ b/components/content-blocks/SummitStatus/index.js @@ -6,6 +6,7 @@ import WidgetGrid from "@/components/layout/WidgetGrid"; import { SummitDataProvider } from "@/contexts/SummitData"; import Weather from "@/components/dynamic/SummitData/Weather"; import Astroweather from "@/components/dynamic/SummitData/Astroweather"; +import Observation from "@/components/dynamic/SummitData/Observation"; const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { return ( @@ -14,6 +15,7 @@ const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { + diff --git a/components/dynamic/SummitData/Observation/Instruments/index.js b/components/dynamic/SummitData/Observation/Instruments/index.js new file mode 100644 index 00000000..c547bff8 --- /dev/null +++ b/components/dynamic/SummitData/Observation/Instruments/index.js @@ -0,0 +1,34 @@ +import PropTypes from "prop-types"; +import { useState } from "react"; +import { useTranslation } from "react-i18next"; +import WidgetSection from "@/components/layout/WidgetSection"; +import * as Styled from "./styles"; + +const Instruments = ({ azimuth, zenith }) => { + const { t } = useTranslation(); + const [isOpen, setOpen] = useState(true); + + const sectionProps = { + title: t("summit_dashboard.sections.observations.instruments"), + onToggleCallback: (value) => setOpen(value), + isOpen, + }; + + return ( + + + + + + + ); +}; + +Instruments.propTypes = { + azimuth: PropTypes.number, + zenith: PropTypes.number, +}; + +Instruments.displayName = "Dynamic.Observation.Insturments"; + +export default Instruments; diff --git a/components/dynamic/SummitData/Observation/Instruments/styles.js b/components/dynamic/SummitData/Observation/Instruments/styles.js new file mode 100644 index 00000000..271954cc --- /dev/null +++ b/components/dynamic/SummitData/Observation/Instruments/styles.js @@ -0,0 +1,31 @@ +import styled from "styled-components"; +import WidgetBackground from "@/components/atomic/WidgetBackground"; +import Azimuth from "@/components/widgets/CurrentData/patterns/Azimuth"; +import Zenith from "@/components/widgets/CurrentData/patterns/Zenith"; +import { BREAK_PHABLET_MIN } from "@/styles/globalStyles"; + +export const InstrumentsLayout = styled(WidgetBackground)` + --instrument-columns: 1fr 1fr; + --instrument-layout: "azimuth zenith" 2fr "slew shutter" 1fr / + var(--instrument-columns); + + display: grid; + grid-template: var(--instrument-layout); + grid-column: 1/-1; + + @media screen and (min-width: ${BREAK_PHABLET_MIN}) { + --instrument-columns: 2fr 2fr 1fr; + --instrument-layout: "azimuth zenith slew" 1fr "azimuth zenith shutter" 1fr / + var(--instrument-columns); + } +`; + +export const BigAzimuth = styled(Azimuth)` + grid-area: azimuth; + aspect-ratio: 1; +`; + +export const BigZenith = styled(Zenith)` + grid-area: zenith; + aspect-ratio: 1; +`; diff --git a/components/dynamic/SummitData/Observation/index.js b/components/dynamic/SummitData/Observation/index.js new file mode 100644 index 00000000..4d36143a --- /dev/null +++ b/components/dynamic/SummitData/Observation/index.js @@ -0,0 +1,36 @@ +import { useState } from "react"; +import WidgetPreview from "@/components/layout/WidgetPreview"; +import SummitStatusModal from "@/components/modal/SummitStatusModal"; + +import Azimuth from "@/components/widgets/CurrentData/patterns/Azimuth"; +import Zenith from "@/components/widgets/CurrentData/patterns/Zenith"; +import Instruments from "./Instruments"; + +import * as Styled from "./styles"; + +const Observation = () => { + const [isModalOpen, setModalOpen] = useState(false); + const azimuth = 0; + const zenith = 0; + + return ( + { + setModalOpen(true); + }} + > + + + + + setModalOpen(false)}> + + + + ); +}; + +Observation.displayName = "Dynamic.Observation"; + +export default Observation; diff --git a/components/dynamic/SummitData/Observation/styles.js b/components/dynamic/SummitData/Observation/styles.js new file mode 100644 index 00000000..e3bcffcc --- /dev/null +++ b/components/dynamic/SummitData/Observation/styles.js @@ -0,0 +1,10 @@ +import styled from "styled-components"; +import WidgetBackground from "@/components/atomic/WidgetBackground"; + +export const CondensedBackground = styled(WidgetBackground)` + display: grid; + grid-template-rows: 100%; + grid-template-columns: repeat(2, 1fr); + grid-column: 1 / -1; + gap: var(--widget-padding); +`; diff --git a/components/widgets/CurrentData/patterns/Azimuth/index.js b/components/widgets/CurrentData/patterns/Azimuth/index.js new file mode 100644 index 00000000..24639ed5 --- /dev/null +++ b/components/widgets/CurrentData/patterns/Azimuth/index.js @@ -0,0 +1,128 @@ +import PropTypes from "prop-types"; +import { useTranslation } from "react-i18next"; +import { formatAngle } from "@/helpers/formatters"; +import * as Styled from "./styles"; + +const Azimuth = ({ azimuth = 0, isCondensed = false, className }) => { + const { t } = useTranslation(); + const width = 100; + const height = width; + return ( + + {!isCondensed && ( + + {t("summit_dashboard.widgets.current.azimuth")} + + )} + + + + + + + + + + + + + + + + + + + + + + + + + + {isCondensed + ? t("summit_dashboard.widgets.current.azimuth", { + context: "angle", + angle: formatAngle(azimuth), + }) + : formatAngle(azimuth)} + + + ); +}; + +Azimuth.displayName = "Widgets.Current.Azimuth"; + +Azimuth.propTypes = { + azimuth: PropTypes.number, + isCondensed: PropTypes.bool, + className: PropTypes.string, +}; + +export default Azimuth; diff --git a/components/widgets/CurrentData/patterns/Azimuth/styles.js b/components/widgets/CurrentData/patterns/Azimuth/styles.js new file mode 100644 index 00000000..e3799c61 --- /dev/null +++ b/components/widgets/CurrentData/patterns/Azimuth/styles.js @@ -0,0 +1,17 @@ +import styled from "styled-components"; +export * from "../../styles"; + +export const Container = styled.div` + display: flex; + flex-direction: column; + gap: 0.5em; + align-items: center; + height: 100%; +`; + +export const Compass = styled.svg` + flex-grow: 1; + width: 100%; + aspect-ratio: 1; + overflow-clip-margin: 1px; +`; diff --git a/components/widgets/CurrentData/patterns/Zenith/index.js b/components/widgets/CurrentData/patterns/Zenith/index.js new file mode 100644 index 00000000..34c4f6f6 --- /dev/null +++ b/components/widgets/CurrentData/patterns/Zenith/index.js @@ -0,0 +1,67 @@ +import PropTypes from "prop-types"; +import { useTranslation } from "react-i18next"; +import { formatAngle } from "@/helpers/formatters"; +import * as Styled from "./styles"; + +const Zenith = ({ zenith = 0, isCondensed = false, className }) => { + const { t } = useTranslation(); + const width = 52; + const height = width; + const clamped = Math.max(Math.min(zenith, 90), 0); + const rotation = 90 - clamped; + + return ( + + {!isCondensed && ( + + {t("summit_dashboard.widgets.current.zenith")} + + )} + + + + + + + + + + {isCondensed + ? t("summit_dashboard.widgets.current.zenith", { + context: "angle", + angle: formatAngle(clamped), + }) + : formatAngle(clamped)} + + + ); +}; + +Zenith.displayName = "Widgets.Current.Zenith"; + +Zenith.propTypes = { + zenith: PropTypes.number, + isCondensed: PropTypes.bool, + className: PropTypes.string, +}; + +export default Zenith; diff --git a/components/widgets/CurrentData/patterns/Zenith/styles.js b/components/widgets/CurrentData/patterns/Zenith/styles.js new file mode 100644 index 00000000..e3799c61 --- /dev/null +++ b/components/widgets/CurrentData/patterns/Zenith/styles.js @@ -0,0 +1,17 @@ +import styled from "styled-components"; +export * from "../../styles"; + +export const Container = styled.div` + display: flex; + flex-direction: column; + gap: 0.5em; + align-items: center; + height: 100%; +`; + +export const Compass = styled.svg` + flex-grow: 1; + width: 100%; + aspect-ratio: 1; + overflow-clip-margin: 1px; +`; diff --git a/lib/localeStrings/en.json b/lib/localeStrings/en.json index ddeee3c1..b237b686 100644 --- a/lib/localeStrings/en.json +++ b/lib/localeStrings/en.json @@ -346,9 +346,16 @@ "m": "m/s", "NM_full": "Knots", "mi_full": "Miles per hour", - "m_full": "Meters per second" + "m_full": "Meters per second", + "north_abbr": "N", + "south_abbr": "S", + "east_abbr": "E", + "west_abbr": "W" }, "sections": { + "observations": { + "instruments": "Where are the instruments pointing at?" + }, "weather": { "preview": "Weather at the summit", "current": "Weather at the summit now", @@ -408,7 +415,11 @@ }, "current": { "windspeed": "Average windspeed", - "moon": "Tonight we will have a" + "moon": "Tonight we will have a", + "azimuth": "Azimuth", + "azimuth_angle": "Azimuth: {{angle}}", + "zenith": "Zenith", + "zenith_angle": "Zenith: {{angle}}" } } } diff --git a/lib/localeStrings/es.json b/lib/localeStrings/es.json index 239ab489..38d827e9 100644 --- a/lib/localeStrings/es.json +++ b/lib/localeStrings/es.json @@ -263,7 +263,7 @@ "description_students": "Únase para aprender cómo los astrónomos aprenden e interactúan con datos astronómicos reales. Gratis para siempre.", "description_educators": "Únase para acceder a datos y herramientas astronómicas reales para su clase. Gratis para siempre.", "sign_in_link": "¿Ya tiene una cuenta?", - "continue_with_google": "Continuar con Google", + "continue_with_google": "Continuar con Google", "continue_with_facebook": "Continuar con Facebook", "sign_up_with_email": "Registrarse con un correo" }, @@ -344,7 +344,15 @@ "email": "Correo", "email_subject": "¡Hola! Mira esta información de la web del Observatorio Rubin: {{title}}", "facebook_quote": "¡Hola! Mira esta información de la web del Observatorio Rubin: {{title}}", - "twitter_title": "¡Hola! Mira esta información de la web del Observatorio Rubin: {{title}}" + "twitter_title": "¡Hola! Mira esta información de la web del Observatorio Rubin: {{title}}" + }, + "summit_dashboard": { + "unit_localization": { + "north_abbr": "N", + "south_abbr": "S", + "east_abbr": "E", + "west_abbr": "O" + } } } -} \ No newline at end of file +} From 4e03b317847f7825c414f1bbd4c61e1cb9895dd5 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 31 Jul 2023 15:51:43 -0700 Subject: [PATCH 57/98] [C] add shutter speed and slew speed --- .eslintrc.js | 1 + components/atomic/RadialMeter/index.js | 98 +++++++++++++++++++ components/atomic/RadialMeter/styles.js | 7 ++ .../Observation/Instruments/index.js | 2 + .../Observation/Instruments/styles.js | 13 ++- .../patterns/ShutterSpeed/index.js | 38 +++++++ .../patterns/ShutterSpeed/styles.js | 10 ++ .../CurrentData/patterns/SlewSpeed/index.js | 35 +++++++ .../CurrentData/patterns/SlewSpeed/styles.js | 10 ++ helpers/index.js | 6 ++ lib/localeStrings/en.json | 10 +- 11 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 components/atomic/RadialMeter/index.js create mode 100644 components/atomic/RadialMeter/styles.js create mode 100644 components/widgets/CurrentData/patterns/ShutterSpeed/index.js create mode 100644 components/widgets/CurrentData/patterns/ShutterSpeed/styles.js create mode 100644 components/widgets/CurrentData/patterns/SlewSpeed/index.js create mode 100644 components/widgets/CurrentData/patterns/SlewSpeed/styles.js diff --git a/.eslintrc.js b/.eslintrc.js index 62db335d..94955577 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -87,6 +87,7 @@ module.exports = { "prefer-const": 2, "react-hooks/rules-of-hooks": "error", "react-hooks/exhaustive-deps": "warn", + "react/no-unknown-property": ["error", { ignore: ["transform-origin"] }], "react/react-in-jsx-scope": 0, "space-before-function-paren": 0, "spaced-comment": 2, diff --git a/components/atomic/RadialMeter/index.js b/components/atomic/RadialMeter/index.js new file mode 100644 index 00000000..64bb1c68 --- /dev/null +++ b/components/atomic/RadialMeter/index.js @@ -0,0 +1,98 @@ +import PropTypes from "prop-types"; +import * as Styled from "./styles"; +import { arrayRange } from "@/helpers"; + +const RadialMeter = ({ min, max, value, text, step = 1, labelledById }) => { + const width = 100; + const height = width; + + const baseRotation = 135; + const range = arrayRange(min, max, step); + const degreeStep = 270 / (range.length - 1); + + return ( + + + + + + + + + + + + + + {range.map((v, i) => ( + + ))} + + + + {range.map((v) => v)} + + + + ); +}; + +RadialMeter.displayName = "Atomic.RadialMeter"; + +RadialMeter.propTypes = { + min: PropTypes.number.isRequired, + max: PropTypes.number.isRequired, + value: PropTypes.number.isRequired, + text: PropTypes.string.isRequired, + step: PropTypes.number, + labelledById: PropTypes.string, +}; + +export default RadialMeter; + +; diff --git a/components/atomic/RadialMeter/styles.js b/components/atomic/RadialMeter/styles.js new file mode 100644 index 00000000..77f652ed --- /dev/null +++ b/components/atomic/RadialMeter/styles.js @@ -0,0 +1,7 @@ +import styled from "styled-components"; + +export const Meter = styled.svg` + width: 100%; + aspect-ratio: 1; + overflow-clip-margin: 1px; +`; diff --git a/components/dynamic/SummitData/Observation/Instruments/index.js b/components/dynamic/SummitData/Observation/Instruments/index.js index c547bff8..ffdfde2b 100644 --- a/components/dynamic/SummitData/Observation/Instruments/index.js +++ b/components/dynamic/SummitData/Observation/Instruments/index.js @@ -19,6 +19,8 @@ const Instruments = ({ azimuth, zenith }) => { + + ); diff --git a/components/dynamic/SummitData/Observation/Instruments/styles.js b/components/dynamic/SummitData/Observation/Instruments/styles.js index 271954cc..d98f8556 100644 --- a/components/dynamic/SummitData/Observation/Instruments/styles.js +++ b/components/dynamic/SummitData/Observation/Instruments/styles.js @@ -2,6 +2,8 @@ import styled from "styled-components"; import WidgetBackground from "@/components/atomic/WidgetBackground"; import Azimuth from "@/components/widgets/CurrentData/patterns/Azimuth"; import Zenith from "@/components/widgets/CurrentData/patterns/Zenith"; +import Slew from "@/components/widgets/CurrentData/patterns/SlewSpeed"; +import Shutter from "@/components/widgets/CurrentData/patterns/ShutterSpeed"; import { BREAK_PHABLET_MIN } from "@/styles/globalStyles"; export const InstrumentsLayout = styled(WidgetBackground)` @@ -12,6 +14,7 @@ export const InstrumentsLayout = styled(WidgetBackground)` display: grid; grid-template: var(--instrument-layout); grid-column: 1/-1; + gap: 0.5em; @media screen and (min-width: ${BREAK_PHABLET_MIN}) { --instrument-columns: 2fr 2fr 1fr; @@ -22,10 +25,16 @@ export const InstrumentsLayout = styled(WidgetBackground)` export const BigAzimuth = styled(Azimuth)` grid-area: azimuth; - aspect-ratio: 1; `; export const BigZenith = styled(Zenith)` grid-area: zenith; - aspect-ratio: 1; +`; + +export const SlewSpeed = styled(Slew)` + grid-area: slew; +`; + +export const ShutterSpeed = styled(Shutter)` + grid-area: shutter; `; diff --git a/components/widgets/CurrentData/patterns/ShutterSpeed/index.js b/components/widgets/CurrentData/patterns/ShutterSpeed/index.js new file mode 100644 index 00000000..4933611f --- /dev/null +++ b/components/widgets/CurrentData/patterns/ShutterSpeed/index.js @@ -0,0 +1,38 @@ +import PropTypes from "prop-types"; +import RadialMeter from "@/components/atomic/RadialMeter"; +import * as Styled from "./styles"; +import { useTranslation } from "react-i18next"; + +const ShutterSpeed = ({ speed = 0, className }) => { + const { t } = useTranslation(); + const shutterLabelId = "shutterLabel"; + return ( + + + {t("summit_dashboard.widgets.current.shutter_speed")} + + + + {t("summit_dashboard.unit_localization.minutes_per_shot")} + + + ); +}; + +ShutterSpeed.displayName = "Widgets.Current.ShutterSpeed"; + +ShutterSpeed.propTypes = { + speed: PropTypes.number, + className: PropTypes.string, +}; + +export default ShutterSpeed; diff --git a/components/widgets/CurrentData/patterns/ShutterSpeed/styles.js b/components/widgets/CurrentData/patterns/ShutterSpeed/styles.js new file mode 100644 index 00000000..13869606 --- /dev/null +++ b/components/widgets/CurrentData/patterns/ShutterSpeed/styles.js @@ -0,0 +1,10 @@ +import styled from "styled-components"; +export * from "../../styles"; + +export const Container = styled.div` + display: flex; + flex-direction: column; + gap: 0.5em; + align-items: center; + height: 100%; +`; diff --git a/components/widgets/CurrentData/patterns/SlewSpeed/index.js b/components/widgets/CurrentData/patterns/SlewSpeed/index.js new file mode 100644 index 00000000..ceab8cfb --- /dev/null +++ b/components/widgets/CurrentData/patterns/SlewSpeed/index.js @@ -0,0 +1,35 @@ +import PropTypes from "prop-types"; +import RadialMeter from "@/components/atomic/RadialMeter"; +import * as Styled from "./styles"; +import { useTranslation } from "react-i18next"; + +const SlewSpeed = ({ speed = 0, className }) => { + const { t } = useTranslation(); + const slewLabelId = "slewLabel"; + return ( + + + {t("summit_dashboard.widgets.current.slew_speed")} + + + + {t("summit_dashboard.unit_localization.degrees_per_second")} + + + ); +}; + +SlewSpeed.displayName = "Widgets.Current.SlewSpeed"; + +SlewSpeed.propTypes = { speed: PropTypes.number, className: PropTypes.string }; + +export default SlewSpeed; diff --git a/components/widgets/CurrentData/patterns/SlewSpeed/styles.js b/components/widgets/CurrentData/patterns/SlewSpeed/styles.js new file mode 100644 index 00000000..13869606 --- /dev/null +++ b/components/widgets/CurrentData/patterns/SlewSpeed/styles.js @@ -0,0 +1,10 @@ +import styled from "styled-components"; +export * from "../../styles"; + +export const Container = styled.div` + display: flex; + flex-direction: column; + gap: 0.5em; + align-items: center; + height: 100%; +`; diff --git a/helpers/index.js b/helpers/index.js index a97a3140..f2e136b5 100644 --- a/helpers/index.js +++ b/helpers/index.js @@ -54,3 +54,9 @@ export const timezoneOffsetLocal = (timezone) => { return localOffset - offset; }; + +export const arrayRange = (start, stop, step) => + Array.from( + { length: (stop - start) / step + 1 }, + (value, index) => start + index * step + ); diff --git a/lib/localeStrings/en.json b/lib/localeStrings/en.json index b237b686..033b4b67 100644 --- a/lib/localeStrings/en.json +++ b/lib/localeStrings/en.json @@ -350,7 +350,11 @@ "north_abbr": "N", "south_abbr": "S", "east_abbr": "E", - "west_abbr": "W" + "west_abbr": "W", + "degrees_per_second": "Degrees per second", + "degrees_per_second_withUnit": "{{unit}} degrees per second", + "minutes_per_shot": "Minutes per shot", + "minutes_per_shot_withUnit": "{{unit}} minutes per shot" }, "sections": { "observations": { @@ -419,7 +423,9 @@ "azimuth": "Azimuth", "azimuth_angle": "Azimuth: {{angle}}", "zenith": "Zenith", - "zenith_angle": "Zenith: {{angle}}" + "zenith_angle": "Zenith: {{angle}}", + "slew_speed": "Slew speed", + "shutter_speed": "Camera shutter speed" } } } From aa4cac86f51f9cbb0603e8eee32d06a5fd655a50 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Tue, 1 Aug 2023 09:19:34 -0700 Subject: [PATCH 58/98] [C] adjust padding --- components/dynamic/SummitData/Observation/Instruments/styles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dynamic/SummitData/Observation/Instruments/styles.js b/components/dynamic/SummitData/Observation/Instruments/styles.js index d98f8556..16a6d0a3 100644 --- a/components/dynamic/SummitData/Observation/Instruments/styles.js +++ b/components/dynamic/SummitData/Observation/Instruments/styles.js @@ -14,7 +14,7 @@ export const InstrumentsLayout = styled(WidgetBackground)` display: grid; grid-template: var(--instrument-layout); grid-column: 1/-1; - gap: 0.5em; + gap: var(--widget-padding); @media screen and (min-width: ${BREAK_PHABLET_MIN}) { --instrument-columns: 2fr 2fr 1fr; From 9614ffd5dc777674106de56a74f557ea7c5a9f43 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Tue, 1 Aug 2023 09:39:39 -0700 Subject: [PATCH 59/98] [C] some cleanup --- components/atomic/RadialMeter/index.js | 43 ++++++++--------- .../CurrentData/patterns/Azimuth/index.js | 48 ++++++++++--------- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/components/atomic/RadialMeter/index.js b/components/atomic/RadialMeter/index.js index 64bb1c68..6596d35e 100644 --- a/components/atomic/RadialMeter/index.js +++ b/components/atomic/RadialMeter/index.js @@ -6,10 +6,14 @@ const RadialMeter = ({ min, max, value, text, step = 1, labelledById }) => { const width = 100; const height = width; - const baseRotation = 135; + const baseRotation = -135; const range = arrayRange(min, max, step); const degreeStep = 270 / (range.length - 1); + const centerX = width / 2; + const centerY = height / 2; + const origin = `${centerX} ${centerY}`; + return ( { { /> - - + + - + {range.map((v, i) => ( ))} diff --git a/components/widgets/CurrentData/patterns/Azimuth/index.js b/components/widgets/CurrentData/patterns/Azimuth/index.js index 24639ed5..0f4be0bb 100644 --- a/components/widgets/CurrentData/patterns/Azimuth/index.js +++ b/components/widgets/CurrentData/patterns/Azimuth/index.js @@ -7,6 +7,10 @@ const Azimuth = ({ azimuth = 0, isCondensed = false, className }) => { const { t } = useTranslation(); const width = 100; const height = width; + + const centerX = width / 2; + const centerY = height / 2; + const origin = `${centerX} ${centerY}`; return ( {!isCondensed && ( @@ -22,34 +26,34 @@ const Azimuth = ({ azimuth = 0, isCondensed = false, className }) => { role="presentation" > - - + + { { {t("summit_dashboard.unit_localization.east", { context: "abbr" })} { { - - + + From d4f896b376654383481616509bb6d1456a44829a Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Tue, 1 Aug 2023 09:22:38 -0700 Subject: [PATCH 60/98] [C] fix daytime showing incorrectly between 12-1pm --- components/dynamic/SummitData/Astroweather/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index f5e62cc4..3aa57099 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -23,7 +23,7 @@ const Astroweather = () => { tomorrow.setDate(tomorrow.getDate() + 1); yesterday.setDate(yesterday.getDate() - 1); - const isAfterNoon = today.getUTCHours() - offset > 12; + const isAfterNoon = today.getUTCHours() - offset >= 12; const dates = isAfterNoon ? [today, tomorrow] : [yesterday, today]; const { phase } = getMoonIllumination(today); From e56bdcd98d1130ef9dd8afeebc6821e968e0fe2e Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 3 Aug 2023 10:12:47 -0700 Subject: [PATCH 61/98] [F] Dewpoint --- .../SummitData/Weather/Current/index.js | 7 ++-- .../dynamic/SummitData/Weather/index.js | 10 ++--- .../CurrentData/patterns/Dewpoint/index.js | 34 ++++++++++++++++ .../patterns/Precipitation/index.js | 39 ------------------- 4 files changed, 43 insertions(+), 47 deletions(-) create mode 100644 components/widgets/CurrentData/patterns/Dewpoint/index.js delete mode 100644 components/widgets/CurrentData/patterns/Precipitation/index.js diff --git a/components/dynamic/SummitData/Weather/Current/index.js b/components/dynamic/SummitData/Weather/Current/index.js index 92ddc0a7..96cd6fb1 100644 --- a/components/dynamic/SummitData/Weather/Current/index.js +++ b/components/dynamic/SummitData/Weather/Current/index.js @@ -6,7 +6,7 @@ import Loader from "@/components/atomic/Loader"; import WidgetSection from "@/components/layout/WidgetSection"; import TemperatureCurrent from "@/components/widgets/CurrentData/patterns/Temperature"; import WindspeedCurrent from "@/components/widgets/CurrentData/patterns/Windspeed"; -import PrecipitationCurrent from "@/components/widgets/CurrentData/patterns/Precipitation"; +import DewpointCurrent from "@/components/widgets/CurrentData/patterns/Dewpoint"; import { convertTemperature, convertWindspeed } from "@/helpers/converters"; const CurrentWeather = () => { @@ -30,8 +30,9 @@ const CurrentWeather = () => { ); - const { temperature0, windspeed, relativeHumidity } = currentData; + const { temperature0, windspeed, dewPoint } = currentData; const temperature = convertTemperature(temperature0, tempUnit); + const dewpoint = convertTemperature(dewPoint, tempUnit); return ( @@ -40,7 +41,7 @@ const CurrentWeather = () => { unit={windspeedUnit} windspeed={convertWindspeed(windspeed, windspeedUnit)} /> - + ); }; diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 5c3f8c4a..7940d4a9 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -3,12 +3,11 @@ import { useTranslation } from "react-i18next"; import Loader from "@/components/atomic/Loader"; import WidgetPreview from "@/components/layout/WidgetPreview"; import SummitStatusModal from "@/components/modal/SummitStatusModal"; -import PrecipitationCurrent from "@/components/widgets/CurrentData/patterns/Precipitation"; +import DewpointCurrent from "@/components/widgets/CurrentData/patterns/Dewpoint"; import TemperatureCurrent from "@/components/widgets/CurrentData/patterns/Temperature"; import { useSummitData } from "@/contexts/SummitData"; import { useWeatherUnit } from "@/contexts/WeatherUnit"; import { convertTemperature } from "@/helpers/converters"; -import DailyWeather from "./Daily"; import HourlyWeather from "./Hourly"; import CurrentWeather from "./Current"; @@ -32,8 +31,9 @@ const Weather = () => { ); - const { temperature0, relativeHumidity } = currentData; + const { temperature0, dewPoint } = currentData; const temperature = convertTemperature(temperature0, tempUnit); + const dewpoint = convertTemperature(dewPoint, tempUnit); return ( { }} > - + setModalOpen(false)}> - + {/* */} ); diff --git a/components/widgets/CurrentData/patterns/Dewpoint/index.js b/components/widgets/CurrentData/patterns/Dewpoint/index.js new file mode 100644 index 00000000..f43ec22e --- /dev/null +++ b/components/widgets/CurrentData/patterns/Dewpoint/index.js @@ -0,0 +1,34 @@ +import PropTypes from "prop-types"; +import { useTranslation } from "react-i18next"; +import { formatTemperature } from "helpers/formatters"; +import WidgetBackground from "@/components/atomic/WidgetBackground"; +import * as Styled from "../../styles"; +import { temperatureUnitType } from "@/components/shapes/units"; + +const DewpointCurrent = ({ dewpoint = 0, unit = "celsius" }) => { + const { + t, + i18n: { language = "en" }, + } = useTranslation(); + + return ( + + Dewpoint + + {formatTemperature(dewpoint, language, unit)} + + + {t(`summit_dashboard.unit_localization.${unit}`)} + + + ); +}; + +DewpointCurrent.displayName = "Widgets.Current.Dewpoint"; + +DewpointCurrent.propTypes = { + dewpoint: PropTypes.number.isRequired, + unit: temperatureUnitType, +}; + +export default DewpointCurrent; diff --git a/components/widgets/CurrentData/patterns/Precipitation/index.js b/components/widgets/CurrentData/patterns/Precipitation/index.js deleted file mode 100644 index a014baca..00000000 --- a/components/widgets/CurrentData/patterns/Precipitation/index.js +++ /dev/null @@ -1,39 +0,0 @@ -import PropTypes from "prop-types"; -import { useTranslation } from "react-i18next"; -import { formatPercent } from "helpers/formatters"; -import WidgetBackground from "@/components/atomic/WidgetBackground"; -import * as Styled from "../../styles"; - -const PrecipitationCurrent = ({ precipitation = 0, humidity = 0 }) => { - const { t, i18n } = useTranslation(); - const { language = "en" } = i18n; - - return ( - - - - {t("summit_dashboard.unit_localization.label_precipitation")} - - - - - {t("summit_dashboard.unit_localization.label_humidity")} - - - ); -}; - -PrecipitationCurrent.displayName = "Widgets.Current.Precipitation"; - -PrecipitationCurrent.propTypes = { - precipitation: PropTypes.number, - humidity: PropTypes.number, -}; - -export default PrecipitationCurrent; From be493fc13f4df9573f1425cf7da63222ecb16dc6 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 3 Aug 2023 11:10:11 -0700 Subject: [PATCH 62/98] [C] Finalize dewpoint --- .../SummitData/Astroweather/Forecast/index.js | 22 +++++++++ .../SummitData/Observation/Related/index.js | 46 +++++++++++++++++++ .../dynamic/SummitData/Observation/index.js | 2 + lib/localeStrings/en.json | 1 + 4 files changed, 71 insertions(+) create mode 100644 components/dynamic/SummitData/Observation/Related/index.js diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js index a108413d..8ddc5064 100644 --- a/components/dynamic/SummitData/Astroweather/Forecast/index.js +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -1,5 +1,8 @@ import { useState } from "react"; import { useTranslation } from "react-i18next"; +import { useWeatherUnit } from "@/contexts/WeatherUnit"; +import { useSummitData } from "@/contexts/SummitData"; +import { convertTemperature } from "@/helpers/converters"; import { getMoonIllumination, getMoonPosition, @@ -11,16 +14,31 @@ import MoonRise from "@/components/widgets/CurrentData/patterns/MoonRise"; import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; import DailyMoonrise from "@/components/widgets/DailyData/patterns/Moonrise"; import { SectionSubHeader } from "@/components/layout/WidgetSection/styles"; +import Loader from "@/components/atomic/Loader"; +import DewpointCurrent from "@/components/widgets/CurrentData/patterns/Dewpoint"; const ForecastAstroweather = () => { const { t } = useTranslation(); const [isOpen, setOpen] = useState(true); + const [{ tempUnit }] = useWeatherUnit(); + const { + currentData, + loading: { currentData: loading }, + } = useSummitData(); + const sectionProps = { title: t("summit_dashboard.sections.astro.title"), onToggleCallback: (value) => setOpen(value), isOpen, }; + if (loading || !currentData) + return ( + + + + ); + const moonriseId = "moonriseTitle"; const now = new Date(); @@ -44,6 +62,9 @@ const ForecastAstroweather = () => { }; }); + const { dewPoint } = currentData; + const dewpoint = convertTemperature(dewPoint, tempUnit); + return ( @@ -51,6 +72,7 @@ const ForecastAstroweather = () => { rise={forecast[0].rise < now ? forecast[1].rise : forecast[0].rise} set={forecast[0].set < now ? forecast[1].set : forecast[0].set} /> + {t("summit_dashboard.sections.astro.moonrise.forecast")} diff --git a/components/dynamic/SummitData/Observation/Related/index.js b/components/dynamic/SummitData/Observation/Related/index.js new file mode 100644 index 00000000..8fd5057a --- /dev/null +++ b/components/dynamic/SummitData/Observation/Related/index.js @@ -0,0 +1,46 @@ +import { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { useWeatherUnit } from "@/contexts/WeatherUnit"; +import { useSummitData } from "@/contexts/SummitData"; +import { convertTemperature } from "@/helpers/converters"; +import Loader from "@/components/atomic/Loader"; +import WidgetSection from "@/components/layout/WidgetSection"; +import DewpointCurrent from "@/components/widgets/CurrentData/patterns/Dewpoint"; + +const Related = () => { + const { t } = useTranslation(); + const [isOpen, setOpen] = useState(true); + const [{ tempUnit }] = useWeatherUnit(); + const { + currentData, + loading: { currentData: loading }, + } = useSummitData(); + + const sectionProps = { + title: t("summit_dashboard.sections.observations.related"), + onToggleCallback: (value) => setOpen(value), + isOpen, + }; + + if (loading || !currentData) + return ( + + + + ); + + const { dewPoint } = currentData; + const dewpoint = convertTemperature(dewPoint, tempUnit); + + return ( + + + + ); +}; + +Related.propTypes = {}; + +Related.displayName = "Dynamic.Observation.Related"; + +export default Related; diff --git a/components/dynamic/SummitData/Observation/index.js b/components/dynamic/SummitData/Observation/index.js index 4d36143a..6bffd23c 100644 --- a/components/dynamic/SummitData/Observation/index.js +++ b/components/dynamic/SummitData/Observation/index.js @@ -7,6 +7,7 @@ import Zenith from "@/components/widgets/CurrentData/patterns/Zenith"; import Instruments from "./Instruments"; import * as Styled from "./styles"; +import Related from "./Related"; const Observation = () => { const [isModalOpen, setModalOpen] = useState(false); @@ -25,6 +26,7 @@ const Observation = () => { setModalOpen(false)}> + diff --git a/lib/localeStrings/en.json b/lib/localeStrings/en.json index 033b4b67..b393d608 100644 --- a/lib/localeStrings/en.json +++ b/lib/localeStrings/en.json @@ -358,6 +358,7 @@ }, "sections": { "observations": { + "related": "Observations-related weather", "instruments": "Where are the instruments pointing at?" }, "weather": { From a2db59ee060f60536ba2d87918ba11fac4822714 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 9 Aug 2023 14:22:49 -0700 Subject: [PATCH 63/98] [C] SVG cross browser compat --- components/atomic/RadialMeter/index.js | 40 ++++++++++--------- components/charts/XAxis/index.js | 2 +- components/charts/XAxis/styles.js | 2 - .../CurrentData/patterns/Azimuth/index.js | 8 ++-- .../CurrentData/patterns/Zenith/index.js | 2 +- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/components/atomic/RadialMeter/index.js b/components/atomic/RadialMeter/index.js index 6596d35e..8821c59b 100644 --- a/components/atomic/RadialMeter/index.js +++ b/components/atomic/RadialMeter/index.js @@ -27,9 +27,6 @@ const RadialMeter = ({ min, max, value, text, step = 1, labelledById }) => { viewBox={`0 0 ${width} ${height}`} aria-labelledby={labelledById} > - - - { fill="none" strokeWidth="4" transform-origin={origin} - transform={`rotate(${value * degreeStep + baseRotation})`} + style={{ + transform: `rotate(${value * degreeStep + baseRotation}deg)`, + }} /> - + {range.map((v, i) => ( - + style={{ + transform: `rotate(${i * degreeStep + baseRotation}deg)`, + }} + key={v} + > + + {v} + + + ))} - - - {range.map((v) => v)} - - ); }; diff --git a/components/charts/XAxis/index.js b/components/charts/XAxis/index.js index 2f6d0d25..2b585cbb 100644 --- a/components/charts/XAxis/index.js +++ b/components/charts/XAxis/index.js @@ -33,7 +33,7 @@ const XAxis = ({ {tickMap.map(({ label, position }, i) => ( - + {label} diff --git a/components/charts/XAxis/styles.js b/components/charts/XAxis/styles.js index 51006180..e249d484 100644 --- a/components/charts/XAxis/styles.js +++ b/components/charts/XAxis/styles.js @@ -11,7 +11,5 @@ export const Tick = styled.line` export const TickLabel = styled.text` font-size: 14px; - alignment-baseline: hanging; - dominant-baseline: hanging; text-anchor: middle; `; diff --git a/components/widgets/CurrentData/patterns/Azimuth/index.js b/components/widgets/CurrentData/patterns/Azimuth/index.js index 0f4be0bb..7cfc73f1 100644 --- a/components/widgets/CurrentData/patterns/Azimuth/index.js +++ b/components/widgets/CurrentData/patterns/Azimuth/index.js @@ -33,14 +33,14 @@ const Azimuth = ({ azimuth = 0, isCondensed = false, className }) => { y1={centerY} y2={centerY} transform-origin={origin} - transform="rotate(45)" + style={{ transform: "rotate(45deg)" }} /> { y1={centerY} y2={centerY} transform-origin={origin} - transform="rotate(-45)" + style={{ transform: "rotate(-45deg)" }} /> @@ -101,7 +101,7 @@ const Azimuth = ({ azimuth = 0, isCondensed = false, className }) => { fill="none" strokeWidth="4" transform-origin={origin} - transform={`rotate(${azimuth})`} + style={{ transform: `rotate(${azimuth}deg)` }} /> diff --git a/components/widgets/CurrentData/patterns/Zenith/index.js b/components/widgets/CurrentData/patterns/Zenith/index.js index 34c4f6f6..d822a590 100644 --- a/components/widgets/CurrentData/patterns/Zenith/index.js +++ b/components/widgets/CurrentData/patterns/Zenith/index.js @@ -31,7 +31,7 @@ const Zenith = ({ zenith = 0, isCondensed = false, className }) => { strokeMiterlimit="10" strokeWidth=".124" transform-origin={`${width / 2} ${height / 2 - 1.5}`} - transform={`rotate(${rotation})`} + style={{ transform: `rotate(${rotation}deg)` }} > From 002575cfd115410371eb72462f17b0a63b46e685 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 7 Aug 2023 15:12:20 -0700 Subject: [PATCH 64/98] [C] try to set up demo --- .../dynamic/SummitData/Weather/index.js | 4 +- contexts/SummitData.js | 56 +++++++------------ lib/api/efd.js | 20 ++++++- pages/api/efd/[type].js | 38 ------------- pages/api/efd/index.js | 35 ++++++++++++ 5 files changed, 75 insertions(+), 78 deletions(-) delete mode 100644 pages/api/efd/[type].js create mode 100644 pages/api/efd/index.js diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 7940d4a9..9ce03a6a 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -16,8 +16,8 @@ const Weather = () => { const [isModalOpen, setModalOpen] = useState(false); const [{ tempUnit }] = useWeatherUnit(); const { - currentData, - loading: { currentData: loading }, + data: { current: currentData }, + isLoading: loading, } = useSummitData(); const previewProps = { diff --git a/contexts/SummitData.js b/contexts/SummitData.js index 461889b4..c0128af5 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -5,45 +5,31 @@ import useEfd from "@/lib/api/efd"; export const SummitDataContext = createContext({}); export const SummitDataProvider = ({ children }) => { - const { - data: currentData, - isLoading: currentIsLoading, - isError: currentIsError, - } = useEfd("current"); - const { - data: hourlyData, - isLoading: hourlyIsLoading, - isError: hourlyIsError, - } = useEfd("hourly"); - const { - data: dailyData, - isLoading: dailyIsLoading, - isError: dailyIsError, - } = useEfd("daily"); + // const { + // data: currentData, + // isLoading: currentIsLoading, + // isError: currentIsError, + // } = useEfd("current"); + // const { + // data: hourlyData, + // isLoading: hourlyIsLoading, + // isError: hourlyIsError, + // } = useEfd("hourly"); + // const { + // data: dailyData, + // isLoading: dailyIsLoading, + // isError: dailyIsError, + // } = useEfd("daily"); + + const { data = {}, isLoading = true, isError = false } = useEfd(); const value = useMemo( () => ({ - currentData, - hourlyData, - dailyData, - error: currentIsError || hourlyIsError || dailyIsError, - loading: { - currentData: currentIsLoading, - hourlyData: hourlyIsLoading, - dailyData: dailyIsLoading, - }, + data, + isLoading, + isError, }), - [ - currentData, - hourlyData, - dailyData, - currentIsLoading, - hourlyIsLoading, - dailyIsLoading, - currentIsError, - hourlyIsError, - dailyIsError, - ] + [data, isLoading, isError] ); return ( diff --git a/lib/api/efd.js b/lib/api/efd.js index 37f203bb..9064b63b 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -1,9 +1,23 @@ import useSWR from "swr"; -const fetcher = (url) => fetch(url).then((res) => res.json()); +const fetcher = (url) => + fetch(url, { + mode: "no-cors", + }).then((res) => { + return res; + }); -export default function useEfd(type) { - const { data, error } = useSWR(`/api/efd/${type}`, fetcher); +export default function useEfd() { + const url = process.env.EFD_URL; + + const { data, error, isLoading } = useSWR(url, fetcher); + + if (error) { + console.info("ERROR"); + } + if (isLoading) { + console.info("LOADING"); + } return { data, diff --git a/pages/api/efd/[type].js b/pages/api/efd/[type].js deleted file mode 100644 index c400ef29..00000000 --- a/pages/api/efd/[type].js +++ /dev/null @@ -1,38 +0,0 @@ -import { InfluxDB } from "@influxdata/influxdb-client"; -import { - currentWeather, - dailyWeather, - hourlyWeather, -} from "@/lib/api/queries/weather"; - -const types = { - current: currentWeather, - hourly: hourlyWeather, - daily: dailyWeather, -}; - -export default function handler(req, res) { - const url = process.env.EFD_URL; - const bucket = process.env.EFD_BUCKET; - const token = process.env.EFD_TOKEN; - - const influxDB = new InfluxDB({ url, token }); - const queryApi = influxDB.getQueryApi(""); - - const { type } = req.query; - const query = types[type]; - - const data = []; - - queryApi.queryRows(query(bucket), { - next(row, tableMeta) { - data.push(tableMeta.toObject(row)); - }, - error(error) { - return res.status(405).json(error); - }, - complete() { - return res.status(200).json(type === "current" ? data[0] : data); - }, - }); -} diff --git a/pages/api/efd/index.js b/pages/api/efd/index.js new file mode 100644 index 00000000..31b550c5 --- /dev/null +++ b/pages/api/efd/index.js @@ -0,0 +1,35 @@ +export default async function handler(req, res) { + const url = process.env.EFD_URL; + const data = await fetch(url); + const { status } = data; + + if (status !== 200) { + res.status(status).json("An error occurred"); + } + + const response = await data.json(); + + return res.status(200).json(response); + // const bucket = process.env.EFD_BUCKET; + // const token = process.env.EFD_TOKEN; + + // const influxDB = new InfluxDB({ url, token }); + // const queryApi = influxDB.getQueryApi(""); + + // const { type } = req.query; + // const query = types[type]; + + // const data = []; + + // queryApi.queryRows(query(bucket), { + // next(row, tableMeta) { + // data.push(tableMeta.toObject(row)); + // }, + // error(error) { + // return res.status(405).json(error); + // }, + // complete() { + // return res.status(200).json(type === "current" ? data[0] : data); + // }, + // }); +} From 3f2b3ceb5be83db0d9450c48f204fa75fa010fa9 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 7 Aug 2023 15:51:24 -0700 Subject: [PATCH 65/98] [C] try other fixes --- lib/api/efd.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/api/efd.js b/lib/api/efd.js index 9064b63b..27117a2c 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -3,12 +3,22 @@ import useSWR from "swr"; const fetcher = (url) => fetch(url, { mode: "no-cors", - }).then((res) => { - return res; - }); + headers: { "Content-Type": "application/json" }, + }) + .then((res) => { + return res; + }) + .error(() => { + console.log("errorrr"); + }) + .finally(() => { + console.log("finally"); + }); export default function useEfd() { - const url = process.env.EFD_URL; + const url = process.env.NEXT_PUBLIC_EFD_URL; + + console.log({ url }); const { data, error, isLoading } = useSWR(url, fetcher); From 61fbc5202c0c53ca306f47f8ba093c58b17e7cc2 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Tue, 8 Aug 2023 09:22:13 -0700 Subject: [PATCH 66/98] [C] Redis setup complete --- .../SummitData/Weather/Current/index.js | 8 ++--- .../dynamic/SummitData/Weather/Daily/index.js | 8 ++--- .../SummitData/Weather/Hourly/index.js | 8 ++--- .../dynamic/SummitData/Weather/index.js | 8 ++--- contexts/SummitData.js | 22 ++---------- helpers/converters.js | 5 +-- lib/api/efd.js | 28 ++++----------- pages/api/efd/index.js | 35 ------------------- 8 files changed, 28 insertions(+), 94 deletions(-) delete mode 100644 pages/api/efd/index.js diff --git a/components/dynamic/SummitData/Weather/Current/index.js b/components/dynamic/SummitData/Weather/Current/index.js index 96cd6fb1..2ba9a122 100644 --- a/components/dynamic/SummitData/Weather/Current/index.js +++ b/components/dynamic/SummitData/Weather/Current/index.js @@ -14,8 +14,8 @@ const CurrentWeather = () => { const [isOpen, setOpen] = useState(true); const [{ tempUnit, windspeedUnit }] = useWeatherUnit(); const { - currentData, - loading: { currentData: loading }, + data: { current }, + isLoading, } = useSummitData(); const sectionProps = { title: t("summit_dashboard.sections.weather.current"), @@ -23,14 +23,14 @@ const CurrentWeather = () => { isOpen, }; - if (loading || !currentData) + if (isLoading || !current) return ( ); - const { temperature0, windspeed, dewPoint } = currentData; + const { temperature0, windspeed, dewPoint } = current; const temperature = convertTemperature(temperature0, tempUnit); const dewpoint = convertTemperature(dewPoint, tempUnit); diff --git a/components/dynamic/SummitData/Weather/Daily/index.js b/components/dynamic/SummitData/Weather/Daily/index.js index 0031e792..535ee4f6 100644 --- a/components/dynamic/SummitData/Weather/Daily/index.js +++ b/components/dynamic/SummitData/Weather/Daily/index.js @@ -12,8 +12,8 @@ const DailyWeather = () => { const [isOpen, setOpen] = useState(true); const [{ tempUnit }] = useWeatherUnit(); const { - dailyData, - loading: { dailyData: loading }, + data: { daily }, + isLoading, } = useSummitData(); const sectionProps = { title: t("summit_dashboard.sections.weather.daily", { @@ -23,14 +23,14 @@ const DailyWeather = () => { isOpen, }; - if (loading || !dailyData) + if (isLoading || !daily) return ( ); - const temperatureData = dailyData + const temperatureData = daily .slice(0, -1) .map(({ _time, temperature0_max: max, temperature0_min: min }) => { return { diff --git a/components/dynamic/SummitData/Weather/Hourly/index.js b/components/dynamic/SummitData/Weather/Hourly/index.js index be243285..b02e2059 100644 --- a/components/dynamic/SummitData/Weather/Hourly/index.js +++ b/components/dynamic/SummitData/Weather/Hourly/index.js @@ -12,8 +12,8 @@ const HourlyWeather = () => { const [isOpen, setOpen] = useState(true); const [{ windspeedUnit }] = useWeatherUnit(); const { - hourlyData, - loading: { hourlyData: loading }, + data: { hourly }, + isLoading, } = useSummitData(); const sectionProps = { title: t("summit_dashboard.sections.weather.hourly"), @@ -21,14 +21,14 @@ const HourlyWeather = () => { isOpen, }; - if (loading || !hourlyData) + if (isLoading || !hourly) return ( ); - const windspeedData = hourlyData + const windspeedData = hourly .slice(0, -1) .map(({ _time, direction_mean: direction, speed_mean: windspeed }) => { return { diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 9ce03a6a..e6ac8947 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -16,22 +16,22 @@ const Weather = () => { const [isModalOpen, setModalOpen] = useState(false); const [{ tempUnit }] = useWeatherUnit(); const { - data: { current: currentData }, - isLoading: loading, + data: { current }, + isLoading, } = useSummitData(); const previewProps = { title: t("summit_dashboard.sections.weather.preview"), }; - if (loading || !currentData) + if (isLoading || !current) return ( ); - const { temperature0, dewPoint } = currentData; + const { temperature0, dewPoint } = current; const temperature = convertTemperature(temperature0, tempUnit); const dewpoint = convertTemperature(dewPoint, tempUnit); diff --git a/contexts/SummitData.js b/contexts/SummitData.js index c0128af5..1c129b52 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -5,31 +5,15 @@ import useEfd from "@/lib/api/efd"; export const SummitDataContext = createContext({}); export const SummitDataProvider = ({ children }) => { - // const { - // data: currentData, - // isLoading: currentIsLoading, - // isError: currentIsError, - // } = useEfd("current"); - // const { - // data: hourlyData, - // isLoading: hourlyIsLoading, - // isError: hourlyIsError, - // } = useEfd("hourly"); - // const { - // data: dailyData, - // isLoading: dailyIsLoading, - // isError: dailyIsError, - // } = useEfd("daily"); - - const { data = {}, isLoading = true, isError = false } = useEfd(); + const { data = {}, isLoading, error } = useEfd(); const value = useMemo( () => ({ data, isLoading, - isError, + error, }), - [data, isLoading, isError] + [data, isLoading, error] ); return ( diff --git a/helpers/converters.js b/helpers/converters.js index 5e2cb0a3..2796cdee 100644 --- a/helpers/converters.js +++ b/helpers/converters.js @@ -2,10 +2,11 @@ import convert from "convert"; import { defaultTempUnit, defaultWindspeedUnit } from "@/contexts/WeatherUnit"; export const convertTemperature = (value, toUnit = defaultTempUnit) => - convert(value, defaultTempUnit).to(toUnit); + convert(Number(value), defaultTempUnit).to(toUnit); export const convertWindspeed = (value, toUnit = defaultWindspeedUnit) => { - const adjustedValue = toUnit !== "m" ? value * 60 * 60 : value; + const numValue = Number(value); + const adjustedValue = toUnit !== "m" ? numValue * 60 * 60 : numValue; return convert(adjustedValue, defaultWindspeedUnit).to(toUnit); }; diff --git a/lib/api/efd.js b/lib/api/efd.js index 27117a2c..f034165b 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -2,36 +2,20 @@ import useSWR from "swr"; const fetcher = (url) => fetch(url, { - mode: "no-cors", + method: "GET", headers: { "Content-Type": "application/json" }, - }) - .then((res) => { - return res; - }) - .error(() => { - console.log("errorrr"); - }) - .finally(() => { - console.log("finally"); - }); + }).then((res) => { + return res.json(); + }); export default function useEfd() { const url = process.env.NEXT_PUBLIC_EFD_URL; - console.log({ url }); - const { data, error, isLoading } = useSWR(url, fetcher); - if (error) { - console.info("ERROR"); - } - if (isLoading) { - console.info("LOADING"); - } - return { data, - isLoading: !error && !data, - isError: error, + isLoading, + error, }; } diff --git a/pages/api/efd/index.js b/pages/api/efd/index.js deleted file mode 100644 index 31b550c5..00000000 --- a/pages/api/efd/index.js +++ /dev/null @@ -1,35 +0,0 @@ -export default async function handler(req, res) { - const url = process.env.EFD_URL; - const data = await fetch(url); - const { status } = data; - - if (status !== 200) { - res.status(status).json("An error occurred"); - } - - const response = await data.json(); - - return res.status(200).json(response); - // const bucket = process.env.EFD_BUCKET; - // const token = process.env.EFD_TOKEN; - - // const influxDB = new InfluxDB({ url, token }); - // const queryApi = influxDB.getQueryApi(""); - - // const { type } = req.query; - // const query = types[type]; - - // const data = []; - - // queryApi.queryRows(query(bucket), { - // next(row, tableMeta) { - // data.push(tableMeta.toObject(row)); - // }, - // error(error) { - // return res.status(405).json(error); - // }, - // complete() { - // return res.status(200).json(type === "current" ? data[0] : data); - // }, - // }); -} From 202ed194694c3161be8cdd191440032be98cb329 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Tue, 8 Aug 2023 16:14:59 -0700 Subject: [PATCH 67/98] [C] remove Number constructors --- helpers/converters.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/helpers/converters.js b/helpers/converters.js index 2796cdee..5e2cb0a3 100644 --- a/helpers/converters.js +++ b/helpers/converters.js @@ -2,11 +2,10 @@ import convert from "convert"; import { defaultTempUnit, defaultWindspeedUnit } from "@/contexts/WeatherUnit"; export const convertTemperature = (value, toUnit = defaultTempUnit) => - convert(Number(value), defaultTempUnit).to(toUnit); + convert(value, defaultTempUnit).to(toUnit); export const convertWindspeed = (value, toUnit = defaultWindspeedUnit) => { - const numValue = Number(value); - const adjustedValue = toUnit !== "m" ? numValue * 60 * 60 : numValue; + const adjustedValue = toUnit !== "m" ? value * 60 * 60 : value; return convert(adjustedValue, defaultWindspeedUnit).to(toUnit); }; From d45af51d6623397eb7c88fa348e587b8dc61cd1a Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 10 Aug 2023 11:28:34 -0700 Subject: [PATCH 68/98] [C] update components to use EFD mappings --- components/atomic/ScrollableHorizontalWrapper/styles.js | 1 + .../dynamic/SummitData/Astroweather/Forecast/index.js | 8 ++++---- .../dynamic/SummitData/Observation/Related/index.js | 8 ++++---- components/dynamic/SummitData/Weather/index.js | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/components/atomic/ScrollableHorizontalWrapper/styles.js b/components/atomic/ScrollableHorizontalWrapper/styles.js index 96eaf5c3..e0ab5f50 100644 --- a/components/atomic/ScrollableHorizontalWrapper/styles.js +++ b/components/atomic/ScrollableHorizontalWrapper/styles.js @@ -4,6 +4,7 @@ export const ScrollableHorizontalWrapper = styled.div` width: 100%; height: 100%; overflow-x: auto; + overflow-y: hidden; scrollbar-color: var(--white, #fff) rgba(255, 255, 255, 20%); scrollbar-width: thin; diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js index 8ddc5064..7e15d729 100644 --- a/components/dynamic/SummitData/Astroweather/Forecast/index.js +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -22,8 +22,8 @@ const ForecastAstroweather = () => { const [isOpen, setOpen] = useState(true); const [{ tempUnit }] = useWeatherUnit(); const { - currentData, - loading: { currentData: loading }, + data: { current }, + isLoading, } = useSummitData(); const sectionProps = { @@ -32,7 +32,7 @@ const ForecastAstroweather = () => { isOpen, }; - if (loading || !currentData) + if (isLoading || !current) return ( @@ -62,7 +62,7 @@ const ForecastAstroweather = () => { }; }); - const { dewPoint } = currentData; + const { dewPoint } = current; const dewpoint = convertTemperature(dewPoint, tempUnit); return ( diff --git a/components/dynamic/SummitData/Observation/Related/index.js b/components/dynamic/SummitData/Observation/Related/index.js index 8fd5057a..ec45e305 100644 --- a/components/dynamic/SummitData/Observation/Related/index.js +++ b/components/dynamic/SummitData/Observation/Related/index.js @@ -12,8 +12,8 @@ const Related = () => { const [isOpen, setOpen] = useState(true); const [{ tempUnit }] = useWeatherUnit(); const { - currentData, - loading: { currentData: loading }, + data: { current }, + isLoading, } = useSummitData(); const sectionProps = { @@ -22,14 +22,14 @@ const Related = () => { isOpen, }; - if (loading || !currentData) + if (isLoading || !current) return ( ); - const { dewPoint } = currentData; + const { dewPoint } = current; const dewpoint = convertTemperature(dewPoint, tempUnit); return ( diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index e6ac8947..5916fb21 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -10,6 +10,7 @@ import { useWeatherUnit } from "@/contexts/WeatherUnit"; import { convertTemperature } from "@/helpers/converters"; import HourlyWeather from "./Hourly"; import CurrentWeather from "./Current"; +import DailyWeather from "./Daily"; const Weather = () => { const { t } = useTranslation(); @@ -47,7 +48,7 @@ const Weather = () => { setModalOpen(false)}> - {/* */} + ); From bbf26540ec0b80dea23d71b164ef422ae2925965 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Fri, 4 Aug 2023 11:32:54 -0700 Subject: [PATCH 69/98] [C] move astroweather calcs to endpoint --- .../SummitData/Astroweather/Current/index.js | 26 +++---- .../SummitData/Astroweather/Forecast/index.js | 32 ++------- .../dynamic/SummitData/Astroweather/index.js | 35 +++------- .../CurrentData/patterns/Daylight/index.js | 51 ++++++++------ .../CurrentData/patterns/MoonRise/index.js | 27 ++++--- .../DailyData/patterns/Moonrise/Time/index.js | 10 ++- .../DailyData/patterns/Moonrise/index.js | 16 +++-- contexts/SummitData.js | 52 ++++++++++++-- lib/api/astroweather.js | 15 ++++ lib/suncalc.js | 2 +- pages/api/astroweather.js | 70 +++++++++++++++++++ 11 files changed, 233 insertions(+), 103 deletions(-) create mode 100644 lib/api/astroweather.js create mode 100644 pages/api/astroweather.js diff --git a/components/dynamic/SummitData/Astroweather/Current/index.js b/components/dynamic/SummitData/Astroweather/Current/index.js index 112b18d0..6cec0474 100644 --- a/components/dynamic/SummitData/Astroweather/Current/index.js +++ b/components/dynamic/SummitData/Astroweather/Current/index.js @@ -1,12 +1,10 @@ -import PropTypes from "prop-types"; import { useState } from "react"; import { useTranslation } from "react-i18next"; +import { useSummitData } from "@/contexts/SummitData"; import WidgetSection from "@/components/layout/WidgetSection"; -import Daylight, { - DaylightDataShape, -} from "@/components/widgets/CurrentData/patterns/Daylight"; +import Daylight from "@/components/widgets/CurrentData/patterns/Daylight"; -const CurrentAstroweather = ({ data }) => { +const CurrentAstroweather = () => { const { t } = useTranslation(); const [isOpen, setOpen] = useState(true); const sectionProps = { @@ -14,22 +12,24 @@ const CurrentAstroweather = ({ data }) => { onToggleCallback: (value) => setOpen(value), isOpen, }; + const { + astroweatherData, + loading: { astroweatherData: loading }, + } = useSummitData(); - const { daylight } = data; + if (loading) { + return null; + } + + const { solarTimes: times } = astroweatherData; return ( - + ); }; CurrentAstroweather.displayName = "Dynamic.Astroweather.Current"; -CurrentAstroweather.propTypes = { - data: PropTypes.shape({ - daylight: PropTypes.shape(DaylightDataShape), - }), -}; - export default CurrentAstroweather; diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js index 7e15d729..e183dd6d 100644 --- a/components/dynamic/SummitData/Astroweather/Forecast/index.js +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -39,44 +39,26 @@ const ForecastAstroweather = () => { ); + // const { lunarPhase: phase, lunarTimes: times } = astroweatherData; + const moonriseId = "moonriseTitle"; const now = new Date(); - const { phase } = getMoonIllumination(now); - - const conversion = 180 / Math.PI; - const getAzimuth = (time) => - getMoonPosition(time, lat, long).azimuth * conversion + 180; - - const forecast = Array.apply(null, Array(14)).map((value, i) => { - const day = new Date(); - day.setDate(now.getDate() + i); - const { rise, set } = getMoonTimes(day, lat, long); - - return { - day: day.getDay(), - rise, - set, - azimuthRise: rise ? getAzimuth(rise) : null, - azimuthSet: set ? getAzimuth(set) : null, - }; - }); - const { dewPoint } = current; const dewpoint = convertTemperature(dewPoint, tempUnit); return ( - + {/* + rise={times[0].rise < now ? times[1].rise : times[0].rise} + set={times[0].set < now ? times[1].set : times[0].set} + /> */} {t("summit_dashboard.sections.astro.moonrise.forecast")} - + {/* */} ); }; diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index 3aa57099..050c01c4 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -1,39 +1,26 @@ import { useState } from "react"; import { useTranslation } from "react-i18next"; -import { getMoonIllumination, getTimes } from "@/lib/suncalc"; +import { useSummitData } from "@/contexts/SummitData"; import WidgetPreview from "@/components/layout/WidgetPreview"; import SummitStatusModal from "@/components/modal/SummitStatusModal"; import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; import Daylight from "@/components/widgets/CurrentData/patterns/Daylight"; -import { altitude, lat, long, timezone } from "@/lib/observatory"; -import { timezoneOffset, timezoneOffsetLocal } from "@/helpers"; import CurrentAstroweather from "./Current"; import ForecastAstroweather from "./Forecast"; const Astroweather = () => { const { t } = useTranslation(); + const { + astroweatherData, + loading: { astroweatherData: loading }, + } = useSummitData(); const [isModalOpen, setModalOpen] = useState(false); - const offset = timezoneOffset(timezone); - const localOffset = timezoneOffsetLocal(timezone); + if (loading) { + return null; + } - const today = new Date(); - const tomorrow = new Date(today); - const yesterday = new Date(today); - tomorrow.setDate(tomorrow.getDate() + 1); - yesterday.setDate(yesterday.getDate() - 1); - - const isAfterNoon = today.getUTCHours() - offset >= 12; - const dates = isAfterNoon ? [today, tomorrow] : [yesterday, today]; - - const { phase } = getMoonIllumination(today); - const { sunset, night } = getTimes(dates[0], lat, long, altitude); - const { nightEnd: dawn, sunrise } = getTimes(dates[1], lat, long, altitude); - - const times = { dawn, sunrise, sunset, night }; - Object.keys(times).forEach((key) => { - times[key].setHours(times[key].getHours() - localOffset); - }); + const { lunarPhase: phase, solarTimes: times } = astroweatherData; return ( { }} > - + setModalOpen(false)}> - + ); diff --git a/components/widgets/CurrentData/patterns/Daylight/index.js b/components/widgets/CurrentData/patterns/Daylight/index.js index a7052b62..d026a08d 100644 --- a/components/widgets/CurrentData/patterns/Daylight/index.js +++ b/components/widgets/CurrentData/patterns/Daylight/index.js @@ -9,14 +9,7 @@ import { timezone } from "@/lib/observatory"; import { useTranslation } from "react-i18next"; import ChartLegend from "@/components/charts/Legend"; -const Daylight = ({ - dawn, - sunrise, - sunset, - night, - dates, - variant = "primary", -}) => { +const Daylight = ({ times, variant = "primary" }) => { const { t, i18n: { language = "en-US" }, @@ -24,13 +17,18 @@ const Daylight = ({ const offset = timezoneOffset(timezone); + const firstDay = new Date(times[0].date); + firstDay.setUTCHours(12 + offset, 0, 0, 0); + const secondDay = new Date(times[1].date); + secondDay.setUTCHours(12 + offset, 0, 0, 0); + const sunset = new Date(times[0].times[0]); + const night = new Date(times[0].times[1]); + const dawn = new Date(times[1].times[0]); + const sunrise = new Date(times[1].times[1]); + const width = variant === "primary" ? 280 : 640; const height = 70; - const xDomain = dates.map((date) => { - const hours = 12 + offset; - date.setUTCHours(hours, 0, 0, 0); - return date.getTime(); - }); + const xDomain = [firstDay.getTime(), secondDay.getTime()]; const xScale = getLinearScale(xDomain, [0, width]); const xHeight = 25; const xPos = height - xHeight; @@ -119,7 +117,7 @@ const Daylight = ({ height={xPos} role="listitem" aria-label={t("summit_dashboard.sections.astro.daylight.daylight", { - from: formatTime(dates[0], language), + from: formatTime(firstDay, language), to: formatTime(sunset, language), })} /> @@ -165,12 +163,12 @@ const Daylight = ({ style={{ "--fill": dayFill }} y={0} x={xScale(sunrise.getTime())} - width={xScale(dates[1].getTime()) - xScale(sunrise.getTime())} + width={xScale(secondDay.getTime()) - xScale(sunrise.getTime())} height={xPos} role="listitem" aria-label={t("summit_dashboard.sections.astro.daylight.daylight", { from: formatTime(sunrise, language), - to: formatTime(dates[1], language), + to: formatTime(secondDay, language), })} /> @@ -200,11 +198,22 @@ const Daylight = ({ }; export const DaylightDataShape = { - dawn: PropTypes.instanceOf(Date).isRequired, - sunrise: PropTypes.instanceOf(Date).isRequired, - sunset: PropTypes.instanceOf(Date).isRequired, - night: PropTypes.instanceOf(Date).isRequired, - dates: PropTypes.arrayOf(PropTypes.instanceOf(Date)).isRequired, + times: PropTypes.arrayOf( + PropTypes.shape({ + date: PropTypes.oneOfType([ + PropTypes.instanceOf(Date), + PropTypes.string, + PropTypes.number, + ]).isRequired, + times: PropTypes.arrayOf( + PropTypes.oneOfType([ + PropTypes.instanceOf(Date), + PropTypes.string, + PropTypes.number, + ]) + ), + }) + ).isRequired, }; Daylight.propTypes = { diff --git a/components/widgets/CurrentData/patterns/MoonRise/index.js b/components/widgets/CurrentData/patterns/MoonRise/index.js index 8e144c8f..742965a9 100644 --- a/components/widgets/CurrentData/patterns/MoonRise/index.js +++ b/components/widgets/CurrentData/patterns/MoonRise/index.js @@ -23,26 +23,29 @@ const MoonRise = ({ rise, set }) => { language ); + const riseDate = new Date(rise); + const setDate = new Date(set); + return ( {t("summit_dashboard.sections.astro.moonrise.time_moonrise")} - - {formatTime(rise, language, { hourCycle: "h24" })} + + {formatTime(riseDate, language, { hourCycle: "h24" })} - {getRelativeTime(rise, now)} + {getRelativeTime(riseDate, now)} {t("summit_dashboard.sections.astro.moonrise.time_moonset")} - - {formatTime(set, language, { hourCycle: "h24" })} + + {formatTime(setDate, language, { hourCycle: "h24" })} - {getRelativeTime(set, now)} + {getRelativeTime(setDate, now)} ); @@ -51,8 +54,16 @@ const MoonRise = ({ rise, set }) => { MoonRise.displayName = "Widgets.Current.MoonRise"; MoonRise.propTypes = { - rise: PropTypes.instanceOf(Date), - set: PropTypes.instanceOf(Date), + rise: PropTypes.oneOfType([ + PropTypes.instanceOf(Date), + PropTypes.string, + PropTypes.number, + ]), + set: PropTypes.oneOfType([ + PropTypes.instanceOf(Date), + PropTypes.string, + PropTypes.number, + ]), }; export default MoonRise; diff --git a/components/widgets/DailyData/patterns/Moonrise/Time/index.js b/components/widgets/DailyData/patterns/Moonrise/Time/index.js index 5b4490da..98688ff6 100644 --- a/components/widgets/DailyData/patterns/Moonrise/Time/index.js +++ b/components/widgets/DailyData/patterns/Moonrise/Time/index.js @@ -6,7 +6,9 @@ import * as Styled from "./styles"; const MoonTime = ({ time, azimuth }) => { return ( - + ({formatAngle(azimuth)}) ); @@ -15,7 +17,11 @@ const MoonTime = ({ time, azimuth }) => { MoonTime.displayName = "Widgets.Daily.MoonTime"; MoonTime.propTypes = { - time: PropTypes.instanceOf(Date), + time: PropTypes.oneOfType([ + PropTypes.instanceOf(Date), + PropTypes.string, + PropTypes.number, + ]), azimuth: PropTypes.number, }; diff --git a/components/widgets/DailyData/patterns/Moonrise/index.js b/components/widgets/DailyData/patterns/Moonrise/index.js index e5b5bac3..bccb1c21 100644 --- a/components/widgets/DailyData/patterns/Moonrise/index.js +++ b/components/widgets/DailyData/patterns/Moonrise/index.js @@ -29,9 +29,9 @@ const DailyMoonrise = ({ data, labelledById }) => { - {data.map(({ day, rise, set, azimuthRise, azimuthSet }) => { + {data.map(({ day, rise, set, azimuthRise, azimuthSet }, i) => { return ( - + {formatDayName(day, language)} @@ -64,8 +64,16 @@ DailyMoonrise.propTypes = { data: PropTypes.arrayOf( PropTypes.shape({ day: PropTypes.number, - rise: PropTypes.instanceOf(Date), - set: PropTypes.instanceOf(Date), + rise: PropTypes.oneOfType([ + PropTypes.instanceOf(Date), + PropTypes.string, + PropTypes.number, + ]), + set: PropTypes.oneOfType([ + PropTypes.instanceOf(Date), + PropTypes.string, + PropTypes.number, + ]), azimuthRise: PropTypes.number, azimuthSet: PropTypes.number, }) diff --git a/contexts/SummitData.js b/contexts/SummitData.js index 1c129b52..9f7afc95 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -1,19 +1,61 @@ import { createContext, useContext, useMemo } from "react"; import PropTypes from "prop-types"; import useEfd from "@/lib/api/efd"; +import useAstroweather from "@/lib/api/astroweather"; export const SummitDataContext = createContext({}); export const SummitDataProvider = ({ children }) => { - const { data = {}, isLoading, error } = useEfd(); + const { + data: astroweatherData, + isLoading: astroweatherIsLoading, + isError: astroweatherIsError, + } = useAstroweather(); + const { + data: currentData, + isLoading: currentIsLoading, + isError: currentIsError, + } = useEfd("current"); + const { + data: hourlyData, + isLoading: hourlyIsLoading, + isError: hourlyIsError, + } = useEfd("hourly"); + const { + data: dailyData, + isLoading: dailyIsLoading, + isError: dailyIsError, + } = useEfd("daily"); const value = useMemo( () => ({ - data, - isLoading, - error, + currentData, + hourlyData, + dailyData, + astroweatherData, + error: + currentIsError || hourlyIsError || dailyIsError || astroweatherIsError, + loading: { + currentData: currentIsLoading, + hourlyData: hourlyIsLoading, + dailyData: dailyIsLoading, + astroweatherData: astroweatherIsLoading, + }, }), - [data, isLoading, error] + [ + currentData, + hourlyData, + dailyData, + currentIsLoading, + hourlyIsLoading, + dailyIsLoading, + currentIsError, + hourlyIsError, + dailyIsError, + astroweatherData, + astroweatherIsLoading, + astroweatherIsError, + ] ); return ( diff --git a/lib/api/astroweather.js b/lib/api/astroweather.js new file mode 100644 index 00000000..a764c826 --- /dev/null +++ b/lib/api/astroweather.js @@ -0,0 +1,15 @@ +import useSWR from "swr"; + +const fetcher = (url) => fetch(url).then((res) => res.json()); + +export default function useAstroweather() { + const { data, error } = useSWR(`/api/astroweather`, fetcher, { + refreshInterval: 60000, + }); + + return { + data, + isLoading: !error && !data, + isError: error, + }; +} diff --git a/lib/suncalc.js b/lib/suncalc.js index cfb38d33..1c78a32f 100644 --- a/lib/suncalc.js +++ b/lib/suncalc.js @@ -263,7 +263,7 @@ export function getMoonPosition(date, lat, lng) { // Chapter 48 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998. export function getMoonIllumination(date) { - const d = toDays(date || new Date()(Date.now())); + const d = toDays(date || new Date(Date.now())); const s = sunCoords(d); const m = moonCoords(d); const sdist = 149598000; // distance from Earth to Sun in km diff --git a/pages/api/astroweather.js b/pages/api/astroweather.js new file mode 100644 index 00000000..7b9db78e --- /dev/null +++ b/pages/api/astroweather.js @@ -0,0 +1,70 @@ +import { altitude, lat, long, timezone } from "@/lib/observatory"; +import { timezoneOffset, timezoneOffsetLocal } from "@/helpers"; +import { + getMoonIllumination, + getMoonPosition, + getMoonTimes, + getTimes, +} from "@/lib/suncalc"; + +const conversion = 180 / Math.PI; + +const getAzimuth = (time) => + getMoonPosition(time, lat, long).azimuth * conversion + 180; + +const getLunarTimes = () => { + const now = new Date(); + + return Array.apply(null, Array(14)).map((value, i) => { + const day = new Date(); + day.setDate(now.getDate() + i); + const { rise, set } = getMoonTimes(day, lat, long); + + return { + day: day.getDay(), + rise, + set, + azimuthRise: rise ? getAzimuth(rise) : null, + azimuthSet: set ? getAzimuth(set) : null, + }; + }); +}; + +const getSolarTimes = () => { + const offset = timezoneOffset(timezone); + const localOffset = timezoneOffsetLocal(timezone); + + const today = new Date(); + const tomorrow = new Date(today); + const yesterday = new Date(today); + tomorrow.setDate(tomorrow.getDate() + 1); + yesterday.setDate(yesterday.getDate() - 1); + + const isAfterNoon = today.getUTCHours() - offset >= 12; + const dates = isAfterNoon ? [today, tomorrow] : [yesterday, today]; + + const { sunset, night } = getTimes(dates[0], lat, long, altitude); + const { nightEnd: dawn, sunrise } = getTimes(dates[1], lat, long, altitude); + + return dates.map((date, i) => { + const times = i === 0 ? [sunset, night] : [dawn, sunrise]; + + times.forEach((time) => { + time.setHours(time.getHours() - localOffset); + }); + + return { date, times }; + }); +}; + +export default function handler(req, res) { + const lunarTimes = getLunarTimes(); + const { phase: lunarPhase } = getMoonIllumination(); + const solarTimes = getSolarTimes(); + + if (!lunarTimes || !lunarPhase || !solarTimes) { + throw new Error("An error occurred while retrieving astroweather data."); + } + + return res.status(200).json({ lunarTimes, lunarPhase, solarTimes }); +} From 063f9b8c36002736a035cd164a336919cfa0d072 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Thu, 10 Aug 2023 12:12:01 -0700 Subject: [PATCH 70/98] [C] integrate astroweather with efd --- .../SummitData/Astroweather/Current/index.js | 7 +-- .../SummitData/Astroweather/Forecast/index.js | 18 +++----- .../dynamic/SummitData/Astroweather/index.js | 7 +-- .../SummitData/Observation/Related/index.js | 6 ++- .../SummitData/Weather/Current/index.js | 2 +- .../dynamic/SummitData/Weather/Daily/index.js | 2 +- .../SummitData/Weather/Hourly/index.js | 2 +- .../dynamic/SummitData/Weather/index.js | 2 +- .../CurrentData/patterns/Daylight/index.js | 2 +- contexts/SummitData.js | 45 +++++-------------- lib/api/efd.js | 4 +- 11 files changed, 33 insertions(+), 64 deletions(-) diff --git a/components/dynamic/SummitData/Astroweather/Current/index.js b/components/dynamic/SummitData/Astroweather/Current/index.js index 6cec0474..82bae47d 100644 --- a/components/dynamic/SummitData/Astroweather/Current/index.js +++ b/components/dynamic/SummitData/Astroweather/Current/index.js @@ -12,12 +12,9 @@ const CurrentAstroweather = () => { onToggleCallback: (value) => setOpen(value), isOpen, }; - const { - astroweatherData, - loading: { astroweatherData: loading }, - } = useSummitData(); + const { astroweatherData, isLoading } = useSummitData(); - if (loading) { + if (isLoading.astroweather || !astroweatherData) { return null; } diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js index e183dd6d..eed40cba 100644 --- a/components/dynamic/SummitData/Astroweather/Forecast/index.js +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -3,12 +3,7 @@ import { useTranslation } from "react-i18next"; import { useWeatherUnit } from "@/contexts/WeatherUnit"; import { useSummitData } from "@/contexts/SummitData"; import { convertTemperature } from "@/helpers/converters"; -import { - getMoonIllumination, - getMoonPosition, - getMoonTimes, -} from "@/lib/suncalc"; -import { lat, long } from "@/lib/observatory"; + import WidgetSection from "@/components/layout/WidgetSection"; import MoonRise from "@/components/widgets/CurrentData/patterns/MoonRise"; import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; @@ -23,6 +18,7 @@ const ForecastAstroweather = () => { const [{ tempUnit }] = useWeatherUnit(); const { data: { current }, + astroweatherData, isLoading, } = useSummitData(); @@ -32,14 +28,14 @@ const ForecastAstroweather = () => { isOpen, }; - if (isLoading || !current) + if (isLoading.astroweather || isLoading.efd || !current || !astroweatherData) return ( ); - // const { lunarPhase: phase, lunarTimes: times } = astroweatherData; + const { lunarPhase: phase, lunarTimes: times } = astroweatherData; const moonriseId = "moonriseTitle"; const now = new Date(); @@ -49,16 +45,16 @@ const ForecastAstroweather = () => { return ( - {/* + */} + /> {t("summit_dashboard.sections.astro.moonrise.forecast")} - {/* */} + ); }; diff --git a/components/dynamic/SummitData/Astroweather/index.js b/components/dynamic/SummitData/Astroweather/index.js index 050c01c4..2068a8a0 100644 --- a/components/dynamic/SummitData/Astroweather/index.js +++ b/components/dynamic/SummitData/Astroweather/index.js @@ -10,13 +10,10 @@ import ForecastAstroweather from "./Forecast"; const Astroweather = () => { const { t } = useTranslation(); - const { - astroweatherData, - loading: { astroweatherData: loading }, - } = useSummitData(); + const { astroweatherData, isLoading } = useSummitData(); const [isModalOpen, setModalOpen] = useState(false); - if (loading) { + if (isLoading.astroweather || !astroweatherData) { return null; } diff --git a/components/dynamic/SummitData/Observation/Related/index.js b/components/dynamic/SummitData/Observation/Related/index.js index ec45e305..ac48e33a 100644 --- a/components/dynamic/SummitData/Observation/Related/index.js +++ b/components/dynamic/SummitData/Observation/Related/index.js @@ -6,6 +6,7 @@ import { convertTemperature } from "@/helpers/converters"; import Loader from "@/components/atomic/Loader"; import WidgetSection from "@/components/layout/WidgetSection"; import DewpointCurrent from "@/components/widgets/CurrentData/patterns/Dewpoint"; +import MoonPhase from "@/components/widgets/CurrentData/patterns/MoonPhase"; const Related = () => { const { t } = useTranslation(); @@ -13,6 +14,7 @@ const Related = () => { const [{ tempUnit }] = useWeatherUnit(); const { data: { current }, + astroweatherData, isLoading, } = useSummitData(); @@ -22,18 +24,20 @@ const Related = () => { isOpen, }; - if (isLoading || !current) + if (isLoading.efd || isLoading.astroweather || !astroweatherData || !current) return ( ); + const { lunarPhase } = astroweatherData; const { dewPoint } = current; const dewpoint = convertTemperature(dewPoint, tempUnit); return ( + ); diff --git a/components/dynamic/SummitData/Weather/Current/index.js b/components/dynamic/SummitData/Weather/Current/index.js index 2ba9a122..e5ca0325 100644 --- a/components/dynamic/SummitData/Weather/Current/index.js +++ b/components/dynamic/SummitData/Weather/Current/index.js @@ -23,7 +23,7 @@ const CurrentWeather = () => { isOpen, }; - if (isLoading || !current) + if (isLoading.efd || !current) return ( diff --git a/components/dynamic/SummitData/Weather/Daily/index.js b/components/dynamic/SummitData/Weather/Daily/index.js index 535ee4f6..e81c53f7 100644 --- a/components/dynamic/SummitData/Weather/Daily/index.js +++ b/components/dynamic/SummitData/Weather/Daily/index.js @@ -23,7 +23,7 @@ const DailyWeather = () => { isOpen, }; - if (isLoading || !daily) + if (isLoading.efd || !daily) return ( diff --git a/components/dynamic/SummitData/Weather/Hourly/index.js b/components/dynamic/SummitData/Weather/Hourly/index.js index b02e2059..368041d4 100644 --- a/components/dynamic/SummitData/Weather/Hourly/index.js +++ b/components/dynamic/SummitData/Weather/Hourly/index.js @@ -21,7 +21,7 @@ const HourlyWeather = () => { isOpen, }; - if (isLoading || !hourly) + if (isLoading.efd || !hourly) return ( diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 5916fb21..4c03047f 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -25,7 +25,7 @@ const Weather = () => { title: t("summit_dashboard.sections.weather.preview"), }; - if (isLoading || !current) + if (isLoading.efd || !current) return ( diff --git a/components/widgets/CurrentData/patterns/Daylight/index.js b/components/widgets/CurrentData/patterns/Daylight/index.js index d026a08d..32dc028e 100644 --- a/components/widgets/CurrentData/patterns/Daylight/index.js +++ b/components/widgets/CurrentData/patterns/Daylight/index.js @@ -9,7 +9,7 @@ import { timezone } from "@/lib/observatory"; import { useTranslation } from "react-i18next"; import ChartLegend from "@/components/charts/Legend"; -const Daylight = ({ times, variant = "primary" }) => { +const Daylight = ({ times = [], variant = "primary" }) => { const { t, i18n: { language = "en-US" }, diff --git a/contexts/SummitData.js b/contexts/SummitData.js index 9f7afc95..6e81ffe4 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -7,51 +7,26 @@ export const SummitDataContext = createContext({}); export const SummitDataProvider = ({ children }) => { const { - data: astroweatherData, + data: astroweatherData = {}, isLoading: astroweatherIsLoading, isError: astroweatherIsError, } = useAstroweather(); - const { - data: currentData, - isLoading: currentIsLoading, - isError: currentIsError, - } = useEfd("current"); - const { - data: hourlyData, - isLoading: hourlyIsLoading, - isError: hourlyIsError, - } = useEfd("hourly"); - const { - data: dailyData, - isLoading: dailyIsLoading, - isError: dailyIsError, - } = useEfd("daily"); + const { data = {}, isLoading, isError } = useEfd(); const value = useMemo( () => ({ - currentData, - hourlyData, - dailyData, + data, astroweatherData, - error: - currentIsError || hourlyIsError || dailyIsError || astroweatherIsError, - loading: { - currentData: currentIsLoading, - hourlyData: hourlyIsLoading, - dailyData: dailyIsLoading, - astroweatherData: astroweatherIsLoading, + error: { efd: isError, astroweather: astroweatherIsError }, + isLoading: { + efd: isLoading, + astroweather: astroweatherIsLoading, }, }), [ - currentData, - hourlyData, - dailyData, - currentIsLoading, - hourlyIsLoading, - dailyIsLoading, - currentIsError, - hourlyIsError, - dailyIsError, + data, + isLoading, + isError, astroweatherData, astroweatherIsLoading, astroweatherIsError, diff --git a/lib/api/efd.js b/lib/api/efd.js index f034165b..3e5ee364 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -11,11 +11,11 @@ const fetcher = (url) => export default function useEfd() { const url = process.env.NEXT_PUBLIC_EFD_URL; - const { data, error, isLoading } = useSWR(url, fetcher); + const { data, error } = useSWR(url, fetcher); return { data, - isLoading, + isLoading: !error && !data, error, }; } From 48c17e86425b25a54a722c48583a9912c840b925 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Mon, 21 Aug 2023 16:22:45 -0700 Subject: [PATCH 71/98] [C] Docker build args include EDC EFD API url --- .github/workflows/dev-pull-request.yaml | 6 +++--- .github/workflows/dev-push.yaml | 4 ++-- .github/workflows/master-pr.yaml | 4 ++-- .github/workflows/master-push.yaml | 4 ++-- .github/workflows/prod-push.yaml | 4 ++-- Dockerfile | 2 ++ lib/api/efd.js | 5 +---- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/dev-pull-request.yaml b/.github/workflows/dev-pull-request.yaml index a65df197..9f9ff1b0 100644 --- a/.github/workflows/dev-pull-request.yaml +++ b/.github/workflows/dev-pull-request.yaml @@ -34,16 +34,16 @@ jobs: docker build \ -t "gcr.io/${{ secrets.SV_PROJ_NAME }}/rubin-obs-client:${{ github.sha }}" \ --build-arg NEXT_PUBLIC_API_URL=https://api-dev.rubinobs.com/api \ + --build-arg NEXT_PUBLIC_BASE_URL=https://dev.rubinobs.com \ --build-arg EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger \ --build-arg NEXT_PUBLIC_DEBUG_LOGGING=false \ --build-arg CLOUD_ENV=DEV \ - --build-arg NEXT_PUBLIC_BASE_URL=https://dev.rubinobs.com \ --build-arg NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps.googleusercontent.com \ --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-dev.rubinobs.com/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ + --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ + --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . - name: Configure Docker Auth diff --git a/.github/workflows/dev-push.yaml b/.github/workflows/dev-push.yaml index bab8c459..b9cc9c37 100644 --- a/.github/workflows/dev-push.yaml +++ b/.github/workflows/dev-push.yaml @@ -36,8 +36,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-dev.rubinobs.com/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ + --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ + --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . - name: Configure Docker Auth diff --git a/.github/workflows/master-pr.yaml b/.github/workflows/master-pr.yaml index 708dc92f..24d12f0c 100644 --- a/.github/workflows/master-pr.yaml +++ b/.github/workflows/master-pr.yaml @@ -42,8 +42,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.org/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ + --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ + --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . - name: Configure Docker Auth diff --git a/.github/workflows/master-push.yaml b/.github/workflows/master-push.yaml index 857a738d..d4385026 100644 --- a/.github/workflows/master-push.yaml +++ b/.github/workflows/master-push.yaml @@ -36,8 +36,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.org/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ + --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ + --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . - name: Configure Docker Auth diff --git a/.github/workflows/prod-push.yaml b/.github/workflows/prod-push.yaml index 859b9464..c90ce4f4 100644 --- a/.github/workflows/prod-push.yaml +++ b/.github/workflows/prod-push.yaml @@ -42,8 +42,8 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api.rubinobs.org/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN=rubinobservatory.org \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_EN=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ - --build-arg NEXT_PUBLIC_PRESS_RELEASE_URL_ES=https://noirlab.edu/public/news/{{id}}/api/jsON/ \ + --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ + --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . - name: Configure Docker Auth run: gcloud --quiet auth configure-docker diff --git a/Dockerfile b/Dockerfile index b8cb68ba..047dbb4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,8 @@ ARG NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps ARG NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api.rubinobs.org/actions/contact-form/send ARG NEXT_PUBLIC_PLAUSIBLE_DOMAIN=rubinobs.org ARG CLOUD_ENV=PROD +ARG NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status +ARG NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` RUN npx browserslist@latest --update-db && yarn static:build diff --git a/lib/api/efd.js b/lib/api/efd.js index 3e5ee364..428b417e 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -9,10 +9,7 @@ const fetcher = (url) => }); export default function useEfd() { - const url = process.env.NEXT_PUBLIC_EFD_URL; - - const { data, error } = useSWR(url, fetcher); - + const { data, error } = useSWR(process.env.NEXT_PUBLIC_EFD_URL, fetcher); return { data, isLoading: !error && !data, From 980fa25b14cd809c88943882de591b27b50587fd Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 29 Aug 2023 10:14:12 -0700 Subject: [PATCH 72/98] [B] VideoBlock has responsive dimensions --- components/content-blocks/Video/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/content-blocks/Video/index.js b/components/content-blocks/Video/index.js index 733856a0..8df8510f 100644 --- a/components/content-blocks/Video/index.js +++ b/components/content-blocks/Video/index.js @@ -7,9 +7,9 @@ export default function VideoBlock({ caption, url }) { if (!isMounted) return null; return ( - +
-
); From fe30f64617fc99481fb59905b2b095610b224cd0 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 29 Aug 2023 10:46:21 -0700 Subject: [PATCH 73/98] [B] Correct int domain env vars --- .github/workflows/master-pr.yaml | 6 +++--- .github/workflows/master-push.yaml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/master-pr.yaml b/.github/workflows/master-pr.yaml index 24d12f0c..eca2e128 100644 --- a/.github/workflows/master-pr.yaml +++ b/.github/workflows/master-pr.yaml @@ -33,13 +33,13 @@ jobs: run: |- docker build \ -t "gcr.io/edc-int-6c5e/rubin-obs-client:${{ github.sha }}" \ - --build-arg NEXT_PUBLIC_API_URL=https://api-int.rubinobs.org/api \ + --build-arg NEXT_PUBLIC_API_URL=https://api-int.rubinobs.dev/api \ --build-arg EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger \ --build-arg NEXT_PUBLIC_DEBUG_LOGGING=false \ --build-arg CLOUD_ENV=INT \ - --build-arg NEXT_PUBLIC_BASE_URL=https://int.rubinobs.org \ + --build-arg NEXT_PUBLIC_BASE_URL=https://int.rubinobs.dev \ --build-arg NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps.googleusercontent.com \ - --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.org/actions/contact-form/send \ + --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.dev/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ diff --git a/.github/workflows/master-push.yaml b/.github/workflows/master-push.yaml index d4385026..a2a390b9 100644 --- a/.github/workflows/master-push.yaml +++ b/.github/workflows/master-push.yaml @@ -27,13 +27,13 @@ jobs: run: |- docker build \ -t "gcr.io/edc-int-6c5e/skyviewer-client:${{ github.sha }}" \ - --build-arg NEXT_PUBLIC_API_URL=https://api-int.rubinobs.org/api \ - --build-arg NEXT_PUBLIC_BASE_URL=https://int.rubinobs.org \ + --build-arg NEXT_PUBLIC_API_URL=https://api-int.rubinobs.dev/api \ + --build-arg NEXT_PUBLIC_BASE_URL=https://int.rubinobs.dev \ --build-arg EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger \ --build-arg NEXT_PUBLIC_DEBUG_LOGGING=false \ --build-arg CLOUD_ENV=INT \ --build-arg NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps.googleusercontent.com \ - --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.org/actions/contact-form/send \ + --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.dev/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ From cc4f5ed05b53daf04aa6bdf22a5d1bc857fc11a5 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 22 Aug 2023 12:46:52 -0700 Subject: [PATCH 74/98] [F] Only show hourly weather for current calendar day --- .../widgets/HourlyData/patterns/Windspeed/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/widgets/HourlyData/patterns/Windspeed/index.js b/components/widgets/HourlyData/patterns/Windspeed/index.js index 01341ef5..e4c22e7a 100644 --- a/components/widgets/HourlyData/patterns/Windspeed/index.js +++ b/components/widgets/HourlyData/patterns/Windspeed/index.js @@ -2,6 +2,7 @@ import { useEffect, useRef } from "react"; import PropTypes from "prop-types"; import { windspeedUnitType } from "@/components/shapes/units"; import { useTranslation } from "react-i18next"; +import { timezone } from "@/lib/observatory"; import { formatAngle, formatTime } from "@/helpers/formatters"; import * as Styled from "./styles"; import UniqueIconComposer from "@/components/svg/UniqueIconComposer"; @@ -54,7 +55,15 @@ const Windspeed = ({ unit, windspeedData = [], labelledById }) => { {windspeedData && windspeedData.map(({ windspeed, direction, time }) => { - const isNow = time.getHours() === new Date().getHours(); + const now = new Date(); + const isYesterday = + time.toLocaleDateString(language, { timeZone: timezone }) !== + now.toLocaleDateString(language, { timeZone: timezone }); + + if (isYesterday) return null; + + const isNow = time.getHours() === now.getHours(); + return ( Date: Tue, 22 Aug 2023 13:23:30 -0700 Subject: [PATCH 75/98] [F] SummitStatus uses hasura graphQL endpoint --- .github/workflows/dev-pull-request.yaml | 2 +- .github/workflows/dev-push.yaml | 2 +- .github/workflows/master-pr.yaml | 2 +- .github/workflows/master-push.yaml | 2 +- .github/workflows/prod-push.yaml | 2 +- Dockerfile | 2 +- .../content-blocks/SummitStatus/index.js | 19 +++- .../content-blocks/SummitStatus/styles.js | 5 + .../SummitData/Astroweather/Forecast/index.js | 2 +- .../CameraFeeds/AllSky/CurrentImage/index.js | 44 +++++++++ .../CameraFeeds/AllSky/CurrentImage/styles.js | 8 ++ .../AllSky/CurrentTimeLapse/index.js | 78 +++++++++++++++ .../AllSky/CurrentTimeLapse/styles.js | 20 ++++ .../SummitData/CameraFeeds/AllSky/index.js | 20 ++++ .../SummitData/CameraFeeds/AllSky/styles.js | 9 ++ .../dynamic/SummitData/CameraFeeds/index.js | 52 ++++++++++ .../dynamic/SummitData/CameraFeeds/styles.js | 10 ++ .../SummitData/Observation/Related/index.js | 2 +- .../dynamic/SummitData/Observation/index.js | 23 ++++- .../SummitData/Weather/Current/index.js | 2 +- .../dynamic/SummitData/Weather/Daily/index.js | 2 +- .../SummitData/Weather/Hourly/index.js | 2 +- .../dynamic/SummitData/Weather/index.js | 9 +- .../dynamic/SummitData/Weather/styles.js | 11 +++ components/dynamic/SummitData/index.js | 38 ++++++++ components/dynamic/SummitData/styles.js | 5 + components/layout/UnitLocalization/styles.js | 3 +- components/layout/WidgetSection/index.js | 2 +- .../HourlyData/patterns/Windspeed/index.js | 2 +- contexts/SummitData.js | 17 +++- lib/api/efd.js | 95 +++++++++++++++++-- package.json | 1 + 32 files changed, 458 insertions(+), 35 deletions(-) create mode 100644 components/content-blocks/SummitStatus/styles.js create mode 100644 components/dynamic/SummitData/CameraFeeds/AllSky/CurrentImage/index.js create mode 100644 components/dynamic/SummitData/CameraFeeds/AllSky/CurrentImage/styles.js create mode 100644 components/dynamic/SummitData/CameraFeeds/AllSky/CurrentTimeLapse/index.js create mode 100644 components/dynamic/SummitData/CameraFeeds/AllSky/CurrentTimeLapse/styles.js create mode 100644 components/dynamic/SummitData/CameraFeeds/AllSky/index.js create mode 100644 components/dynamic/SummitData/CameraFeeds/AllSky/styles.js create mode 100644 components/dynamic/SummitData/CameraFeeds/index.js create mode 100644 components/dynamic/SummitData/CameraFeeds/styles.js create mode 100644 components/dynamic/SummitData/Weather/styles.js create mode 100644 components/dynamic/SummitData/index.js create mode 100644 components/dynamic/SummitData/styles.js diff --git a/.github/workflows/dev-pull-request.yaml b/.github/workflows/dev-pull-request.yaml index 9f9ff1b0..284e493e 100644 --- a/.github/workflows/dev-pull-request.yaml +++ b/.github/workflows/dev-pull-request.yaml @@ -42,7 +42,7 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-dev.rubinobs.com/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ + --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . diff --git a/.github/workflows/dev-push.yaml b/.github/workflows/dev-push.yaml index b9cc9c37..de5d53ef 100644 --- a/.github/workflows/dev-push.yaml +++ b/.github/workflows/dev-push.yaml @@ -36,7 +36,7 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-dev.rubinobs.com/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ + --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . diff --git a/.github/workflows/master-pr.yaml b/.github/workflows/master-pr.yaml index eca2e128..8e519736 100644 --- a/.github/workflows/master-pr.yaml +++ b/.github/workflows/master-pr.yaml @@ -42,7 +42,7 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.dev/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ + --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . diff --git a/.github/workflows/master-push.yaml b/.github/workflows/master-push.yaml index a2a390b9..adff4873 100644 --- a/.github/workflows/master-push.yaml +++ b/.github/workflows/master-push.yaml @@ -36,7 +36,7 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-int.rubinobs.dev/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ + --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . diff --git a/.github/workflows/prod-push.yaml b/.github/workflows/prod-push.yaml index c90ce4f4..3a7f98c3 100644 --- a/.github/workflows/prod-push.yaml +++ b/.github/workflows/prod-push.yaml @@ -42,7 +42,7 @@ jobs: --build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api.rubinobs.org/actions/contact-form/send \ --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN=rubinobservatory.org \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ - --build-arg NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status \ + --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . - name: Configure Docker Auth diff --git a/Dockerfile b/Dockerfile index 047dbb4c..f3d27bb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ ARG NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps ARG NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api.rubinobs.org/actions/contact-form/send ARG NEXT_PUBLIC_PLAUSIBLE_DOMAIN=rubinobs.org ARG CLOUD_ENV=PROD -ARG NEXT_PUBLIC_EFD_URL=https://us-west1-skyviewer.cloudfunctions.net/redis-client/summit-status +ARG NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql ARG NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` RUN npx browserslist@latest --update-db && yarn static:build diff --git a/components/content-blocks/SummitStatus/index.js b/components/content-blocks/SummitStatus/index.js index 1fc1e251..e01e1839 100644 --- a/components/content-blocks/SummitStatus/index.js +++ b/components/content-blocks/SummitStatus/index.js @@ -7,15 +7,32 @@ import { SummitDataProvider } from "@/contexts/SummitData"; import Weather from "@/components/dynamic/SummitData/Weather"; import Astroweather from "@/components/dynamic/SummitData/Astroweather"; import Observation from "@/components/dynamic/SummitData/Observation"; +import CameraFeeds from "@/components/dynamic/SummitData/CameraFeeds"; +import * as Styled from "./styles"; const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { - return ( + return summitStatusLayout === "compact" ? ( + + + + + + + + + + + + + + ) : ( + diff --git a/components/content-blocks/SummitStatus/styles.js b/components/content-blocks/SummitStatus/styles.js new file mode 100644 index 00000000..2bebdcc3 --- /dev/null +++ b/components/content-blocks/SummitStatus/styles.js @@ -0,0 +1,5 @@ +import styled from "styled-components"; + +export const Container = styled.div` + background-color: var(--neutral95, #1f2121); +`; diff --git a/components/dynamic/SummitData/Astroweather/Forecast/index.js b/components/dynamic/SummitData/Astroweather/Forecast/index.js index eed40cba..6b02dc62 100644 --- a/components/dynamic/SummitData/Astroweather/Forecast/index.js +++ b/components/dynamic/SummitData/Astroweather/Forecast/index.js @@ -17,7 +17,7 @@ const ForecastAstroweather = () => { const [isOpen, setOpen] = useState(true); const [{ tempUnit }] = useWeatherUnit(); const { - data: { current }, + summitData: { current }, astroweatherData, isLoading, } = useSummitData(); diff --git a/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentImage/index.js b/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentImage/index.js new file mode 100644 index 00000000..0e0c0604 --- /dev/null +++ b/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentImage/index.js @@ -0,0 +1,44 @@ +import PropTypes from "prop-types"; +import { useTranslation } from "react-i18next"; +import { Image } from "@rubin-epo/epo-react-lib"; +import { timezone } from "@/lib/observatory"; +import { formatTime } from "@/helpers/formatters"; +import * as Styled from "./styles"; + +export default function CurrentImage({ image, caption, altText }) { + const { + t, + i18n: { language = "en" }, + } = useTranslation(); + const { mediaLink, timeCreated } = image; + const timeShort = formatTime(new Date(timeCreated), language, { + dateStyle: "short", + timeStyle: "short", + timeZone: timezone, + }); + const timeLong = formatTime(new Date(timeCreated), language, { + dateStyle: "full", + timeStyle: "short", + timeZone: timezone, + }); + const defaultAltText = `The sky over Rubin: ${timeLong}`; + const defaultCaption = `The sky over Rubin: ${timeShort}`; + const currentImage = { + altText: altText || defaultAltText, + url: mediaLink, + url2x: mediaLink, + url3x: mediaLink, + }; + + return ( + + + + ); +} + +CurrentImage.propTypes = { + image: PropTypes.object, + caption: PropTypes.string, + altText: PropTypes.string, +}; diff --git a/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentImage/styles.js b/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentImage/styles.js new file mode 100644 index 00000000..85fed278 --- /dev/null +++ b/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentImage/styles.js @@ -0,0 +1,8 @@ +import styled from "styled-components"; +import { Figure as Fig } from "@rubin-epo/epo-react-lib"; + +export const Figure = styled(Fig)` + figcaption { + text-align: center; + } +`; diff --git a/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentTimeLapse/index.js b/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentTimeLapse/index.js new file mode 100644 index 00000000..b5b6bde0 --- /dev/null +++ b/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentTimeLapse/index.js @@ -0,0 +1,78 @@ +import PropTypes from "prop-types"; +import ReactPlayer from "react-player/file"; +import { useTranslation } from "react-i18next"; +import { timezone } from "@/lib/observatory"; +import { formatTime } from "@/helpers/formatters"; +import { useIsMounted } from "@/hooks"; +import * as Styled from "./styles"; + +export default function CurrentTimeLapse({ video, caption }) { + const { + t, + i18n: { language = "en" }, + } = useTranslation(); + const isMounted = useIsMounted(); + if (!isMounted) return null; + const { mediaLink, timeCreated } = video; + const isAfterMidnight = + formatTime(new Date(timeCreated), language, { + dateStyle: undefined, + timeStyle: "short", + hour12: false, + timeZone: timezone, + }).substring(0, 2) < 12; + const startTimeCreated = isAfterMidnight + ? new Date(timeCreated).setDate(new Date(timeCreated).getDate() - 1) + : new Date(timeCreated); + const startDate = formatTime(startTimeCreated, language, { + dateStyle: "short", + timeStyle: undefined, + timeZone: timezone, + }); + const startTime = "12:00 PM"; + const endDate = formatTime(new Date(timeCreated), language, { + dateStyle: "short", + timeStyle: undefined, + timeZone: timezone, + }); + const endTime = formatTime(new Date(timeCreated), language, { + dateStyle: undefined, + timeStyle: "short", + timeZone: timezone, + }); + const defaultCaption = + startDate === endDate + ? `Timelapse of sky over Rubin: ${startDate}, ${startTime} – ${endTime}` + : `Timelapse of sky over Rubin: ${startDate}, ${startTime} – ${endDate}, ${endTime}`; + + return ( + + + + + + ); +} + +CurrentTimeLapse.propTypes = { + video: PropTypes.object, + caption: PropTypes.string, +}; diff --git a/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentTimeLapse/styles.js b/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentTimeLapse/styles.js new file mode 100644 index 00000000..eccb296c --- /dev/null +++ b/components/dynamic/SummitData/CameraFeeds/AllSky/CurrentTimeLapse/styles.js @@ -0,0 +1,20 @@ +import styled from "styled-components"; +import { Figure as Fig } from "@rubin-epo/epo-react-lib"; + +export const Figure = styled(Fig)` + figcaption { + text-align: center; + } +`; + +export const Wrapper = styled.div` + position: relative; + display: block; + padding-top: 100%; + + .react-player { + position: absolute; + top: 0; + left: 0; + } +`; diff --git a/components/dynamic/SummitData/CameraFeeds/AllSky/index.js b/components/dynamic/SummitData/CameraFeeds/AllSky/index.js new file mode 100644 index 00000000..059a2ae8 --- /dev/null +++ b/components/dynamic/SummitData/CameraFeeds/AllSky/index.js @@ -0,0 +1,20 @@ +import PropTypes from "prop-types"; +import CurrentImage from "./CurrentImage"; +import CurrentTimeLapse from "./CurrentTimeLapse"; +import * as Styled from "./styles"; + +const CameraFeeds = ({ image, video }) => { + return ( + + + + + ); +}; + +CameraFeeds.propTypes = { + image: PropTypes.object, + video: PropTypes.object, +}; + +export default CameraFeeds; diff --git a/components/dynamic/SummitData/CameraFeeds/AllSky/styles.js b/components/dynamic/SummitData/CameraFeeds/AllSky/styles.js new file mode 100644 index 00000000..2024525e --- /dev/null +++ b/components/dynamic/SummitData/CameraFeeds/AllSky/styles.js @@ -0,0 +1,9 @@ +import styled from "styled-components"; + +export const Container = styled.div` + display: grid; + grid-template-rows: 100%; + grid-template-columns: repeat(2, 1fr); + grid-column: 1 / -1; + gap: var(--widget-padding); +`; diff --git a/components/dynamic/SummitData/CameraFeeds/index.js b/components/dynamic/SummitData/CameraFeeds/index.js new file mode 100644 index 00000000..34d4ec23 --- /dev/null +++ b/components/dynamic/SummitData/CameraFeeds/index.js @@ -0,0 +1,52 @@ +import { useState } from "react"; +import { useSummitData } from "@/contexts/SummitData"; +import Loader from "@/components/atomic/Loader"; +import WidgetPreview from "@/components/layout/WidgetPreview"; +import WidgetSection from "@/components/layout/WidgetSection"; +import SummitStatusModal from "@/components/modal/SummitStatusModal"; +import AllSky from "./AllSky"; +import CurrentImage from "./AllSky/CurrentImage"; +import * as Styled from "./styles"; + +const CameraFeeds = () => { + const { + summitMedia: { + items: { allSkyImage, allSkyVideo }, + }, + astroweatherData, + isLoading, + } = useSummitData(); + const [isModalOpen, setModalOpen] = useState(false); + + return ( + { + setModalOpen(true); + }} + > + + {isLoading.efd ? ( + + ) : ( + + )} + + setModalOpen(false)} + > + + + + + + + + ); +}; + +CameraFeeds.displayName = "Dynamic.CameraFeeds"; + +export default CameraFeeds; diff --git a/components/dynamic/SummitData/CameraFeeds/styles.js b/components/dynamic/SummitData/CameraFeeds/styles.js new file mode 100644 index 00000000..2b6c2f72 --- /dev/null +++ b/components/dynamic/SummitData/CameraFeeds/styles.js @@ -0,0 +1,10 @@ +import styled from "styled-components"; +import WidgetBackground from "@/components/atomic/WidgetBackground"; + +export const CondensedBackground = styled(WidgetBackground)` + display: grid; + grid-template-rows: 100%; + grid-template-columns: repeat(1, 1fr); + grid-column: 1 / -1; + gap: var(--widget-padding); +`; diff --git a/components/dynamic/SummitData/Observation/Related/index.js b/components/dynamic/SummitData/Observation/Related/index.js index ac48e33a..08065b4d 100644 --- a/components/dynamic/SummitData/Observation/Related/index.js +++ b/components/dynamic/SummitData/Observation/Related/index.js @@ -13,7 +13,7 @@ const Related = () => { const [isOpen, setOpen] = useState(true); const [{ tempUnit }] = useWeatherUnit(); const { - data: { current }, + summitData: { current }, astroweatherData, isLoading, } = useSummitData(); diff --git a/components/dynamic/SummitData/Observation/index.js b/components/dynamic/SummitData/Observation/index.js index 6bffd23c..7184eb86 100644 --- a/components/dynamic/SummitData/Observation/index.js +++ b/components/dynamic/SummitData/Observation/index.js @@ -1,7 +1,8 @@ import { useState } from "react"; +import Loader from "@/components/atomic/Loader"; import WidgetPreview from "@/components/layout/WidgetPreview"; import SummitStatusModal from "@/components/modal/SummitStatusModal"; - +import { useSummitData } from "@/contexts/SummitData"; import Azimuth from "@/components/widgets/CurrentData/patterns/Azimuth"; import Zenith from "@/components/widgets/CurrentData/patterns/Zenith"; import Instruments from "./Instruments"; @@ -11,8 +12,24 @@ import Related from "./Related"; const Observation = () => { const [isModalOpen, setModalOpen] = useState(false); - const azimuth = 0; - const zenith = 0; + const { + summitData: { current }, + isLoading, + } = useSummitData(); + + if (isLoading.efd || !current) + return ( + { + setModalOpen(true); + }} + > + + + ); + + const { azimuth, zenith } = current; return ( { const [isOpen, setOpen] = useState(true); const [{ tempUnit, windspeedUnit }] = useWeatherUnit(); const { - data: { current }, + summitData: { current }, isLoading, } = useSummitData(); const sectionProps = { diff --git a/components/dynamic/SummitData/Weather/Daily/index.js b/components/dynamic/SummitData/Weather/Daily/index.js index e81c53f7..bbae2c1d 100644 --- a/components/dynamic/SummitData/Weather/Daily/index.js +++ b/components/dynamic/SummitData/Weather/Daily/index.js @@ -12,7 +12,7 @@ const DailyWeather = () => { const [isOpen, setOpen] = useState(true); const [{ tempUnit }] = useWeatherUnit(); const { - data: { daily }, + summitData: { daily }, isLoading, } = useSummitData(); const sectionProps = { diff --git a/components/dynamic/SummitData/Weather/Hourly/index.js b/components/dynamic/SummitData/Weather/Hourly/index.js index 368041d4..914eb17e 100644 --- a/components/dynamic/SummitData/Weather/Hourly/index.js +++ b/components/dynamic/SummitData/Weather/Hourly/index.js @@ -12,7 +12,7 @@ const HourlyWeather = () => { const [isOpen, setOpen] = useState(true); const [{ windspeedUnit }] = useWeatherUnit(); const { - data: { hourly }, + summitData: { hourly }, isLoading, } = useSummitData(); const sectionProps = { diff --git a/components/dynamic/SummitData/Weather/index.js b/components/dynamic/SummitData/Weather/index.js index 4c03047f..cb79bf3a 100644 --- a/components/dynamic/SummitData/Weather/index.js +++ b/components/dynamic/SummitData/Weather/index.js @@ -11,13 +11,14 @@ import { convertTemperature } from "@/helpers/converters"; import HourlyWeather from "./Hourly"; import CurrentWeather from "./Current"; import DailyWeather from "./Daily"; +import * as Styled from "./styles"; const Weather = () => { const { t } = useTranslation(); const [isModalOpen, setModalOpen] = useState(false); const [{ tempUnit }] = useWeatherUnit(); const { - data: { current }, + summitData: { current }, isLoading, } = useSummitData(); @@ -43,8 +44,10 @@ const Weather = () => { setModalOpen(true); }} > - - + + + + setModalOpen(false)}> diff --git a/components/dynamic/SummitData/Weather/styles.js b/components/dynamic/SummitData/Weather/styles.js new file mode 100644 index 00000000..fb0cb1c5 --- /dev/null +++ b/components/dynamic/SummitData/Weather/styles.js @@ -0,0 +1,11 @@ +import styled from "styled-components"; + +export const Preview = styled.div` + display: flex; + flex-wrap: wrap; + width: 100%; +`; + +export const PreviewItem = styled.div` + display: flex; +`; diff --git a/components/dynamic/SummitData/index.js b/components/dynamic/SummitData/index.js new file mode 100644 index 00000000..d73f3311 --- /dev/null +++ b/components/dynamic/SummitData/index.js @@ -0,0 +1,38 @@ +import PropTypes from "prop-types"; +// import { Container } from "@rubin-epo/epo-react-lib"; +import { WeatherUnitProvider } from "@/contexts/WeatherUnit"; +import UnitLocalization from "@/components/layout/UnitLocalization"; +import WidgetGrid from "@/components/layout/WidgetGrid"; +import { SummitDataProvider } from "@/contexts/SummitData"; +import Weather from "@/components/dynamic/SummitData/Weather"; +import Astroweather from "@/components/dynamic/SummitData/Astroweather"; +import Observation from "@/components/dynamic/SummitData/Observation"; +import CameraFeeds from "@/components/dynamic/SummitData/CameraFeeds"; +import * as Styled from "./styles"; + +const SummitStatus = ({ summitStatusLayout, widgetPreviews = [] }) => { + return ( + + + + + + + + + + + + + + ); +}; + +SummitStatus.propTypes = { + summitStatusLayout: PropTypes.oneOf(["compact", "full"]), + widgetPreviews: PropTypes.arrayOf({}), +}; + +SummitStatus.displayName = "ContentBlock.SummitStatus"; + +export default SummitStatus; diff --git a/components/dynamic/SummitData/styles.js b/components/dynamic/SummitData/styles.js new file mode 100644 index 00000000..2bebdcc3 --- /dev/null +++ b/components/dynamic/SummitData/styles.js @@ -0,0 +1,5 @@ +import styled from "styled-components"; + +export const Container = styled.div` + background-color: var(--neutral95, #1f2121); +`; diff --git a/components/layout/UnitLocalization/styles.js b/components/layout/UnitLocalization/styles.js index 5249b624..070b0d83 100644 --- a/components/layout/UnitLocalization/styles.js +++ b/components/layout/UnitLocalization/styles.js @@ -7,7 +7,8 @@ export const LocalizationBar = styled.div` row-gap: var(--PADDING_SMALL, 20px); align-items: center; width: 100%; - padding: 0; + padding: var(--PADDING_SMALL, 20px) var(--PADDING_SMALL, 20px) 0 + var(--PADDING_SMALL, 20px); margin: 0; color: var(--white, #fff); border: none; diff --git a/components/layout/WidgetSection/index.js b/components/layout/WidgetSection/index.js index 10ec8be1..c86d9b48 100644 --- a/components/layout/WidgetSection/index.js +++ b/components/layout/WidgetSection/index.js @@ -42,7 +42,7 @@ WidgetSection.propTypes = { title: PropTypes.string, isCollapsible: PropTypes.bool, isOpen: PropTypes.bool, - onToggleCallback: PropTypes.func.isRequired, + onToggleCallback: PropTypes.func, }; export default WidgetSection; diff --git a/components/widgets/HourlyData/patterns/Windspeed/index.js b/components/widgets/HourlyData/patterns/Windspeed/index.js index e4c22e7a..5d97c7dc 100644 --- a/components/widgets/HourlyData/patterns/Windspeed/index.js +++ b/components/widgets/HourlyData/patterns/Windspeed/index.js @@ -4,9 +4,9 @@ import { windspeedUnitType } from "@/components/shapes/units"; import { useTranslation } from "react-i18next"; import { timezone } from "@/lib/observatory"; import { formatAngle, formatTime } from "@/helpers/formatters"; -import * as Styled from "./styles"; import UniqueIconComposer from "@/components/svg/UniqueIconComposer"; import { ScreenreaderText } from "@rubin-epo/epo-react-lib"; +import * as Styled from "./styles"; const Windspeed = ({ unit, windspeedData = [], labelledById }) => { const currentTimeRef = useRef(); diff --git a/contexts/SummitData.js b/contexts/SummitData.js index 6e81ffe4..0a862e00 100644 --- a/contexts/SummitData.js +++ b/contexts/SummitData.js @@ -1,6 +1,6 @@ import { createContext, useContext, useMemo } from "react"; import PropTypes from "prop-types"; -import useEfd from "@/lib/api/efd"; +import { useEfd, efdQuery } from "@/lib/api/efd"; import useAstroweather from "@/lib/api/astroweather"; export const SummitDataContext = createContext({}); @@ -11,11 +11,17 @@ export const SummitDataProvider = ({ children }) => { isLoading: astroweatherIsLoading, isError: astroweatherIsError, } = useAstroweather(); - const { data = {}, isLoading, isError } = useEfd(); + const { data, isLoading, isError } = useEfd(efdQuery); + const { summitData, summitMedia } = data || { + summitData: {}, + summitMedia: { items: {} }, + }; + // || { summitData: {}, summitMedia: {} } const value = useMemo( () => ({ - data, + summitData, + summitMedia, astroweatherData, error: { efd: isError, astroweather: astroweatherIsError }, isLoading: { @@ -24,10 +30,11 @@ export const SummitDataProvider = ({ children }) => { }, }), [ - data, + summitData, + summitMedia, + astroweatherData, isLoading, isError, - astroweatherData, astroweatherIsLoading, astroweatherIsError, ] diff --git a/lib/api/efd.js b/lib/api/efd.js index 428b417e..9a309f2d 100644 --- a/lib/api/efd.js +++ b/lib/api/efd.js @@ -1,15 +1,92 @@ import useSWR from "swr"; +import { GraphQLClient } from "graphql-request"; -const fetcher = (url) => - fetch(url, { - method: "GET", - headers: { "Content-Type": "application/json" }, - }).then((res) => { - return res.json(); - }); +export const efdQuery = ` + query { + summitData: summitCachedData { + current { + dewPoint + azimuth: mountAz + zenith: mountEl + pressure0 + relativeHumidity + temperature0 + windDirection + windspeed + } + daily { + _time + temperature0_max + temperature0_min + } + hourly { + _time + dewPoint_max + dewPoint_min + dewPoint_mean + direction_max + direction_mean + direction_min + pressure0_max + pressure0_mean + pressure0_min + relativeHumidity_max + relativeHumidity_mean + relativeHumidity_min + speed_max + speed_mean + speed_min + temperature0_max + temperature0_mean + temperature0_min + } + } + summitMedia: summitItemsList { + items { + allSkyImage { + timeCreated + updated + mediaLink + } + allSkyVideo { + timeCreated + updated + mediaLink + } + } + } + } +`; -export default function useEfd() { - const { data, error } = useSWR(process.env.NEXT_PUBLIC_EFD_URL, fetcher); +async function gqlFetcher(query, variables = {}) { + const client = new GraphQLClient(process.env.NEXT_PUBLIC_EFD_URL); + const headers = { + "Content-Type": "application/json", + "Hasura-Client-Name": "hasura-console", + "x-hasura-admin-secret": process.env.NEXT_PUBLIC_HASURA_SECRET, + "x-hasura-access-key": process.env.NEXT_PUBLIC_HASURA_SECRET, + }; + return client + .request(query, variables, headers) + .then((data) => data) + .catch((error) => { + process.exitCode = 1; + console.warn("Error in fetch.js :"); + console.warn(error); + return error.response; + }); +} + +// const fetcher = (url) => +// fetch(url, { +// method: "GET", +// headers: { "Content-Type": "application/json" }, +// }).then((res) => { +// return res.json(); +// }); + +export function useEfd(query) { + const { data, error } = useSWR([query, null, null, {}], gqlFetcher); return { data, isLoading: !error && !data, diff --git a/package.json b/package.json index 8f76feb6..9a686b8b 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ "react-hook-form": "^7.33.1", "react-i18next": "^12.0.0", "react-is": "^18.2.0", + "react-player": "^2.12.0", "react-popper": "^2.3.0", "react-uid": "^2.3.2", "striptags": "^3.2.0", From 3d37117e5eb1909186da489b4f2ab8c81b8db50c Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Thu, 24 Aug 2023 11:27:47 -0700 Subject: [PATCH 76/98] [C] Add editor config for IDE code styles --- .editorconfig | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..a51f0ed2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,38 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[**.{js,jsx,json}] +indent_style = space +indent_size = 2 + +[**.{css,scss}] +indent_style = space +indent_size = 2 + +[**.{rb,pp}] +indent_style = space +indent_size = 2 + +[**.php] +indent_style = space +indent_size = 4 + +[**.{yml,yaml}] +indent_style = space +indent_size = 2 + +[**.{txt}] +indent_style = space +indent_size = 2 + +[**.{html,htm,erb,twig,svg}] +indent_style = space +indent_size = 4 \ No newline at end of file From 87fb00f901c043a21ca9dd864822bd275600167a Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 29 Aug 2023 10:40:12 -0700 Subject: [PATCH 77/98] [C] ENV VARS include Hasura secret --- .github/workflows/dev-pull-request.yaml | 3 ++- .github/workflows/dev-push.yaml | 3 ++- .github/workflows/master-pr.yaml | 1 + .github/workflows/master-push.yaml | 3 ++- .github/workflows/prod-push.yaml | 1 + Dockerfile | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev-pull-request.yaml b/.github/workflows/dev-pull-request.yaml index 284e493e..7388bdd0 100644 --- a/.github/workflows/dev-pull-request.yaml +++ b/.github/workflows/dev-pull-request.yaml @@ -43,6 +43,7 @@ jobs: --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ + --build-arg NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . @@ -146,4 +147,4 @@ jobs: # Destruct! - name: Destroy version - run: gcloud app versions delete ${{ env.version_name }} --service=default \ No newline at end of file + run: gcloud app versions delete ${{ env.version_name }} --service=default diff --git a/.github/workflows/dev-push.yaml b/.github/workflows/dev-push.yaml index de5d53ef..dca62ef0 100644 --- a/.github/workflows/dev-push.yaml +++ b/.github/workflows/dev-push.yaml @@ -37,6 +37,7 @@ jobs: --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ + --build-arg NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . @@ -55,4 +56,4 @@ jobs: --quiet \ --image-url=gcr.io/${{ secrets.SV_PROJ_NAME }}/rubin-obs-client:${{ github.sha }} \ --promote \ - --project=${{ secrets.SV_PROJ_NAME }} \ No newline at end of file + --project=${{ secrets.SV_PROJ_NAME }} diff --git a/.github/workflows/master-pr.yaml b/.github/workflows/master-pr.yaml index 8e519736..dc3777cb 100644 --- a/.github/workflows/master-pr.yaml +++ b/.github/workflows/master-pr.yaml @@ -43,6 +43,7 @@ jobs: --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ + --build-arg NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . diff --git a/.github/workflows/master-push.yaml b/.github/workflows/master-push.yaml index adff4873..f9839403 100644 --- a/.github/workflows/master-push.yaml +++ b/.github/workflows/master-push.yaml @@ -37,6 +37,7 @@ jobs: --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ + --build-arg NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . @@ -54,4 +55,4 @@ jobs: gcloud app deploy app.yaml \ --image-url=gcr.io/edc-int-6c5e/skyviewer-client:${{ github.sha }} \ --promote \ - --project=edc-int-6c5e \ No newline at end of file + --project=edc-int-6c5e diff --git a/.github/workflows/prod-push.yaml b/.github/workflows/prod-push.yaml index 3a7f98c3..59fb9e6a 100644 --- a/.github/workflows/prod-push.yaml +++ b/.github/workflows/prod-push.yaml @@ -43,6 +43,7 @@ jobs: --build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN=rubinobservatory.org \ --build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \ --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ + --build-arg NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ . - name: Configure Docker Auth diff --git a/Dockerfile b/Dockerfile index f3d27bb5..aabfb314 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ ARG NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api.rubinobs.org/actions/contact-f ARG NEXT_PUBLIC_PLAUSIBLE_DOMAIN=rubinobs.org ARG CLOUD_ENV=PROD ARG NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql +ARG NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 ARG NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` RUN npx browserslist@latest --update-db && yarn static:build From 08f7c36607aa56257a4a47b49efd0e597c795ae5 Mon Sep 17 00:00:00 2001 From: Jared Trouth Date: Thu, 7 Sep 2023 15:36:44 -0500 Subject: [PATCH 78/98] add build and push workflow --- .github/workflows/build-and-push.yaml | 86 +++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/build-and-push.yaml diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml new file mode 100644 index 00000000..f51d3c40 --- /dev/null +++ b/.github/workflows/build-and-push.yaml @@ -0,0 +1,86 @@ +name: build-and-push + +on: + push: + branches: + - '*' + tags: + - 'v.*' + pull_request: + types: + - 'opened' + - 'synchronize' + - 'reopened' + - 'closed' + branches: + - 'develop' + - 'master' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + # list of Docker images to use as base name for tags + images: | + gcr.io/skyviewer/rubinobs-client,enable=${{ github.ref != 'master' && github.ref_type != 'tag' }} + gcr.io/edc-int-6c5e/rubinobs-client,enable=${{ github.ref == 'master'}} + gcr.io/edc-prod-eef0/rubinobs-client,enable=${{ github.ref_type == 'tag'}} + flavor: | + latest=true + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to GCP Dev + uses: google-github-actions/setup-gcloud@v0 + if: ${{ github.ref != 'master' && github.ref_type != 'tag' }} + with: + service_account_key: ${{ secrets.DEV_SA_KEY }} + project_id: skyviewer + export_default_credentials: true + - + name: Login to GCP Int + uses: google-github-actions/setup-gcloud@v0 + if: ${{ github.ref == 'master' }} + with: + service_account_key: ${{ secrets.SKYVIEWER_INT_SERVICE_ACCOUNT }} + project_id: edc-int-6c5e + export_default_credentials: true + - + name: Login to GCP Prod + uses: google-github-actions/setup-gcloud@v0 + if: ${{ github.ref_type == 'tag' }} + with: + service_account_key: ${{ secrets.PIPELINE_EPO_PROD_PROJECT }} + project_id: edc-prod-eef0 + export_default_credentials: true + - + run: gcloud --quiet auth configure-docker + - + name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From e2078cf8728efd9da26f0ed8b8cb6f965d41edbb Mon Sep 17 00:00:00 2001 From: Jared Trouth Date: Thu, 7 Sep 2023 15:53:44 -0500 Subject: [PATCH 79/98] Update Dockerfile for k8s --- .github/workflows/build-and-push.yaml | 7 ++- Dockerfile | 66 +++++++++++++++++++-------- 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index f51d3c40..c3e0d7f6 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -83,4 +83,9 @@ jobs: context: . push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} + cache-to: | + type=gha + cache-from: | + type=gha + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index aabfb314..a3b38a17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,26 @@ -# This file is based on the official Next.js Docker example. https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile +FROM node:18-alpine AS base -# Rebuild the source code only when needed -FROM node:16-alpine AS builder +# Install dependencies only when needed +FROM base AS deps +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat WORKDIR /app -COPY . /app -RUN apk add --no-cache libc6-compat git -RUN yarn install --frozen-lockfile +# Install dependencies based on the preferred package manager +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ +RUN \ + if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ + elif [ -f package-lock.json ]; then npm ci; \ + elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ + else echo "Lockfile not found." && exit 1; \ + fi + + +# Rebuild the source code only when needed +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . ARG NEXT_PUBLIC_API_URL=https://api.rubinobs.org/api ARG EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger @@ -15,28 +29,42 @@ ARG NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps ARG NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api.rubinobs.org/actions/contact-form/send ARG NEXT_PUBLIC_PLAUSIBLE_DOMAIN=rubinobs.org ARG CLOUD_ENV=PROD -ARG NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql -ARG NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 -ARG NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` -RUN npx browserslist@latest --update-db && yarn static:build +ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL +ENV EDC_LOGGER_API_URL=$EDC_LOGGER_API_URL +ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL +ENV NEXT_PUBLIC_GOOGLE_APP_ID=$NEXT_PUBLIC_GOOGLE_APP_ID +ENV NEXT_PUBLIC_CONTACT_FORM_POST_URL=$NEXT_PUBLIC_CONTACT_FORM_POST_URL +ENV NEXT_PUBLIC_PLAUSIBLE_DOMAIN=$NEXT_PUBLIC_PLAUSIBLE_DOMAIN +ENV CLOUD_ENV=$CLOUD_ENV + +# Next.js collects completely anonymous telemetry data about general usage. +# Learn more here: https://nextjs.org/telemetry +# Uncomment the following line in case you want to disable telemetry during the build. +# ENV NEXT_TELEMETRY_DISABLED 1 + +# RUN yarn static:build + +# If using npm comment out above and use below instead +# RUN npm run build # Production image, copy all the files and run next -FROM node:16-alpine AS runner +FROM base AS runner WORKDIR /app -RUN addgroup -g 1001 -S nodejs -RUN adduser -S nextjs -u 1001 +ENV NODE_ENV production +# Uncomment the following line in case you want to disable telemetry during runtime. +# ENV NEXT_TELEMETRY_DISABLED 1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs COPY --from=builder --chown=nextjs:nodejs /app/ ./ USER nextjs -# Next.js collects completely anonymous telemetry data about general usage. -# Learn more here: https://nextjs.org/telemetry -# Uncomment the following line in case you want to disable telemetry. -# ENV NEXT_TELEMETRY_DISABLED 1 - EXPOSE 8080 -CMD ["yarn", "start"] +ENV PORT 8080 + +CMD ["yarn", "start"] \ No newline at end of file From 18cc16b9ceb1a239cff877055c22e49ae4bcd252 Mon Sep 17 00:00:00 2001 From: Jared Trouth Date: Thu, 7 Sep 2023 15:55:11 -0500 Subject: [PATCH 80/98] update trigger branches --- .github/workflows/build-and-push.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index c3e0d7f6..cf4c1d94 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -3,7 +3,8 @@ name: build-and-push on: push: branches: - - '*' + - 'develop' + - 'master' tags: - 'v.*' pull_request: @@ -88,4 +89,3 @@ jobs: type=gha cache-from: | type=gha - \ No newline at end of file From bb312103dedbf3a343568d9d93657f8210efb186 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Tue, 21 Nov 2023 14:22:43 -0800 Subject: [PATCH 81/98] [F] Callouts use new DAM plugin Includes: - Main Callout Image - TwoTone Callout Background Image - Glossary Term Image - Investigation Hero Images --- .../Tile/patterns/InvestigationTile/index.js | 8 ++-- .../content-blocks/Callout/CalloutMain.js | 9 ++-- .../content-blocks/Callout/CalloutTwoTone.js | 8 ++-- components/layout/InvestigationHero/index.js | 7 +-- components/templates/GlossaryPage/index.js | 8 ++-- lib/api/fragments/content-blocks.js | 38 +++------------- lib/api/fragments/glossary-term.js | 10 +---- lib/api/fragments/image.js | 21 +++++++++ lib/api/fragments/investigation.js | 12 ++---- lib/api/investigation.js | 10 +---- lib/utils.js | 43 +++++++++++-------- 11 files changed, 78 insertions(+), 96 deletions(-) diff --git a/components/atomic/Tile/patterns/InvestigationTile/index.js b/components/atomic/Tile/patterns/InvestigationTile/index.js index 8a9be253..2195fc78 100644 --- a/components/atomic/Tile/patterns/InvestigationTile/index.js +++ b/components/atomic/Tile/patterns/InvestigationTile/index.js @@ -3,15 +3,15 @@ import { useUID } from "react-uid"; import { Image } from "@rubin-epo/epo-react-lib"; import * as Styled from "./styles"; import { useTranslation } from "react-i18next"; -import { useDamAssetAsImage } from "@/lib/utils"; +import { imageShaper } from "@/lib/utils"; const InvestigationTile = ({ investigation, useExternalLink }) => { const uid = useUID(); const { t } = useTranslation(); - const { damAsset, status, title, externalUrl, landingPage } = + const { cantoAssetSingle, status, title, externalUrl, landingPage } = investigation || {}; - const image = useDamAssetAsImage(damAsset?.[0]); + const image = imageShaper("EN", cantoAssetSingle?.[0]); const url = useExternalLink ? externalUrl : landingPage?.[0]?.uri; const isInactive = status === "inactive"; @@ -43,7 +43,7 @@ InvestigationTile.propTypes = { investigation: PropTypes.shape({ uri: PropTypes.string, title: PropTypes.string, - damAsset: PropTypes.array, + cantoAssetSingle: PropTypes.array, externalUrl: PropTypes.string, status: PropTypes.string, landingPage: PropTypes.arrayOf( diff --git a/components/content-blocks/Callout/CalloutMain.js b/components/content-blocks/Callout/CalloutMain.js index dab55d96..2c395d24 100644 --- a/components/content-blocks/Callout/CalloutMain.js +++ b/components/content-blocks/Callout/CalloutMain.js @@ -2,25 +2,24 @@ import PropTypes from "prop-types"; import classNames from "classnames"; -import imageShape from "@/shapes/image"; import { linksShape } from "@/shapes/link"; import Wrapper from "./Wrapper"; import { Header, Text, StyledMixedLink, StyledImage } from "./styles"; import TempList from "@/components/dynamic/TempList"; -import { useDamAssetAsImage } from "@/lib/utils"; +import { imageShaper } from "@/lib/utils"; export default function CalloutMain({ callout }) { const { dynamicComponent, header, - damAsset, + cantoAssetSingle, links, padImage, text, ...wrapperProps } = callout; - const calloutImage = useDamAssetAsImage(damAsset[0]); + const calloutImage = imageShaper("EN", cantoAssetSingle[0]); return ( @@ -73,10 +73,10 @@ export default function CalloutTwoTone({ callout }) { CalloutTwoTone.propTypes = { callout: PropTypes.shape({ backgroundColor: PropTypes.string, - backgroundImage: PropTypes.arrayOf(imageShape).isRequired, + backgroundImage: PropTypes.array, captionRichText: PropTypes.node, header: PropTypes.string, - image: PropTypes.arrayOf(imageShape).isRequired, + image: PropTypes.arrayOf(imageShape), links: linksShape, text: PropTypes.node, }).isRequired, diff --git a/components/layout/InvestigationHero/index.js b/components/layout/InvestigationHero/index.js index a656de27..2457abee 100644 --- a/components/layout/InvestigationHero/index.js +++ b/components/layout/InvestigationHero/index.js @@ -2,12 +2,12 @@ import PropTypes from "prop-types"; import * as Styled from "./styles"; import { Button, Image, IconComposer } from "@rubin-epo/epo-react-lib"; import T from "@/page/Translate"; -import { useDamAssetAsImage } from "@/lib/utils"; +import { imageShaper } from "@/lib/utils"; export default function InvestigationHero({ investigation }) { - const { damAsset, title, externalUrl, duration, status } = + const { cantoAssetSingle, title, externalUrl, duration, status } = investigation || {}; - const image = useDamAssetAsImage(damAsset?.[0]); + const image = imageShaper("EN", cantoAssetSingle?.[0]); if (!investigation) return null; @@ -52,5 +52,6 @@ InvestigationHero.propTypes = { title: PropTypes.string, }) ), + cantoAssetSingle: PropTypes.array, }), }; diff --git a/components/templates/GlossaryPage/index.js b/components/templates/GlossaryPage/index.js index a46d3503..10bf1def 100644 --- a/components/templates/GlossaryPage/index.js +++ b/components/templates/GlossaryPage/index.js @@ -1,7 +1,7 @@ import PropTypes from "prop-types"; import Body from "@/global/Body"; import Breadcrumbs from "@/page/Breadcrumbs"; -import { useCustomBreadcrumbs, useDamAssetAsImage } from "@/lib/utils"; +import { useCustomBreadcrumbs, imageShaper } from "@/lib/utils"; import { Container, ResponsiveImage, @@ -13,7 +13,7 @@ import { useTranslation } from "react-i18next"; export default function GlossaryPage({ data }) { const { t } = useTranslation(); - const { id, title, description, uri, text, damAsset, caption } = data; + const { id, title, description, uri, text, cantoAssetSingle, caption } = data; const customBreadcrumbs = useCustomBreadcrumbs("Glossary"); @@ -21,7 +21,7 @@ export default function GlossaryPage({ data }) { b.uri.includes("glossary") ); - const image = useDamAssetAsImage(damAsset); + const image = imageShaper("EN", cantoAssetSingle[0]); const bodyProps = { description, @@ -68,7 +68,7 @@ GlossaryPage.propTypes = { description: PropTypes.string, uri: PropTypes.string, text: PropTypes.node, - damAsset: PropTypes.array, + cantoAssetSingle: PropTypes.array, caption: PropTypes.string, }), }; diff --git a/lib/api/fragments/content-blocks.js b/lib/api/fragments/content-blocks.js index 74e89465..d3fa7216 100644 --- a/lib/api/fragments/content-blocks.js +++ b/lib/api/fragments/content-blocks.js @@ -1,4 +1,4 @@ -import { getImageFields } from "@/api/fragments/image"; +import { getImageFields, cantoSingleAsset } from "@/api/fragments/image"; import { getLinkFields } from "@/api/fragments/link"; /// /////////////////////////////////////////// @@ -31,14 +31,7 @@ export const calloutBlockFragment = ` backgroundColor dynamicComponent header - damAsset { - height - width - damMetadata { - metadataKey - metadataValue - } - } + ${cantoSingleAsset} links { ...links } @@ -51,14 +44,7 @@ export const calloutBlockFragment = ` } ...on callouts_calloutTwoTone_Entry { backgroundColor - backgroundImage: damAsset { - height - width - damMetadata { - metadataKey - metadataValue - } - } + backgroundImage: ${cantoSingleAsset} captionRichText header image: contentImage { @@ -277,14 +263,7 @@ export const investigationGridBlockFragment = ` title externalUrl: externalUrlTranslatable status: investigationStatus - damAsset { - height - width - damMetadata { - metadataKey - metadataValue - } - } + ${cantoSingleAsset} landingPage { uri title @@ -381,14 +360,7 @@ export const relatedContentFragment = ` uri status: investigationStatus description: investigationDescription - damAsset { - height - width - damMetadata { - metadataKey - metadataValue - } - } + ${cantoSingleAsset} landingPage { uri } diff --git a/lib/api/fragments/glossary-term.js b/lib/api/fragments/glossary-term.js index a40aaf6d..0018ac33 100644 --- a/lib/api/fragments/glossary-term.js +++ b/lib/api/fragments/glossary-term.js @@ -1,4 +1,5 @@ import { fullBaseFields } from "@/lib/api/fragments/shared"; +import { cantoSingleAsset } from "@/api/fragments/image"; export const glossaryTermFragment = ` fragment glossaryTermFragment on glossaryTerms_glossaryTerm_Entry { @@ -10,14 +11,7 @@ export const glossaryTermFragmentFull = ` fragment glossaryTermFragmentFull on glossaryTerms_glossaryTerm_Entry { ...on glossaryTerms_glossaryTerm_Entry { text - damAsset { - height - width - damMetadata { - metadataKey - metadataValue - } - } + ${cantoSingleAsset} caption } ancestors { diff --git a/lib/api/fragments/image.js b/lib/api/fragments/image.js index 56cafed4..0ae71545 100644 --- a/lib/api/fragments/image.js +++ b/lib/api/fragments/image.js @@ -18,3 +18,24 @@ export function getImageFields(mode = "fit", width = 900, height) { url ${transform(mode, width, height)} `; } + +export const cantoSingleAsset = gql` +cantoAssetSingle { + url { + directUrlPreview + directUrlOriginal + PNG + HighJPG + LowJPG + preview + } + width + height + metadata: additional { + AltTextEN + AltTextES + CaptionEN + CaptionES + Credit + } +}`; diff --git a/lib/api/fragments/investigation.js b/lib/api/fragments/investigation.js index cb335811..461d3f72 100644 --- a/lib/api/fragments/investigation.js +++ b/lib/api/fragments/investigation.js @@ -1,3 +1,5 @@ +import { cantoSingleAsset } from "@/api/fragments/image"; + export const investigationFragment = ` fragment investigationFragment on investigations_investigation_Entry { id @@ -5,15 +7,7 @@ export const investigationFragment = ` uri ...on investigations_investigation_Entry { date: dateUpdated - # description - damAsset { - height - width - damMetadata { - metadataKey - metadataValue - } - } + ${cantoSingleAsset} } } `; diff --git a/lib/api/investigation.js b/lib/api/investigation.js index b40b4651..e563f3b2 100644 --- a/lib/api/investigation.js +++ b/lib/api/investigation.js @@ -1,5 +1,6 @@ import { gql } from "graphql-request"; import { queryAPI } from "@/lib/fetch"; +import { cantoSingleAsset } from "@/api/fragments/image"; export async function addRelatedInvestigation(entryData, site) { if (!entryData || !entryData.id) return null; @@ -36,14 +37,7 @@ export async function getRelatedInvestigation(entryData, site = "default") { title } } - damAsset { - height - width - damMetadata { - metadataKey - metadataValue - } - } + ${cantoSingleAsset} } } } diff --git a/lib/utils.js b/lib/utils.js index 452e87af..f19f8bd1 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -408,29 +408,36 @@ export function getLocaleString(siteString) { } // DAM METADATA -export const useDamAssetAsImage = (damAsset) => { - if (!damAsset || damAsset.length === 0) { - return null; - } +export const imageShaper = (site, data, className) => { + if (!data) return undefined; + + const localeKeys = { + default: "EN", + es: "ES", + }; - const { height, width, damMetadata: rawMetadata } = damAsset; + const key = localeKeys[site]; - const damMetadata = rawMetadata.reduce((previous, current) => { - const { metadataKey, metadataValue } = current; - previous[metadataKey] = metadataValue; + const { metadata, url, width, height } = data; + const { directUrlPreview = "", directUrlOriginal = "", preview = "" } = url; - return previous; - }, {}); + const urlWithoutConstraint = directUrlPreview.slice(0, -3); + const constraint = Math.max(width, height); - const { directImageUrl: url, altText, thumbnailUrl: thumb } = damMetadata; + const altText = metadata[`AltText${key}`]; + const caption = metadata[`Caption${key}`]; + const credit = metadata.Credit; return { - url, - url2x: url, - url3x: url, - height, - width, - altText, - thumb, + url: `${urlWithoutConstraint}${Math.floor(constraint / 3)}`, + url2x: `${urlWithoutConstraint}${Math.floor(constraint / 2)}`, + url3x: directUrlOriginal, + thumb: preview, + width: Number(width), + height: Number(height), + className, + altText: altText === null ? undefined : altText, + caption: caption === null ? undefined : caption, + credit: credit === null ? undefined : credit, }; }; From c4099a3aac9425f8c9675a9f3a1a7046b4d4c1d1 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Wed, 13 Sep 2023 15:54:11 -0700 Subject: [PATCH 82/98] [F] ImageGrid content block --- components/atomic/Tile/styles.js | 7 +++-- .../content-blocks/GridBlock/ImageGrid.js | 31 +++++++++++++++++++ components/content-blocks/GridBlock/index.js | 3 ++ components/factories/ContentBlockFactory.js | 1 + lib/api/fragments/content-blocks.js | 26 ++++++++++++++++ 5 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 components/content-blocks/GridBlock/ImageGrid.js diff --git a/components/atomic/Tile/styles.js b/components/atomic/Tile/styles.js index 201c6476..424cd1d5 100644 --- a/components/atomic/Tile/styles.js +++ b/components/atomic/Tile/styles.js @@ -103,7 +103,7 @@ export const MixedLink = styled(BaseMixedLink)` } } - /* CTA */ + /* CTA (Also used for Image Grid) */ &.cta { grid-template-areas: "image" @@ -123,7 +123,7 @@ export const MixedLink = styled(BaseMixedLink)` } .title { - padding: 20px 0; + padding: 20px 5px; font-size: 16px; font-weight: 700; text-align: center; @@ -146,6 +146,7 @@ export const MixedLink = styled(BaseMixedLink)` img { width: 100px; height: 100px; + object-fit: cover; } } @@ -863,7 +864,7 @@ export const MixedLink = styled(BaseMixedLink)` color: var(--white); } - &.cta { + &.cta[href] { .image { outline: none; opacity: 0.7; diff --git a/components/content-blocks/GridBlock/ImageGrid.js b/components/content-blocks/GridBlock/ImageGrid.js new file mode 100644 index 00000000..fe42aa53 --- /dev/null +++ b/components/content-blocks/GridBlock/ImageGrid.js @@ -0,0 +1,31 @@ +import PropTypes from "prop-types"; +import { Grid } from "@rubin-epo/epo-react-lib"; +import Tile from "@/atomic/Tile"; + +const CTAGrid = ({ items, limit }) => { + const cols = limit === 4 ? 4 : 3; + + return ( + <> + {items.length > 0 && ( + + {items.map(({ id, contentImage, header }) => ( + + ))} + + )} + + ); +}; + +CTAGrid.propTypes = { + items: PropTypes.array, + limit: PropTypes.number, +}; + +export default CTAGrid; diff --git a/components/content-blocks/GridBlock/index.js b/components/content-blocks/GridBlock/index.js index 65642c1d..eb5cbbec 100644 --- a/components/content-blocks/GridBlock/index.js +++ b/components/content-blocks/GridBlock/index.js @@ -3,6 +3,7 @@ import styled from "styled-components"; import { Container, MixedLink } from "@rubin-epo/epo-react-lib"; import { mixedLinkShape } from "@/shapes/link"; import CTAGrid from "./CTAGrid"; +import ImageGrid from "./ImageGrid"; import MainGrid from "./MainGrid"; import NewsGrid from "./NewsGrid"; import CarouselGrid from "./CarouselGrid"; @@ -36,6 +37,7 @@ export default function GridBlock({ const gridMap = { ctaGrid: CTAGrid, + imageGrid: ImageGrid, news: NewsGrid, investigationGrid: InvestigationGrid, relatedContent: CarouselGrid, @@ -43,6 +45,7 @@ export default function GridBlock({ const widthMap = { ctaGrid: undefined, + imageGrid: undefined, news: undefined, investigationGrid: "regular", }; diff --git a/components/factories/ContentBlockFactory.js b/components/factories/ContentBlockFactory.js index b5053f72..35507664 100644 --- a/components/factories/ContentBlockFactory.js +++ b/components/factories/ContentBlockFactory.js @@ -27,6 +27,7 @@ const blockMap = { contact: Contact, contactStaff: ContactStaff, ctaGrid: GridBlock, + imageGrid: GridBlock, image: Image, link: Link, linkedAsset: Link, diff --git a/lib/api/fragments/content-blocks.js b/lib/api/fragments/content-blocks.js index a58f0aba..74e89465 100644 --- a/lib/api/fragments/content-blocks.js +++ b/lib/api/fragments/content-blocks.js @@ -220,6 +220,30 @@ export const ctaGridBlockFragment = ` } `; +export const imageGridBlockFragment = ` + fragment imageGridBlock on contentBlocks_NeoField { + ... on contentBlocks_imageGrid_BlockType { + typeHandle + id + header + mixedLink { + ${getLinkFields()} + } + items: children { + ... on contentBlocks_imageGridItem_BlockType { + id + header + contentImage { + ...on contentImages_Asset { + ${getImageFields("crop", 572, 316)} + } + } + } + } + } + } +`; + export const imageBlockFragment = ` fragment imageBlock on contentBlocks_NeoField { ...on contentBlocks_image_BlockType { @@ -578,6 +602,7 @@ ${calloutBlockFragment} ${complexTableBlockFragment} ${contactBlockFragment} ${ctaGridBlockFragment} +${imageGridBlockFragment} ${imageBlockFragment} ${investigationGridBlockFragment} ${linkBlockFragment} @@ -602,6 +627,7 @@ export const allPageBlocks = ` ...complexTableBlock ...contactBlock ...ctaGridBlock + ...imageGridBlock ...imageBlock ...investigationGridBlock ...linkBlock From 65ca339f953e0169955c8d91268599d1c6246a81 Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Thu, 14 Sep 2023 12:41:15 -0700 Subject: [PATCH 83/98] [B] Search results only return entries with uris - Search results Tile layout refined for mobile - Search results Tile does not include nested a tags - Minor style changes - All entire include fullBaseFragment boilerplate fields --- components/atomic/Tile/index.js | 11 +++++- components/atomic/Tile/styles.js | 39 +++++++++++++------ components/dynamic/SearchList/index.js | 34 ++++++++++++++-- components/dynamic/SearchList/styles.js | 6 +++ lib/api/entries.js | 3 -- lib/api/fragments/educator-page.js | 4 +- .../fragments/investigation-landing-page.js | 5 +-- lib/api/fragments/page.js | 5 +-- lib/api/fragments/staff-profile.js | 7 +--- lib/api/fragments/student-page.js | 5 +-- lib/localeStrings/en.json | 12 +++++- lib/localeStrings/es.json | 12 +++++- 12 files changed, 103 insertions(+), 40 deletions(-) create mode 100644 components/dynamic/SearchList/styles.js diff --git a/components/atomic/Tile/index.js b/components/atomic/Tile/index.js index 8b801fc5..89c65ae9 100644 --- a/components/atomic/Tile/index.js +++ b/components/atomic/Tile/index.js @@ -46,7 +46,7 @@ const Tile = ({ return ( )} {pretitle &&
{pretitle}
} - {title && ( + {title && type === "search" && ( + + + {title} + + + )} + {title && type !== "search" && ( {title} diff --git a/components/atomic/Tile/styles.js b/components/atomic/Tile/styles.js index 424cd1d5..165baa41 100644 --- a/components/atomic/Tile/styles.js +++ b/components/atomic/Tile/styles.js @@ -683,14 +683,32 @@ export const MixedLink = styled(BaseMixedLink)` font-size: 16px; font-weight: 700; + nav { + background-color: transparent; + } + li:last-of-type { display: none; } } - .title { - font-size: 20px; - font-weight: 700; + .title-link { + text-decoration-color: var(--turquoise85); + + .title { + font-size: 20px; + font-weight: 700; + color: var(--turquoise85); + } + + &:hover, + &:focus-visible { + text-decoration-color: var(--black); + + .title { + color: var(--black); + } + } } .text { @@ -705,13 +723,13 @@ export const MixedLink = styled(BaseMixedLink)` @media (max-width: ${BREAK_TABLET}) { grid-template-areas: - "pretitle" - "title" - "text" - "subtitle"; - grid-template-columns: 1fr; + "image pretitle" + "image title" + "image text" + "image subtitle"; + grid-template-columns: 100px 1fr; - .image { + .pretitle { display: none; } } @@ -828,8 +846,6 @@ export const MixedLink = styled(BaseMixedLink)` &.pages:focus-visible, &.darkSlide:hover, &.darkSlide:focus-visible, - &.search:hover, - &.search:focus-visible, &.slideshows:hover, &.slideshows:focus-visible, &.news:hover, @@ -850,7 +866,6 @@ export const MixedLink = styled(BaseMixedLink)` &:focus-visible { &.pages, &.news, - &.search, &.slideshows { color: var(--turquoise85); } diff --git a/components/dynamic/SearchList/index.js b/components/dynamic/SearchList/index.js index 45a9fd72..00d30e90 100644 --- a/components/dynamic/SearchList/index.js +++ b/components/dynamic/SearchList/index.js @@ -12,6 +12,7 @@ import Breadcrumbs from "@/components/page/Breadcrumbs"; import { Grid } from "@rubin-epo/epo-react-lib"; import DataList from "@/dynamic/DataList"; import Tile from "@/atomic/Tile"; +import * as Styled from "./styles"; const SearchList = ({ button, @@ -24,6 +25,7 @@ const SearchList = ({ const localeInfo = useGlobalData("localeInfo"); const rootPages = useGlobalData("rootPages"); const lang = localeInfo?.language || "en-US"; + const makePretitle = (entry) => { if (entry.eventType) { return entry.eventType[0].title; @@ -84,6 +86,33 @@ const SearchList = ({ return ; }; + const makeSubtitle = (entry) => { + const type = { + galleryItem: t("gallery.gallery-item"), + slideshow: t("gallery.slideshow"), + events: t("events.event"), + job: t("jobs.job"), + post: t("news.news"), + pages: t("pages.page"), + studentPages: t("pages.page"), + educatorPages: t("pages.page"), + staffProfiles: t("staff.rubin-voices"), + glossaryTerm: t("glossary.glossary-term"), + investigationLandingPage: t("investigation.investigation"), + }[entry.typeHandle]; + + return ( + +
{type ? `${type} ` : ``}
+
+ {entry.date + ? `${t("published")} ${makeDateString(entry.date, lang)}` + : ``} +
+
+ ); + }; + return ( Date: Mon, 23 Oct 2023 13:11:24 -0700 Subject: [PATCH 84/98] [B] Locale string Rubin Voices typo fixed --- lib/localeStrings/es.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/localeStrings/es.json b/lib/localeStrings/es.json index a7651059..7db769ff 100644 --- a/lib/localeStrings/es.json +++ b/lib/localeStrings/es.json @@ -71,7 +71,7 @@ "gallery-items": "Items de la galería", "jobs": "Trabajos", "news": "Noticias", - "staff-profiles": "PVoces de Rubin", + "staff-profiles": "Voces de Rubin", "slideshows": "Diapositivas", "image": "Imagen", "video": "Video", From 6ed171bfc7ed4676c915ffdbf4ff8e73f60b0dcb Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Mon, 23 Oct 2023 13:10:19 -0700 Subject: [PATCH 85/98] [F] Survey Sparrow script --- .env.local.sample | 16 ++++--- .github/workflows/dev-pull-request.yaml | 1 + .github/workflows/dev-push.yaml | 1 + .github/workflows/master-pr.yaml | 1 + .github/workflows/master-push.yaml | 1 + .github/workflows/prod-push.yaml | 1 + Dockerfile | 4 ++ pages/_app.js | 61 +++++++++++++++++++++++++ 8 files changed, 79 insertions(+), 7 deletions(-) diff --git a/.env.local.sample b/.env.local.sample index 39b64239..99c5675c 100644 --- a/.env.local.sample +++ b/.env.local.sample @@ -3,12 +3,14 @@ # Prepend "NEXT_PUBLIC_" to Next.js env vars to expose them as process.env.NEXT_PUBLIC_ANALYTICS_ID, for example NEXT_PUBLIC_API_URL=http://localhost:8080/api/ -NEXT_PUBLIC_BASE_URL=http://localhost:8080 -NEXT_PUBLIC_CONTACT_FORM_POST_URL="https://rubinobs.org" +NEXT_PUBLIC_BASE_URL=http://localhost:3000 +NEXT_PUBLIC_CONTACT_FORM_POST_URL=http://localhost:8080/actions/contact-form/send NEXT_PUBLIC_GOOGLE_APP_ID= -NEXT_PUBLIC_PAGEPROOFER_ID= - CRAFT_REVALIDATE_SECRET_TOKEN= - -# This should not be present in Production, but it's OK for dev. -# NODE_TLS_REJECT_UNAUTHORIZED=0 +CLOUD_ENV = DEV +NEXT_PREVIEW_SLUG= +NEXT_PUBLIC_DEBUG_LOGGING= +NEXT_PUBLIC_RELEASE_URL= +NEXT_PUBLIC_EFD_URL= +NEXT_PUBLIC_HASURA_SECRET= +NEXT_PUBLIC_SURVEY_SPARROW= diff --git a/.github/workflows/dev-pull-request.yaml b/.github/workflows/dev-pull-request.yaml index 7388bdd0..f1c5c923 100644 --- a/.github/workflows/dev-pull-request.yaml +++ b/.github/workflows/dev-pull-request.yaml @@ -45,6 +45,7 @@ jobs: --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ --build-arg NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ + --build-arg NEXT_PUBLIC_SURVEY_SPARROW=true \ . - name: Configure Docker Auth diff --git a/.github/workflows/dev-push.yaml b/.github/workflows/dev-push.yaml index dca62ef0..ea07650a 100644 --- a/.github/workflows/dev-push.yaml +++ b/.github/workflows/dev-push.yaml @@ -39,6 +39,7 @@ jobs: --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ --build-arg NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ + --build-arg NEXT_PUBLIC_SURVEY_SPARROW=true \ . - name: Configure Docker Auth diff --git a/.github/workflows/master-pr.yaml b/.github/workflows/master-pr.yaml index dc3777cb..28754090 100644 --- a/.github/workflows/master-pr.yaml +++ b/.github/workflows/master-pr.yaml @@ -45,6 +45,7 @@ jobs: --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ --build-arg NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ + --build-arg NEXT_PUBLIC_SURVEY_SPARROW=true \ . - name: Configure Docker Auth diff --git a/.github/workflows/master-push.yaml b/.github/workflows/master-push.yaml index f9839403..c847e266 100644 --- a/.github/workflows/master-push.yaml +++ b/.github/workflows/master-push.yaml @@ -39,6 +39,7 @@ jobs: --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ --build-arg NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ + --build-arg NEXT_PUBLIC_SURVEY_SPARROW=true \ . - name: Configure Docker Auth diff --git a/.github/workflows/prod-push.yaml b/.github/workflows/prod-push.yaml index 59fb9e6a..28925f13 100644 --- a/.github/workflows/prod-push.yaml +++ b/.github/workflows/prod-push.yaml @@ -45,6 +45,7 @@ jobs: --build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \ --build-arg NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 \ --build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \ + --build-arg NEXT_PUBLIC_SURVEY_SPARROW=true \ . - name: Configure Docker Auth run: gcloud --quiet auth configure-docker diff --git a/Dockerfile b/Dockerfile index a3b38a17..b5c6149f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,10 @@ ARG NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps ARG NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api.rubinobs.org/actions/contact-form/send ARG NEXT_PUBLIC_PLAUSIBLE_DOMAIN=rubinobs.org ARG CLOUD_ENV=PROD +ARG NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql +ARG NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 +ARG NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` +ARG NEXT_PUBLIC_SURVEY_SPARROW=true ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL ENV EDC_LOGGER_API_URL=$EDC_LOGGER_API_URL diff --git a/pages/_app.js b/pages/_app.js index a97061a9..d3bb646f 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -11,6 +11,7 @@ import GlobalStyles from "@/styles/globalStyles"; import styles from "@/styles/styles.scss"; const PLAUSIBLE_DOMAIN = process.env.NEXT_PUBLIC_PLAUSIBLE_DOMAIN; +const SURVEY_SPARROW = process.env.NEXT_PUBLIC_SURVEY_SPARROW; function Client({ Component, pageProps }) { const authData = useAuthentication({ @@ -30,6 +31,66 @@ function Client({ Component, pageProps }) { strategy="afterInteractive" /> )} + {SURVEY_SPARROW && ( + <> +
+