[p42] - settings under network
ilarimikkonen opened this issue · comments
if selected proxy is p42, user can see only"proxy base path", "api base path" and port.
after saving setting, user can send requests via configured URLs
if possible, do not keep any information in local db, but state is in proxy
Current situation
It seems, that the functionality of connecting an API to Proxy 42 needs to be completely separated from the functionality of connecting an API to apinfUmbrella.
- in apinfUmbrella case the connection information is stored in proxy and in addition to that, it is duplicated in local DB.
- Handling the data exchange to apinfUmbrella proxy is intertwined with storing data to local database, which means that in Proxy 42 case also a kind of mock data record is needed to be stored in proxyBackend DB containing some data.
- Also the sending and receiving requests and responses is heavily related to updating to data from form to db. Thus adding handling of proxy 42 HTTP requests and responses to that would increase the complexity in code.
Suggestion
Separate connecting an API to proxy 42 from API to apinfUmbrella completely
- API > Settings
- add a new button, e.g. [Proxy 42] to Settings page
- when API is connected to apinfUmbrella, the Proxy 42 button is not visible
- when API is connected to Proxy 42, the button [ApinfUmbrella] (replacing button [Network]) is not visible.
- API > Settings > Proxy 42
- when API is connected to Proxy 42, the id of used Proxy card is stored into API data as a new field
- in case API is connected to Proxy 42, the correct Proxy card is found by Proxy Id in API data. From Proxy card can be read the URL, from where the API-Proxy connection data is requested from Proxy 42 using HTTP GET method. After data response is gotten, the data is filled in and shown on Proxy 42 connection page.
- in case API is not connected to Proxy 42, a page with empty input fields is displayed.
- the connection data can be filled (or changed) in input fields. When button [Save configuration] is clicked, the connection data is updated to Proxy 42 using HTTP POST request.
- In successful case the Proxy card id is stored into API card.
- in unsuccessful case the response error code with possible error message is shown as an alert on page, providing user a possibility to make corrections.
- when the connection is successfully established, also a button [] possible to add connection, update connection or remove connection
When the API is successfully connected to Proxy 42, a new button [RESET CONFIGURATION] is included in the page.
By clicking this button the connection is removed by sending a HTTP DELETE request to Proxy 42 in question.
- After successful response, the Proxy id is removed from API data and the button [RESET CONFOGURATION] is no more visible.
- In unsuccessful case the HTTP error code and possible error message are displayed on page as an alert.