Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rewrite the Weather to an Edge App #105

Merged
merged 16 commits into from
Aug 15, 2023

Conversation

nicomiguelino
Copy link
Contributor

@nicomiguelino nicomiguelino commented Jul 13, 2023

General

Checklist

  • Move contents of edge-apps/weather/src into edge-apps/weather (the root directory) instead.
  • Remove unnecessary files — gulpfile.js, .babelrc, load-metadata.js, load-screenly.js.
  • Modify index.html.
  • Make use of client-side storage for caching the API key and weather data instead.
  • Have main.js get the OpenWeatherMap API key from the settings instead.

Screenshots

In order to test the Weather app (rewritten as an Edge App), started a simple HTTP server by running python3 -m http.server, which hosts the app at 0.0.0.0:8000 by default. I've also used a mocked screenly.js, which I didn't commit in this PR.

image

@nicomiguelino nicomiguelino marked this pull request as ready for review July 13, 2023 05:20
@vpetersson
Copy link
Contributor

@nicomiguelino what are these things? Is this an encoding issue?
Screenshot 2023-08-14 at 10 55 56 AM

Copy link
Contributor

@vpetersson vpetersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending question about encoding issue.

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment-with-locales.min.js" integrity="sha512-42PE0rd+wZ2hNXftlM78BSehIGzezNeQuzihiBCvUEB3CVxHvsShF86wBWwQORNxNINlBPuq7rG4WWhNiTVHFg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

<script
src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment-with-locales.min.js"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ship moment as part of the edge app.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All done (locally). Expect changes on succeeding commit/s.

try {
const endpointUrl = `https://api.openweathermap.org/data/2.5/forecast`
const apiKey = screenly.settings.openweathermap_api_key
const queryParams = `lat=${lat}&lon=${lng}&units=metric&cnt=10&appid=${apiKey}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's easier to just pass the right unit here (matric is hard coded) than to do Fahrenheit conversion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll address this comment on another issue or pull request. I'll keep you posted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #110 for details.

@nicomiguelino
Copy link
Contributor Author

@nicomiguelino what are these things? Is this an encoding issue? Screenshot 2023-08-14 at 10 55 56 AM

My bad, I haven't updated the screenshots. It's all good now.

- Host `Moment.js` locally.
- Have the indexed DB be cleared first before caching a new set of data.
- Refactor how the query parameters are declared (for readability).
@nicomiguelino
Copy link
Contributor Author

@vpetersson, I'd like to request a code review. Thanks.

@vpetersson vpetersson merged commit 37d4cd1 into Screenly:master Aug 15, 2023
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rewrite Weather app to edge app
3 participants