LiveWidgetUIHelper.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2017, 2020
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['../../lib/@waca/dashboard-common/dist/ui/WidgetAddUIHelper', '../../visualizations/definitions/VisDefinitionManager', 'underscore'], function (WidgetAddUIHelper, VisDefinitionManager, _) {
  8. /**
  9. * Extension of the WidgetAddUIHelper that allows entries to be built up by querying the list of definitions
  10. * rather than a static json list
  11. *
  12. * This is a LiveWidget version of WidgetAddUIHelper which uses the livewidget and VisDefinitionManager of the livewidget
  13. */
  14. var LiveWidgetUIHelper = WidgetAddUIHelper.extend({
  15. init: function init(params) {
  16. LiveWidgetUIHelper.inherited('init', this, arguments);
  17. this.dashboardApi = params.dashboardApi;
  18. this.iconsFeature = this.dashboardApi.getFeature('Icons');
  19. },
  20. /**
  21. * Build up a livewidget entry for each possible archetype, use the archetype icon as the icon
  22. * to see in the visualizations drop down
  23. */
  24. getEntries: function getEntries() {
  25. var _this = this;
  26. var definitionAPI = this.dashboardApi.getFeature('VisDefinitions');
  27. return _.map(definitionAPI.getList(), function (definition) {
  28. return {
  29. label: definition.getLabel(),
  30. name: definition.getId(),
  31. icon: _this._getVisualizationIcon(definition),
  32. type: definition.getType(),
  33. placeholderIcon: definition.getPlaceholderIconUri(),
  34. content: {
  35. title: definition.getId(),
  36. iconUrl: definition.getIconUri(),
  37. name: definition.getId(),
  38. widget: 'dashboard-analytics/widgets/livewidget/LiveWidget',
  39. options: {
  40. visId: definition.getId(),
  41. avatarIcon: definition.getPlaceholderIconUri()
  42. }
  43. }
  44. };
  45. });
  46. },
  47. _getVisualizationIcon: function _getVisualizationIcon(definition) {
  48. var icon = this.iconsFeature.getIcon(definition.getId());
  49. icon = icon === undefined ? definition.getIcon() : icon.id;
  50. return icon;
  51. }
  52. });
  53. return LiveWidgetUIHelper;
  54. });
  55. //# sourceMappingURL=LiveWidgetUIHelper.js.map