Loading client-app/src/component/layout/SupersetDisplayer.js +11 −68 Original line number Diff line number Diff line define([ 'dojo/_base/declare' , 'dojo/_base/lang' , 'dojo/Deferred' , 'dojo/dom-class' , 'src/component/base/_Module' , 'src/component/base/_Show' , 'src/component/base/_Store' , 'src/redmicConfig' , 'src/util/Credentials' , 'superset-sdk' ], function( declare , lang , Deferred , domClass , _Module , _Show , _Store , redmicConfig , Credentials , SupersetSdk ) { return declare([_Module, _Show, _Store], { return declare([_Module, _Show], { // summary: // Cargador de dashboards de Superset. // description: Loading @@ -38,7 +32,6 @@ define([ events: { }, ownChannel: 'supersetDisplayer', target: redmicConfig.services.getSupersetToken, className: 'supersetDashboard' }; Loading @@ -58,6 +51,8 @@ define([ postCreate: function() { this.inherited(arguments); if (!this.dashboardConfig) { console.error('Missing dashboard configuration for SupersetDisplayer!'); return; Loading @@ -71,9 +66,7 @@ define([ _prepareDashboard: function() { this._prepareDashboardConfig(); let tokenDfd = this._getGuestToken(); tokenDfd.then(() => this._prepareDashboardInstance(), () => this._missingUserToken()); this._prepareDashboardInstance(); }, _prepareDashboardConfig: function() { Loading @@ -91,50 +84,18 @@ define([ _getDashboardConfig: function() { this.dashboardConfig.dashboardUiConfig.urlParams = this._merge([ this.dashboardConfig.dashboardUiConfig.urlParams, { const urlParams = this._merge([this.dashboardConfig.dashboardUiConfig.urlParams, { activityid: this.pathVariableId } ]); }]); this.dashboardConfig.dashboardUiConfig.urlParams = urlParams; return this._merge([this.dashboardConfig, { mountPoint: this.getNodeToShow(), fetchGuestToken: lang.hitch(this, this._fetchGuestToken) fetchGuestToken: () => Credentials.get('oidAccessToken') }]); }, _getGuestToken: function() { this._guestToken = new Deferred(); const userToken = Credentials.get('oidAccessToken'); if (userToken?.length) { this._requestGuestToken(userToken); } else { this._guestToken.reject(); } return this._guestToken; }, _missingUserToken: function() { // TODO }, _requestGuestToken: function(token) { this._emitEvt('GET', { target: this.target, requesterId: this.getOwnChannel(), id: this.dashboardConfig.id, query: { token } }); }, _prepareDashboardInstance: function() { this._supersetInstance = SupersetSdk.embedDashboard(this._supersetConfig); Loading @@ -142,11 +103,6 @@ define([ this._supersetInstance.then(lang.hitch(this, this._onSupersetDashboardReady)); }, _fetchGuestToken: function() { return this._guestToken; }, _onSupersetDashboardReady: function(evt) { this._supersetUnmount = evt.unmount; Loading @@ -154,9 +110,7 @@ define([ _clearDashboard: function() { if (this._supersetUnmount) { this._supersetUnmount(); } this._supersetUnmount?.(); }, _subChangeDashboard: function(req) { Loading @@ -172,17 +126,6 @@ define([ this._clearDashboard(); }, _itemAvailable: function(res) { let token = res?.data?.token; if (token) { this._guestToken.resolve(token); } else { this._guestToken.reject('No token available'); } }, getNodeToShow: function() { return this.domNode; Loading Loading
client-app/src/component/layout/SupersetDisplayer.js +11 −68 Original line number Diff line number Diff line define([ 'dojo/_base/declare' , 'dojo/_base/lang' , 'dojo/Deferred' , 'dojo/dom-class' , 'src/component/base/_Module' , 'src/component/base/_Show' , 'src/component/base/_Store' , 'src/redmicConfig' , 'src/util/Credentials' , 'superset-sdk' ], function( declare , lang , Deferred , domClass , _Module , _Show , _Store , redmicConfig , Credentials , SupersetSdk ) { return declare([_Module, _Show, _Store], { return declare([_Module, _Show], { // summary: // Cargador de dashboards de Superset. // description: Loading @@ -38,7 +32,6 @@ define([ events: { }, ownChannel: 'supersetDisplayer', target: redmicConfig.services.getSupersetToken, className: 'supersetDashboard' }; Loading @@ -58,6 +51,8 @@ define([ postCreate: function() { this.inherited(arguments); if (!this.dashboardConfig) { console.error('Missing dashboard configuration for SupersetDisplayer!'); return; Loading @@ -71,9 +66,7 @@ define([ _prepareDashboard: function() { this._prepareDashboardConfig(); let tokenDfd = this._getGuestToken(); tokenDfd.then(() => this._prepareDashboardInstance(), () => this._missingUserToken()); this._prepareDashboardInstance(); }, _prepareDashboardConfig: function() { Loading @@ -91,50 +84,18 @@ define([ _getDashboardConfig: function() { this.dashboardConfig.dashboardUiConfig.urlParams = this._merge([ this.dashboardConfig.dashboardUiConfig.urlParams, { const urlParams = this._merge([this.dashboardConfig.dashboardUiConfig.urlParams, { activityid: this.pathVariableId } ]); }]); this.dashboardConfig.dashboardUiConfig.urlParams = urlParams; return this._merge([this.dashboardConfig, { mountPoint: this.getNodeToShow(), fetchGuestToken: lang.hitch(this, this._fetchGuestToken) fetchGuestToken: () => Credentials.get('oidAccessToken') }]); }, _getGuestToken: function() { this._guestToken = new Deferred(); const userToken = Credentials.get('oidAccessToken'); if (userToken?.length) { this._requestGuestToken(userToken); } else { this._guestToken.reject(); } return this._guestToken; }, _missingUserToken: function() { // TODO }, _requestGuestToken: function(token) { this._emitEvt('GET', { target: this.target, requesterId: this.getOwnChannel(), id: this.dashboardConfig.id, query: { token } }); }, _prepareDashboardInstance: function() { this._supersetInstance = SupersetSdk.embedDashboard(this._supersetConfig); Loading @@ -142,11 +103,6 @@ define([ this._supersetInstance.then(lang.hitch(this, this._onSupersetDashboardReady)); }, _fetchGuestToken: function() { return this._guestToken; }, _onSupersetDashboardReady: function(evt) { this._supersetUnmount = evt.unmount; Loading @@ -154,9 +110,7 @@ define([ _clearDashboard: function() { if (this._supersetUnmount) { this._supersetUnmount(); } this._supersetUnmount?.(); }, _subChangeDashboard: function(req) { Loading @@ -172,17 +126,6 @@ define([ this._clearDashboard(); }, _itemAvailable: function(res) { let token = res?.data?.token; if (token) { this._guestToken.resolve(token); } else { this._guestToken.reject('No token available'); } }, getNodeToShow: function() { return this.domNode; Loading