System

system. System

new System()

Source:

Represents the system that can be interacted with. There is a single instance of this pre-defined onto the d2 object after initialisation. This can be interacted with using its property objects to among other be used to get and save systemSettings.

Members

configuration :SystemConfiguration

Source:

A representation of the system configuration, that can be used to retrieve and change system configuration options.

Type:
  • SystemConfiguration

installedApps :Array

Source:

An array of all the webapps that are installed on the current DHIS2 instance

Type:
  • Array

settings :SystemSettings

Source:

Contains a reference to a SystemSettings instance that can be used to retrieve and save system settings.

d2.system.settings.get('keyLastSuccessfulResourceTablesUpdate')
 .then(systemSettingsValue => {
   console.log('Analytics was last updated on: ' + systemSettingsValue);
 });
Type:
  • SystemSettings

systemInfo :Object

Source:

An object containing system information about the DHIS2 instance

Type:
  • Object

version :Object

Source:

An object containing version information about the DHIS2 instance

Type:
  • Object

Methods

(static) compareVersions(a, b) → {number}

Source:

Compares version a to version b.

Parameters:
Name Type Description
a string | module:system.ParsedVersion
b string | module:system.ParsedVersion
Returns:

0 if same version, else a - b.

Type
number

(static) getSystem() → {System}

Source:

Get a new instance of the system object. This will function as a singleton, when a System object has been created when requesting getSystem again the original version will be returned.

Returns:

Object with the system interaction properties

Type
System

(static) isVersionCompatible(systemVersion, appVersion) → {boolean}

Source:

Checks if systemVersion is compatible with appVersion. Versions are compatible if appVersion.minDhisVersion <= parsed systemVersion and if appVersion.maxDhisVersion >= parsed systemVersion.

Parameters:
Name Type Description
systemVersion string | module:system.ParsedVersion

systemVersion to check

appVersion Object

AppVersion object to check

Returns:

true if compatible, false otherwise.

Type
boolean

(static) parseVersionString(version) → {module:system.ParsedVersion}

Source:

Parses a version string into an object describing the version.

Parameters:
Name Type Description
version string

Version-string to parse

Returns:
Type
module:system.ParsedVersion

installAppVersion(uid) → {Promise}

Source:

Install the specified app version from the DHIS 2 app store

Parameters:
Name Type Description
uid

The uid of the app version to install

Returns:
Type
Promise

loadAppStore(compatibleOnly) → {Promise}

Source:

Load the list of apps available in the DHIS 2 app store

Parameters:
Name Type Default Description
compatibleOnly true

If true, apps that are incompatible with the current system will be filtered out

Returns:
Type
Promise

loadInstalledApps() → {Promise}

Source:

Refreshes the list of currently installed webapps

Returns:

A promise that resolves to the list of installed apps

Type
Promise

reloadApps() → {Promise}

Source:

Refresh the list of apps that are installed on the server

Returns:

A promise that resolves to the updated list of installed apps

Type
Promise

setInstalledApps(apps)

Source:

Sets the list of currently installed webapps

Parameters:
Name Type Description
apps

setSystemInfo(systemInfo)

Source:

Sets the systemInfo and version properties

Parameters:
Name Type Description
systemInfo

uninstallApp(appKey) → {Promise}

Source:

Remove the specified app from the system

Parameters:
Name Type Description
appKey

The key of the app to remove

Returns:
Type
Promise

uploadApp(zipFile, onProgress) → {Promise}

Source:

Upload and install a zip file containing a new webapp

Parameters:
Name Type Description
zipFile

Zip file data from a file input form field

onProgress

An optional callback that will be called whenever file upload progress info is available

Returns:
Type
Promise