metasfresh / metasfresh-webui-frontend-legacy

metasfresh Webui Frontend
GNU General Public License v2.0
57 stars 35 forks source link

Add redux reducer for app updates websocket events #2324

Open siemiatj opened 5 years ago

siemiatj commented 5 years ago

Is this a bug or feature request?

Feature

What is the current behavior?

Together with @metas-ts we've decided there must be a way of notifying the application about changes to data without altering the current UI. So plan is to have new websocket requests that will be stored in the app state available for the app to check.

Which are the steps to reproduce?

What is the expected or desired behavior?

Example flow (just to get the basic idea of what we're trying to accomplish) would be as follows :

siemiatj commented 5 years ago

Websockets communication

  1. Use the websocket server provided by https://www.websocket.org/echo.html
  2. Metasfresh app is using the stompjs library for ws connections, but since STOMP format it's not supported by the websocket.org server, you can use ws, or any other package.
  3. We have redux actions for connecting/disconnecting websockets (https://github.com/metasfresh/metasfresh-webui-frontend/blob/master/src/actions/WindowActions.js#L1327) as a general guidance, but for reasons mentioned above (and since you're gonna be using a different endpoint for communication) you have to create new ones
  4. Returned websocket message should have a json format and two fields:
    {
    id,
    name,
    }

Where to start:

First, when creating your dev environment (https://github.com/metasfresh/metasfresh-webui-frontend/blob/master/README.md#dev-environment) point your configs to https://dev667.metasfresh.com/ instead of localhost. Credentials to authenticate are:

This is a dev instance with only basic test data added, so you can play around there without breaking things.

Implementation requirements