Code Monkey home page Code Monkey logo

dojo-fmeserver-portal's Introduction

dojo-fmeserver-portal

The municipality of Gävles FME portal - A configurable webb portal developed using Dojo and ESRI:js JavaScript API. The portal is a dojo widget that can be integrated in a mapping application. The purpose of the widget is to allow quick setup of customized portals for easy access to FME workspaces stored on FME-server.

Features:

  • Authentication using credentials or tokens, auto-sign-in option
  • Two "portal modes", admin or custom mode.
  • Most FME parameter types are supported and represented as dijit form widgets.
  • File Upload forms.
  • Map and drawing tools for managing clipping geometries, buffering and multipolygon support.
  • Simple JSON configuration.
  • Internationalization (English and Swedish).
  • Supports FME-server service types Data Download, Job Submitter and Data Streaming.
  • Run workspaces synchronously or asynchronous by sending results to email.
  • Access workspace metadata and see running and queued jobs on FME-server.

Table of Contents

Examples

The examples are connected to a Safe Software demo FME-server.

Demo 1 - Automatic sign-in using a token, four workspaces configured

Demo 2 - Authenticate using a token or credentials with possibility to change server url and admin-mode

Usage

Define a package pointing to the widget location in the dojoConfig. Use the src for development or the optimized built version of the widget in the dist folder.

Include ESRI:s JavaScript API or Dojo. Remember to set dojoConfig before loading Dojo.

 <script>
    var dojoConfig = {
       async: true,
       packages: [
          {
          'name': 'app',
          'location': location.protocol + "//" + location.host + "/src/app"
          }
       ]
   };
</script>
<script src="https://js.arcgis.com/3.18/"></script>

Initialize the widget by passing a map (optional), a configuration object and a DOM-node or a DOM id to the widget constructor.

Example:

<script>
    require([
        "app/FMEPortal",
        "esri/map"
    ], function (FMEPortal, Map) {

        var map = new Map("map", {
            basemap: "topo",
            center: [ -123.114166, 49.264549 ],
            zoom: 12,
            minZoom: 12
        });

        var fmeportal = new FMEPortal({
            "settings": configuration,
            "map": map
        }, "fmeportal");
    });
</script>

CSS

All symbols except the loader gif are from Google Material Icons. ESRI:s JavaScript API require esri.css for the map and a dijit theme like calcite, tundra, claro etc. to render the forms correctly. More information about esri css here.

<link rel="stylesheet" href="https://js.arcgis.com/3.18/esri/css/esri.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.18/esri/themes/calcite/dijit/calcite.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

Configuration

For a full configuration example, see src/app/FMEPortal/Config.

General

Set a unique id for the portal, a title and the about popup contents. The id is used to remember token and server settings in the browsers localStorage on refresh.

"general": {
    "id": "portal-1",
    "title": "FME Portal",
    "about": "About this FMEPortal..."
}

Server

The server section of the configuration controls the portal mode, authentication options, FME-server url and API-version.

