AppFactory.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 Cognos Products: BI Cloud (C) Copyright IBM Corp. 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['../lib/@waca/dashboard-common/dist/core/APIFactory', '../dashboard/loader/BoardLoaderHelper', '../api/impl/LegacyViewControllers', '../api/impl/DashboardCore', '../app/util/GlassUtil', './features/contentStore/ContentStore', './features/userProfile/CAUserProfile'], function (APIFactory, BoardLoaderHelper, LegacyViewControllers, DashboardCore, GlassUtil, ContentStore, CAUserProfile) {
  9. var DEFAULT_FEATURES_EXCLUDES = {
  10. 'com.ibm.bi.dashboard.features': ['DashboardLearning', 'deleteAction', 'groupAction', 'duplicateAction', 'orderAction', 'alignAction', 'pinAction', 'editTitleAction', 'launchIntoExplore', 'disconnectEventGroupAction', 'linkEventGroupAction', 'createEventGroupAction', 'DockAction', 'ResetDashboard', 'editNotebookAction', 'ConvertToTemplate', 'CanvasDnD', 'InAppSlideoutState', 'InAppSlideoutDOM', 'PropertiesPane', 'PropertiesPaneDOM', 'PropertiesAction', 'lassoSelectAction', 'contextualGridAction', 'jumpToAction', 'changeVisTypeAction', 'suppressionAction', 'HideRowColumnAction', 'SearchAction', 'AggregationTypeAction', 'FormatAction', 'CrosstabActions', 'FilterDockAction', 'MetadataDnDProvider', 'SlotEditorState', 'SlotEditorDOM', 'OnLoadFilterModifier', 'ToolbarDock', 'ToolbarDockDOM', 'OnDemandToolbarSectionDOM', 'CanvasToolbarSectionDOM', 'SmartsService', 'Print', 'DashboardPrint', 'developerWidgetRefreshAction', 'LocalFilterExtension', 'SampleFeature', 'CsvExport'],
  11. 'com.ibm.bi.dashboard.content-features': ['VisDnD', 'VisDnD.utils', 'contextualGridAction', 'Visualization.SmartsRecommender', 'Toolbar', 'HideRowColumnAction', 'VisExpandMode', 'DataBehindTheVis', 'ViprUITest', 'LocalFilterDialog', 'ContentMenu', 'DropZonesOverlayState', 'DropZonesOverlayDOM']
  12. };
  13. /**
  14. * @classdesc API class that is used to create a custom dashboard application that is dependent on glass.
  15. * Glass refers to an internal Cognos Analytics API that controls the user interface. It allows developers to perform actions on the UI,
  16. * such as opening a view or accessing view configurations or services.
  17. */
  18. var AppFactory = function () {
  19. /**
  20. * @param {Object} options
  21. * @param {String} options.glassContext - Contains the glass context of the application.
  22. * @param {String[]} options.features.name.excludes - List of feature names to prevent from loading for a feature collection.
  23. *
  24. */
  25. function AppFactory() {
  26. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  27. _classCallCheck(this, AppFactory);
  28. this._glassContext = options.glassContext || window.__glassAppController.glassContext;
  29. var dashboardFeatures = options.features && options.features['com.ibm.bi.dashboard.features'] || {};
  30. var contentFeatures = options.features && options.features['com.ibm.bi.dashboard.content-features'] || {};
  31. this._featuresOverride = {
  32. 'com.ibm.bi.dashboard.features': {
  33. excludes: DEFAULT_FEATURES_EXCLUDES['com.ibm.bi.dashboard.features'].concat(dashboardFeatures.excludes || [])
  34. },
  35. 'com.ibm.bi.dashboard.content-features': {
  36. excludes: DEFAULT_FEATURES_EXCLUDES['com.ibm.bi.dashboard.content-features'].concat(contentFeatures.excludes || [])
  37. }
  38. };
  39. var _ajaxService = GlassUtil.getAjaxService(this._glassContext);
  40. var contentStore = new ContentStore(_ajaxService);
  41. var userProfile = new CAUserProfile();
  42. userProfile.initialize(this._glassContext);
  43. this._featureMap = new Map();
  44. this._featureMap.set('ContentStore', contentStore.getAPI());
  45. this._featureMap.set('UserProfile', userProfile.getAPI());
  46. return APIFactory.createAPI(this, [function () {
  47. function _class() {
  48. _classCallCheck(this, _class);
  49. }
  50. _class.prototype.create = function create() {};
  51. _class.prototype.getFeature = function getFeature() {};
  52. return _class;
  53. }()]);
  54. }
  55. /**
  56. *
  57. * @param {Object} options
  58. * @param {String} options.assetId - Specifies the dashboard asset ID.
  59. * @param {String} options.spec - Specifies the dashboard specification.
  60. * @param {String[]} options.features.name.excludes - List of feature names to prevent from loading for a feature collection.
  61. * @return {Promise<DashboardCoreAPI>} Dashboard API object
  62. *
  63. */
  64. AppFactory.prototype.create = function create() {
  65. var _this = this;
  66. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  67. var env = void 0,
  68. boardLoaderHelper = void 0;
  69. return this._glassContext.getSvc('.DashboardRuntime').then(function (runtimeService) {
  70. var runtimeOptions = {
  71. featuresOverride: _this._featuresOverride,
  72. assetId: options.assetId,
  73. spec: options.spec
  74. };
  75. if (!runtimeOptions.assetId && !runtimeOptions.spec) {
  76. runtimeOptions.spec = runtimeService.getDefaultSpec();
  77. }
  78. return runtimeService.getRuntimeEnvironment(runtimeOptions);
  79. }).then(function (environment) {
  80. env = environment;
  81. boardLoaderHelper = new BoardLoaderHelper(env.dashboardApi);
  82. env.boardModuleFactory = boardLoaderHelper.createBoardModuleFactory();
  83. return boardLoaderHelper.loadLayoutExtensions(env.layoutExtensions, env.boardModuleFactory);
  84. }).then(function (layoutExtensions) {
  85. boardLoaderHelper.registerLayoutExtensions(layoutExtensions);
  86. var legacyViewControllers = new LegacyViewControllers({
  87. environment: env
  88. });
  89. env.dashboardApi.getFeature('FeatureRegistry.internal').registerFeature('LegacyViewControllers', legacyViewControllers);
  90. return new DashboardCore({
  91. dashboardAPI: env.dashboardApi,
  92. internalDashboardAPI: env.internalDashboardAPI
  93. }).getAPI();
  94. });
  95. };
  96. /**
  97. *
  98. * @param {String} featureName - Name of feature that is supported by the AppFactory, for example 'ContentStore'.
  99. * @return {Object} Feature, for example ContentStore object.
  100. */
  101. AppFactory.prototype.getFeature = function getFeature(featureName) {
  102. return this._featureMap.get(featureName);
  103. };
  104. return AppFactory;
  105. }();
  106. return AppFactory;
  107. });
  108. //# sourceMappingURL=AppFactory.js.map