Add-On Manager download and install from add-on index feature needing help

Hi family, The add-on manager OWA which is a refresh of the Open Web App Management Module is almost done. We have so far implemented features to upload, search, list and delete Open Web Apps and looking forward to more improvements to the OWA as my team’s stay at OpenMRS elapses. However, we added a new feature to search for OWAs online via the openmrs add-on index and install them. The online search feature has been successfully implemented but the installation feature after an OWA is retrieved from the add-on index is what is yet to be completed. The reason for the delay in the install feature completion is due to CORS blocker that we have. The feature works in a way that a user searches for the module and directly installs it if it is not available. The installation process includes retrieving the OWA from whatever site it is being hosted at e.g bintray. We welcome any suggestions and approaches towards the problem at hand or yet better ways to install OWAs after a successful online search. cc: @suthagar23 @dkayiwa @kingisaac95 @jeiddiah @millicent

2 Likes

@suthagar23 do you wanna share how you approached this when doing the system admin app?

@dkayiwa Sure, I will share that after look at this code base :slight_smile:

Here I also faced same CORS situation while working with SysAdmin OWA. I contacted Bintary support team for this problem, they informed me that they will work on this browser based CORS problem at the end of the year.

Another solution for this problem is, Using JSONP instead of JSON calls. Anyway this also did not work for at that time for the Bintary.

For the immediate solution, Do not call the Bintary REST end point from the broswer(using JS - React or Angular). Just do the Bintary side REST request from the server(Inside the OpenMRS server). Then you can successfully download the package from the bintary without any issues :slight_smile:

Cc : @dkayiwa

@suthagar23 I successfully download the package but this was after I got a chrome extension to curb the CORS issue ( not scaleable) but on upload of the package the response I get from the server is that the App is not a zip archive. Although I used promises to get the zip and send it as part of the body for a POST request to install the app. Would you please shed more light on this: [quote=“suthagar23, post:4, topic:13616”] Just do the Bintary side REST request from the server(Inside the OpenMRS server). Then you can successfully download the package from the bintary without any issues :slight_smile: [/quote]

First, you can’t depend on the Chrome Extension for the CORS issue :smile:. That’s only for the developers, not for the users. How can you ensure that the user alreadty installed this extension to avoid the CORS in their browser level? They may use some other browsers, then they can’t download the module from the browser level. So best way is, avoid the chrome extension and implement this function in the server level.

For the module upload, you should create a FormData including that Zip as file type. Please find the uploadModule method from here,

@suthagar23 Okay. I will be reaching out soon enough.

cc: @kingisaac95 @jeiddiah @millicent

I just prepared a workflow for this access. You need to accesss Bintary API from the Server Side.

This is some resource for your help,