Layouts
5.21.0The Layouts API allows you to save the arrangement and context of any set of applications running in Glue42 Enterprise as a named Layout and later restore it. You can also choose a default Global Layout which Glue42 Enterprise will load upon startup.
The Layouts library supports different types of Layouts - e.g., Global, Application Default, Workspace.
The Layouts API is accessible through the glue.layouts
object.
APIobject
Description
Layouts API.
Methods
clearDefaultGlobalmethod
Signature
() => Promise<void>
Description
Clears the default global layout
exportmethod
Signature
(layoutType?: LayoutType) => Promise<Layout[]>
Description
Returns all layouts in the system.
Parameters
Name | Type | Required | Description |
---|---|---|---|
layoutType | LayoutType |
getmethod
Signature
(name: string, type: LayoutType) => Promise<Layout>
Description
Fetches a saved layout or returns undefined if a layout with the provided name and type does not exist.
Parameters
Name | Type | Required | Description |
---|---|---|---|
name | string | Name of the layout to fetch. |
|
type | LayoutType | Type of the layout to fetch. |
getAllmethod
Signature
(type: LayoutType) => Promise<LayoutSummary[]>
Description
Returns a lightweight, summarized version of all layouts of the provided type.
Parameters
Name | Type | Required | Description |
---|---|---|---|
type | LayoutType | Type of the layouts to fetch. |
getCurrentLayoutmethod
getDefaultGlobalmethod
hibernatemethod
Signature
(name: string, options?: HibernationOptions) => Promise<HibernateResult>
Description
Hibernates a layout.
Available since version 4.8 and Glue42 3.9
Parameters
Name | Type | Required | Description |
---|---|---|---|
name | string | The name of the layout |
|
options | HibernationOptions | Options for hibernating a layout. |
importmethod
Signature
(layouts: Layout[], mode?: "replace" | "merge") => Promise<ImportLayoutResult>
Description
Imports one or more layouts.
Parameters
Name | Type | Required | Description |
---|---|---|---|
layouts | Layout[] | Layouts to import. |
|
mode | "replace" | "merge" | Mode for importing the layouts - |
listmethod
onAddedmethod
onChangedmethod
onRemovedmethod
onRenamedmethod
onRestoredmethod
onSaveRequestedmethod
Signature
(callback: (info?: SaveRequestContext) => SaveRequestResponse) => () => void
Description
Subscribes for layout save requests.
Parameters
Name | Type | Required | Description |
---|---|---|---|
callback | (info?: SaveRequestContext) => SaveRequestResponse | The callback passed as an argument will be invoked when a layout save is requested. You have the option to save data (context) which will be restored when the layout is restored. Returns an unsubscribe function. |
removemethod
Signature
(type: string, name: string) => Promise<void>
Description
Removes a layout
Parameters
Name | Type | Required | Description |
---|---|---|---|
type | string | Type of the layout to remove. |
|
name | string | Name of the layout to remove. |
renamemethod
Signature
(layout: Layout, newName: string) => Promise<LayoutResult>
Description
Renames a layout.
Parameters
Name | Type | Required | Description |
---|---|---|---|
layout | Layout | Existing layout to rename. |
|
newName | string | The new name of the layout. |
restoremethod
Signature
(options: RestoreOptions) => Promise<void>
Description
Restores a layout.
Parameters
Name | Type | Required | Description |
---|---|---|---|
options | RestoreOptions | Options for restoring a layout. |
resumemethod
Signature
(name: string, context?: any, options?: ResumeOptions) => Promise<ResumeResult>
Description
Resumes a layout.
Available since version 4.8 and Glue42 3.9
Parameters
Name | Type | Required | Description |
---|---|---|---|
name | string | The name of the layout. |
|
context | any | The context of the layout |
|
options | ResumeOptions |
savemethod
Signature
(layout: NewLayoutOptions) => Promise<Layout>
Description
Saves a new layout.
Parameters
Name | Type | Required | Description |
---|---|---|---|
layout | NewLayoutOptions | Options for saving a layout. |
setDefaultGlobalmethod
Signature
(name: string) => Promise<void>
Description
Sets a new default global layout
Parameters
Name | Type | Required | Description |
---|---|---|---|
name | string |
updateAppContextInCurrentmethod
Signature
(context: object) => Promise<void>
Description
Updates the context saved for your application in the currently loaded layout
Parameters
Name | Type | Required | Description |
---|---|---|---|
context | object | the new context |
updateDefaultContextmethod
Signature
(context: object) => Promise<LayoutResult>
Description
Updates the context that will be saved as a default context for the current window.
Available since version Glue42 3.10
Parameters
Name | Type | Required | Description |
---|---|---|---|
context | object | New context that will be saved as a default window context. |
Configurationobject
Description
Layouts library configuration object.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
autoSaveWindowContext | boolean | LayoutType[] | false | If |
|
mode | Mode | Layouts mode. |
HibernateResultobject
Description
Describes the shape of the result returned when hibernating a Layout.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
layout | Layout | Hibernated layout. |
||
status | string | Status of the Layout operation. If successful, will be set to |
HibernationOptionsobject
Description
Options object for hibernating layouts.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
context | object | Context object that will be passed to the restored apps. It will be merged with the saved context object. |
||
metadata | any | Metadata to be saved with the layout. |
ImportLayoutResultobject
Description
Describes the shape of the result returned when importing Layouts.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
failed | { name: string; type: LayoutType; }[] | Array of objects describing all Layouts that failed to import. Each object contains the name and the type of the Layout. |
||
status | string | Status of the Layout operation. If successful, will be set to |
Layoutobject
Description
Describes a layout and its state.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
components | LayoutComponent[] | Array of component objects describing the applications that are saved in the layout. |
||
context | any | Context object passed when the layout was saved. |
||
metadata | any | Metadata passed when the layout was saved. |
||
name | string | Name of the layout. The name is unique per layout type. |
||
type | LayoutType | Type of the layout. |
||
version | number | Version of the layout |
LayoutComponentobject
Description
Saved component (single window application or activity) with its state (bounds, context).
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
componentType | ComponentType | Type of the component - can be application or activity. |
||
state | any | Object describing the application bounds, name, context, etc. |
||
type | string |
LayoutResultobject
Description
Describes the shape of the base result returned by methods for manipulating Layouts - e.g., renaming, hibernating, updating default context.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
status | string | Status of the Layout operation. If successful, will be set to |
LayoutSummaryobject
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
context | any | Context object passed when the layout was saved. |
||
metadata | any | Metadata passed when the layout was saved. |
||
name | string | Name of the layout. The name is unique per layout type. |
||
type | LayoutType | Type of the layout. |
NewLayoutOptionsobject
Description
Object describing the layout that you want to save.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
activityId | string | Only if the layout type is |
||
context | any | Context (application specific data) to be saved with the layout. Used to transfer data to the applications when restoring a layout. |
||
ignoreInstances | string[] | Only if the layout type is |
||
instances | string[] | Only if the layout type is |
||
metadata | any | Metadata to be saved with the layout. |
||
name | string | Name of the layout. |
||
type | LayoutType | "Global" | Type of the layout. |
RestoreOptionsobject
Description
Options object for restoring layouts.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
activityIdToJoin | string | Only if the type is |
||
closeMe | boolean | true | If |
|
closeRunningInstance | boolean | Deprecated. Use |
||
closeRunningInstances | boolean | Only if the type is |
||
context | unknown | Context object that will be passed to the restored apps. It will be merged with the saved context object. |
||
ignoreActivityWindowTypes | string[] | Only if the type is |
||
name | string | Name of the layout to restore. |
||
reuseWindows | boolean | Only if the type is |
||
setActivityContext | boolean | Only if the type is |
||
timeout | number | Restore timeout option. |
||
type | string | "Global" | Type of the layout to restore. |
RestoreSplashOptionsobject
Description
Options for the restore splash screen.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
animationColor | string | Animation color. |
||
backgroundColor | string | Background color. |
||
text | string | Text for the splash screen. |
||
textColor | string | Text color. |
ResumeOptionsobject
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
cleanUp | boolean | Whether to stop any already running apps before resuming the layout. |
ResumeResultobject
Description
Describes the shape of the result returned when resuming a Layout.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
instances | { instanceId: string; appName: string; }[] | Array of objects describing all resumed app instances participating in the Layout. Each object contains the instance ID and the app name of the resumed app instance. |
||
status | string | Status of the Layout operation. If successful, will be set to |
SaveRequestContextobject
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
context | unknown | |||
layoutName | string | |||
layoutType | LayoutType |
SaveRequestResponseobject
Description
Object returned as a result to a save layout request.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
activityContext | object | The window can return activity context if it is an owner window of the activity. On restore, this context will be merged with the activity context passed when restoring the layout. |
||
windowContext | object | Context object specific to the application. |
ComponentTypeenumeration
Description
Type of the layout component - activity or application.
- "activity"
- "application"
ImportModeenumeration
Description
Controls the import behavior. If replace
(default), all existing layouts will be removed.
If merge
, the layouts will be added to the existing ones.
- "replace"
- "merge"
LayoutTypeenumeration
Description
The supported Layout types are "Global"
, "ApplicationDefault"
and "Workspace"
.
The "Activity"
and "Swimlane"
types are legacy Layout types and shouldn't be used.
In a Global Layout, all running applications and their state is saved. By default, hidden windows are ignored.
The Application Default Layout describes the default Layout for an application instance - the last saved window bounds,
state and context. The Workspace Layout describes the arrangement of the Workspace elements, its bounds and individual window context.
- "Global"
- "Activity"
- "ApplicationDefault"
- "Swimlane"
- "Workspace"
Modeenumeration
Description
Library initialization mode:
slim
- in this mode the application will be able to store custom data when a layout is saved and will not track layout events. It will not be able to manage layouts - create, delete, rename.full
- in this mode the application will be able to store custom data when a layout is saved and will track layout events. It will be able to manage layouts - create, delete, rename.fullWaitSnapshot
- same asfull
, only the library will notify that it is ready when it receives the snapshot of the layouts. Infull
mode,ready()
is called when the library has successfully subscribed to a stream (a little earlier).
- "slim"
- "full"
- "fullWaitSnapshot"