AnalyticsBaseWidget.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Watson Analytics (C) Copyright IBM Corp. 2017, 2019
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['../lib/@waca/dashboard-common/dist/ui/WidgetBase'], function (BaseWidget) {
  8. 'use strict';
  9. /**
  10. * Base widget for any analytics relatee widget. (e.g. liveWidget, fitlerWidget)
  11. *
  12. */
  13. var AnalyticsBaseWidget = BaseWidget.extend({
  14. init: function init() {
  15. AnalyticsBaseWidget.inherited('init', this, arguments);
  16. var internalDashboardFeature = this.dashboardApi.getFeature('internal');
  17. if (internalDashboardFeature) {
  18. this.boardModel = internalDashboardFeature.getBoardModel();
  19. if (this.boardModel.pageContext) {
  20. this.pageContextAPI = this.boardModel.pageContext.getAPI();
  21. }
  22. }
  23. },
  24. getDashboardApi: function getDashboardApi() {
  25. return this.dashboardApi;
  26. },
  27. _updateEventGroupIdInPageContext: function _updateEventGroupIdInPageContext(newChannelId, options) {
  28. if (this.pageContextAPI) {
  29. this.pageContextAPI.updateEventGroupId(this.id, this.getContainerPageId(), newChannelId, options);
  30. }
  31. },
  32. onRemoveCurrentEventRouter: function onRemoveCurrentEventRouter(options) {
  33. this._updateEventGroupIdInPageContext(null, options);
  34. },
  35. onNewEventRouter: function onNewEventRouter(options) {
  36. this._updateEventGroupIdInPageContext(this.eventRouter.channelId, options);
  37. }
  38. });
  39. return AnalyticsBaseWidget;
  40. });
  41. //# sourceMappingURL=AnalyticsBaseWidget.js.map