Example:

    { 
       "server": {
           "adminMode": false,
           "token": {
              "token": "568c604bc1f235bbe137sdfgh32h45h45bh",
              "time": 480,
              "unit": "minute",
              "showTokenTab": true,
              "autoLogin": false
           },
           "url": "https://my-fmeserver.com",
           "version": "v2",
           "showSettingsTab": true,
		   "allowAsyncJobs": true
    }

adminMode

True/False

If adminMode is enabled, the portal will query FME-server for all repositorys and workspaces the authenticated user has access too and populate two dropdowns.

Additionally, workspace forms will have two extra options next to the Run button:

  • A service type selector allowing the user to run a workspace using a specific registered service
  • A button to show metadata about the workspace.

If adminMode is disabled, specific workspaces to include in the portal must be set using the includedWorkspaces option.

token

  • token - Default token (optional)
  • time - Token lifespan
  • unit - Token lifespan unit
  • showTokenTab - True/False - Allow the user to sign in using a token
  • autoLogin - True/False - Use the supplied token to automatically sign in the visitor.

url

The FME-server base url.

version

The API version, currently v2 and v3 are supported.

showSettingsTab

True/False

Allow the visitor to change server url and set adminMode before signing in.

allowAsyncJobs

True/False

Always show email forms for workspaces registered to the Data Download and Job Submitter services. This allows running jobs asynchronously.

Uploads

Disable selection of specific filetypes for upload to FME-server.

Example:

"uploadSettings": { 
   "disabledFiles": [".shx", ".prj", ".dbf", ".sbn", ".sbx", ".lock", ".png", ".xml", ".jpg", ".doc", ".docx", ".skp", ".cpg"]
}

Included workspaces

Array of workspaces to include in the portal, each item must have:

  • title - The workspace title.
  • description - Description of the workspace. Visible when the user clicks the question mark.
  • repository - Name of the FME-server repository.
  • workspace - Name of the FME-server workspace (including *.fmw)
  • service - The registered service type to use when running the workspace, "fmedatadownload", "fmejobsubmitter" and "fmedatastreaming" are supported.

Example:

"includedWorkspaces": [
    {
        "title": "WKT Clip",
        "description": "Description of the WKT Clip workspace.",
        "repository": "REST-Playground",
        "workspace": "WKTClip.fmw",
        "service": "fmedatadownload"
    },{
        "title": "Austin Transport example",
        "description": "Description of the Austin Transport workspace.",
        "repository": "REST-Playground",
        "workspace": "AustinTransport.fmw",
        "service": "fmedatastreaming"
    }
]

Custom error messages

Map error codes reported from FME Terminator transformers to specific error messages.

This can be useful for sending back messages from a workspace when something is wrong and a terminator is triggered.

Example:

 "customErrors": {
     "101": "No data in the area.",
     "102": "Draw a smaller area to extract data...",
     "103": "You don't have permission to extract data in the area"
  }

Geometry

Drawing tools will automatically appear when a selected workspace have a parameter name defined in the geometry section. The drawn geometry will be passed to the server as a string in the specified format. A map is required.

  • parameter - The name of the workspace parameter that is used to send a clipping geometry to the server
  • format - The geometry-format that is sent to the server, wkt, geojson or esrijson are supported.

Example:

"geometry": {
    "parameter": "GEOM",
    "format": "wkt"
}

Map

If a map is used, these settings are required.

  • drawColor - The color used for map drawings (rgba).
  • bufferColor - The color used for the original geometry when a buffer is applied (right click on a geometry) (rgba).
  • geometryService - An ArcGIS Server geometry service used to buffer geometry and calculate areas and lengths.

Example:

"map": {
    "drawColor": [255, 170, 0, 0.75],
    "bufferColor": [0, 0, 0, 0.25],
    "geometryService": "https://tasks.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer"
}

Internationalization

The widget is internationalized in English, en, (default) and Swedish, sv. see the FMEPortal/nls folder.

More on Dojo internationalization here: https://dojotoolkit.org/documentation/tutorials/1.10/i18n/.

History

2019-03-13 - Support multipolygon clipping geometry. Add forms for running jobs asynchronously by entering an email address. Add submitJob and runJobSubmitter methods to RestManager. The runJobSubmitter method can be used instead of submitSyncJob or submitJob.

2019-03-08 - Add support for the opt_namespace parameter. Create new file upload session on each portal visit. Fix an issue that the geometry needed to be redrawn when changing workspace.

2016-12-26 - Add support for FME-server REST versions, v2 and v3. FMEServer JavaScript library is no longer required. The new RestManager module manages FME-server communication.

2016-12-18 - v1.0 First release

Credits

dojo-fmeserver-portal was developed by Peter Jäderkvist at Community Development Gävle.

License

dojo-fmeserver-portal is released under the MIT license.

dojo-fmeserver-portal's People

Contributors

gavlepeter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

gitwinters1973

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.