LegacyViewControllers.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Business Analytics (C) Copyright IBM Corp. 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['jquery', '../../lib/@waca/dashboard-common/dist/core/APIFactory', '../deprecated/LegacyViewControllersAPI', '../../dashboard/layout/LayoutController', '../../dashboard/loader/WidgetLoader'], function ($, APIFactory, LegacyViewControllersAPI, LayoutController, WidgetLoader) {
  9. /**
  10. * @implements LegacyViewControllersAPI
  11. * @hideconstructor
  12. */
  13. var LegacyViewControllers = function () {
  14. function LegacyViewControllers(_ref) {
  15. var environment = _ref.environment,
  16. layoutController = _ref.layoutController;
  17. _classCallCheck(this, LegacyViewControllers);
  18. this._widgetLoader = layoutController && layoutController.widgetLoader || this._createWidgetLoader(environment);
  19. this._layoutController = layoutController || this._createLayoutController(environment);
  20. }
  21. LegacyViewControllers.prototype.getAPI = function getAPI() {
  22. if (!this._api) {
  23. this._api = APIFactory.createAPI(this, [LegacyViewControllersAPI]);
  24. }
  25. return this._api;
  26. };
  27. LegacyViewControllers.prototype.getLayoutController = function getLayoutController() {
  28. return this._layoutController;
  29. };
  30. LegacyViewControllers.prototype.getWidgetLoader = function getWidgetLoader() {
  31. return this._widgetLoader;
  32. };
  33. LegacyViewControllers.prototype._createWidgetLoader = function _createWidgetLoader(env) {
  34. return new WidgetLoader({
  35. glassContext: env.glassContext,
  36. services: env.serviceRegistry,
  37. appSettings: {},
  38. dashboardApi: env.dashboardApi,
  39. eventRouter: env.eventRouter,
  40. widgetRegistry: env.widgetRegistry,
  41. loadedWidgets: {},
  42. boardModel: env.boardModel,
  43. contentFeatureLoader: env.internalCanvas,
  44. canvas: env.canvas
  45. });
  46. };
  47. LegacyViewControllers.prototype._createLayoutController = function _createLayoutController(env) {
  48. return new LayoutController({
  49. glassContext: env.glassContext,
  50. services: env.serviceRegistry,
  51. appSettings: {},
  52. contentFeatureLoader: env.internalCanvas,
  53. dashboardApi: env.dashboardApi,
  54. eventRouter: env.eventRouter,
  55. $el: $('body'),
  56. boardModel: env.boardModel,
  57. boardModuleFactory: env.boardModuleFactory,
  58. widgetLoader: this._widgetLoader,
  59. layoutExtensions: env.layoutExtensions,
  60. gatewayUrl: 'v1',
  61. cdnUrl: '',
  62. canvas: env.canvas
  63. });
  64. };
  65. LegacyViewControllers.prototype.destroy = function destroy() {
  66. this.getWidgetLoader().cleanup();
  67. this.getLayoutController().destroy();
  68. };
  69. return LegacyViewControllers;
  70. }();
  71. return LegacyViewControllers;
  72. });
  73. //# sourceMappingURL=LegacyViewControllers.js.map