-
Notifications
You must be signed in to change notification settings - Fork 44
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
O3-310: allow Put operations on an application-writable config.json file to openmrs/data/frontends/config.json #57
Conversation
omod/src/main/java/org/openmrs/module/spa/controllers/TrialConfigController.java
Outdated
Show resolved
Hide resolved
omod/src/main/java/org/openmrs/module/spa/filter/SpaFilter.java
Outdated
Show resolved
Hide resolved
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
omod/src/test/java/org/openmrs/module/spa/servlet/SpaServletTest.java
Outdated
Show resolved
Hide resolved
omod/src/test/java/org/openmrs/module/spa/servlet/SpaServletWebTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, every request to spa/
transformed with an a retrieve the index.html
file.
Ideally, i think, this is the reason the controllers i registered with 70e0cdd were actually not being called (silent).
I tried to call them manually but things just got messed up the more, leaving me with implementing the logic in the doGet
and doPut
.
I also didn't want to reimplement the existing logic of rendering the index.html
logic
cc @dkayiwa @ibacher @hadijahkyampeire @vasharma05 @brandones @denniskigen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jnsereko Thanks for the PR! I think there are some decent ideas here, but some things that need to be addressed before this can be merged in.
I think there are some design questions here that need to be handled as well, specifically around how this is supposed to interact with the implementer tools. What should happen when, having created a configuration, I go back into the implementer tools to configure a different component? What if I decide my configuration is broken and I want to get rid of it?
Finally, why is this defaulting to /openmrs/spa/frontend/config
instead of, e.g., /openmrs/spa/config.json`?
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
PS The requests for |
@ibacher @dkayiwa, i think we have to change the endpoint simply to I have also removed creation of the |
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
@jnsereko are you still working on this? |
omod/src/main/java/org/openmrs/module/spa/servlet/SpaServlet.java
Outdated
Show resolved
Hide resolved
The Docker images have never used module-spa. |
The reason why I asked @ibacher is because deployed the spa module into
docker for 3.x but all requests to spa/config.json actually returned 404
yet it used to work sometime back (on opening this PR)
…On Mon, May 29, 2023, 3:34 PM Ian ***@***.***> wrote:
Is it that 3.x has finally migrated away form using the this module?
The Docker images have never used module-spa.
—
Reply to this email directly, view it on GitHub
<#57 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AN2Q67ZXA5VF4HBKG2MWE4DXISJWZANCNFSM6AAAAAAVKTVR74>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
When you were testing this previously, I'm pretty sure you were using the SDK. We haven't changed anything about how the routing works. If you're using the Docker containers, requests to |
This now makes sense @ibacher
Maybe I was using the sdk to test those days but now using docker.
Actually logs were showed only frontend and getway images. I was wondering
why the backed was not showing.
Since I prefer docker, and now that all requests to */spa/* go to frontend,
how can I override this? Additionally, would there another better option?
…On Mon, May 29, 2023, 7:19 PM Ian ***@***.***> wrote:
When you were testing this previously, I'm pretty sure you were using the
SDK. We haven't changed anything about how the routing works. If you're
using the Docker containers, requests to /openmrs/spa will never hit the
backend... and that's been the case since we put the Docker containers
together. (This is, in fact, what allows us to provide the "single-page"
experience; any request to /openmrs/spa is forwarded to the frontend
container and any request for a URL in the frontend container that does not
otherwise resolve to something serves the single-page content).
—
Reply to this email directly, view it on GitHub
<#57 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AN2Q675TFNAHBUMBCX3ANUTXITEBVANCNFSM6AAAAAAVKTVR74>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
i have created a thread for how to move forward because we cant limit this feature to working only in the |
config.json file name shouldn't be dynamic dynamically serve 'frontend/config.json' endpoint remove unrequited change
thanks to @dkayiwa, i dynamically defined a servlet to expose an end-point This works fine in both |
@dkayiwa @ibacher the frontend implementation has been approved see openmrs/openmrs-esm-core#629 (review) |
public void setServletContext(ServletContext servletContext) { | ||
|
||
try { | ||
ServletRegistration openmrsServletReg = servletContext.getServletRegistration("openmrs"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this mapping used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we need to ensure that any mapping is supposed to be on top of the OpenMRS servlet. just to eliminate circumstances like https:localhost:port/ws/frontend/config.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when you remove line 32?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If servletContext.getServletRegistration("openmrs");
isn't necessary @dkayiwa, how can i add mappings to the Openmrs Servlet then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when you remove line 32?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works fine.
String basicAuth = request.getHeader("Authorization"); | ||
if (basicAuth != null) { | ||
// check that header is in format "Basic ${base64encode(username + ":" + password)}" | ||
if (isValidAuthFormat(response, basicAuth)) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ServletRegistration servletReg = servletContext.addServlet("spaServlet", new SpaServlet()); | ||
servletReg.addMapping("/ws/frontend/config.json"); | ||
|
||
Dynamic filter = servletContext.addFilter("spaFilter", new SpaFilter()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the SpaFilter part of this ticket?
@Override | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
String requestURI = request.getRequestURI(); | ||
if (requestURI.endsWith("/config.json")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you reduce the deep nesting of these if statements?
I completely agree! 👍 |
updating it now |
Is this functionality going to be only for those who are not using the docker setup of O3 (Because it does not load the spa module) |
We can add the module to distro if we choose to. I can do that with your permission |
I do not think that would be the best option. One other option is adding this to the rest webservices module. This calls for some sort of discussion on talk. |
I have created a thread: https://talk.openmrs.org/t/adding-openmrs-spa-module-to-dev3-vs-migrating-some-of-its-logic-to-rest-webservices/41250 |
@dkayiwa PR created in Rest web services repo openmrs/openmrs-module-webservices.rest#595 |
There should be a
config.json
file that the application is allowed to manage, which lives in the application data directory.module-spa should have a REST endpoint
PUT /ws/frontend/config
that sets the value of this file.The file is served the usual way along with everything else in the
frontend/
directory.The Implementer Tools should have a button that updates that file with the temporary config.
cc @dkayiwa @hadijahkyampeire
Issue Link: https://issues.openmrs.org/browse/O3-310
Screenshots
Uploading screen recording.mov…
config.video.mov