Professional Documents
Culture Documents
MEDMGT220200-AIG-EN-02
OpenText™ Media Management
HTML5 Integration Guide
MEDMGT220200-AIG-EN-02
Rev.: 2022-May-05
This documentation has been created for OpenText™ Media Management CE 22.2.
It is also valid for subsequent software releases unless OpenText has made newer documentation available with the product,
on an OpenText website, or by any other means.
Tel: +1-519-888-7111
Toll Free Canada/USA: 1-800-499-6544 International: +800-4996-5440
Fax: +1-519-888-0677
Support: https://support.opentext.com
For more information, visit https://www.opentext.com
One or more patents may cover this product. For more information, please visit https://www.opentext.com/patents.
Disclaimer
Every effort has been made to ensure the accuracy of the features and techniques presented in this publication. However,
Open Text Corporation and its affiliates accept no responsibility and offer no warranty whether expressed or implied, for the
accuracy of this publication.
Table of Contents
1 Introduction ................................................................................ 9
1.1 JavaScript API documentation ......................................................... 10
1.2 REST API documentation ................................................................ 10
1.3 Examples pack ............................................................................... 10
1.3.1 Examples pack setup ...................................................................... 11
2 Environment ............................................................................. 13
2.1 Layout ............................................................................................ 13
2.2 Production code .............................................................................. 15
2.2.1 Source maps .................................................................................. 15
2.2.2 Debug mode ................................................................................... 16
9 Templates ................................................................................. 43
9.1 Custom elements ............................................................................ 44
9.1.1 ot-resource ..................................................................................... 44
9.1.2 ot-metadata .................................................................................... 44
9.1.3 ot-rendition ..................................................................................... 45
9.1.4 ot-i18n ............................................................................................ 45
9.1.5 ot-point ........................................................................................... 45
9.1.6 ot-select ......................................................................................... 46
9.2 Overriding and altering templates ..................................................... 46
9.3 Modifying the legal terms and conditions .......................................... 48
9.4 Cross-platform templates ................................................................. 49
10 Localization .............................................................................. 51
10.1 Mark text for translation ................................................................... 51
10.1.1 Format ........................................................................................... 51
10.1.2 Basic usage .................................................................................... 52
10.1.3 Plurals ............................................................................................ 53
10.1.4 Context .......................................................................................... 54
10.1.5 Style ............................................................................................... 55
10.1.5.1 Styled replacements ........................................................................ 55
10.1.5.2 Styled text ...................................................................................... 56
10.1.6 Tips and tricks to localize ................................................................. 56
10.2 Generate, localize, and deploy custom UI integration messages ........ 57
10.2.1 To generate a POT file .................................................................... 58
10.2.2 To generate a localization (PO) file from the template (POT) .............. 58
10.2.3 To deploy a localization file for your custom UI integration messages ...59
10.2.3.1 To deploy a custom localization for a new locale ............................... 60
10.2.3.2 To deploy a new custom localization for an existing locale ................. 60
13 Views ........................................................................................ 73
13.1 Create a view .................................................................................. 73
13.1.1 Create the content template ............................................................. 73
13.1.2 Definition function ........................................................................... 74
13.1.2.1 Properties ....................................................................................... 74
13.1.2.2 Content function .............................................................................. 74
13.1.2.3 Watch properties ............................................................................. 75
13.1.2.4 Event listeners ................................................................................ 75
13.1.2.5 Additional functions ......................................................................... 76
13.1.2.6 Additional constructor ...................................................................... 76
13.1.3 Display the view as a dialog box ....................................................... 76
13.1.4 Display the view as a main application area ...................................... 76
13.1.4.1 Define the route URL and its mappings ............................................. 77
13.1.4.2 Use the route URL .......................................................................... 79
13.2 Functionality within views ................................................................. 79
13.2.1 Display resources ........................................................................... 79
13.2.1.1 Add resource elements to a template ............................................... 79
13.2.1.2 Apply the resource to that template .................................................. 80
13.2.1.3 Use ot-resource for third party resources .......................................... 80
13.2.2 Collapsible sidebars ........................................................................ 81
13.2.3 Sidebar styles ................................................................................. 82
13.3 Chains of requirement ..................................................................... 82
13.4 View mixins .................................................................................... 82
13.5 Composite views ............................................................................. 83
13.5.1 Freeflow composites ....................................................................... 83
14 Widgets ..................................................................................... 87
14.1 Configure OTMM ............................................................................ 88
14.1.1 To configure CORS to allow access to OTMM widgets ...................... 89
14.1.2 To configure extensions to be visible outside of OTMM ...................... 89
14.2 Get embed code ............................................................................. 90
14.3 Include widgets on a page ............................................................... 90
14.3.1 To include widgets on a page manually ............................................ 90
14.3.1.1 To include Folders widget functionality ............................................. 91
14.3.1.2 To include Saved searches widget functionality ................................. 93
14.3.1.3 To include Asset widget functionality ................................................ 95
14.3.1.4 To include Upload widget functionality .............................................. 96
14.3.2 Include a widget programmatically .................................................... 97
14.3.2.1 Load widgets after page load ........................................................... 98
14.4 Authenticate widgets in host applications .......................................... 99
14.4.1 To specify the session headers ...................................................... 100
14.4.2 To configure authentication on the OTMM server ............................ 100
14.5 How to interact with widgets ........................................................... 102
14.5.1 Widget attributes ........................................................................... 103
14.5.2 Widget features ............................................................................. 103
14.5.3 Widget events ............................................................................... 103
14.6 Style and position widgets ............................................................. 103
14.6.1 To add custom styles to widgets ..................................................... 104
This guide contains instructions on how to write, deploy and manage integrations
for the OpenText Media Management (OTMM) HTML5 User Interface (UI).
The HTML5 UI for OTMM is a new interface built using the latest standards of
HTML5, CSS3, and JavaScript. It uses a combination of JavaScript views and HTML
templates to drive the presentation and functionality of the UI.
• It is a singular-page application.
• All business logic and display templates are retrieved from the HTML5 UX
server upon page load. There is a complete separation between the data for assets
and resources and their display.
• All data from OTMM is retrieved from the REST API server in the JSON format.
This is always just data. It is never combined with its display when downloaded.
This is in contrast with a technology such as JSP, where a full page may be
downloaded that contains both the data and its display code.
Important
Due to framework changes, the following areas of the OTMM Web Client UI
are not currently customizable:
This guide comes with an examples pack, contained in an installed folder, which can
be used as a reference guide for integration development.
If the examples have loaded successfully, there will be an extra menu entry available
called Code examples.
Name
ARTESIA.DOMAIN.USERNAMES
Database Table
USERS
ID (Join) Column
LOGIN_ID
Value (Display) Column
NAME
Order By
NAME
Environment
This section discusses the Media Management HTML5 UI layout and production
code.
2.1 Layout
The Media Management HTML5 UI layout is in the deployment folders under the
following folder:
artesia.ear/war/otmmux.war/ux-html
adobe connector
Used for closing the authentication panel for the OpenText™ Media
Management Connector for Adobe Creative Cloud™.
app
Contains the core JavaScript code and styles for the HTML5 User Interface (UI).
branding
Contains all customer created brand information for the application, such as
HTML, Cascading Style Sheets (CSS) and JavaScript.
compliance
Contains JavaScript code that deals with accessibility for the end user.
debug
This folder is included as a shortcut for accessing the debug mode of the
application. For more information, see “Production code” on page 15.
demo
Unused.
dist
Contains the minified, concatenated code used with the production version of
the application. For more information, see “Production code” on page 15.
dist_appworks
Contains the minified, concatenated code used with the production version of
our AppWorks app.
doc
Contains the API documentation for the HTML5 UI. For more information, see
“JavaScript API documentation” on page 10.
error
Contains an error page that is displayed to users who are attempting to access
the application using an unsupported browser.
lib
Contains third-party libraries that are used with the HTML5 UI.
locale
Contains the default core translations and localizations for the HTML5 UI.
META-INF
Contains information for the deployment server.
otmm
Contains the core JavaScript code, styles, and templates for the full version of
the HTML5 UI.
otmm/model/manager
Contains all the REST API interfaces that OTMM uses to fetch data that you can
use for your customizations.
Important
You can reuse the existing REST API code for your customization. The
code in the otmm/model/manager folder may be modified, deprecated or
removed in future releases.
result-mosaic
Contains the HTML, CSS, and JavaScript code required to support the Mosaic
layout throughout the application. This is used in various Gallery views.
style
Contains all the stylesheets and images used for the HTML5 UI.
ui
Contains core JavaScript code for the HTML5 UI.
widget
Contains the core JavaScript code, styles and templates for external widgets.
otmm/view/home-new
Contains new Home page and the widgets that are used in it.
Note: Due to framework changes, the following areas of the OTMM Web
Client UI are not customizable and integration development is currently
unavailable. In addition, source maps are not available for these areas.
• To enable source maps in Google Chrome™ (used for debugging purposes), see
the following link: https://developer.chrome.com/devtools/docs/javascript-
debugging#source-maps
• To enable source maps in Mozilla® Firefox® (used for debugging purposes), see
the “Seeing Results” section in the following link:
https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-
source-maps/
• Apple Safari 7 and higher has source maps enabled by default.
• Microsoft® Internet Explorer® does not support source maps.
/otmm/ux-html/index-dev.html
Note: Instead of using concatenated or minified sources, debug mode uses the
individual files that make up the interface. As a result, it is slower to load.
Therefore, debug mode is not intended to be used in a production
environment.
Note: Due to framework changes, the following areas of the OTMM Web
Client UI are not customizable and integration development is currently
unavailable:
3.1.1 Requirements
The following tools are required to create integrations for the HTML5 UI:
When developing integrations, OpenText recommends that you use the debug mode
of OTMM, to allow easier inspection of the core code of the application and to allow
for in situ style editing. For more information, see “Debug mode” on page 16.
<script>otui.Templates.load()</script>
3. Click the Sources tab and confirm that the development folder and the
include.html file appear under the sources for the HTML5 UX (this is the list
of sources underneath the IP address/host name for the server) on the left-hand
side.
6. Navigate to the development folder you previously created and select it. Grant
permission to use that folder.
7. Under the sources for the HTML5 UX, find the development folder and right-
click the include.html file.
On restart, the development folder will no longer be visible under the list of sources
for the HTML5 UX, but will instead have its own top-level folder. You are now
ready to use the Chrome workspaces for development. For more information about
Chrome workspaces, see https://developer.chrome.com/devtools/docs/workspaces.
Integrations for OTMM use this technology in the same way as the core OTMM UI.
As files are added to a customer-specific integration, they should be written to the
include.html file for the integration. On the next page refresh, they will be loaded
into the page.
3.2.1 otui.Templates.load()
When using HTML imports, if you are including any new or modified templates,
you should have at the bottom of your import HTML file something like the
following:
<script>otui.Templates.load()</script>
By doing this, you will be loading the import scanner to scan the import for relevant
content to load into the UI.
HTML templates which are put into an HTML import file are only auto-ingested in
the following cases:
For more information about HTML templates, see “Templates“ on page 43.
When using LESS files directly in debug mode, the watch mode is enabled. This
means that as you make changes to the LESS file, the changes are automatically
applied to the page without having to refresh.
• ux-html/style/format/variables.less
• ux-html/style/format/mixins.less
When creating a LESS file, OpenText recommends including these two files at the
top of your file using a relative path. For example, if the LESS file is in:
ux-html/cs_demointegration/styles.less
@import "../style/format/variables.less";
@import "../style/format/mixins.less";
(function(otui)
})(otui);
By encapsulating the code, you ensure that all variables created, unless attached to a
window, otui or some other global object, will not exist outside of the JavaScript file.
In this way, the chance of two pieces of code interfering with each other is greatly
reduced.
3.5.2 otui.ready
With the exception of advanced integrations involving views (see “Views“
on page 73), most integration code should be executed after the user has logged in.
To do this, the otui.ready function should be used to execute your code. For
example:
(function(otui)
function startIntegration()
otui.ready(startIntegration);
})(otui);
• Write the text in English but write anything which will differ in that text as a
number in braces{ }.
• Wrap the text in one of the HTML5 UI translation functions or elements, passing
in the differing parts as extra arguments in the order you specified them in.
For example, in the phrase Welcome to OpenText Media Management version 20.3,
John Doe!, the parts that may vary are the version number and the user's name.
Therefore, you would write it in JavaScript as follows:
Or, if you wanted to display it directly to the user as HTML as a View (for advanced
integrations only), you could write it as follows:
OpenText recommends that you add data to DOM by using the textContent
property. By doing this, content that is written to a DOM will be treated as simple
text content, thus preventing attacks, even if there are some tags in the response
being written to the DOM.
If you are not using textContent because you intend to construct a DOM, use the
sanitization API as follows:
The above produces sanitized text. This text can safely be used to construct the
DOM. For example, you could use the innerHTML property of an element to append
child nodes.
You can modify existing entries or add new entries to all menus within the OTMM
HTML5 UI through small pieces of JavaScript, “registering” a description for those
entries in JSON.
Function Description
register Register a new menu item, or an array of
new menu items.
remove Remove an existing menu item.
modify Get an existing menu item and modify it.
extend Register a new menu item, using an existing
menu item as the basis.
Generic menu entries are entries that exist without the context of a specific asset or
resource, such as the main menu or the menu in the Gallery View.
Resource-specific menu entries are entries that are tied to a specific asset or resource.
When functions are called on these menu entries, a reference to the asset JSON that
the menu item is tied to is passed as a parameter.
event
This is the setup event object.
resource
For resource-specific menu entries, this is the reference to the JSON for the asset
that this menu item precedes.
base
This is a reference to the parent element for the menu entry that is being
displayed. By using the "base" parameter, you will always have a link to the area
where the menu entry is being rendered.
In the function, the value of this is the menu entry that is being set up.
The return value from setup function decides the display of menu entry. The
following values are supported:
Function Description
otui.Views.containing() This retrieves the view object which contains
the element passed to this function. Within a
menu setup/select function, passing base as
the argument will give you the view which
contains the given menu entry.
resultsView.getSelectedAssets() For views which allow for multiple
selections, such as Gallery View, you can
retrieve all currently selected asset IDs using
this call. This is an asynchronous function
which takes a callback, because it may not be
known at the point of call which assets have
been selected.
Function Description
resultView.getSelectionContext() If interfacing with the REST API to create
functionality, you could use this function
instead of using getSelectedAssets() to
retrieve the asset IDs. This will return a
selection context, which is a piece of JSON
which can be used in the calls to the REST
API to tell it how to retrieve assets.
Property Description
name A unique, internal name for this menu entry.
title Localized display name for this menu entry.
This should be wrapped in a translation
function.
select An optional function to execute when the
menu entry is selected.
url A URL to go to when the menu entry is
selected. This is optional.
For example, you could write a registering menu entry that would display an alert
when clicked as:
(function(otui) {
function showAlert() {
otui.alert(otui.tr("This is an alert”)); // Translated
};
otui.ready(function() {
otui.Menus.register({
'name' : 'showalert',
'title' : otui.tr('Show alert'), // Translated
'select' : showAlert
});
});
})(otui);
Each multiple asset menu entry type includes the following properties:
Property Description
name A unique, internal name for this menu entry.
text Localized display name for this menu entry.
This should be wrapped in a translation
function.
img A URL to a 16x60 image used for this menu
entry. This property is optional.
In addition, the register function can include the following optional parameters:
index
A numerical parameter to specify the position of the entry in the menu or, if
groupIndex is specified, the position within the menu group. For
example, .register(entry, 1, 4), where 1 is the index parameter.
If this parameter is not specified, the entry is placed in the last position in the
menu or group.
groupIndex
A numerical parameter to specify the position of the entry in a menu group. For
example, .register(entry, 1, 4), where 4 is the groupIndex parameter.
If this parameter is not specified, the entry is placed in the last group in the
menu.
});
};
otui.ready(function() {
// Create definition of the menu entry.
var entry = {
'name' : 'showassets',
'text' : 'Log selected assets',
'select' : showAssets
};
All single asset menu entry types require the same properties.
Property Description
name A unique, internal name for this menu entry.
text Localized display name for this menu entry.
This should be wrapped in a translation
function.
img A URL to a 16x16 image used for this menu
entry.
select A function to execute when this menu entry
is selected.
setup An optional function to execute when this
menu entry is initially displayed. For more
information, see “Setup function”
on page 24.
The select and setup functions are both passed a resource parameter, which is the
JSON for the resource the menu entry should act upon. However, under certain
circumstances, this may be undefined. In such cases, your functions should cope
with this and not do anything.
In addition, the register function can include the following optional parameters:
index
A numerical parameter to specify the position of the entry in the menu or, if
groupIndex is specified, the position within the menu group. For
example, .register(entry, 1, 4), where 1 is the index parameter.
If this parameter is not specified, the entry is placed in the last position in the
menu or group.
groupIndex
A numerical parameter to specify the position of the entry in a menu group. For
example, .register(entry, 1, 4), where 4 is the groupIndex parameter.
If this parameter is not specified, the entry is placed in the last group in the
menu.
The following example shows how to create a single asset menu entry which,
when selected, will open the preview rendition of an image asset in a new
window. It also has a setup function which will hide the entry if the asset in
question has no preview rendition or is not a picture. It is then added to the
Gallery view asset actions and Detail view asset actions.
(function(otui) {
function openAsset(event, resource) {
if (resource) {
// The setup function guarantees that this will exist so we can skip the existence
checks.
var renditionObject = resource.rendition_content.preview_content;
var url = renditionObject.url;
var height = renditionObject.height;
var width = renditionObject.width;
otui.ready(function() {
// Create definition of the menu entry.
var entry = {
'name' : 'openAsset',
'text' : 'Open preview',
'img' : 'path/to/myimg.png',
'select' : openAsset,
'setup' : setupOpenAsset
};
New status icons can be added in the same way as resource-based menu entries (see
“Menu entries“ on page 23). Status icons and menu entries share the same common
functions and properties. The only difference is that status icons are mostly inert.
Property Description
name A unique, internal name for this status icon.
text Localized display name for this status icon.
This should be wrapped in a translation
function.
img A URL to a 16x16 image used for this status
icon.
setup A mandatory function which is called when
the status icon is to be displayed. This should
return true or false depending on whether
the status icon should be displayed for this
asset. For more information, see “Setup
function” on page 24.
Status icon definitions are interchangeable and the same definition can be added to
more than one area.
(function(otui) {
function setupIcon(event, resource) {
if (resource) {
var formatter = otui.DateFormat.get(otui.DateFormat.OTMM_DATETIME);
var importDate = formatter.parse(resource.date_imported);
var now = Date.now();
return (now – importDate.getTime() < (24 * 60 * 60 * 1000))
}
}
otui.ready(function() {
var definition = {
'name' : 'recentasset',
'text' : otui.tr('Asset was loaded recently') // Translated,
'img' : 'path/to/myimg.png'
'setup' : setupIcon
};
otui.GalleryStatusIcons.register(definition);
otui.InspectorStatusIcons.register(definition);
});
})(otui);
Note: All alternate entry URLs will automatically convert the URL given into
the standard format required for the HTML5 UI. This is designed behavior.
http://path.to.otmm/otmm/ux-html/?p=keywordsearch&term=<prefered_
search_keyword>
where
Within results lists for OTMM, assets of any content type will be displayed by
default. OTMM has a default list of content types which it has display attributes for.
However, any new content types which are added will appear in results lists initially
as an unknown asset type. It is possible to augment the display of these content
types by registering it with the HTML5 UI. This can be done by using the otui.
MetadataModelManager.addContentTypes() function.
This function can be passed a content type descriptor or an array of content type
descriptors. Each descriptor is a JSON object containing the following properties:
name
The name of the content type as returned from OTMM, such as BITMAP.
displayName
The translated display name for the content type.
icon
A URL to a 16x16 PNG used as an icon in the gallery view for this content type.
fallback
A URL to a 96x96 PNG used as a default fallback image if an asset with this
content type has no displayable rendition.
Any calls to this function should be wrapped in an otui.ready() call to ensure that
the locale for the user has been successfully loaded.
A full reference of this can be found in the JavaScript API Documentation for the
MetadataModelManager namespace. The following is a brief example:
otui.MetadataModelManager.addFieldLookup("CUSTOM.FIELD.NAME", function(field,
populateValue) {
cs.pollUserForValue(field.name, field.type, function gotValue(value, displayValue) {
if (value && displayValue)
populateValue({'value' : value, 'displayValue' : displayValue});
}):
});
The following is an example of the syntax that you need to use to register a
cascading domain group:
},
…………………………………………………………
});
viewMode
The view in which the cascading group is rendered. The viewMode property can
use one of the following values in the otui.ViewState.mode object:
Name Description
UNKNOWN Any view other than those mentioned in
this table, such as jobs, tasks, and so on.
ASSET_IMPORT New Assets dialog box, which is accessible
by clicking the Folders page > New >
Assets.
FOLDER_CREATE New Folder dialog box, which is accessible
by clicking the Folders page > New >
Folder.
BULK_EDIT Edit multiple assets dialog box, which is
accessible by selecting multiple assets and
clicking Edit.
GALLERY_VIEW Gallery view on the Folders and
Collections pages, which is accessible by
clicking the Folders or Collections menu
entry on the Navigation bar and using the
Gallery view.
ASSET_VIEW Asset Detail view, which is accessible by
double-clicking an asset to invoke the
Detail view.
ASSET_EDIT Asset Detail Edit view, which is accessible
by clicking an asset to invoke the Detail
view, then clicking Edit.
Name Description
FOLDER_VIEW Folder Detail view, which is accessible by
clicking the Folders tab, navigating to the
folder you want, and then clicking its
Show Properties icon to invoke the
Detail view.
FOLDER_EDIT Folder Detail Edit view, which is accessible
by clicking the Folders tab, navigating to
the folder you want and, clicking its Show
Properties icon to invoke the Detail view,
and then clicking Edit.
CLIP_CREATE Create sub clip dialog box, which is
accessible by clicking a video asset to
invoke the Detail view, then clicking More
> Create Sub clip.
CHECK_OUT_VIEW Checked out page, which is accessible by
clicking the Checked out tab.
ADV_SEARCH_VIEW Advanced search dialog box, which is
accessible by clicking the search icon ,
and then clicking the Advanced search
link in the search options dialog box.
For example, to conditionally test for the ASSET_IMPORT view, write the code as
follows:
otui.ViewState.mode.ASSET_IMPORT === context.viewMode
fieldMode
Describes the way the domain field is rendered. It can be read-only or edit. Use
the one of following properties in the OTMetadataElement.fieldMode function
to check against the actual value returned for this property:
edit
readonly
Name Description
edit Displays the field in edit mode. Users can
select an option.
readonly Displays read-only text. Users cannot
select an option.
lookup
The name of the registered cascading group for preselection.
domainID
The registered domain field.
options
The domain field options that are available.
model
A JavaScript object that contains modelId and name, as follows:
{
'modelId' : 'test_model_id',
' name ' : 'test_model_name'
}
Generally, the following properties will be undefined for bulk operations, such as
bulk edit.
resource
Asset or folder-related metadata.
cascadeEl
The cascading group DOM element, which can be used to get additional node
and parent details using the HTML DOM API.
The registered handler function can programmatically decide, based on the supplied
context, which option needs to be selected and the way the domain field or member
should be displayed. The handler function returns a JavaScript object that consists of
following properties:
selectedOption
The option to be displayed for the current domain field. The handler takes this
from the options list that is supplied in context. For more information, see
options on page 40.
display
This property can use the following strings in OTMetadataElement.
fieldDisplay.
Name Description
hide Hides the domain field from being
displayed.
show Displays the field, this is default display. If
the field mode is edit, the field is
displayed as a combo box or option list. If
the field mode is readonly, the field is
displayed as read-only.
disable Applicable to domain fields. When the
field mode is edit, the handler displays
the option list as disabled. The user will
not be able to choose an option.
Name Description
readonly The field is displayed as text.
For example, the following custom code can return an object in the following
way:
return {
"display" : OTMetadataElement.fieldDisplay.hide, 'selectedOption' : "<option1>"
};
Generic templates
These are standard pieces of markup which are reused throughout the UI. They
have only an ot-template attribute (not an ot-view attribute).
Content templates
These are templates which are intended to serve as the main content for a given
view within the application, such as Gallery view or asset Detail view. They
have an ot-template attribute and an ot-view attribute which is set to the view
they are the content for. Content templates are usually named using the format
<view>_content. For example:
ResultsView_content
Resource templates
These are templates which are intended to serve as a template for an individual
resource used within a specific view, such as assets within Gallery view. They
have an ot-template attribute and an ot-view attribute, which is set to the
view that they are resource templates for. Resource templates are usually named
using the format "<view>_resource". For views that can show more than one
type of resource, such as the results view, which can show assets or folders.
Resource templates may also be suffixed with an asset type. For example:
FolderView_resource#folder.
Layout templates
These are templates which dictate how the content on screen is broadly laid out,
such as putting the folders view on the left, taking up 25% of the screen, and
putting the results view on the right, using the remaining space. They have an
ot-template attribute and an ot-view attribute set to MainView.
• ot-resource
• ot-metadata
• ot-rendition
• ot-i18n
• ot-point
• ot-select
9.1.1 ot-resource
The ot-resource element is primarily used within resource templates for views and
contains a base anchor point for all data about the resource, such as assets or folders,
which the template is displaying. It is primarily used in conjunction with the ot-
metadata and ot-rendition elements.
9.1.2 ot-metadata
The ot-metadata element is used in conjunction with the ot-resource element to
show a particular piece of metadata. Field type detection, such as date or string, is
automatically handled by the UI. For basic use in templates, the following attributes
are relevant:
ot-fields
Comma separated list of fields to display for this element. Only field name
needs to be specified. Only one field is displayed per element. If multiple fields
are specified, then it will display the first one that has a value.
ot-with-label
An optional attribute. If specified on the element, the field will have a localized
label for the field displayed with it. This label is retrieved from the metadata
model.
ot-as-attribute
An optional attribute. If specified on the element, it will not render anything,
and will just put the value in as a data-value attribute. This is useful for
displaying icons that are dependent on metadata.
ot-with-title
An optional attribute. If specified on the element, the value of the metadata field
will be displayed in a tooltip when the value overflows the container.
ot-length
An optional attribute. If specified on the element, editable string, or text area,
metadata fields will restrict the length to the given value.
ot-date-restriction
An optional attribute. If specified on an element with a metadata date field, the
given restriction parameters will be enforced.
9.1.3 ot-rendition
The ot-rendition element is used in conjunction with the ot-resource element to
show a particular rendition for an asset. For basic use in templates, the following
attributes are relevant:
ot-rendition-types
Comma-separated list of rendition types to display for this element. Only one
type is displayed per element. If multiple types are specified, then it will display
the first one which exists for the asset.
ot-rendition-format
Format of the rendition. Valid formats are Image (IMG), video, audio and
Acrobat.
9.1.4 ot-i18n
The ot-i18n element is part of the localization and translation layer of the UI. Each
ot-i18n element specifies a string to be localized and translated into the user's
locale when displayed. For more information, see “Localization“ on page 51.
9.1.5 ot-point
The ot-point element contains a reference to a specific integration point which
should be rendered for a given resource. This is an easy way to incorporate
integration points, such as asset actions or menu entries, into a template and have it
apply setup methods for the given resource. ot-point is used in conjunction with
the ot-resource element. For basic use in templates, the following attributes are
relevant:
ot-lookup
A required attribute. The name of the integration point to use for rendering the
content of this element.
ot-max-items
An optional attribute. Used for overflow-style integration points, specifies an
overriding number of maximum items to display.
9.1.6 ot-select
The ot-select element generates a drop-down list. This user interface element
presents users with a list of options. You can add entries with the standard
<option> tag. For basic use in templates, the following attribute is relevant:
ot-as-multiselect
Creates a select box which allows the user to select multiple entries rather than
just a single entry.
To override templates:
1. Find the template you want to override. Templates can be found in HTML files
underneath the /otmm/ux-html/otmm folder. The files are named to reference
their area. So for example, results.html contains templates for the results
view, inspector.html contains templates for the Detail view, and so forth.
Generic templates can be found in the file /otmm/ux-html/ui/templates.
html. Templates always start with a <template> element.
2. Copy the whole template into the HTML import file in your development folder
and modify it as desired.
Modifying templates will usually involve modifying the CSS styles that are meant
for that template as well because the two exist in a symbiotic relationship. For more
information about modifying the CSS styles, see “Create a theme” on page 117. If
the styling is radically different, you may want to consider adding or changing the
CSS classes used on elements. This should be done with caution because some
classes are used as identifiers within JavaScript to enact code and changing these
classes could break functionality.
For example, the resource template used for displaying individual folders in the
folder view typically looks like this:
<div class="ot-folder-entry">
<ot-metadata ot-fields="container_child_count" ot-as-attribute class="ot-
folder-disclose"></ot-metadata>
<span id="ot-folder-icon" class="ot-folder-icon-close"></span>
<ot-metadata ot-fields="name" class="ot-folder-title"></ot-metadata>
</div>
<div class="ot-folder-children">
<ot-i18n id="ot-folder-loading">Loading...</ot-i18n>
</div>
</ot-resource>
</template>
If, for example, you wanted to show an icon which showed the type of folder, you
could copy the template into an HTML import file in your development folder and
modify it as follows:
.ot-cs-folder-type {
background-repeat: no-repeat;
background-size: contain;
width: 1rem;
height: 1rem;
display: inline-block;
&[data-value="CUSTOMER.FOLDER.LOGOS"] {
background-image: url('./folder_types/logo.png');
}
&[data-value="CUSTOMER.FOLDER.DOCUMENTS"] {
Background-image: url('./folder_types/document.png');
}
}
Note: This is written in LESS syntax, which is not strictly CSS compatible.
This would then show a "logo" icon for logo-type folders and a "document" icon for
document-type folders.
2. In the folder that you created in Step 1, add an HTML file, and name it
include.html.
c. Inside the <ot-i18n> element, write the legal text using plain text, without
any HTML elements or styling applied.
<script>otui.Templates.load()</script>
Note: You can also use this approach to make the legal text available for
translations. For more information, see “Localization“ on page 51.
desktop
This template should be for desktop platforms only.
mobile
This template should be for mobile platforms only. This is a shortcut for both
tablet and phone.
tablet
This template should be for tablets only.
phone
This template should be for phones only.
Localization
The HTML5 UI includes a full localization and translation layer. This section will
explain how to do the following:
• Mark text for translation, used for customizations that include new messages.
• Generate localization files for the translation of new messages present in
customizations and integrations.
• Apply localized text for database labels to the user interface
By marking text for translation using the following guidelines, once the integration
has been developed, it becomes a one-click operation to generate a localization
template (otmm-messages.pot) for all messages in the integration, which you can
then use to generate localization (PO) files for that integration.
10.1.1 Format
Each translation token to be used in the application is specified as the English US
translation of the message, marked up using the gettext standard. For example, if
the user interface is to display the message “Welcome to OpenText Media
Management”, the translation token which should be used is “Welcome to OpenText
Media Management”.
Once used with one of the translation functions, or the translation element, at the
point of translation, {0} will be replaced with the version number and {1} will be
replaced with the user's name.
It is also possible to specify that a particular message has a plural form as well. For
more information, see “Plurals” on page 53.
// Do this
var translated = otui.tr("Welcome to OpenText MediaManagement");
// DO NOT DO THIS
var message = "Welcome to OpenText MediaManagement");
var translated = otui.tr(message);
The otui.tr() function should never be passed a variable reference. This is the
fundamental underpinning of how the translations are extracted from the
application. However, any replacements can be passed as variables.
//Translate this into the user's language, substituting {0} for the version and {1} for
the username passed
return otui.tr(
);
Templates
It is also possible to markup templates in the application that should contain
translated text by using the <ot-i18n> element and specifying the translation
token as the text content of the element. Replacements are specified as the ot-
replacements attribute on the element. The ot-replacements attribute should
be a comma separated list of replacements. By default, it will be assumed that
replacements will be properties of the view that the ot-i18n element is in,
although string literals can be specified by wrapping them in single quotes.
10.1.3 Plurals
It is possible to specify that a message has a singular and plural format by specifying
both the singular and plural variant of the message as the US English translation of
the variant. Using this does not limit the translation to having just one plural, as is
the case in English. The gettext standard allows for an arbitrary number of plurals,
including no plurals in languages such as Japanese. The following examples show
how to use the US English variant to mark that a message has a plural.
JavaScript
In JavaScript, the function to use for translating text with a plural format is
otui.trn(). This function takes at least the following arguments:
Any further arguments are, like otui.tr(), interpreted as replacements for the
translation.
Templates
The ot-i18n element can also be used to specify singular and plural versions of
a message. This can be done by specifying an "ot-n" argument containing the
view property name or string literal used for determining plurality (in the same
format as ot-replacements). The text, however, should be specified as two
child elements under the ot-i18n element called singular and plural, which
contain the singular and plural versions of the message.
10.1.4 Context
In some cases, it is necessary to provide extra context when translating a particular
term, such as when the same word can have multiple meanings. For example, the
English word charge could be used in the context to charge a battery or to charge a
customer, which are two very different things.
JavaScript
When you are looking to provide some context, you should use the otui.trc()
and otui.trnc() functions. These functions work in the same way as otui.
tr() and otui.trn() respectively, with the addition of an extra first argument,
which is the context for the translation. This is then displayed to the translator
when translating the text.
Templates
Context can be specified on an ot-i18n tag by using the ot-context attribute.
10.1.5 Style
When using the ot-i18n element for translation, it is also possible to apply styles to
portions of the text through one of two ways:
• Styled replacements
• Styled text
2. Create CSS rules which match the elements underneath that ot-i18n element
which have the attribute ot-replacement-idx.
The following CSS will change the color of the first replaced text and make the
second replaced text bold:
.cs-styled-translation [ot-replacement-idx=0] {
color: blue;
}
.cs-styled-translation [ot-replacement-idx=1] {
font-weight: bold;
}
Note: For @link[url]@, If you add a URL, the address is opened in a new tab
in the browser.
Important
Style tags cannot be mixed or nested. For example, you cannot apply both bold
and underline to the same text.
Text in images
Try to avoid using text in images whenever possible. If you have text in images
that are used in the UI, they will not be translated. This will add overhead to any
translation because the original image will have to be altered to include the text
in the correct language.
Broken up strings
To help ease the task of translating text, try to consolidate text as much as
possible by using replacements to concatenate several broken up strings into one
string.
For example, instead of using:
<span>Welcome</span>
<ot-view-prop ot-prop="username"><ot-view-prop>
Buttons
For clickable buttons, you should use the <button> element as opposed to the
<input type="button"> element. This is mainly because <button> elements can
have child elements and <input> elements cannot. Using the <button> element
will make the internationalization of button text easier because you can do the
following:
<button>
<ot-i18n>OK</ot-i18n>
</button>
3. To load and scan the integration for translation tabs and generate the POT file,
click the Generate button beside Generate translation template for customer
specific integrations option.
4. Click Download after the file is generated. The file name will be cs-
translation-template.pot.
Note: This template contains only the changes for the customization. This
means that only new labels that were added to OTMM are reflected in this
POT file.
1. Open Poedit.
2. Click File > New from POT/PO file and navigate to your POT file.
4. Select the string that you want to localize from the list and type the translation
in the Translation area. Repeat this for each string (source text) that you want to
localize.
5. Click Save and use the following naming convention for the new PO file:
<language_Territory>.po
For example, for French locale (fr_FR), the file name would be fr_FR.po.
3. On the Languages page, click Choose file, choose your ZIP file and click
Upload.
Tip: You can click View in the Actions column of the new locale to verify
that the file for your UI messages deployed. For more info, see section
20.4.4 “Generate and manage custom language packs” in OpenText Media
Management - Administration Guide (MEDMGT220200-AGD).
2. Go to the Actions column of the locale to which you want to add your custom
UI messages and click View.
3. On the Language page, go to the UI messages row and click Add in the Custom
version column.
4. Click Choose File, choose your ZIP file, and click Upload.
Note: If the custom version for your UI messages is from a previous version of
a custom UI integration, you can replace it with your updated PO file.
2. Go to the Actions column of the locale for which you want to replace your
custom UI messages and click View.
3. On the Language page, go to the row of the custom UI messages file that you
want to replace and do the following:
a. Click Download in the Custom version column and save the downloaded
filto create back up the previous version of the UI messages file.
b. Click Delete in the Custom version column to remove the existing version
of the UI messages file.
c. Click Add in the Custom version column to add the new version of the UI
messages file.
d. Choose the new version of the PO file and click Upload.
2. Go to the Actions column of the locale for which you want to add your custom
UI messages and click View.
3. Download the custom version of your existing OTMM UI messages file. For
more information, see section 20.4.4.3 “To download component files” in
OpenText Media Management - Administration Guide (MEDMGT220200-AGD).
4. Create a backup of the OTMM UI messages file that you downloaded in Step 3.
5. In a text editor, open your new custom integration UI messages PO file and
copy all the rows with translated strings to the Clipboard.
Tip: The translation rows start at the first hashtag (#), which is below the
PO file configuration setting section.
6. In a text editor, open the existing custom UI messages PO file that you
downloaded in Step 3 and do the following:
7. To verify that the merged PO file does not contain duplicate entries, do the
following:
Note: PO files cannot contain duplicate entries. Prior to uploading the new
PO file to OTMM, you need to remove duplicate entries as source text.
You can do this using Poedit Gettext Translations Editor, which you can
download from http://poedit.net/.
a. Go to the Actions column of the locale for which you want to replace your
custom UI messages and click View.
b. On the Language page, go to the row of the custom UI messages file that
you want to replace and click Delete in the Custom version column
c. Click Add in the Custom version column to add the new version of the UI
messages file.
d. Choose the new version of the PO file and click Upload.
Note: For more information, see section 20.4.4 “Generate and manage custom
language packs” in OpenText Media Management - Administration Guide
(MEDMGT220200-AGD).
When the proper PO file exists for the database values, all of the translations for the
current locale are loaded upon startup. However, these values need to be used
within the UI. You can do this using the otui.TranslationManager.
getTranslation() function. For example, within the ShareView, which is opened
when the user clicks Share for an asset, the UI retrieves a list of delivery
transformers from the back-end and stores them within a local variable array called
_deliveryMethods;. This list is then displayed dynamically within a drop-down
list. For each option within the drop-down list, the text is dynamically added with
the following code:
optionItem.textContent = otui.TranslationManager.
getTranslation(_deliveryMethods[i].name);
The drop-down list will then display these options within the current locale,
provided a translation for the locale exists.
The HTML5 UX has a built-in API for displaying notifications to a user as well as
displaying alert and confirmation dialog boxes in a consistent, cross-platform way.
Non-modal notifications
Take the form of a small banner at the top of the UI.
Modal notifications
Take the form of a small modal dialog box.
message
This is the message to show in the notification.
status
How to present this notification to the user. The following values are possible:
stayopen
An optional Boolean which, when set to true, causes the notification to stay open
until the user manually closes it. Otherwise, the notification will gradually fade
and then disappear.
// Warn the user that the system will be going down for maintenance soon
otui.NotificationManager.showNotification({
'message' : otui.tr("The system will shortly be going down for periodic
maintenance."),
'status' : 'warning',
'stayOpen' : true
});
11.3 Alerts
Modal alert notifications can be created by using the otui.alert() call. The
function can take just a string to display as a modal alert message, but it can also
take a single object which contains more details about the alert to display. This object
can contain the following properties:
title
This is the title of the alert.
message
This is the message to show in the alert.
status
How to present this alert to the user. The following values are possible:
// Warn the user that the system is going down for maintenance
otui.alert({
'title' : otui.tr("System maintenance"),
'status' : 'warning',
'message' : otui.tr("The system is going down for periodic maintenance.")
});
The details object takes the same parameters as for modal alerts.
The callback object is passed a single Boolean indicating if the user clicked the Yes or
No button.
This section details how to retrieve details pertinent to the current OTMM
environment and the currently signed-in user, in order to apply security, feature
checking, and so forth.
otui.UserFETManager.getUserFET()
Return an Array of every FET that the user has available.
otui.UserFETManager.isTokenAvailable(tokenName)
Returns true or false depending on whether the user has the given FET.
// Create a new gallery view action which will link the currently selected assets into a
newly created personal folder.
otui.GalleryViewActions.register({
'name' : 'create-personal',
'text' : 'Save assets into personal folder',
'setup' : function () {
// Only display this menu entry if the user has the FET for creating folders.
return otui.UserFETManager.isTokenAvailable("FOLDER.CREATE");
},
'select' : function () {
// Create personal folder here
}
});
otui.PreferencesManager.preferences
Object containing all preferences currently used by the HTML5 UX and their
value objects.
otui.PreferencesManager.preference(id)
Retrieves the value for the current preference. For simple, single value
preferences, this will return the preference value itself. For more complex
preferences, the full value object is returned.
otui.PreferencesManager.preference(id, value, callback)
Sets the value for the current preference. For simple, single value preferences,
the value can just be the preference value itself. For more complex preferences,
the full value object should be passed. A callback function can be passed which
will be called after the preference has been set.
// Create a new gallery view action which will reset the user's preference for seeing
drag hints.
otui.GalleryViewActions.register({
'name' : 'reset-preference',
'text' : 'Show drag hints',
'setup' : function () {
// Only display this menu entry if the user has already seen the drag hint
return (otui.PreferencesManager.preference("seenDragHint") === "true");
},
'select' : function () {
// Set the preferences then show a notification saying it's been set
otui.PreferencesManager.preference("seenDragHint", "false", function(response,
success)
{
if (success)
otui.NotificationManager.showNotification({
'message' : otui.tr('Drag hints will be shown the next time you
navigate to a folder')
});
});
}
});
System settings are typically broken down by configuration group, component, key,
and name. When viewing system settings through the Settings page in the Web
Administration tool, the component and key both come from the group heading. For
example:
When reading TResource, the component and the key both come from the group
heading, and the name comes from the setting itself. For example:
UserDetailsManager.getUserDetails
Object containing all details of the currently signed in user.
UserDetailsManager.isAdmin
Returns true if the current user is an administrator. Otherwise, it returns false.
All services under the OTMM HTML5 UX can be accessed under otui.services.
Each service typically has create, read, update, and delete methods, each of which
take a data object containing information about what is being accessed and a
callback which is called after the service has completed its work.
While it is not guaranteed that all objects will be accessible under services, it is also
not guaranteed that each service present will have create, read, update, and delete
methods available. If you find that a given service is not available, or it does not
meet your requirements, then you should make use of the REST API directly.
Services will be augmented to be fully representative of the functionality required in
subsequent releases.
field
The field used for sorting on. This is commonly a metadata field name.
direction
The direction to sort in. Should be asc (ascending) or desc (descending).
12.5.1 Services
Each service function takes two arguments: A data object (which data is required is
listed against each service), and a callback function.
The callback function will be given at least two arguments, including the response,
and a Boolean indicating whether the request was successful or not. There may also
be a third argument, which is the HTTP status returned from the REST API when
performing a call. In all cases, the success Boolean is always the last argument to the
callback.
If the request was successful, then the response will contain the data requested in the
case of read requests. If the request was not successful, then the response, if it exists,
will be an object containing an exception_body object, which will contain a
message detailing why the request failed. This can then be used to notify the user of
an error.
For more information about the data format, see “REST API documentation”
on page 10.
});
}
else {
// Success, alert the user with the asset name.
var assetName = response.asset_resource.asset.name;
otui.alert(otui.tr("Asset name is {0}", assetName));
}
Note: For additional guidance on using the REST API to retrieve data, see the
otmm/model/manager folder. These methods may be modified, deprecated or
removed in future releases.
Within the OTMM HTML5 UX, views are the medium through which functionality
is delivered to the end user. Views provide a standardized, modular base for
encapsulating an area of functionality entirely, including its display, state, and route
through the application.
Each view is comprised of a HTML template used for content and a JavaScript View
class which provides state and parameter tracking to back it.
Views can be cached and are intended to be self-contained and reusable across the
application. They can also be displayed both as main areas of the application or as
modal dialog boxes.
Throughout this section the views examples pack that comes with OTMM will be
referenced.
For examples of everything detailed in this section, see the businesscard folder in
the examples pack.
The ID attribute specifies the name of the template, the ot-template attribute marks
it as a template to be ingested, and the ot-view attribute marks it for the
BusinessCardView.
Once the view object begins to take shape, the content view can be expanded to
include more content.
Note: When creating a content template, there should only be one top-level
element in the template, which encapsulates the rest of the content.
The definition function for a view is called to define properties and methods on
instantiations of that view. In JavaScript terms, this is called the view prototype.
13.1.2.1 Properties
All views should have a properties object. This is a map of default and expected
properties which will be required for the view to work. There should be at least one
property specified, which is name. This should be a unique name for the view.
Aside from that, any default property values which would be required for the view's
logic should be specified there.
The most typical use of the content function is to retrieve a HTML template and
send that to be placed as content for the view. This can be done, as seen in
BusinessCardView.js, by using the this.getTemplate() function. This will
retrieve the template with the given ID that is marked for that view.
Examples of this can be seen in every example where the setup event listener is used
to set up interaction events.
While the example uses a custom render event which is emitted by the
ResultsView, the following set of standard events can be bound to any view.
Event Description
setup Called whenever the view is displayed.
setup-finished Called whenever the view is displayed,
useful for ensuring something is run after
other setup functions.
teardown Called when a view is to be destroyed.
resize Called whenever the view is resized, either
from the window being resized or by another
view modifying it.
detach Called when the view is detached from the
UI, so that it is no longer visible. Useful for
resetting the state when the view is on
screen.
attached-to-view Called when a view is attached to a parent
view. Useful for pulling through data from
parent views in a view hierarchy.
removed-from-view Called when a view is removed from a
parent view. Useful for cleaning up data that
was pulled through from parent views.
Event Description
show For tabbed composite views, this event will
be called on a child view (tab) whenever it is
shown.
Creating a route is a two-step process. An example of this process can be seen at the
bottom of examples.js in the examples pack.
URL format
The URL format for a route consists of a parameterized URL fragment which,
when the URL for the page is set to that URL, will navigate or route to the view.
Every parameter which is specified as part of a URL format will be placed into
the views which are displayed when users navigate to that URL. Parameters are
bound to a URL format by specifying the parameter with the colon (:) character
added as a prefix. Parameters are, by default, mandatory, unless question mark
(?) character is added as a suffix.
For example, the URL for displaying the Detail view for an asset in OTMM may
be the following:
asset/:resourceID@:InspectorView_selected?
This URL format will then match on any URL in the application which matches
that format, and will set the resourceID parameter and the InspectorView_
selected parameter, should it exist, into any views that are created.
The remaining functions typically dictate which views to display in the layout
template. When inserting views into the layout templates, the views are always
inserted left to right and then top to bottom. These functions are usually variants of
route.to on a view, called on the view to display. This function can be passed an
object of extra properties to use for instantiation or alternatively, a function which
can read the parameters from the URL and return an object of extra properties.
ExamplesView.route.define("open",
ExamplesView.route.as("demo/examples/:example?",
otui.withTemplate("main-with-sidebar"),
ExamplesView.route.to(),
loadCurrentExample));
ExamplesView.route.define("open-contents",
ExamplesView.route.use("open"));
ot-resource
ot-metadata
ot-rendition
verbose
For assets/folders which have been requested from the REST API without
specifying any specific fields to return.
light
For assets/folders which have been requested from the REST API with only
specific fields return.
path
For all other assets/folders.
You can place the ot-metadata and ot-rendition elements at any point within the
ot-resource element.
For ot-metadata elements, you must specify the ot-fields attribute, which is one
or more fields from the resource to display. For resources without asset-type
metadata, such as anything other than folders or assets, you should specify the
data-type attribute. For a full list of types, as well as a full reference on this
Note: If you are using the ot-resource element with objects retrieved directly
from the REST API, and not through one of the UI services, then ensure that
the object passed into otui.Templates.applyObject is the resource itself and
not it's wrapper. For example, retrieving an asset directly from the REST API
will wrap the asset itself in an asset object, which is itself wrapped in an
asset_resource object. The UI expects just the asset itself, not the wrappers.
• Resources must be in JSON, and that JSON cannot have recursive links in it, such
as
obj.a = obj
• The resource JSON must be a flat object with each value as a primitive value such
as string, number, or Boolean, or in the case where there are both internal and
display values, as a JavaScript object with ID and name as the internal and
display names respectively.
• Dates in the JSON must be specified as either a JavaScript Date object, or a String
in ISO-8601 date format.
{
"string_field" : "string value",
"date_field" : "2014-07-04T14:10:44",
"number_field" : 5,
"boolean_field" : true,
"key_value_field" : {
"id" : "internalvalue",
"name" : "Display value"
}
}
If the resource JSON that is to be displayed cannot be put into this format, you will
need to write a custom resource locator for the ot-resource element to allow the
resource element to navigate the JSON structure, and set the ot-resource-locator
attribute to be the name of that custom resource locator. For more information, see
the ot-resource namespace in “JavaScript API documentation” on page 10.
• To the content template for your sidebar view, add the following underneath
your main element:
<ot-view-collapser collapser-style="vertical-bar" ot-
platform="desktop"></ot-view-
This adds the display and functionality for a vertical view collapse.
• Add the header as the first element underneath your main element in your
content template and give it the class ot-view-header-title.
• Apply the OTMM default styles to those list entries by giving each entry a class
of ot-list-view-entry. An example of this can be seen in include.html in
the examples pack.
Example 13-2: Pass the array of mixins in as the second argument to otui.
define
There are also several mixins which come with the framework and can be used to
create composite views, which are described in “Composite views” on page 83.
• Freeflow composites.
• Tabbed composites.
An example of this kind of view can be seen in the examples pack under
AddressBookView.js, which will display a series of business cards in a grid-like
view.
2. Create a content template for the view which contains an element with the class
ot-child-container. This will contain all the child views when displayed.
When using freeflow composite views, it is possible to specify a template which will
be used to wrap each child view so that extra functionality and display attributes
can be incorporated without having to specifically modify the child views. This can
be done by specifying the name of the template as the property child-template and
ensuring that the template has an element with the class ot-child-content. For an
example, see AddressBookView.js in the examples pack.
2. Create a content template for the view which contains an ot-tabs element. This
will contain all of the tabs and each of the views for those tabs.
During definition/construction
If you want to have a default or predefined set of child views for a composite
view, you can specify this.hierarchy in the definition function for the view.
This should be an array which contains one or more objects with the following
attributes:
view
The constructor of the view to use.
properties
An object of properties to use for instantiation of that view.
After construction
If you want to dynamically add views after construction, you can use the
addChildView function on a view, passing in an instantiation of the view to add.
Example 13-4: Augment a view to add a new tab to the asset Detail view
(function(otui) {
/* otui.require ensures that the view named in the argument exists before continuing
the function chain.
* otui.augment augments the prototype of an existing view, without extending it to
create a new view.
* the line below essentially reads "Once the CustomChildView exists, augment the
InspectorView by executing the following function on its prototype".
*/
otui.require("CustomChildView").augment("InspectorView", function() {
/* As detailed in the integrators guide, the 'hierarchy' property of a view's
prototype is the list of all child views which will be created for that view.
* We add a child view by pushing a new entry into that ar-ray.
* Note: this.inherit() is a special function which can be used in this
circumstance to indicate that properties for the parent view should be passed down to
the child view. For exam-ple, the line
* 'assetID' : this.inherit("assetID")
* indicates that this child view should inherit the "as-setID" property from
the parent view (InspectorView).
*/
this.hierarchy.push({
'view' : CustomChildView, // 'view' attribute is a refer-ence to the view
which will be used for this tab
'if' : function() { return true; }, // 'if' attribute is an optional attribute which
references a function. When the child view is due to be created for an asset inspector,
it will call this function. Returning false from this function will hide this child view
and make it inaccessible for that instance of the asset inspector.
'properties' : { // 'properties' attribute is a map of properties which will
be passed to this child view on instan-tiation
Widgets
Using widgets, you can integrate OTMM into any external applications that allows
you to add embed code. By integrating widgets, you provide that external
application with access to a large portion of the functionality in OTMM.
Important
• This section uses host applications to refer to the external applications that
integrate widgets.
• This section is only applicable to widgets that are being added to host
applications.
• If you created custom widgets, those widgets will no longer display on the
Home page. Depending on how you developed and implemented these
widgets, they may cause issues loading the Home page. You may need to
remove these widgets from the host application, or update the code to
resolve any JavaScript errors or conflicts to use them in host applications as
external widgets.
The following lists the task that you need to perform to integrate widgets into a host
application.
2. Get the embed code and add it to your application. See “Get embed code”
on page 90.
By default, the following widgets are included with OTMM:
• Asset widget
This widget displays a given asset, with some basic metadata and
functionality, such as playing video or audio. Currently, download is the
only action available for assets in the Asset widget.
• Upload widget
This widget displays an area which can be used to upload files to OTMM.
Note: If a user does not have the necessary upload permissions, import
template, or security policies, then the Upload widget is not available
on the Home page.
3. Include widgets on a page. See “Include widgets on a page” on page 90.
4. Provide a way to authenticate widgets in the host application. See “Authenticate
widgets in host applications” on page 99.
5. Interact with widgets by adding widget attributes, features, and events. See
“Include widgets on a page” on page 90.
6. Style and position widgets. See “Style and position widgets” on page 103.
In addition, you may want to use extensions for the UI in the widgets. To do this,
you must configure OTMM to make the appropriate extension folders visible outside
of main OTMM.
Notes
Note: This procedure discusses editing system settings. You can search for
system setting on the Settings page in the Web Administration tool. For
more information about how to search for settings, see section 23.1.2.4 “To
search for a property” in OpenText Media Management - Administration
Guide (MEDMGT220200-AGD). After finding the setting on the Search
results page, click the property name. For more information about how to
configure system settings, see section 23.1.2.3 “To edit a component and
properties” in OpenText Media Management - Administration Guide
(MEDMGT220200-AGD).
Note: An origin site is the end-point address to access the host application.
If the host application uses load balancers, you only need to specify the
end point URL that the user uses to access the host application. You also
need to specify the resource locator protocol for each origin site, such as
http:// or https://, and the port of the host application. For example, if
the host application can be accessed at the URL http://third.party.
application:2890/app, then the setting would be as follows:
"CORS_ORIGIN_LIST"="http://third.party.application:2890"
JBoss EAP
<TEAMS_HOME>/ear/artesia.ear/otmmux.war/WEB-INF
TomEE
<TEAMS_HOME>/ear/atresia/otmmux/WEB-INF
2. Navigate to the last XML tag, <filter-mapping>, and then add the following
below it:
<filter-mapping>
<filter-name>CORSFilter</filter-name>
<url-pattern>/ux-html/directory/*</url-pattern>
</filter-mapping>
where
directory is replaced with the name of the extension folder that you want to
expose.
Note: Getting the embed code through the OTMM Web client provides you
with the IDs. For more information about how to get embed code using the UI,
see section 25 “Generating embed code” in OpenText Media Management - Web
Desktop Client User Guide (MEDMGTMOD220200-UCW).
To get the embed code for the Upload widget, copy it from this document. See “To
include Upload widget functionality” on page 96.
2. Include the HTML import link elements for each widget library that is required.
See the following sections for information about their locations:
Note: For more information about including the widget element, see
“How to interact with widgets” on page 102.
a. In a text editor, open the web.xml file, which is located in one of the
following deployed folders:
JBoss EAP
<TEAMS_HOME>/ear/artesia.ear/otmmux.war/WEB-INF
TomEE
<TEAMS_HOME>/ear/atresia/otmmux/WEB-INF
Note: Be aware that the name of the HTML file is otmm-asset-widget. This is
so for future releases, single asset functionality can be shipped while being
backwards compatible with existing integrations.
Attribute Description
header A displayable title for the widget. (Optional)
folder-id The ID of the folder to display for this
widget. If one is not supplied, and the
settings feature is available for the widget,
then the settings area will automatically
display. The attribute is mandatory.
template-name The name of the template to use for
displaying assets in this folder. Defaults to
tiled-cell can be one of tiled-cell, masonry-
cell, table-cell, grid-cell, assets-slider. The
attribute is optional.
user-page-properties The controls for the Sort results by
parameters. This attribute allows users to
sort by prefix, field, and assets per page. You
must use the JSON format and provide all or
none of the following supported properties:
sortField, sortPrefix, and
assetsPerPage.
Event Description
open-contents Fired when the user clicks on an asset. Detail
object contains:
• resourceID - The ID of the asset selected.
• resourceType - The object type of the
asset selected.
open-folder Fired when the user clicks on a folder in the
main view, folders list, or breadcrumb. Detail
object contains:
• nodeID - The ID of the folder selected.
• breadcrumb - Object containing the full
breadcrumb for the folder selected, split
into IDs and names lists.
update Fired when the user has changed settings in
the settings area. It requires the settings
feature to be turned on. The Detail object is
empty. However, all attributes will have
been updated by this point.
Note: This is the same import link that is used for Folders widget.
Note: Be aware that the name of the HTML file is otmm-asset-widget. This is
for future releases. Single asset functionality can be shipped while being
backwards compatible with existing integrations.
Attribute Description
header A displayable title for the widget. This
attribute is optional.
saved-search-id The ID of the saved search to display for this
widget. If one is not supplied, and the
settings feature is available for the widget,
then the settings area will automatically
display. This attribute is mandatory.
template-name The name of the template to use for
displaying assets in this folder. Defaults to
tiled-cell, can be one of tiled-cell, masonry-
cell, table-cell , grid-cell, assets-slider. This
attribute is optional.
user-page-properties The controls for the Sort results by
parameters. This attribute allows users to
sort by prefix, field and assets per page. You
must use the JSON format and provide all or
none of the following supported properties:
sortField, sortPrefix, and
assetsPerPage.
Event Description
open-contents Fired when the user clicks on an asset. Detail
object contains:
• resourceID - The ID of the asset selected.
• resourceType - The object type of the
asset selected.
open-folder Fired when the user clicks on a folder in the
Main View, folders list, or breadcrumb.
Detail object contains:
• nodeID - The ID of the folder selected.
• breadcrumb - Object containing the full
breadcrumb for the folder selected, split
into IDs and names lists.
open-search Fired when the user clicks on the "see all"
area for the widget. Detail object contains:
• searchID - A string which contains the
title of the saved search and the ID of the
saved search in such a format that can be
used by the UI.
update Fired when the user has changed settings in
the settings area. It requires the settings
feature to be turned on. The Detail object is
empty. However, all attributes will have
been updated by this point.
Attribute Description
header A displayable title for the widget. This
attribute is optional.
asset-id The ID of the asset to display for this widget.
This attribute is mandatory.
asset-type Set this attribute to detect. This attribute is
mandatory.
Attribute Description
header A displayable title for the widget. This
attribute is optional.
folder-id The ID of the folder to upload assets into. If
you do not provide a folder ID, the user can
choose by browsing.
Event Description
upload-started Fired when an asset upload is initiated.
upload-finished Fired when an asset upload completes.
To template a widget:
1. Create an HTML file which includes a <template> tag and give it the ot-
template attribute and an ID attribute. Ensure that this ID attribute is unique to
the system. You can do this by prefix the template with the name of the
application. Inside the template element, write the widget as you normally
would write a widget. For example:
Example: <template ot-template id="sample-app-folder">
<otmm-folder header="OTMM Folder picker">
2. Go to the end of the file and include a script tag that calls otui.Templates.
load().
Note: Any templates that were in the file can then be accessed using otui.
Templates.get(), passing in the ID of the template. This will return a
document fragment that can be inserted into the page.
// Assume that the otmm-platform has loaded, along with all prerequisites
function addWidget(element) {
var widget = otui.Templates.get("sample-app-folder");
element.appendChild(widget);
}
Note: On some systems, it may not be possible or desirable to alter core HTML
files to include script and link tags. In these cases, you can load the OTMM
widgets programmatically after the page of the host application loads.
2. Add an event listener to the window for the event OTUIReady. This should be
placed in the same function as where the script is created. This event will be
fired after the OTMM platform has been loaded and is ready for use.
3. In the event listener function, load one or more of the widget libraries by using
the function otui.loadImport(), passing in a URL (or an array of URLs), and a
function to call once those have been loaded. In this case, each of the URLs
should be one of the widget library URLs. For more information about their
locations, see the following sections.
Note: For advanced configurations, this could also be used to load another
HTML page which in turn includes links to the widget libraries.
Note: The host application needs to pass a valid OTDS ticket to the
OTMM widget.
Note: For use cases beyond these options, implement a custom SSO
Resolver. For more information, see section 9.1.2.4 “Configure SSO
resolver” in OpenText Media Management - Integration Guide
(MEDMGT220200-AIN).
• To specify the session headers as a JavaScript variable, set the headers object
as a JavaScript variable by setting the JSON object to the variable otui.
sessionHeaders. For example:
otui.sessionHeaders = {"OTDSToken" : "valuegoeshere"};
1. Specify the session headers if you are using one of the following in Step 4:
Note: This procedure discusses editing system settings. You can search for
system setting on the Settings page in the Web Administration tool. For
more information about how to search for settings, see section 23.1.2.4 “To
search for a property” in OpenText Media Management - Administration
Guide (MEDMGT220200-AGD). After finding the setting on the Search
results page, click the property name. For more information about how to
configure system settings, see section 23.1.2.3 “To edit a component and
properties” in OpenText Media Management - Administration Guide
(MEDMGT220200-AGD).
4. To configure the REST API authentication to work with the widgets on host
applications, enable remote sign-in by change the value of the ALLOW_REMOTE_
USER_LOGIN system setting to Y.
Note: For more information about the OTMM SSO resolvers and
guidelines, see “Authenticate widgets in host applications” on page 99.
Example:
"SSO_RESOLVER"="com.opentext.mediamanager.restapi.common.sso.WidgetUserNameResolv
er"
"USER_HEADER_NAME"="John_Doe"
• Configure the OTDS Ticket resolver – Set or append the value of the SSO_
RESOLVER setting with com.opentext.mediamanager.restapi.common.
sso.OTDSHeaderTokenResolver. Set the OTDS_SSO_HEADER_NAME system
setting with the header name that you set in the session headers.
The OTMM system settings configuration will look as follows:
Example: "SSO_RESOLVER"="com.opentext.mediamanager.restapi.
common.sso.OTDSHeaderTokenResolver"
"OTDS_SSO_HEADER_NAME"="OTDSToken"
The client code on the host application will look as follows if the JavaScript
object is being passed as an element:
Example:
<otmm-setup session-headers='
{"OTDSToken" : "value-goeshere"}
'></otmm-setup>
The client code on the host application will look as follows if the JavaScript
object is being passed as a JavaScript variable
Example:
otui.sessionHeaders =
{"OTDSToken" : "OTMMTicket"}
Note: The value of the user set in the header should be a valid OTMM
username. This resolver checks the username.
The client code on the host application will look as follows if the JavaScript
object is being passed as an element:
Example:
<otmm-setup session-headers='
{"OTMMUser" : "value-goeshere"}
'></otmm-setup>
The client code on the host application will look as follows if the JavaScript
object is being passed as a JavaScript variable:
Example:
<otmm-setup session-headers='{"OTMMUser" : "app-user"}'></otmm-setup> or
otui.sessionHeaders = {"OTMMUser " : "app-user"};
• Attributes
• Features
• Events
Each widget includes a discover() method, which lists all available attributes,
features, and events for that widget.
Attributes are fully reflective of the current state of the widget. Changing an
attribute's value will update the widget. For example, changing the folder ID
attribute for a Folders widget will change the widget to display that folder. If the
widget internally changes, the attributes will be updated to reflect that change.
Note: Features are not changeable once the widget has been instantiated and
are read-only.
Widget events work in the same way as normal browser events, such as a click or a
keypress, and can be attached as such. Each event includes a detail object which
includes information pertaining to the event in question.
Note: If using jQuery events, jQuery wraps their own event around the
original event, so the detail object will be accessible under event.
originalEvent.detail instead.
By default, widgets are displayed as inline-blocks and do not have a specified width
or height. As part of the integration, OpenText recommends that you set these
yourself. Any changes to padding, margin and background color will be honored.
Widgets will respond to any change in size automatically.
For some integrations, you might want to apply custom styling to the internals of
widgets to better integrate into the host application. You can do this through simple
CSS changes, much in the same way that styles can be changed for core OTMM.
2. Create a CSS file and include a link to it in the HTML import file created in Step
1. Ensure that the rel attribute is set to stylesheet/shadow as opposed to just
stylesheet. This will ensure that it is placed into the widgets.
3. Within the widgets, write a CSS to affect the styles.
Note: You must write each style specification twice, with different prefixes
due to technological limitations. Be sure to write each style with the
following prefixes:
:host({widgetname}) {rest of selector}, {widgetname}[ot-
shadow-host] {rest of selector}
For example, this is how you would change the background color of the
footer in the Folders widget to light grey:
:host(otmm-folder) .ot-results-widget-footer, otmm-folder[ot-shadow-host] .ot-
results-widget-footer {
background-color: rgba(224, 224, 224, 0.9);
}
When you are ready to deploy the integration in your development environment to
your production environment, you must replace any references to .less files with
references to .css files. This removes the ability to auto-reload .less files during
development. Instead, the processing of .less files into CSS will shift to the server,
which speeds up the user experience in the production environment.
The changes to each <link> element which references a .less file are as follows:
To:
You can style the OTMM UI by changing icons and images, display attributes, and
colors. To do this, you either create or override CSS files that are used for those
styles.
• Brand
Using this method, you create a brand to style the UI, and you assign the brand
to user groups. You can create a basic brand using the Web Administration tool
or create and configure an advanced brand. To create an advanced brand, you
need to create a brand folder and a file called branding.html. Reference all files,
such as CSS, that you used to create your brand in branding.html. Compress
the brand folder to create a brand configuration file, and then import the
branding configuration ZIP file using the Web Administration tool. For more
information, see “Create a brand” on page 108.
Note: This method does not allow you to override global CSS variables. For
more information, see “Brand limitations” on page 109.
• Theme
Using this method, you create a theme to style the UI and you override the CSS
files. The changes you make will be applied to all user groups automatically. To
change the theme, you need to create a LESS file and an include.html file. The
include.html file must reference the LESS file. For more information, see
“Create a theme” on page 117.
Important
You must choose one of these methods. If you implement a theme, then create
and apply brands to user groups, the brands might not override the style
elements in all cases.
If your organization has multiple business units and each business unit has a
different theme or style, create a brand for each business unit and then assign
each brand to the appropriate user group.
Using the Brands page in the Web Administration tool, you can quickly create
a basic brand. If you want to style the brand further, you can use the basic
brand as an example or as a basis for an advanced brand. To do this, download
the brand and extend it. After creating an advanced brand, use the Brands page
to import it.
If your organization has one corporate style, you can create a theme. Your
theme will apply to all user groups automatically. Another option would be to
create one brand and apply it to the Everyone user group. However, if you take
this approach, note that the brand method does not allow you to override
global CSS variables. See “Brand limitations” on page 109.
• Basic branding
Fill out and submit a form that defines the brand components.
• Advanced branding
Upload a brand configuration file that contains the branding.html file and
brand components. You must reference all the files that you used to create the
brand in the branding.html file, for example all CSS files and theme.js. After
creating the brand, create a brand configuration file by compressing the folder;
ensure that branding.html is at the top of the folder. Use the Brands page to
import the ZIP file.
Note: You need to create both CSS and theme.js files to style the OTMM
GUI.
The following sections explain how to create a brand configuration file using the
Advanced brand method. For more information about creating a brand
configuration using the basic branding method, see section 7 “Create and manage
branding configurations” in OpenText Media Management - Administration Guide
(MEDMGT220200-AGD).
However, there is a limitation to the functionality. Due to the structure of the global
variables, you cannot override global CSS variables in the same way that you can
with themes. Consequently, outside of the use of branding helper functions, you
must redefine colors on a per-element basis.
2. Under the /mybrand folder, create an HTML file and name it branding.html.
Important
You must reference all the files that you use to create your brand in
branding.html, such as CSS file and theme.js.
Task Procedure
Use branding helpers to change the home See “To add branding helpers”
screen, logo, color scheme and on page 111.
background header, and so on.
Copy and edit the CSS sheets as you See “To copy and override style sheets”
would for a theme. on page 118.
Change images or icons as you would for See “To copy and override style sheets”
a theme. on page 118.
Change display element as you would for See “To copy and override style sheets”
a theme. on page 118.
Note: Anything that will work with a theme, such as changing styles or
templates, adding new menu entries, and reordering menu entries, will
also work in a branding.html file, with a few exceptions. For more
information about the exceptions, see “Brand limitations” on page 109.
Tip: To ensure that your advanced brand contains all necessary files,
OpenText recommends that you first create a basic brand and use it as the
foundation for your advanced brand. Go to the Brands page in the Web
Administration tool, create the basic brand, then download the brand and
modify it as required. When modifying the brand, remember to update the
link to the favicon in the branding.html file to match the new folder for
the advanced brand. For more information, see section 7 “Create and
manage branding configurations” in OpenText Media Management -
Administration Guide (MEDMGT220200-AGD).
4. Create a brand configuration file by compressing your brand folder and the files
that you used to create the brand. Ensure that branding.html is at the top level
of the ZIP file.
Note: If you do not specify a folder name, the name of the ZIP file that
you upload is used.
c. Click Advanced Branding > Choose File and select the brand configuration
file.
d. Click Save. For more information, see section 7.3 “To upload an advanced
branding configuration” in OpenText Media Management - Administration
Guide (MEDMGT220200-AGD).
7. To verify your brand, sign in to the Web Client as member of the user group
that you created in Step 6. The OTMM UI reflects the brand associated with that
user group when you sign in or refresh your browser.
Note: If a user belongs to multiple user groups that are associated with
different brands, OTMM will choose the first brand in the list. Users can
set their default brand through their user preferences. In the absence of
any configured brand for user groups, OTMM will load the default brand.
8. With one of the users who is a member of the user group you assigned the
brand to in Step 6, sign in to Media Management, click , General. In the
Brand list, choose the newly created brand and save the preferences. When you
refresh your browser or the next time you sign in to Media Management with
that user, the branding.html that you created will be loaded for that user.
You can also use branding helpers to simplify the process of styling the application.
Branding helpers are functions that you add to a LESS file that you create.
3. To make the branding helpers available, include the following line at the top of
the LESS file that you created in Step 1:
@import (reference) "../brand-functions.less";
4. To implement the branding helpers, use them in the LESS file as you would call
a function in JavaScript.
Notes
Note: Changes that you make to the background apply to the home screen
only.
The first value of the pair accepts a background image CSS property. This value
supports a URL or gradient, including all the gradient possibilities. For more
information, see https://www.w3schools.com/cssref/pr_background-image.asp.
If you are using the first value of the pair, you must pass one of the following:
• A color gradient for the home screen background. The sample branding file
provided in the otmmux.war/ux-html/branding/dev-test/dev-branding.
less provides a color a gradient color.
Example 16-2, “Set a background image” shows you how to change the background
image, where an image called background.jpg is in the same directory as
branding.html.
Note: You can also add a background color as a backup. For example:
.set-homescreen-background(url('./background.jpg'), #000000);
Example 16-3, “Set a background image for devices” shows you how to set a
background image using an image for tablets, phones, or both. This image is called
mybackground.jpg and is located in the same directory as the branding.html file.
Phones
.ot-phone-ui { set-homescreen-background(url('./mybackground.jpg'), 250px,
24px);}
Tablets
.ot-tablet-ui { set-homescreen-background(url('./mybackground.jpg'), 250px, 24px);}
Example 16-4, “Set a background color” shows you how to change the background
color.
Example 16-5, “Set a background color for devices” shows you how to set the
background color for tablets, phones, or both.
Phones
.ot-phone-ui { set-homescreen-background(none, #000000), 250px, 24px);}
Tablets
.ot-tablet-ui { set-homescreen-background(none, #000000), 250px, 24px);}
Note: For the home screen background image, OpenText recommends using a
size of 1920 x 1080 pixels. Avoid using an image file that is over 500KB; images
larger than this will take up a lot of resources when the screen loads
To change the logo image in the UI, use the .set-logo() branding helper function.
You must pass this function to a relative URL for the logo image that you want to
use, as well as its dimensions in pixels:.set-logo(image, width, height).
Note: If you do not specify dimensions for the image, OTMM will set the
width and height as 322 by 32 pixels respectively. The dimensions apply to all
devices. However, you can override the logo and dimensions for either tablets
or phones, or both.
Example 16-6, “Set the logo” shows you how to set the logo image.
where
400px is the width, in pixels, that you want to use for the logo.
40px is the height, in pixels, that you want to use for the logo.
Example 16-7, “Set the logo for devices” shows you how to override the logo image
for phones, tablets or both.
Phones
.ot-phone-ui { .set-logo(url('./logo_phone.png'), 250px, 24px);}
Tablets
.ot-tablet-ui { .set-logo(url('./logo_tablet.png'), 250px, 24px);}
To change the entire color scheme of the application, use the brand function set-
color. This function requires at least one argument, which is the main color of the
UI. You can also pass a second argument, which will be the accent color of the UI.
You can pass this color as any valid CSS color, such as named colors, HEX, RGBA or
HSLA. For more information, see https://www.w3schools.com/cssref/
pr_background-color.asp. Some accent colors may not contrast well with the entire
color scheme; use your discretion when choosing the accent color.
Notes
• The accent color is applied to the header text and the accordion tabs on the
sidebar.
• OTMM tests the contrast of text in some areas of the UI and icons on the
accordion tabs in the sidebar against the color scheme. Depending on the
OTMM color scheme being used, OTMM applies white or black to the text
and icons, whichever color creates the most contrast.
• Dimmed (gray) colors that represent options that are unavailable colors in the
application remain unchangeable.
• The background color used for views (such as Gallery and Spreadsheet) in the
Web Client UI will remain white.
Note: To the change background color of various areas in the UI, such as
the Gallery view, you can follow the standard procedures to customize
advanced brands.
• Changing the icon color is not currently supported.
If the main brand color is a shade of teal, specifically, HEX color #008C82, then
Example 16-8, “Set the color scheme to teal” will recolor the UI using that shade of
teal.
.set-color(#008C82);
Example 16-9, “Set the color scheme to teal for devices” shows you how to recolor
the UI the same way as Example 16-8, “Set the color scheme to teal” for phones,
tablets or both.
Phones
.ot-phone-ui { .set-color(#008C82);}
Tablets
.ot-tablet-ui { .set-color(#008C82);}
If the main brand colors are red and yellow, specifically hex #DD1021 for red and
hex #FFCC00 for yellow, then Example 16-10, “Set the color scheme to teal red and
yellow” will recolor the UI primarily around the red, using the yellow for accents:
Example 16-10: Set the color scheme to teal red and yellow
@import (reference) "../brand-functions.less";
.set-color(#DD1021, #FFCC00);
Example 16-11, “Set the color scheme to teal red and yellow for devices” shows you
how to recolor the UI the same way as Example 16-10, “Set the color scheme to teal
red and yellow” for phones, tablets or both.
Example 16-11: Set the color scheme to teal red and yellow for devices
Phones
.ot-phone-ui { .set-color(#DD1021, #FFCC00);}
Tablets
.ot-tablet-ui { .set-color(#DD1021, #FFCC00);}
Note: This function accepts any valid W3Schools color combinations or image.
For more information, see https://www.w3schools.com/cssref/
css3_pr_background.asp.
Example 16-12, “Set the header background to a linear gradient” shows how to set
the header background to a linear gradient with shades of Gainsboro and Pioneer
Red.
Example 16-13, “Set the header background to a linear gradient for devices” shows
how to set the header background to a linear gradient for phones, tablets or both.
Example 16-13: Set the header background to a linear gradient for devices
Phones
.ot-phone-ui { .set-header-background(linear-gradient(61deg, #B1343A 0%, #E2E2E2
59%, #B1343A 100%));}
Tablets
.ot-tablet-ui { .set-header-background(linear-gradient(61deg, #B1343A 0%,
#E2E2E2 59%, #B1343A 100%));}
Example 16-14, “Set the header background to an image” shows how to set the
header background to an image.
Example 16-15, “Set the header background to an image for devices” shows how to
set the header background to an image for phones, tablets or both.
Phones
.ot-phone-ui { .set-header-background(url('./myheader.jpg'));}
Tablets
.ot-tablet-ui { .set-header-background(url('./myheader.jpg'));}
A theme is automatically applied to all user groups. To create a theme, you need to
create a LESS file and reference it in the include.html file.
Tip: You can also add branding helpers in a theme to simplify process of
styling the application. To use branding helpers, you need to add them to the
LESS file that you create in your development directory. For more information
branding helpers, see “Use branding helpers” on page 111.
3. Find the style that you would like to modify in the UI and right-click it. Select
Inspect Element.
4. In the development tools that appear, the element you right-clicked will be
selected and there will be a description of the CSS styles/rules used for that
element, usually on the right-hand side of the tools area. Find the appropriate
CSS and copy the following two items into your LESS file:
6. Refresh the page if the styles do not automatically update after a few seconds.
.ot-folder-icon-close {
margin-left: 0.5rem;
margin-right: 0.5rem;
width: 16px;
height: 2.4rem;
display: inline-block;
cursor: pointer;
background-image: url('../../style/img/folder16.png');
background-repeat: no-repeat;
background-position: center center;
}
The copied and modified CSS rule you would place in your LESS file would look
like this:
.ot-folder-icon-close {
background-image: url('./img/new-folder-img.png');
}
When replacing icons or images, ensure that the replacements meet the following
criteria:
• Borders
• Fonts
• Text alignment
• Height/width of elements
• Paddings/margins on elements
For more information about performing more advanced display alterations, see
“Templates“ on page 43.
To override the color variables, create a LESS file in your integration development
folder and name it variables.less. Then, copy and change the variables from the
original variables.less in the same way as you would copy and change normal
CSS styles, including referencing the LESS file in the include.html file.
You can specify any valid CSS color when you are changing the color variables. For
more information, see:
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
In the original variables.less, the border color for active (focused) text
inputs, which is traditionally green, is written as:
@input_border_focus: #8dc63f;
To change this color to purple, copy the variable into your variables.less
file, and then modify the color as follows:
@input_border_focus: #CC99CC;
HTML5 UI examples
These examples use the pre-defined formatting, templates, and functions defined in
the OTMM UI. For more examples of defining and customizing views, see the demo
views provided in the demo/cs-examples folder.
Caution
To avoid conflicts with the OTMM namespaces and pre-defined
templates and functions, use the cs (customer specific) prefix when
naming files and defining functions.
}, true);
})(window);
3. Add an include.html file to the cs_alert folder. OTMM scans for files named
include.html in the top-level folder. This is the page that is ingested,
interpreted and displayed in the OTMM UI. Add the following lines to the
include.html page:
<script type=”text/javascript” src=”./cs_alert.js”></script>
<script>otui.Templates.load()</script>
5. To add an alert action to the menu item so that a message window pops up
when the button is clicked, add a function to the select menu property,
replacing the null. The otui.tr function is used to define the popup alert
message (for a description of otui.tr usage, see “Basic usage” on page 52).
b. Map the new function to the menu select property by changing the select
setting in the outui.ready function:
'select' : showAlert
Layout templates
These define the overall page layout. For example, plain (“main”), with frame to
the left (“main-with-sidebar”), or with action buttons at the top of the page
(“main-with-actionbar”).
Content templates
These define the content for the specific layout. Content templates have ot-
template and ot-view attributes.
Resource templates
These serve as the template for an individual resource. If, for example, the
resource is an OTMM asset, and there are twenty assets in the content set, then
the resource template will be applied twenty times. Examples of resource
templates are “masonry-cell” (asset per block) and “table-cell”(asset per row).
1. Create a new cs_recent project folder in the ux-html folder. The OTMM
HTML5 UI framework monitors the top-level folder for new applications.
Caution
To avoid conflicts with the OTMM namespaces and pre-defined
templates and functions, use the ‘cs’ (customer specific) prefix when
naming files and defining functions.
2. Add a new JavaScript file to the cs_recent folder called cs_recent.js with
the following contents:
(function(exports) {
// Custom View Example
var csRecentView = exports.csRecentView =
otui.define("csRecentView", function() {
this.properties = {
'name' : 'csrecent', // Name of the view
};
}); // END: csRecentView definition block
3. Add an include.html file to the cs_recent folder. OTMM scans for files
named include.html in the top-level folder. This is the page that is ingested,
interpreted and displayed in the OTMM UI. Add the following lines to the
include.html page:
<script type=”text/javascript” src=”./cs_recent.js”></script>
<script>otui.Templates.load()</script>
5. Optional Set up a Chrome Workspace so you can edit, test, and debug from a
single window. Setting up a Chrome Workspace simplifies the edit and debug
cycle for creating a new view. For more information, see “Set up Chrome
workspaces” on page 18.
• The Sources tab will give you access to viewing and editing the source code.
• The Network tab will show you network activity to the OTMM services,
including the REST API requests and responses. The REST API calls are of
the form: /otmmapi/v1/…
To view the details of a REST API call, click on that row and then select from
the tabs in the right-hand pane: Headers, Preview, Response.
• Click on the Folders menu item, navigate through the folders, and view the
assets to see the network activity.
6. Define the content template. The template in the include.html file defines
what the content of the page will be. To start, add a header and banner to the
template. Add the ot-view attribute, which assigns the csRecentView, defined
in the cs_recent.js javascript file, to the content template, as follows:
<template ot-template id="content" ot-view="csRecentView">
<div class="ot-content">
<ot-i18n class="ot-view-header-title">
Recently Viewed Assets
</ot-i18n>
<ot-i18n> Assets will be displayed here </ot-i18n>
</div>
</template>
This example will use the “main” layout template, which displays the contents
in full-page mode without a sidebar or action bar.
• The code for this step is located outside the csRecentView block and before
the otui.ready() call.
For more information about defining a “route”, see the online documentation
http://<otmmhost>:11090/otmm/ux-html/doc/Views.asViewModule.
route.html.
9. Define the “open” route to use the new csOpenView route definition, as follows:
// (after the csOpenView definition)
// Bind that route URL into the named route "open".
csRecentView.route.define("open", csOpenView);
10. Update the menu item to “open” the view by modifying the otui.Menus.
register block and setting the select property to use the new routing URL:
The content takes up the whole page (“main” layout template) and the content
defined in the include.html template block is displayed in the content area.
1. To determine which REST API call will provide the required functionality,
investigate the Swagger™ UI documentation:
http://<otmmhost>:11090/swagger-ui
Note: Be patient as it will take some time for the documentation home
page to display.
For the purposes of this example, the assets GET API will allow us to request
the most recently used assets. Scroll down the page to the Parameters section.
We are going to specify the following two input parameters to the method:
limit
The maximum number of assets we want returned.
selection_context
Define the properties to guide the selection of assets returned.
2. Define and register the service that will retrieve the assets. In the cs_request.
js JavaScript file, define a new service that will retrieve the assets from the
OTMM server.
callback(assets, true);
}
}); // END: otui.get()
3. Specify the selection context property. The /assets REST API requires a selection
context parameter as input. The selection context defines how assets are selected
from OTMM. In the csRecentView definition block, define a new function to
setup the selection context property. For more information about the selection
context, see the online Swagger documentation.
a. Type = ‘FolderSelectionContext’
b. Folder_id = ARTESIA.PUBLIC.TREEN
Select assets from the top-level public folder.
c. Include_descendants = ALL
d. Child_type = ASSETS
Only include asset types. Do not display folders.
e. Exclusion_asset_id_list = []
The empty list. Do not exclude any assets.
f. Define the createSelectionContext function inside the csRecentView
block.
// Internal function to generate selection context parameter.
function createSelectionContext()
{
var selectionContext = {
‘type’ : ‘com.artesia.asset.selection.FolderSelectionContext’,
‘folder_id’ : ‘ARTESIA.PUBLIC.TREEN’,
‘include_descendants’ : ‘ALL’,
‘child_type’ : ‘ASSETS’,
‘exclusion_asset_id_list’ : []
};
• title
• service
• serviceData
• sourceName
• templateName
• no-results-msg
this.idProperty = 'assetID';
// _initContent() function….
// createSelectionContext function HERE ….
Note: Using the inherited _initContents() function will cause the page
to be populated using the registered cs-recent-svc service.
6. Map the selection context to the new serviceDataMap property. Instantiate the
selection context by calling the new createSelectionContext function. Then
map this selection context to its serviceDataMap so that it will be seen by the
cs-recent-svc as input. This mapping occurs inside the csRecentView
definition block after the function definition.
// createSelectionContext function HERE…
// DataMap is required by ResultsView to build the data object
this.serviceDataMap = {
‘selection’ : ‘selectionContext’
};
1. Define the asset action routes. The "open” route is defined for the
csRecentView. To enable the asset inspection view (open-contents) and edit
properties actions, use the routes already defined for the InspectorView. Add
the following route definitions for the csRecentView in the cs_recent.js
JavaScript file:
• csRecentView.route.define("open-contents", InspectorView.route.
use("open"));
• csRecentView.route.define("edit-contents", InspectorEditView.
route.use("open"));
For more information about the Detail view, see the online documentation
http://<otmmhost>:11090/otmm/ux-html/doc/InspectorView.html.
2. Refresh the browser page and verify that the Edit Properties asset action is
functional. Verify that when an asset is clicked, the Detail view is opened for
that asset.
3. Display the asset action bar. To display the action bar, you must update the
layout template to provide a space for the action buttons. Edit the cs_recent.
js JavaScript file and change the template in the csOpenView function from
main to main-with-actionbar. This will include a space at the top of the page
for asset action buttons.
4. Update the template, include.html, to define the action bar. Add a new ot-
layout section specifying the GalleryViewActions to be used in the action bar.
<div class="ot-content">
<ot-i18n class="ot-view-header-title">
Recently Viewed Assets
</ot-i18n>
<ot-layout class="ot-folder-asset-actions-holder"
ot-platform="desktop">
<ot-point ot-lookup="GalleryViewActions"
class="ot-folder-asset-actions" ot-layout-fill-width>
</ot-point>
</ot-layout>
<div class="ot-results-wrapper">
<div class="ot-results"></div>
</div>
</div>
5. Refresh the browser and verify that there are now action buttons at the top of
the recently viewed assets page.
6. Select the check box in the upper-left corner of an asset and verify that the
buttons at the top of the page become active.
17.2.3 csRecentView
Here are the final copies of the JavaScript view and HTML template.
Include.html
<script type="text/javascript" src="./cs_recent.js"></script>
<script>otui.Templates.load()</script>
Cs_recent.js
(function(exports) {
// Custom View Example
var csRecentView = exports.csRecentView =
otui.extend("ResultsView","csRecentView", function() {
this.properties = {
'selection_context' : null,
'service' : 'cs-recent-svc',
'serviceData' : {},
'sourceName' : 'csrecent',
'templateName' : 'masonry-cell',
'minCellWidth' : 320,
'no-results-msg' : otui.tr("No Assets Found")
};
{'selection_context' : selectionContext}};
};
this.idProperty = 'assetID';
// Data map is required by results view to build data object
this.serviceDataMap = { 'selection' : 'selectionContext' }
;
// Then bind that route URL into the named route "open".
csRecentView.route.define("open", csOpenView);
csRecentView.route.define("open-contents",
InspectorView.route.use("open"));
csRecentView.route.define("edit-contents",
InspectorEditView.route.use("open"));
callback(assets, true);
}
});
}
}); // END: service definition/registration
Example 17-1: Multiple asset menu entry JavaScript code for launching a
custom job
(function(otui) {
function launchCustomJob(event) {
var view = otui.Views.containing(this); // Get the view for this entry.
// The user may have chosen "select all", which means the UI needs to ask the
server for the full list of asset IDs.
view.getSelectedAssets(function(assets) // Only give us the asset IDs
{
var jobName = "CustomNotification"; // This is the user defined name for
the job
var jobType = "CustomNotification"; // This is the configured job type in
the system
console.log("Assets selected:", assets);
if(assets !== undefined && assets.length > 0)
{
var assetsToPass = "";
for(var i = 0;i < assets.length;i++)
{
if(i !== 0)
assetsToPass = assetsToPass + ',';
assetsToPass = assetsToPass + '"' + assets[i] + '"';
}
var serviceUrl = otui.service + "/jobs";
var jobRequestParam = '{"job_request_param":{"job_request":
{"asset_ids":[' + assetsToPass + '],
"job_name":"'+ jobName + '", "job_type":"'+ jobType + '"}}}';
var data = "job_request=" + jobRequestParam;
otui.post(serviceUrl, data, otui.contentTypes.formData,
function(response)
{
otui.NotificationManager.showNotification(successNotification);
} else {
var errorMsg = otui.tr("{0} launch has failed.", jobName);
var errorNotification = {'message' :
errorMsg, 'stayOpen': true, 'status' : 'error' };
otui.NotificationManager.showNotification(errorNotification);
}
});
}
});
};
otui.ready(function() {
// Create definition of the menu entry.
var entry = {
'name' : 'launchcustomjob',
'text' : 'Launch custom job',
'select' : launchCustomJob
};
// Then add it to all the locations available. Adding here only for Gallery
View
otui.GalleryViewActions.register(entry);
});
})(otui);
2. Create a CSS file and name it cs_footer.css, and add it to the <TEAMS_HOME>/
ear/artesia.ear/otmmux.war/ux-html/cs_footer folder.
ot-web-footer .ot-web-footer-bar
{
height: <specify required height for the footer>
}
Callback function
A function in JavaScript which expects to be called with data at a later point in
time. It is usually passed into an asynchronous function.
JSON
JavaScript Object Notation. A lightweight, serializable format for storing
properties which is used throughout JavaScript. For more information, see http://
en.wikipedia.org/wiki/JSON.
REST API
The REST API for OTMM is a server component of OTMM which allows for
stateless requests to be made and to send data back in a consistent JSON format.
Settings page
System settings and preferences are stored in a database. You can access these
settings through the Settings page in the Web Administration tool. For more
information, see section 23.1 “Manage configuration groups, components, and
properties” in OpenText Media Management - Administration Guide
(MEDMGT220200-AGD).
TResource
A resource file used by OTMM to store node-specific settings. This file is located
in the <TEAMS_HOME>/data/cs/global directory of each installation.