Global ViewModel

The global ViewModel is available in many places throughout the application and can be used in XTemplates, among other places. It contains important information such as data on the user session, the global date range filter, the selected language, the active module, the user’s roles and permissions, and maintenance mode. This centrally managed data enables consistent and efficient handling of application-wide settings and user information

Structure of the ViewModel

Table 1. Attributes of the global ViewModel
Name Description

activeModule

Contains information about the currently active module, including ID, name, etc.

dateRange

Defines the global date range for data filtering with properties such as value, global mode, and activity status.

language

Stores the currently selected user interface language (e.g., "de" for German).

license

Contains information on various licensing aspects of the application, modules, and services.

maintenanceModeEnabled

A Boolean value indicating whether the application is in maintenance mode.

monitor

Configuration settings for the monitor module.

right

Defines the user’s access rights to various modules and functions.

role

Contains the roles assigned to the user (e.g., administrator, regular user).

status

The status attribute includes various sub-attributes that provide information about the current state of the application, including the CRUD state, active user sessions, and license details. These attributes help monitor the system status and identify issues to ensure smooth functionality.

userSession

Stores information about the current user session, such as login credentials and session duration.

uuid

A unique identification number for the current instance or session.

This overview represents the main components of the global ViewModel; however, depending on the configuration, application context, and specific implementations, additional attributes and data structures may be present.

Access via the browser console

To view the current contents of the global ViewModel, you can perform the following steps in the browser console:

  1. Open your browser’s developer tools (F12 in most browsers)

  2. Switch to the console

  3. Enter the following command:

    BpcCommon.Api.getGlobalViewModel().get("global")

This displays the current state of the global ViewModel.

Usage in XTemplates

When using XTemplates, you can access the global ViewModel.

Example:

new Ext.XTemplate(
  '<p>Aktueller Benutzer: {global.userSession.firstName} {global.userSession.lastName} </p>'
)