'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. 2018, 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['../../../api/core/glass/GlassDashboardFactory'], function (GlassDashboardFactory) { /** * Dashboard service that can be used to provide a dashboard runtime environment * that is needed to run code that is dashboard dependant (e.g. live widget) but without a dashboard Perspective * The service will require the dashboard perspective json, and use it to provide all the needed extensions and collections */ var DashboardRuntimeService = function () { function DashboardRuntimeService() { _classCallCheck(this, DashboardRuntimeService); } DashboardRuntimeService.prototype.initialize = function initialize(glassContext) { this.dashboardFactory = new GlassDashboardFactory({ glassContext: glassContext }); return Promise.resolve(); }; DashboardRuntimeService.prototype.getDefaultSpec = function getDefaultSpec() { return { 'name': 'New dashboard', 'layout': { 'id': 'page0', 'items': [], 'style': {}, 'type': 'tab' }, 'theme': 'defaultTheme', 'eventGroups': [], 'fredIsRed': { 'colorMap': {}, 'saveId': 2 }, 'pageContext': [], 'dataSources': { 'version': '1.0', 'sources': [] }, 'widgets': {} }; }; DashboardRuntimeService.prototype.getRuntimeEnvironment = function getRuntimeEnvironment(options) { var _this = this; if (!options && this.defaultRuntimeEnv) { return Promise.resolve(this.defaultRuntimeEnv); } return this.dashboardFactory.initializeRuntime().then(function () { return _this.dashboardFactory.runtimeEnv.getRuntimeEnvironment(options, _this.getDefaultSpec.bind(_this)).then(function (env) { if (!options) { _this.defaultRuntimeEnv = env; } return env; }); }); }; return DashboardRuntimeService; }(); return DashboardRuntimeService; }); //# sourceMappingURL=DashboardRuntimeService.js.map