Front End Public API
Overview
For the deep integration with the UUX, it is possible to use a Public Module inside custom Frontend Workspaces. It is highly recommended not to use services and methods not from a Public Module because they can have breaking changes.
To use it, inject public service 'mx.sb.public.service' into your component controller (or service):
class CustomComponentCtrl {
static $inject = ['mx.sb.public.service'];
constructor(publicService) {
this.publicService = publicService;
}
public getCurrentApplication() {
return this.publicService.getCurrentApplication();
}
}
There are next methods available in this service:
| Function | Arguments | Description |
|---|---|---|
|
getCurrentApplication() |
|
Async function which returns the current application in format
type MxApplication = {
name: string;
title: string;
value: string;
icon?: string;
navigationItem?: string;
position?: number;
supportedRoutes?: string[];
showFavourites?: boolean;
showRecent?: boolean;
showOperationMonitor?: boolean;
url?: string;
helpValue?: string;
helpSourceType?: number;
unifiedSearchEnabled?: boolean;
unifiedSearchTitle1?: string;
unifiedSearchTitle2?: string;
unifiedSearchBackground?: string;
unifiedSearchTitleColorOverride?: string;
};
|
| getFullImageUrl(imageUrl, baseFolder) |
imageUrl: string, baseFolder?: string - optional |
Return the correct image URL for the server |
| getUserProfile() |
Async function which returns user profile data in format
type MxUserProfile = {
id: string;
firstName: string;
lastName: string;
accountName: string;
avatar: string;
email: string;
phone: string;
languageId: string;
isDevMode: boolean;
isCustomizationMode: boolean;
isAdmin: boolean;
objectId: string;
status: number;
profileDialogId: string;
};
|
|
|
navigate(navigationItemId) |
navigationItemId: string |
Navigates to the selected navigation item |
|
auth.onBeforeSessionDestroy(callback) |
callback: () => void | Promise<void> |
Register a callback which should be executed before logout. The callback can be async. Returns a function to unregister the callback. |
|
auth.onSessionExpired(callback) |
callback: () => void | Promise<void> |
Register a callback which should be executed before the authorization session expires. The callback can be async. Returns a function to unregister the callback. |
| data.getRelationItems(options) |
options: { dataQueryName: string; objectId?: string; fragmentId?: string; entityClassName?: string; allowedTypes?: string; relationName?: string; addedRelations?: string[]; removedRelations?: string[]; whereExpression?: string; filterId?: string; filterPath?: IFilterExpressionPath; filterParams?: IFilterStrictParam[]; additionalFilter?: string; filters?: string; pageSize?: number; pageNumber?: number; search?: string; orderBy?: string; columns?: string; archived: boolean; } |
|
| data.getFragmentDescriptors(options, searchText) |
options: { entityClass: string; filter?: string; filterId?: string; filterPath?: IFilterExpressionPath; filterParams?: IFilterStrictParam[]; top?: number; allowedTypes?: string; exclude?: string; ids?: string[]; objectId?: string; fragmentId?: string; parent?: string; rootElement?: string; includeRoot?: boolean; relationName?: string; useObjectId?: boolean; displayExpression?: string; notStrictAutocomplete?: boolean; archived?: boolean; }, searchText?: string |
|
| event.subscribe(eventCode, handler, scope, destroyHandler) |
eventCode: string, handler: () => void, scope: IScope, - angular scope of the component where subscribe is used destroyHandler?: () => void - execute when the component is destroyed |
Subscribe to an event. Should be used inside a component and not in a service. |
| event.subscribeGlobal(eventCode, handler) |
eventCode: string, handler: () => void |
Subscribe globally to an event. Should be used inside a service. |
| event.dispatch(eventCode, parameters) |
eventCode: string, parameters?: any |
Dispatch new event with optional parameters |
| http.get(url, queryParams, requestParams, skipNotification) |
url: string, queryParams - any object with query parameters, requestParams? - optional params for angular http service skipNotification? - skip notification on error |
Make http GET request |
|
http.post(url, data, requestParams, skipNotification),
http.put(url, data, requestParams, skipNotification)
http.remove(url, data, requestParams, skipNotification) |
url: string, data - any body, requestParams? - optional params for angular http service skipNotification? - skip notification on error
|
Make http POST/PUT/DELETE request. Returns a promise with the response data. |
| http.upload(url, file, requestParams, skipNotification) |
url: string, file- File object, requestParams? - optional params for angular http service skipNotification? - skip notification on error |
Upload a file |
| i18n.get(key) | key: string | Returns a localization string by key |
| i18n.getFormatted(key, param1, param2, ...) | key: string | Returns a localization string by key with parameters used in string pattern |
| i18n.getFormattedCurrency(currency, useSymbols, availableCurrencies) |
currency: { Value: number, CC: string } useSymbols: boolean availableCurrencies: array of currencies in format { code: string, symbol: string } |
Returns formatted currency value |
| config.get(key) | key: string | Returns a config value by key |
| sidePanel.getCurrentView() | Returns a current widget opened in Side Panel | |
| sidePanel.setCurrentView(view) | view: DetailsView | Show a widget on the Side Panel. Can be used a new one or already opened to switch to it. |
| sidePanel.closeCurrentView() | Close the widget which is currently opened in Side Panel | |
| sidePanel.closeView(view) | view: DetailsView | Close some widget which is opened in Side Panel (may be not current but hidden) |
| sidePanel.refreshView(view) | view: DetailsView | Refresh a selected view in Side Panel |
| sidePanel.getOpenedViews() |
|
Returns all opened views from Side Panel |
| sidePanel.openPreview(entityDetails) |
entityDetails: { _id: string; _type: string; - CI _name?: string; _state?: string; _displayName: string; _archived?: boolean; } |
Open a preview for the entity using ID and CI |
| sidePanel.openListPreview(options) |
options: { title: string, - title of the widget, entityClassName: string - DataDefinition, columnDefinition - name of DataQuery filterExpression, filterId, filterPath, filterParams, selectedItemIds: string[], excludedIDs?: string[], allowedTypes?: string, archived?: boolean, multiselection?: boolean, useObjectId?: boolean } |
Open a list of items using Data Definition and filter |
| notification.confirm() |
title: string, prompt?: string, okLabel?: string, cancelLabel?: string
|
Show confirmation notification. The function returns a promise, succeeded if clicked 'Ok' and rejected if clicked 'Cancel' |
| notification.alert() | ||
|
notification.info(message, title), notification.warning(message, title), notification.error(message, title), notification.success(message, title), |
message: string, title: string |
Show a notification in the left bottom corner |
| action.get(id) | id: string | Returns an action object by id |
| theme.getCurrent() |
Returns a promise resolved with an object of the current theme. type Theme = { isDarkTheme: boolean; - true if dark colors are the predominant colors in the current theme isContrastTheme?: boolean; - true if a high constrast mode is enabled [color-name]: string; - a collection of properties with all available colors of a theme (e.g. "content-text-color": #00aa11", "header-text-color": "#ffffff"). Each color is a separate property in a theme object } |