DashboardAPI.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Business Analytics (C) Copyright IBM Corp. 2018, 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define([], function () {
  9. /**
  10. * @interface DashboardAPI
  11. * @hideconstructor
  12. * @classdesc API class that is used to control a dashboard instance behaviour.
  13. */
  14. var DashboardAPI = function () {
  15. function DashboardAPI() {
  16. _classCallCheck(this, DashboardAPI);
  17. }
  18. /**
  19. * @description Change the dashboard mode between <tt>EDIT</tt>, <tt>VIEW</tt> and <tt>EDIT_GROUP</tt>.
  20. * @param {DashboardApi.MODES} mode Dashboard {@link DashboardApi#MODES mode} enumeration value
  21. * @example
  22. * DashboardApi.setMode(DashboardApi.MODES.VIEW);
  23. */
  24. DashboardAPI.prototype.setMode = function setMode() {};
  25. /**
  26. * @function DashboardAPI#setDirty
  27. * @description set a dashboard as dirty or not
  28. * @param {boolean} dirty true if set a dashboard to dirty, false otherwise
  29. */
  30. DashboardAPI.prototype.setDirty = function setDirty() {};
  31. /**
  32. * @function DashboardAPI#getMode
  33. * @description Get the current dashboard mode.
  34. * @return {DashboardApi.MODES} Dashboard {@link DashboardApi#MODES mode} enumeration value
  35. * @example
  36. * DashboardApi.getMode().then(function(mode) {
  37. * console.log(mode);
  38. * });
  39. */
  40. DashboardAPI.prototype.getMode = function getMode() {};
  41. /**
  42. * @description Get the dashboard instance specification
  43. * @return {Object} dashboard spec
  44. * @example
  45. * DashboardApi.getSpec().then(function(spec) {
  46. * console.log(spec);
  47. * });
  48. */
  49. DashboardAPI.prototype.getSpec = function getSpec() {};
  50. /**
  51. * @function DashboardAPI#undo
  52. * @description Undo the last action performed on the dashboard
  53. * @example
  54. * // edit the dashboard
  55. * ...
  56. * DashboardApi.undo();
  57. */
  58. DashboardAPI.prototype.undo = function undo() {};
  59. /**
  60. * @function DashboardAPI#redo
  61. * @description Redo the last {@link DashboardApi#undo DashboardApi.undo} action performed on the dashboard
  62. * @example
  63. * // edit the dashboard
  64. * ...
  65. * DashboardApi.undo();
  66. * DashboardApi.redo();
  67. */
  68. DashboardAPI.prototype.redo = function redo() {};
  69. /**
  70. * @function DashboardAPI#toggleProperties
  71. * @description Toggle the properties pane
  72. * @param {boolean} [toggle] if <tt>true</tt> display the properties pane,
  73. * otherwise hide the properties pane. The state is toggled from the current state when omitted.
  74. */
  75. DashboardAPI.prototype.toggleProperties = function toggleProperties() {};
  76. /**
  77. * @function DashboardAPI#on
  78. * @description Register an event handler for dashboard events
  79. * @param {string} eventName Name of the dashboard event
  80. * @param {function} handler Event handler to be called when the event occurrs.
  81. * Multiple handlers can be registered with the same <strong>eventName</strong>.
  82. * Each handlers needs to be registered and unregistered individually.
  83. * @example
  84. * // handle the event when the dashboard is modified
  85. * function onModified(event) {
  86. * console.log('dashboard has been modified');
  87. * }
  88. *
  89. * // Register the event handler
  90. * DashboardApi.on(DashboardApi.EVENTS.DIRTY, onModified);
  91. */
  92. DashboardAPI.prototype.on = function on() {};
  93. /**
  94. * @function DashboardAPI#off
  95. * @description Unregister an event handler that was registered with {@link DashboardApi#on DashboardApi.on}
  96. * @param {string} eventName Name of the dashboard event
  97. * @param {function} handler Event handler to be called when the event occurrs
  98. * @example
  99. * // handle the event when the dashboard is modified
  100. * function onModified(event) {
  101. * console.log('dashboard has been modified');
  102. * }
  103. *
  104. * // Register the event handler
  105. * DashboardApi.on(DashboardApi.EVENTS.DIRTY, onModified);
  106. * ...
  107. * // Unregister the event handler
  108. * DashboardApi.off(DashboardApi.EVENTS.DIRTY, onModified);
  109. */
  110. DashboardAPI.prototype.off = function off() {};
  111. /**
  112. * @function DashboardAPI#addSources
  113. * @description Add sources that can used as data sources in the dashboard.<br>
  114. * Once the source is successfully added, it will appear on the datasource list pane with the given name.
  115. * @param {String} sourceInfo.id Identifier for the source. Will be passed back for actions such as relink
  116. * @param {String} sourceInfo.name Name of the source
  117. * @param {String} sourceInfo.module The module definition
  118. * @example
  119. * DashboardApi.addSources([{
  120. * id: 'myUniqueId',
  121. * name: 'Sample datasource',
  122. * module: {...}
  123. * }, {
  124. * id: 'myUniqueId2',
  125. * name: 'Sample datasource 2',
  126. * module: {...}
  127. * }]);
  128. * @deprecated Use {@link DataSourcesAPI#addDataSource}
  129. */
  130. DashboardAPI.prototype.addSources = function addSources() {};
  131. /**
  132. * @function DashboardAPI#relink
  133. * @description Relink an existing source to a new module.<br>
  134. * Widgets that reference this source will reload after the relink is finished.
  135. * @param {String} sourceInfo.id Id of the source to relink. This id is passed to the caller in the relink:clicked event
  136. * @param {String} sourceInfo.name Name of the source, only needed if you wish to change the name.
  137. * @param {String} sourceInfo.module The module definition
  138. * @example
  139. * DashboardApi.relink({
  140. * id: '123456',
  141. * name: 'Sample datasource',
  142. * module: {...}
  143. * });
  144. * @deprecated Use {@link DataSourceAPI#relink}
  145. */
  146. DashboardAPI.prototype.relink = function relink() {};
  147. /**
  148. * @function DashboardAPI#getCanvas
  149. * @description Get the {@link CanvasAPI Canvas} API
  150. * @return {CanvasAPI}
  151. */
  152. DashboardAPI.prototype.getCanvas = function getCanvas() {};
  153. /**
  154. * @async
  155. * @function DashboardAPI#getCanvasWhenReady
  156. * @description Asynchronously get the {@link CanvasAPI Canvas} API
  157. * @return {Promoise<CanvasAPI>}
  158. */
  159. DashboardAPI.prototype.getCanvasWhenReady = function getCanvasWhenReady() {};
  160. /**
  161. * @function DashboardAPI#getType
  162. * @description Get the dashboard type
  163. * @return {string} dashboard type ['dashboard' | 'story' | 'explore']
  164. */
  165. DashboardAPI.prototype.getType = function getType() {};
  166. /**
  167. * @function DashboardAPI#getName
  168. * @description Get the dashboard name
  169. * @return {string} dashboard name
  170. */
  171. DashboardAPI.prototype.getName = function getName() {};
  172. /**
  173. * @function DashboardAPI#canAuthor
  174. * @description Determine whether user has permission to author the dashboard
  175. * @return {boolean} true if the dashboard can be authored, otherwise false
  176. */
  177. DashboardAPI.prototype.canAuthor = function canAuthor() {};
  178. /**
  179. * @function DashboardAPI#getService
  180. * @description Get a global service
  181. * @param {DashboardAPI.GLOBAL_SERVICES} service global service enum
  182. * @return {object} service object
  183. */
  184. DashboardAPI.prototype.getService = function getService() /* service */{};
  185. /**
  186. * @async
  187. * @function DashboardAPI#getServiceWhenReady
  188. * @description Asynchronously get the global service
  189. * @param {DashboardAPI.GLOBAL_SERVICES} service global service enum
  190. * @return {Promise<object>} Promise which resolves a service object
  191. */
  192. DashboardAPI.prototype.getServiceWhenReady = function getServiceWhenReady() /* service */{};
  193. /**
  194. * @function DashboardAPI#getFeature
  195. * @description Get the feature with the given feature name
  196. * @param {string} name unique name of the feature
  197. * @return {object} the feature API object
  198. */
  199. DashboardAPI.prototype.getFeature = function getFeature() /* name */{};
  200. /**
  201. * @function DashboardAPI#triggerDashboardEvent
  202. * @description Trigger a dashboard event
  203. * @param {string} name Event name
  204. * @param {object} payload Event payload
  205. */
  206. DashboardAPI.prototype.triggerDashboardEvent = function triggerDashboardEvent() /* name, payload */{};
  207. /**
  208. * @function DashboardAPI#showToast
  209. * @description Display a toast message
  210. * @param {string} message the message string
  211. * @param {object} options toast message options
  212. * @param {string} options.type message type ('info', 'error')
  213. * @param {boolean} options.preventDuplicates prevent from duplicate toast messages being displayed
  214. */
  215. DashboardAPI.prototype.showToast = function showToast() /* message, options */{};
  216. /**
  217. * @function DashboardAPI#showMessage
  218. * @description Display a message box with the given message
  219. * @param {string} message the message string
  220. * @param {string} [type] message type ('info', 'error')
  221. */
  222. DashboardAPI.prototype.showMessage = function showMessage() /* message, type = 'info' */{};
  223. /**
  224. * @function DashboardAPI#showSlideOut
  225. * @description Display a slideout on the dashboard
  226. * @param {object} option slideout options
  227. */
  228. DashboardAPI.prototype.showSlideOut = function showSlideOut() /* options */{};
  229. /**
  230. * @function DashboardAPI#showContextMenu
  231. * @description Display a context menu on the dashboard
  232. * @param {object} option Context menu options
  233. */
  234. DashboardAPI.prototype.showContextMenu = function showContextMenu() /* options */{};
  235. /**
  236. * @function DashboardAPI#getPluginExtension
  237. * @description get the plugin extension object
  238. * @param {string} id unique plugin identifier
  239. */
  240. DashboardAPI.prototype.getPluginExtension = function getPluginExtension() /* id */{};
  241. /**
  242. * @function DashboardAPI#getCollectionExtension
  243. * @description get the collection extension object
  244. * @param {string} id unique collection identifier
  245. */
  246. DashboardAPI.prototype.getCollectionExtension = function getCollectionExtension() {};
  247. /**
  248. * @function DashboardAPI#getConfiguration
  249. */
  250. DashboardAPI.prototype.getConfiguration = function getConfiguration() {};
  251. /**
  252. * @function DashboardAPI#getAppConfig
  253. * @deprecated replaced by DashboardAPI#getConfiguration
  254. */
  255. DashboardAPI.prototype.getAppConfig = function getAppConfig() {};
  256. /**
  257. * @function DashboardAPI#openApplication
  258. * @param {string} name application name
  259. * @param {object} options application options
  260. */
  261. DashboardAPI.prototype.openApplication = function openApplication() /* name, options */{};
  262. /**
  263. * @function DashboardAPI#closeApplication
  264. * @param {string} name application name
  265. * @param {string} id application unique identifier
  266. * @param {object} options application options
  267. */
  268. DashboardAPI.prototype.closeApplication = function closeApplication() /* name, id, options */{};
  269. /**
  270. * @function DashboardAPI#showErrorMessage
  271. * @deprecated replaced by DashboardAPI#showMessage
  272. */
  273. DashboardAPI.prototype.showErrorMessage = function showErrorMessage() {};
  274. /**
  275. * @function DashboardAPI#getApplicationName
  276. * @deprecated replaced by DashboardAPI#getType
  277. */
  278. DashboardAPI.prototype.getApplicationName = function getApplicationName() {};
  279. /**
  280. * @function DashboardAPI#getApplicationLabel
  281. * @deprecated replaced by DashboardAPI#getName
  282. */
  283. DashboardAPI.prototype.getApplicationLabel = function getApplicationLabel() {};
  284. /**
  285. * @function DashboardAPI#getGlassSvc
  286. * @deprecated replaced by DashboardAPI#getServiceWhenReady
  287. */
  288. DashboardAPI.prototype.getGlassSvc = function getGlassSvc() {};
  289. /**
  290. * @function DashboardAPI#getGlassCoreSvc
  291. * @deprecated replaced by DashboardAPI#getService
  292. */
  293. DashboardAPI.prototype.getGlassCoreSvc = function getGlassCoreSvc() {};
  294. /**
  295. * @function DashboardAPI#getDashboardSvc
  296. * @deprecated replaced by {@link DashboardAPI#getFeature}
  297. */
  298. DashboardAPI.prototype.getDashboardSvc = function getDashboardSvc() {};
  299. /**
  300. * @function DashboardAPI#getDashboardSvc
  301. * @deprecated replaced by {@link DashboardAPI#getFeature}
  302. */
  303. DashboardAPI.prototype.getDashboardCoreSvc = function getDashboardCoreSvc() {};
  304. /**
  305. * @function DashboardAPI#findGlassPlugin
  306. * @deprecated replaced by {@link DashboardAPI#getPluginExtension}
  307. */
  308. DashboardAPI.prototype.findGlassPlugin = function findGlassPlugin() {};
  309. /**
  310. * @function DashboardAPI#findGlassCollection
  311. * @deprecated replaced by {@link DashboardAPI#getCollectionExtension}
  312. */
  313. DashboardAPI.prototype.findGlassCollection = function findGlassCollection() {};
  314. /**
  315. * @function DashboardAPI#getLayout
  316. * @deprecated already exists in {@link CanvasAPI}
  317. * @todo confirm this is not being used by explore
  318. */
  319. DashboardAPI.prototype.getLayout = function getLayout() {};
  320. /**
  321. * @function DashboardAPI#deselectAllWidgets
  322. * @deprecated moved to {@link CanvasAPI}
  323. * Delect all currently select widgets
  324. */
  325. DashboardAPI.prototype.deselectAllWidgets = function deselectAllWidgets() {};
  326. /**
  327. * @function DashboardAPI#getToolbarActions
  328. * @deprecated
  329. */
  330. DashboardAPI.prototype.getToolbarActions = function getToolbarActions() {};
  331. /**
  332. * @function DashboardAPI#openAppView
  333. * @deprecated Replaced by {@link DashboardAPI#openGlassApplication}
  334. */
  335. DashboardAPI.prototype.openAppView = function openAppView() {};
  336. /**
  337. * @function DashboardAPI#addContentToCanvas
  338. * @description Add a content to the current dashboard canvas
  339. * @deprecated Replaced by {@link CanvasAPI#addContent}
  340. */
  341. DashboardAPI.prototype.addContentToCanvas = function addContentToCanvas() {};
  342. /**
  343. * @function DashboardAPI#waitTillWidgetsRendered
  344. * @deprecated Replaced by {@link CanvasAPI#getWidgetsWhenRendered}
  345. */
  346. DashboardAPI.prototype.waitTillWidgetsRendered = function waitTillWidgetsRendered() {};
  347. /**
  348. * @function DashboardAPI#getCollectionConfig
  349. * @deprecated needs to be integrated as part of {@link DashboardAPI#getCollectionExtension}
  350. */
  351. DashboardAPI.prototype.getCollectionConfig = function getCollectionConfig() {};
  352. /**
  353. * @todo DO NOT document. Needs to be removed.
  354. * @deprecated this should not be exposed as an API
  355. * @ignore
  356. */
  357. DashboardAPI.prototype.getCurrentContentView = function getCurrentContentView() {};
  358. /**
  359. * @function DashboardAPI#getSources
  360. * @description Gets the data sources that are in use in the dashboard.<br>
  361. * Once the source is successfully added, it will appear on the datasource list pane with the given name.
  362. * Returns a promise that resolves to an array of datasource info:
  363. * [{ name: <localized name of datasource>,
  364. * assetId: <storeId of datasource>,
  365. * type: <datasource type e.g. uploadedFile>}],
  366. * active: <true if the datasource is used in selected widgets or selected in datasource panel>}],
  367. * @example
  368. * DashboardApi.getSources();
  369. * @deprecated Use{@link DataSourcesAPI#getSourcesInfo} instead
  370. */
  371. DashboardAPI.prototype.getSources = function getSources() {};
  372. /**
  373. * @function DashboardAPI#getDataSourceList
  374. * @description Gets the data sources that are being used by the dashboard.
  375. * @return {Promise<DataSourceAPI[]>} Returns a promise that will be resolved with an array of {@link DataSourceAPI} objects.
  376. * @deprecated Use {@link DashboardAPI#getFeature} to get the dataSource feature and call {@link DataSourcesAPI#getDataSourceList}
  377. */
  378. DashboardAPI.prototype.getDataSourceList = function getDataSourceList() {};
  379. /**
  380. * @function DashboardAPI#setActiveDataSourceId
  381. * @description Keep track of the current active datasource with the given datasource id
  382. * @param {string} sourceId current active datasource identifier
  383. * @deprecated Use {@link DataSourcesAPI#setActiveDataSourceId} instead
  384. */
  385. DashboardAPI.prototype.setActiveDataSourceId = function setActiveDataSourceId() {};
  386. /**
  387. * @function DashboardAPI#getActiveDataSourceId
  388. * @description Get the current active datasource id
  389. * @return {string} current active datasource identifier
  390. * @deprecated Use {@link DataSourcesAPI#getActiveDataSourceId} instead
  391. */
  392. DashboardAPI.prototype.getActiveDataSourceId = function getActiveDataSourceId() {};
  393. /**
  394. * @deprecated Moved to {@link CanvasAPI Canvas} API
  395. * @function DashboardAPI#copy
  396. * @description Copy the currently selected widget(s) on the dashboard
  397. */
  398. DashboardAPI.prototype.copy = function copy() {};
  399. /**
  400. * @deprecated Moved to {@link CanvasAPI Canvas} API
  401. * @function DashboardAPI#paste
  402. * @description Paste the copied widget(s) to the dashboard
  403. * @return {Promise} promise which is resolved once the widget(s) are successfully pasted
  404. */
  405. DashboardAPI.prototype.paste = function paste() {};
  406. DashboardAPI.prototype.destroy = function destroy() {};
  407. return DashboardAPI;
  408. }();
  409. /**
  410. * @public
  411. * @readonly
  412. * @enum {string}
  413. * @memberof DashboardAPI
  414. */
  415. DashboardAPI.MODES = {
  416. /** Edit (authoring) mode.<br>
  417. Allows user to author the current dashboard. */
  418. EDIT: 'authoring',
  419. /** View (consumption) mode.<br>
  420. Allows user to view and explore the current dashboard. */
  421. VIEW: 'consumption',
  422. /** Event group edit mode.<br>
  423. Allows user to edit the widget connections in the current dashboard. */
  424. EDIT_GROUP: 'eventGroups'
  425. };
  426. /**
  427. * @public
  428. * @readonly
  429. * @enum {string}
  430. * @memberof DashboardAPI
  431. */
  432. DashboardAPI.GLOBAL_SERVICES = {
  433. /** AJAX service */
  434. AJAX: '.Ajax',
  435. /** Logger service */
  436. LOGGER: '.Logger',
  437. /** LiveWidget service */
  438. LIVEWIDGET: '.LiveWidgetService'
  439. };
  440. /**
  441. * @public
  442. * @readonly
  443. * @enum {string}
  444. * @memberof DashboardAPI
  445. */
  446. DashboardAPI.GLOBAL_INTERNAL_SERVICES = {
  447. CONTENT: '.Content',
  448. USER_PROFILE: '.UserProfile',
  449. PINNING: '.DashboardPinning',
  450. THEME: '.DashboardTheme',
  451. CONVERSION: '.ConversionService',
  452. DRILL_INFO: '.DrillInfoService',
  453. CONTENT_DIALOG: '.ContentDialogFactory',
  454. DATA_CONNECTION: '.DataConnectionServiceFactory'
  455. };
  456. return DashboardAPI;
  457. });
  458. //# sourceMappingURL=DashboardAPI.js.map