'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ 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) { var DEFAULT_FEATURES_EXCLUDES = { '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'], 'com.ibm.bi.dashboard.content-features': ['VisDnD', 'VisDnD.utils', 'contextualGridAction', 'Visualization.SmartsRecommender', 'Toolbar', 'HideRowColumnAction', 'VisExpandMode', 'DataBehindTheVis', 'ViprUITest', 'LocalFilterDialog', 'ContentMenu', 'DropZonesOverlayState', 'DropZonesOverlayDOM'] }; /** * @classdesc API class that is used to create a custom dashboard application that is dependent on glass. * Glass refers to an internal Cognos Analytics API that controls the user interface. It allows developers to perform actions on the UI, * such as opening a view or accessing view configurations or services. */ var AppFactory = function () { /** * @param {Object} options * @param {String} options.glassContext - Contains the glass context of the application. * @param {String[]} options.features.name.excludes - List of feature names to prevent from loading for a feature collection. * */ function AppFactory() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, AppFactory); this._glassContext = options.glassContext || window.__glassAppController.glassContext; var dashboardFeatures = options.features && options.features['com.ibm.bi.dashboard.features'] || {}; var contentFeatures = options.features && options.features['com.ibm.bi.dashboard.content-features'] || {}; this._featuresOverride = { 'com.ibm.bi.dashboard.features': { excludes: DEFAULT_FEATURES_EXCLUDES['com.ibm.bi.dashboard.features'].concat(dashboardFeatures.excludes || []) }, 'com.ibm.bi.dashboard.content-features': { excludes: DEFAULT_FEATURES_EXCLUDES['com.ibm.bi.dashboard.content-features'].concat(contentFeatures.excludes || []) } }; var _ajaxService = GlassUtil.getAjaxService(this._glassContext); var contentStore = new ContentStore(_ajaxService); var userProfile = new CAUserProfile(); userProfile.initialize(this._glassContext); this._featureMap = new Map(); this._featureMap.set('ContentStore', contentStore.getAPI()); this._featureMap.set('UserProfile', userProfile.getAPI()); return APIFactory.createAPI(this, [function () { function _class() { _classCallCheck(this, _class); } _class.prototype.create = function create() {}; _class.prototype.getFeature = function getFeature() {}; return _class; }()]); } /** * * @param {Object} options * @param {String} options.assetId - Specifies the dashboard asset ID. * @param {String} options.spec - Specifies the dashboard specification. * @param {String[]} options.features.name.excludes - List of feature names to prevent from loading for a feature collection. * @return {Promise} Dashboard API object * */ AppFactory.prototype.create = function create() { var _this = this; var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var env = void 0, boardLoaderHelper = void 0; return this._glassContext.getSvc('.DashboardRuntime').then(function (runtimeService) { var runtimeOptions = { featuresOverride: _this._featuresOverride, assetId: options.assetId, spec: options.spec }; if (!runtimeOptions.assetId && !runtimeOptions.spec) { runtimeOptions.spec = runtimeService.getDefaultSpec(); } return runtimeService.getRuntimeEnvironment(runtimeOptions); }).then(function (environment) { env = environment; boardLoaderHelper = new BoardLoaderHelper(env.dashboardApi); env.boardModuleFactory = boardLoaderHelper.createBoardModuleFactory(); return boardLoaderHelper.loadLayoutExtensions(env.layoutExtensions, env.boardModuleFactory); }).then(function (layoutExtensions) { boardLoaderHelper.registerLayoutExtensions(layoutExtensions); var legacyViewControllers = new LegacyViewControllers({ environment: env }); env.dashboardApi.getFeature('FeatureRegistry.internal').registerFeature('LegacyViewControllers', legacyViewControllers); return new DashboardCore({ dashboardAPI: env.dashboardApi, internalDashboardAPI: env.internalDashboardAPI }).getAPI(); }); }; /** * * @param {String} featureName - Name of feature that is supported by the AppFactory, for example 'ContentStore'. * @return {Object} Feature, for example ContentStore object. */ AppFactory.prototype.getFeature = function getFeature(featureName) { return this._featureMap.get(featureName); }; return AppFactory; }(); return AppFactory; }); //# sourceMappingURL=AppFactory.js.map