Add Servers

How to Connect to One or More ActivePivot, ActiveMonitor or Content Server(s)

There are three ways to connect your application to ActivePivot, ActiveMonitor or Content servers:

Programmatically #

Building the Server URL #

The main thing needed to add a server in ActiveUI is its URL. There are several ways to build one:

Hardcoded URL #

If the URL will be the same on all your environments, the simple and obvious way is just to do this:

const url = 'http://{serverHost}:{serverProtocol}/{serverPath}';

For instance:

const url = 'http://my-host.com:9090';

Using a Proxy #

This is basically the same technique than the one above but this time you give the URL of a proxy.

When the URL of the server changes, you just have to reconfigure your proxy to point to the new URL, there is nothing to do on the ActiveUI side.

Deriving the URL from the Current Window Location #

If the server hosting ActiveUI is on the same machine than the server you want to connect to, you can use something like that:

const url = `${window.location.protocol}//${window.location.hostname}:{serverProtocol}/{serverPath}`;

Environment-Specific URL #

You may want to use a different URL depending on the environment on which ActiveUI is deployed. For instance, you might want to connect to http://localhost:9090 in development and https://prod.com:9090 in production.

  • Build-time configuration:

    Your build process could define the process.env.NODE_ENV to development or production which would allow you to do this:

    const url = process.env.NODE_ENV === 'production' ? 'https://prod.com:9090' : 'http://localhost:9090';
    
  • Runtime configuration

    You could load an env.js file before loading ActiveUI. In development, env.js would be window.env = {url: 'http://localhost:9090'}, while in production it would be window.env = {url: 'https://prod.com:9090'}.

    The env.js would need not to be bundled with the rest of your application so that you could change its content easily on the machine where ActiveUI is deployed.

    Anywhere in your application, you could then do:

    const url = window.env.url;
    

    This technique works well when you want to deploy the same build to several environment but still want to have a different configuration on each environment.

Tip

Both of these methods can be used easily with the Sandbox.

Methods to Add Servers #

Once you have your server URL, you can retrieve the serversPool to add your server in ActiveUI:

const servers = activeUI.queries.serversPool;

From here, we have several methods for adding different types of servers:

Server Type Method
ActivePivot Server addActivePivotServer(serverParameters)
ActiveMonitor Server addActiveMonitorServer(serverParameters)
Content Server addContentServer(serverParameters)

In order for the application to deliver all its features, one need to attach the ActiveMonitor and Content servers to their related ActivePivot Server:

const activePivotServer = servers.addActivePivotServer({
  url: activePivotServerUrl,
  contentServer: servers.addContentServer({url: contentServerUrl}),
  activeMonitorServer: servers.addActiveMonitorServer({url: activeMonitorServerUrl})
});

Through the UI #

When no servers have already been added and that a bookmark tree, a data explorer widget or any container requiring an ActivePivot Server is in the view, a button will be displayed to add a first server. The bookmark tree and the data explorer widget also always display an icon next to the search bar to add a new server.

Clicking on the “add server” button will open a popup that will let you add ActivePivot, Content and ActiveMonitor Servers. The popup also contains a “Persist server(s)” checkbox. If you check it, the servers defined in the form will be store in the “servers” setting.

Using the “servers” Setting #

The servers setting can store the different servers you want to connect to. To take advantage of it, you can for instance write the following JSON into the default preferences file:

{
  "map": {
    "servers": [
      {
        "pivot": {
          "url": "http://localhost:9090",
          "name": "Sandbox"
        },
        "sentinel": {},
        "contentServer": {}
      }
    ]
  }
}

Once you have your servers setting stored in a Content Server, you just need to connect to it and all the servers defined in the setting will be automatically added.

Tip

The typical use case of this setting is to only add one Content Server programmatically and let the setting add all the other servers.