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

Elm PWA on Capture page #55

Closed
3 tasks done
SimonLab opened this issue Dec 13, 2019 · 7 comments
Closed
3 tasks done

Elm PWA on Capture page #55

SimonLab opened this issue Dec 13, 2019 · 7 comments
Assignees
Labels
T1h Time Estimate 1 Hour

Comments

@SimonLab
Copy link
Member

SimonLab commented Dec 13, 2019

ref: dwyl/app#254
At the moment the capture page is displayed with Phoenix template. To test PWA we can create an simple Elm app which will allow the user to capture the text via Elm.

  • Create a Browser.element application which will compiled and bundle to the main app.js script file

  • Nest this application on a specific elm capture page

  • Send post request to the api endpoint (see Add routes for API capture #53) to save the text

Once this checkbox for the main structure of the Elm nested app have been implemented we can enhance the application by adding offline feature with PWA

@SimonLab SimonLab added the T1h Time Estimate 1 Hour label Dec 13, 2019
@SimonLab SimonLab self-assigned this Dec 13, 2019
@SimonLab SimonLab added the in-progress An issue or pull request that is being worked on by the assigned person label Dec 13, 2019
@SimonLab
Copy link
Member Author

SimonLab commented Dec 13, 2019

Creating a simple elm application:

main = text "Hello Elm Capture!

And nesting this application on /elm/capture (keep the original capture endpoint for now but we can deleted later when Elm application is fully functional). Visiting http://localhost:4000/elm/capture will display the Phoenix html page (only containing the h1) and initialise the Elm app containing the "Hello Elm Capture!" text:
image

Now that the app is nested we can start to build the textarea and using Browser.document to manage the view and the state of the application
see commit f43b139

@SimonLab
Copy link
Member Author

SimonLab commented Dec 13, 2019

Updating application with Browser.element to manage the capture text state with via a textarea:
image
see 9681363

The next step is to send the capture with a post request to the api.
I've forgotten the details on sending and decoding the response from an api so reading the Elm in Action chapters:
image

@SimonLab SimonLab removed the in-progress An issue or pull request that is being worked on by the assigned person label Dec 13, 2019
@SimonLab
Copy link
Member Author

Saving capture using post request from Elm:
image

@SimonLab
Copy link
Member Author

To use PWA we need to create and add files to our application assets, see https://shaun-etherton.com/tech/2019/01/24/phoenix-1.4-js-static-assets.html

@SimonLab
Copy link
Member Author

Following the article and repo above I've manage to make the service_worker.js file accessible for the Elm application:
image

@SimonLab
Copy link
Member Author

The application can't be installed yet as the following error is displayed:
image

reading https://stackoverflow.com/questions/45534076/site-cannot-be-installed-no-matching-service-worker-detected

Using service worker with Phoenix https://www.botsquad.com/2018/03/07/phoenix-sw/

@SimonLab
Copy link
Member Author

Testing WPA on a separate Elm application using its own navigation to see if the issue above can be resolved without using Phoenix routing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T1h Time Estimate 1 Hour
Projects
None yet
Development

No branches or pull requests

2 participants