Skip to content
François Prunayre edited this page Jan 18, 2017 · 14 revisions

The JS API mode allows to build a catalog application from a JSON configuration file and the load of the GeoNetwork JS library. The main goals are:

  • clarify UI configuration (by grouping and documenting all UI options)
  • be able to embed GeoNetwork in third party website like CMS.
  • add admin interface to customize UI options (and preview results)

The initial development was made for Ifremer to add GeoNetwork catalog and maps in Liferay & EZpublish. This proposal is supported by the Metawal project.

API configuration

A new setting ui/searchAppConfig for the main app configuration is added.

This setting is a JSON object that can be configured from the admin page. It defines how the main search application is. The configuration is the following:

// GeoNetwork JS API Configuration
var gnCfg = {
      'langDetector': {
        'fromHtmlTag': false,
        'regexp': '^\/[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+\/([a-z]{3})\/',
        'default': 'eng'
      },
      'nodeDetector': {
        'regexp': '^\/[a-zA-Z0-9_\-]+\/([a-zA-Z0-9_\-]+)\/[a-z]{3}\/',
        'default': 'srv'
      },
      'mods': {
        'header': {
          'enabled': true,
          'languages': {
            'eng': 'en',
            'dut': 'du',
            'fre': 'fr',
            'ger': 'ge',
            'kor': 'ko',
            'spa': 'es',
            'cze': 'cz',
            'cat': 'ca',
            'fin': 'fi',
            'ice': 'is'
          }
        },
        'home': {
          'enabled': true,
          'appUrl': '#/home'
        },
        'search': {
          'enabled': true,
          'appUrl': '#/search',
          'hitsperpageValues': [10, 50, 100],
          'paginationInfo': {
            'hitsPerPage': 20
          },
          'facetsSummaryType': 'details',
          'facetConfig': [
            // {
            // key: 'createDateYear',
            // labels: {
            //   eng: 'Published',
            //   fre: 'Publication'
            // }}
          ],
          filters: [],
          'sortbyValues': [{
            'sortBy': 'relevance',
            'sortOrder': ''
          }, {
            'sortBy': 'changeDate',
            'sortOrder': ''
          }, {
            'sortBy': 'title',
            'sortOrder': 'reverse'
          }, {
            'sortBy': 'rating',
            'sortOrder': ''
          }, {
            'sortBy': 'popularity',
            'sortOrder': ''
          }, {
            'sortBy': 'denominatorDesc',
            'sortOrder': ''
          }, {
            'sortBy': 'denominatorAsc',
            'sortOrder': 'reverse'
          }],
          'sortBy': 'relevance',
          'resultViewTpls': [{
            'tplUrl': '../../catalog/components/' +
                'search/resultsview/partials/viewtemplates/grid.html',
            'tooltip': 'Grid',
            'icon': 'fa-th'
          }],
          'resultTemplate': '../../catalog/components/' +
              'search/resultsview/partials/viewtemplates/grid.html',
          'formatter': {
            'list': [{
              'label': 'full',
              'url' : '../api/records/{{md.getUuid()}}/' +
                  'formatters/xsl-view?root=div&view=advanced'
            }]
          },
          'linkTypes': {
            'links': ['LINK', 'kml'],
            'downloads': ['DOWNLOAD'],
            'layers': ['OGC'],
            'maps': ['ows']
          }
        },
        'map': {
          'enabled': true,
          'appUrl': '#/map',
          'is3DModeAllowed': true,
          'storage': 'sessionStorage',
          'map': '../../map/config-viewer.xml',
          'listOfServices': {
            'wms': [{'name': 'BRGM',
              'url': 'http://geoservices.brgm.fr/geologie'}],
            'wmts': []},
          'useOSM': true,
          'context': '',
          'layer': {
            'url': 'http://www2.demis.nl/mapserver/wms.asp?',
            'layers': 'Countries',
            'version': '1.1.1'
          },
          'projection': 'EPSG:3857',
          'projectionList': [{
            'code': 'EPSG:4326',
            'label': 'WGS84 (EPSG:4326)'
          }, {
            'code': 'EPSG:3857',
            'label': 'Google mercator (EPSG:3857)'
          }]
        },
        'editor': {
          'enabled': true,
          'appUrl': '../../srv/eng/catalog.edit'
        },
        'admin': {
          'enabled': true,
          'appUrl': '../../srv/eng/admin.console'
        },
        'signin': {
          'enabled': true,
          'appUrl': '../../srv/eng/catalog.signin'
        },
        'signout': {
          'appUrl': '../../signout'
        }
      }
    }
};

<!-- Main application container -->
<div ng-app="gn_app"
     ng-controller="GnCatController"
     ng-include="'../../catalog/views/myapp.html'"></div>

<!-- Chargement des librairies -->
<script src="http://localhost:8080/geonetwork/static/lib.js"></script>

This configuration is used in:

  • the GeoNetwork main app.
  • the API testing page

Settings change

Old UI settings are moved to that main app configuration. The list of old settings are:

  • map/isMapViewerEnabled
  • map/is3DModeAllowed
  • map/bingKey
  • map/isSaveMapInCatalogAllowed
  • map/proj4js
  • map/config
  • system/ui/defaultView

Check if needed:

  • metadata/editor/schemaConfig

Settings API change:

  • A new operation is added in order to collect the value of JSON node in a JSON setting. GET /api/settings/?node=config.download

Build custom configuration

From the admin panel, catalog administrator can also create custom configuration for third party application. This page provides all the JS API settings and allows user to download the application configuration as JSON file.

Testing

A simple HTML page is created in order to test the JS API.

Clone this wiki locally