12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- '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: Dashboard
- *| (C) Copyright IBM Corp. 2020
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['underscore', 'com/ibm/vida/control/vida', 'text!../../visualizations/vipr/viprVisLibrary.json'], function (_, vida, viprVisLibrary) {
- 'use strict';
- var hostAPI = {};
- /**
- * This class is exposed as a glass service; the CA Mobile App will use it to "warm up" VIDA
- */
- var VidaResourceLoader = function () {
- function VidaResourceLoader() {
- _classCallCheck(this, VidaResourceLoader);
- }
- VidaResourceLoader.prototype.initialize = function initialize() {
- var _this = this;
- if (this.done) return Promise.resolve();
- this.done = true;
- try {
- var bundles = JSON.parse(viprVisLibrary).system;
- _.extend(this, vida.VIPR.create({ bundles: bundles }));
- var bundleIds = bundles.map(function (bundle) {
- return bundle.id;
- });
- var promises = [];
- bundleIds.forEach(function (id) {
- return promises.push(_this._loadBundle(id));
- });
- var loadPromise = this._delay();
- return Promise.all(promises).then(function () {
- bundleIds.forEach(function (id) {
- loadPromise = loadPromise.then(_this._loadWidgetResources.bind(_this, id));
- });
- return loadPromise;
- });
- } catch (err) {
- console.debug(err);
- return Promise.resolve();
- }
- };
- VidaResourceLoader.prototype._loadWidgetResources = function _loadWidgetResources(id) {
- var _this2 = this;
- var widget = void 0;
- return this._delay().then(function () {
- widget = new vida.SmallMultipleGrid({ vipr: _this2, hostAPI: hostAPI }, id);
- return widget.newViz(id, 'client');
- }).then(function () {
- if (widget && typeof widget.destroy === 'function') {
- return widget.destroy();
- }
- }).catch(console.debug);
- };
- VidaResourceLoader.prototype._loadBundle = function _loadBundle(id) {
- return this.load(id).then(function (bundle) {
- return vida.SmallMultipleGrid.extendVizBundle(bundle);
- }).catch(console.debug);
- };
- VidaResourceLoader.prototype._delay = function _delay() {
- var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 50;
- return new Promise(function (resolve) {
- return setTimeout(resolve, time);
- });
- };
- return VidaResourceLoader;
- }();
- return VidaResourceLoader;
- });
- //# sourceMappingURL=VidaResourceLoaderService.js.map
|