predix-apphub-config-service

1.0.1 • Public • Published

apphub-config-service

Build Status

A simple implementation of a nav service as required by the UI AppHub.

Usage

After cloning this repo, install runtime dependencies:

% npm install

To start:

% node app.js

Provision Tenant

In CF:

cf cs predix-apphub Beta js-apphub-beta \
--config '{"uaa":{"uaaUri":"https://js-uaa-prod.predix-uaa.run.aws-usw02-pr.ice.predix.io","clientID":"apphub","clientSecret":"apphub"},"appConfigURL":"","routeInfo":{"hostName”:”js-apphub-beta","context":"","shared":false},"applicationChrome":true, "customHeader": {}}'

Metrics

A very basic, but correct and useful, prometheus.yml can look like this.

scrape_configs:  
- job_name: PrometheusApp
  scrape_interval: 5s
  scrape_timeout: 5s
  metrics_path: /ijdc72jg2ugg2dikkkl236f2rhma6qaz/metrics
  scheme: https
  static_configs:
  - targets:
    - integration.cloud.tibcoapps.com
    labels:
      app: PrometheusApp
      sandbox: MyDefaultSandbox

Details

This service exposes two routes: / and /nav/<app id>. The root route returns the entire config object for a hub instance, for example: Your Hub configuration service should return some JSON response such as this below: Start with your Main AppHub name, it appears at the top left corner of the view port. the apps property holds information regarding to all the micro apps that you intend to bundle with your main App.

For example:

EX1

Calling /, this service return this JSON.

  • name - The name of your application, it appears at the top of the navigation bar
  • user - The user information, this config service needs to provide such information to ui-app-hub. At minimum, user name, however, user.picture (optional) is where the user avatar image url is. You can also provide 'firstName' and 'lastName', if this is specified, it takes a precedence over 'name'. You are free to add whatever additional key/value pairs you like.
  • apps[0].id - a unique identifier for this micro app.
  • apps[0].host - the domain url of this micro app.
  • apps[0].path - the base url path of this micro app, it will be added to the host so when users click the navigation links on the left navigation side bar, it will take them to the micro app. If a fully qualified url is specified for e.g. "https://www.predix.io/resources" then it will open the url in the a new window.
  • apps[0].template - the main html page for that path. apps[0].navService is where app-hub will pull/query the navigation information from your micro app so it can construct the relative url links for your app.
  • apps[0].default - if set to true, it means you want app-hub to load this micro app as soon as user log in.
  • apps[0].location - where links of your micro app should be placed in the navigation side bar. We have three locations, "main", "profile", and "settings. "main" location is for the main navigation section, "profile" location is for user specific functionality, "settings" location is for app/system related functionality.
{
  "name":"AppHub Demo",
  "user": { "name": "hubpocuser", "firstName": "First", "lastName": "Last", "picture": "https://user.ge.com/avatar"},
  "apps":[
    {
      "id":"dashboard",
      "location": "main",
      "host":"http://dashboard.com",
      "path":"/dash",
      "template":"/content.html",
      "navService":"/nav",
      "default":"true"
    },
    {
      "id":"analytics",
      "location": "main",
      "host":"http://analytics.com",
      "path":"/analytics",
      "template":"/content.html",
      "navService":"/nav"
    },

    {
      id:'user',
      location: 'profile',
      host:  'http://<your-use-profile-domain>',
      path:'/user',
      template:'/index.html',
      navService:'/nav'
    },
    {
      id:'settings',
      location:'settings',
      host: 'http://<your-settings-domain>',
      path:"/settings",
      template:"/index.html",
      navService:'/nav/settings'
    }
  ]
}

Calling the /nav/<app id> route returns the navigation details for a single micro app:

{
"id":"analytics",
  "path":"/analytics",
  "items":[
    {
      "label":"Analytics",
      "icon":"fa-gauge",
      "path":"/analytics/#/",
      "items":[
        {
          "label":"New",
          "path":"/analytics/#/create"
        }
      ]
    }
  ]
}

Note: Each navService specified under above apps e.g. /nav/ /nav/settings route returns the navigation details for a single micro app. ui-app-hub uses will make call to these navServices when server is started. It is vital to provide these links for routing of micro app should it offer many routes and url path for user to navigate.

EX2

This example is mainly the same as the above except that some of the micro apps whose navigation item object are defined already. As a result, ui-app-hub will not make request to fetch the navigation item object for that particular micro app. For instance:

  • apps[0].items offers links for sub sections of your micro app. These sub items follow nearly the same structure of the main micro app properties, excluding "location".
  • you can mix and match both approach.
{
  "name":"AppHub Demo",
  "user": { "name": "hubpocuser", "firstName": "First", "lastName": "Last", "picture": "https://user.ge.com/avatar"},
  "apps":[
    {
      "id":"dashboard",
      "location": "main",
      "host":"http://dashboard.com",
      "path":"/dash",
      "template":"/content.html",
      "default":"true",
      "items":[
        {
          "label":"Dashboard",
          "icon":"fa-dashboard",
          "path":"/dash/#/",
          "items":[
            {
              "label":"Notifications",
              "path":"/dash/#/notifications",
              "badge":{
                "status":"info",
                "count":1
              }
            }
          ]
        }
      ]
    },
    {
      "id":"analytics",
      "location": "main",
      "host":"http://analytics.com",
      "path":"/analytics",
      "template":"/content.html",
      "items":[
        {
          "label":"Analytics",
          "icon":"fa-gauge",
          "path":"/analytics/#/",
          "items":[
            {
              "label":"New",
              "path":"/analytics/#/create"
            }
          ]
        }
      ]
    },

    {
      id:'user',
      location: 'profile',
      host:  'http://<your-use-profile-domain>',
      path:'/user',
      template:'/index.html',
      navService:'/nav'

    },
    {
      id:'settings',
      location:'settings',
      host: 'http://<your-settings-domain>',
      path:"/settings",
      template:"/index.html",
      "items":[
        {
          "label":"Settings",
          "icon":"fa-gauge",
          "path":"/settings/#/"
        },
                {
          "label":"Help",
          "icon":"fa-gauge",
          "path":"https://www.predix.io/resources"
        }
      ]

    }
  ]
}

Authorization

The UI Config Service should properly authorize against any bearer token passed in the request. If a user doesn't have access to a microapp, that microapp shouldn't appear in the "apps" array.

Other Questions

Do you still have questions? If so, post them on http://stackoverflow.apps.ge.com/ tagged with apphub or app-hub. Our team checks there every so often.

Performance

Baseline Test

1000 POST requests 1000 GET requests

Readme

Keywords

none

Package Sidebar

Install

npm i predix-apphub-config-service

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

5.22 MB

Total Files

269

Last publish

Collaborators

  • jonniespratley