'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 Business Analytics (C) Copyright IBM Corp. 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['./Dashboard', './DashboardCore'], function (DashboardImpl, DashboardCore) { /** * @class DashboardFactory * @classdesc Factory class creating an instance of DashboardAPI */ var DashboardFactory = function () { function DashboardFactory() { _classCallCheck(this, DashboardFactory); this._bootstrapFeatures = {}; this._featureDefinitions = { dashboard: [], content: [] }; } /** * Initializes the DashboardFactory; creates default bootstrap features if none is provided * @param {Object} initParams - map of name-instance of the bootstrap features * @param {Object} initParams.bootstrapFeatures - map of name-instance of the bootstrap features * @param {Array} initParams.dashboardFeatures - array listing all the dashboard feature definitions * @param {Array} initParams.contentFeatures - array listing all the content feature definitions * @return {Promise} - resolved if init is successful, rejected if an error occurred during the init process * @throws throws an exception if no parameter is provided */ DashboardFactory.prototype.init = function init(_ref) { var bootstrapFeatures = _ref.bootstrapFeatures, dashboardFeatures = _ref.dashboardFeatures, contentFeatures = _ref.contentFeatures; if (typeof bootstrapFeatures['Logger'] === 'undefined') { this._bootstrapFeatures['Logger'] = console; } else { this._bootstrapFeatures['Logger'] = bootstrapFeatures['Logger']; } this._featureDefinitions.dashboard = dashboardFeatures ? dashboardFeatures : []; this._featureDefinitions.content = contentFeatures ? contentFeatures : []; return Promise.resolve(); }; /** * Returns the instance of a bootstrap feature * @param {String} name - name of the feature * @returns {Object} instance of the feature or undefined if unknown */ DashboardFactory.prototype.getBootstrapFeature = function getBootstrapFeature(name) { return this._bootstrapFeatures[name]; }; /** * Returns the dashboard features * @returns [] Json array describing the dashboard features */ DashboardFactory.prototype.getDashboardFeatures = function getDashboardFeatures() { return this._featureDefinitions.dashboard; }; /** * Returns the content features * @returns [] Json array describing the content features */ DashboardFactory.prototype.getContentFeatures = function getContentFeatures() { return this._featureDefinitions.content; }; /** * creates an instance of DashboardAPI based on the passed spec * @param {Object} options - map of parameters * @param {Object} options.spec - dashboard spec * @returns {Promise} - resolved when the CoreDashboard instance is created */ DashboardFactory.prototype.create = function create() { this._dashboardAPI = new DashboardImpl({ view: {} }); return Promise.resolve(new DashboardCore({ dashboardAPI: this._dashboardAPI }).getAPI()); }; return DashboardFactory; }(); return DashboardFactory; }); //# sourceMappingURL=DashboardFactory.js.map