123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- 'use strict';
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2017, 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['../../../lib/@waca/core-client/js/core-client/ui/core/Class', 'underscore'], function (BaseClass, _) {
- 'use strict';
- /**
- * @class DashboardFactory
- * @hideconstructor
- * @classdesc Factory class that is used to instantiate a {@link DashboardApi} instance.<br>
- * <strong>DashboardFactory</strong> can not be instantiated directly.
- * <strong>DashboardFactory</strong> can be obtained through an instance of {@link CognosApi}.
- * @example
- * // Create an instance of the CognosApi
- * const api = new CognosApi({
- * cognosRootURL: 'http://localhost/bi/',
- * node: document.getElementById('containerDivId'),
- * sessionCode: 'CD1a2b34567b8c901234d5'
- * });
- *
- * // initialize the CognosApi in order to obtain the service APIs
- * api.initialize().then(() => {
- * // create a new dashboard through the dashboard factory
- * api.dashboard.createNew();
- * ...
- * // open an existing dashboard through the dashboard factory
- * api.dashboard.openDashboard();
- * ...
- * });
- */
- var DashboardFactory = BaseClass.extend({
- API_METHODS: ['createNew', 'openDashboard'],
- API_ENUMS: [],
- init: function init(options) {
- this.glassContext = options.glassContext;
- },
- /**
- * Create a {@link DashboardApi} instance of a new dashboard
- * @function DashboardFactory#createNew
- * @example
- * const dashboardApi = null;
- * api.dashboard.createNew().then((dashboardApi) => {
- * console.log('Dashboard created successfully.');
- * dashboardApi = dashboardApi;
- * }).catch((err) => {
- * console.log('Cancelled by user.');
- * });
- */
- createNew: function createNew() {
- return new Promise(function (resolve, reject) {
- this.glassContext.appController.openAppView('createBoard', {
- content: {
- id: 'createBoardPage_dashboard',
- editMode: true,
- restrictTemplate: 'dashboard',
- containerAppOptions: {
- callbacks: {
- resolve: resolve,
- reject: reject
- },
- configuration: {
- ui: {},
- pinning: 'disabled'
- }
- },
- ui_appbar: false
- }
- });
- }.bind(this));
- },
- /**
- * Create a {@link DashboardApi} instance of an existing dashboard
- * @function DashboardFactory#openDashboard
- * @param {Object} option.dashboardSpec dashboard specification to open
- * @see {@link DashboardApi#getSpec DashboardApi.getSpec}
- * @example
- * const dashboardApi = null;
- * api.dashboard.openDashboard({
- * dashboardSpec: {...}
- * }).then((dashboardApi) => {
- * console.log('Dashboard opened successfully.');
- * dashboardApi = dashboardApi;
- * });
- */
- openDashboard: function openDashboard(options) {
- return new Promise(function (resolve, reject) {
- this.glassContext.appController.openAppView('dashboard', {
- content: {
- id: _.uniqueId(),
- editMode: false,
- containerAppOptions: {
- callbacks: {
- resolve: resolve,
- reject: reject
- },
- configuration: {
- ui: {},
- pinning: 'disabled'
- }
- },
- ui_appbar: false,
- boardId: options.dashboardId || null,
- boardSpec: options.dashboardSpec
- }
- });
- }.bind(this));
- }
- });
- return DashboardFactory;
- });
- //# sourceMappingURL=DashboardFactory.js.map
|