Skip to content

MindSphere Web Components
Demo Application

The Simple Demo Application shows how to use MindSphere Web Components when building MindSphere applications just using HTML, CSS and JavaScript.

It is provided via download on Siemens Industry Online Support.

The following picture shows an example of the demo application: Demo

Prerequisites

  • MindSphere user account on a developer tenant
  • Cloud Foundry Command Line Interface (CF CLI)
  • A Cloud Foundry role which allows to push applications, e.g. spaceDeveloper
  • A MindSphere developer role, either mdsp:core:Developer or mdsp:core:DeveloperAdmin

Deploy the Application to Cloud Foundry

  1. Unzip the demo application folder on your local computer.
  2. Open the manifest.yml and modify the name as desired.

Deviation in region China 1

For region China 1, open the demo/index.html and replace The key value you applied for with valid Amap key applied from Amap service.

  1. Open a command line interface (CLI) inside the folder with the application to be deployed.
  2. Configure the proxy settings, if necessary.

    Click here for detailed information on proxy settings

    If you are in a company network behind a proxy, you may have to set the proxies to reach the Cloud Foundry endpoints. Contact your administrator, if you face any timeouts or connectivity problems.

    Set the proxies for the Cloud Foundry CLI as shown below:

    1
    2
    set http_proxy=http://PROXY_IP:PROXY_PORT
    set https_proxy=http://PROXY_IP:PROXY_PORT
    
    1
    2
    export http_proxy=http://PROXY_IP:PROXY_PORT
    export https_proxy=http://PROXY_IP:PROXY_PORT
    
  3. Enter cf login -a https://api.cf.{region}.{mindsphere-domain} --sso.

  4. Open the URL printed by the CLI and log in using your WebKey credentials to get a One Time Code.
  5. Enter the One Time Code in the CLI.
  6. Select your Cloud Foundry org and space using the following command:

    1
    cf target -o {org_name} -s {space_name}
    

    No Cloud Foundry Orgs displayed

    If you do not see any Cloud Foundry orgs, you need to be added to your org. Refer to the How Tos for Cloud Foundry.

  7. Push the application to your Cloud Foundry space using:

    1
    cf push
    

    Vendoring dependencies in region China 1

    Pushing applications to MindSphere Cloud Foundry in region China 1 sometimes fails while downloading dependencies due to unstable international network access from China. Refer to the Cloud Foundry buildpack's documentation for 'vendoring' your application's dependencies:

Integrate the Application into MindSphere

Configure the Application via the Developer Cockpit

  1. Open the Developer Cockpit from the Launchpad and select the Dashboard tab.
  2. Click on Create new application.
  3. Select Type Standard and Infrastructure MindSphere Cloud Foundry.
  4. Enter an arbitrary Display Name and an Internal Name which will be part of the application URL. The Internal Name cannot be changed after initial creation!

  5. Enter a version number.

    • MindSphere supports a Major.Minor.Patch scheme.
    • Versions must start with a major number >= 1.
    • The version cannot be changed after saving.
  6. Upload an icon for your application.
  7. Enter the component name. The component name must be the same as specified in the manifest.yml file.

  8. Add one endpoint for your component using /** to match all of your application paths.

  9. Enter the Cloud Foundry URL of your application.
    • Use cf app {app_name} to get the URL for your deployed application.
  10. Set the content-security-policy according to the examples:
1
    default-src 'self' *.eu1.mindsphere.io; style-src * 'unsafe-inline'; script-src 'self' 'unsafe-inline' *.eu1.mindsphere.io; img-src * data:;
1
    default-src 'self' *.eu1.mindsphere.io *.eu2.mindsphere.io; style-src * 'unsafe-inline'; script-src 'self' 'unsafe-inline' *.eu1.mindsphere.io *.eu2.mindsphere.io; img-src * data:;
1
    default-src 'self' static.cn1.mindsphere-in.cn *.amap.com *.is.autonavi.com; style-src * 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' static.cn1.mindsphere-in.cn *.amap.com *.is.autonavi.com; worker-src blob:; img-src * data:;

  11. Click on Save.

You are redirected to the application details. Your application is in the In-Development state and is ready for registration.

Configure the Application Roles & Scopes

  1. Switch to the Authorization Management tab.
  2. Select the application.
  3. Create an application scope, e.g. simplecomponentdemo.all, for accessing the application from the Launchpad.
  4. Add the following Core roles to enable access to the respective APIs. If one of these role is missing, the related web component will not work.
    • mdsp:core:assetmanagement.xxx
      Required for asset view and custom map
    • mdsp:core:iot.tsaUser
      Required for aggregate chart
    • mdsp:core:em.eventcreator
      Required for event view
    • mdsp:core:iot.filAdmin
      Required for file view
    • mdsp:core:tsm.full-access
      Required for rule view

Register the Application

  1. Switch to the Dashboard tab.
  2. Open the application details.
  3. Click on Register.

Assign the Application Roles

  1. Open the Settings app from the Launchpad and switch to the Roles tab.
  2. Select the application role and click on Edit assignments.
  3. Assign your user to the application role.
  4. Click on End editing.
  5. Log out of from MindSphere and log in again.

Logout

The user token is only updated with the new scopes after logging out and logging in again. In rare cases it might take a couple of minutes until the role assignment has been propagated through the system.

Congratulations, your very first application based on MindSphere Web Components is running in your tenant.

Feel free to adapt the web components with attributes, stylings etc. for your needs.

Troubleshooting

  • The App is not visible on the Launchpad
    Check if you assigned the application role to your user in the Settings app. After assigning new roles, a logout/login is required.
  • The App does not fully load and the developer console shows "Content Security Policy" errors
    Unregister the app and update the content-security-policy settings in the Developer Cockpit as instructed above.
  • Web components are loaded, but there is an "assetList" error or no assets are shown
    Make sure that the mdsp:core:assetmanagement.*** role is assigned to your application.

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.