For this week, I spent time trying to integrate my project, P3, with a sister project, i.e S3. The relationship between them is that P3 is a project dashboard manager, allowing users to create, read, update and delete their projects and boards, configure a cloud storage to be used to store the project files, and the downloading of a project’s firmware into a board of their choice, while S3 is an Integrated Development Environment (IDE) that provides an environment for users to edit a project’s source files, run simulations, etc.

P3’s backend communicates with S3’s backend through REST API endpoints. The procedure for communicating between these two projects is as follows:

  1. User double clicks on a project in P3’s front end interface.
  2. This would trigger a GET request to the cache endpoint, since the requested project archive could only either be in the cache or in the user’s cloud storage.
  3. If the requested project archive exists, then subsequently create a workspace in S3, which is done through a POST request to a REST endpoint dealing with the workspace.
  4. The response upon successful creation of the workspace would have its Location header containing a URI path pointing to the workspace endpoint but with a specified path info and additional parameters to be used for further requests.
  5. The project archive is then pushed to the newly created workspace, through a PUT request.
  6. A new tab in the browser would be opened, sending the GET request to that workspace URI, resulting in a 301 Moved Permanently redirection to the IDE application.

The previous intern had already set up the requests that would be used for communicating with S3, so it was just a matter of reusing it for my current cache implementation and then adding some code on the front end to trigger the GET request to the cache endpoint when the user double clicks a project. The opening of a new tab is done through the window.open() method that is part of the JavaScript Web APIs.

However, the issue now is that the browser pop-up blocker would prevent the opening of a new tab, unless the user authorized it. The reason being is that the programmatic opening of a new tab should be done as a result of a user action, such as a click, not through the completion of some asynchronous operations like Ajax requests. At the moment, the window.open() method is called within a callback that fires once the GET request to the cache endpoint successfully returns a response, hence it is not considered to be a user action. I would need to find a way such that the opening of a new tab is actually done based on the user’s action.

Unfortunately I didn’t have enough time to explore options, as on the last working day of the week, most of the time was spent working with Marcus to fixed a bug in CRS and also attempting to help him with the problems that he is having while trying to manually test CRS. Next week it is then.


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.