Dashboard SDK
The Dashboard SDK is a JavaScript library which provides communication between the app hosted within the Dashboard's iframe with the hosting Dashboard. It allows to manage assets, themes, fetch various configurations and present standardized User Interface components.
Development tips
The app using Dashboard SDK has to be run inside of the Dashboard's iframe to function properly as the SDK serves as a transport channel of the messages only. All commands are actually executed by the hosting Dashboard. This means that running your app outside of the Dashboard will not work. To run your app inside of the Dashboard, you need to add it to the system. See Creating an App.
#
Installing the Dashboard SDKInclude the Dashboard SDK script in your app, by adding the following code to the <head>
section of your app's HTML file:
<script type="text/javascript" src="https://apps.enplug.com/sdk/v1/dashboard.js"></script>
This will create a global enplug
/window.enplug
object which gives you the access to the methods provided by the Dashboard.
#
Type supportIf you use TypeScript and would like to have the typings checked in your IDE you can load the following NPM package:
npm install @enplug/sdk-dashboard --save-dev
Then, add "@enplug/sdk-dashboard"
to the types
array in your TypeScript config file. Make sure that typeRoots
array has the "node_modules"
entry, so that the whole path is available to the compiler.
#
UsageAfter the Dashboard SDK script gets loaded into your app, it will instantly create a global enplug
/window.enplug
object which gives you the access to the methods provided by the Dashboard.
See more: enplug
#
Useful APIs#
Account APIUse enplug.account
to manipulate assets, access account and configuration related commands.
#
Assetsenplug.account.getAssets()
- fetch the asset listenplug.account.getAssetsByIds()
- fetch provided assetsenplug.account.saveAsset()
- creates/updates an asset, can display Deploy Dialog for editingenplug.account.deleteAsset()
- removes an assetenplug.account.touchAsset()
- marks asset as recently viewed
#
Othersenplug.account.getAccount()
- fetch current account dataenplug.account.getUser()
- fetch current user dataenplug.account.getThemes()
- fetches list of themesenplug.account.getTheme()
- fetches themeenplug.account.editTheme()
- edits the themeenplug.account.deleteTheme()
- deletes the theme
See more: enplug.account
#
Dashboard APIUse enplug.dashboard
to use standardized User Interface components and actions.
#
Header sectionenplug.dashboard.setHeaderTitle()
- sets header titleenplug.dashboard.setHeaderButtons()
- sets header buttonsenplug.dashboard.setDisplaySelectorCallback()
- sets Display Group selector callbackenplug.dashboard.setDisplaySelectorVisibility()
- sets Display Group selector visibility
#
Progress indicatorenplug.dashboard.pageLoading()
- sets the app's loader visibilityenplug.dashboard.loadingIndicator()
- shows Loading indicatorenplug.dashboard.successIndicator()
- shows Success indicatorenplug.dashboard.errorIndicator()
- shows Error indicator
#
Dialogsenplug.dashboard.previewAsset()
- shows asset previewenplug.dashboard.upload()
- shows upload dialogenplug.dashboard.openConfirm()
- shows custom confirmation dialogenplug.dashboard.confirmUnsavedChanges()
- shows unsaved changes dialogenplug.dashboard.setAppHasUnsavedChanges()
- sets dashboard's navigation guard
See more: enplug.dashboard