diff --git a/CHANGELOG.md b/CHANGELOG.md index af7186a241abbca849299410816b97e56be16de4..22c4cac5378588ef99f2e30d994c3e7473d07975 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added (for new features, dependecies etc.) +* ext_bottom_line module (v0.1 - Experimental) + * A module which adds a preview section where any kind of summarizing + information (like plots, video players, thumbnails...) can be shown. + * Apart from some limitted standard configuration for images and videos, + the content of the preview section (the bottom line) has to be configured + in `conf/ext/json/ext_bottom_line.json`. An example configuration with + made-up entities is located in `conf/core/json/ext_bottom_line.json`. + * More documentation in `src/core/js/ext_bottom_line.js`. * Map (v0.3) * Adds a button to the navbar which toggles a map in the top of the main panel. The map currently shows all known entities which have geolocation diff --git a/conf/core/json/ext_bottom_line.json b/conf/core/json/ext_bottom_line.json new file mode 100644 index 0000000000000000000000000000000000000000..528402f7b382ea40ad3ffe679606c5bb029ce7ea --- /dev/null +++ b/conf/core/json/ext_bottom_line.json @@ -0,0 +1,20 @@ +{ "version": 0.1, + "creators": [ + { "id": "test.success", + "is_applicable": "(entity) => getParents(entity).map(par => par.name).includes('TestPreviewRecordType') && getEntityName(entity) === 'TestPreviewRecord-success'", + "create": "(entity) => 'SUCCESS'" + }, + { "id": "test.error", + "is_applicable": "(entity) => getParents(entity).map(par => par.name).includes('TestPreviewRecordType') && getEntityName(entity) === 'TestPreviewRecord-error'", + "create": "(entity) => new Promise((res,rej) => {rej('Test Error');})" + }, + { "id": "test.load-forever", + "is_applicable": "(entity) => getParents(entity).map(par => par.name).includes('TestPreviewRecordType') && getEntityName(entity) === 'TestPreviewRecord-load-forever'", + "create": "(entity) => new Promise((res,rej) => {})" + }, + { "id": "test.success-2", + "is_applicable": "(entity) => getParents(entity).map(par => par.name).includes('TestPreviewRecordType') && getEntityName(entity) !== 'TestPreviewRecord-fall-back'", + "create": "(entity) => { return plotly_preview.create_plot([{x: [1,2,3,4,5], y: [1,2,4,8,16]}]); }" + } + ] +} diff --git a/src/core/js/ext_bottom_line.js b/src/core/js/ext_bottom_line.js index c6b4a09b8fe6358959e42a4b67db8f0455c7132a..c9d0b9f196b68fbefd534a42a8f75096fa82ca65 100644 --- a/src/core/js/ext_bottom_line.js +++ b/src/core/js/ext_bottom_line.js @@ -28,6 +28,11 @@ * Add a special section to each entity one the current page where a thumbnail, * a video preview or any other kind of summary for the entity is shown. * + * Apart from some defaults, the content for the bottom line has to be + * configured in the file `conf/ext/json/ext_bottom_line.json` which must + * contain a {@link BottomLineConfig}. An example is located at + * `conf/core/json/ext_bottom_line.json`. + * * @module ext_bottom_line * @version 0.1 * @@ -40,6 +45,26 @@ */ var ext_bottom_line = function ($, logger, is_in_view_port, load_config, getEntityPath, connection) { + /** + * @type {BottomLineConfig} + * @property {string} version - the version of the configuration which must + * match this module's version. + * @property {CreatorConfig[]} creators - an array of creators. + */ + + /** + * @type {CreatorConfig} + * @property {string} [id] - a unique id for the creator. optional, for + * debuggin purposes. + * @property {string} is_applicable - This has to be valid javascript! A + * function which accepts one parameter, an entity in html + * representation, and returns a truth value. + * @property {string} create - This has to be valid javascript! A function + * which accepts one parameter, an entity in html representation, and + * returns a HTMLElement which will be shown in the bottom line + * container. + */ + /** * Check if an entity has a path attribute and one of a set of extensions. *