From 0220d2e79d3da9462baed6ec9cb16d744da81912 Mon Sep 17 00:00:00 2001 From: Adam Driscoll Date: Tue, 18 Jun 2019 12:19:26 -0600 Subject: [PATCH] Merge --- src/client/src/app/App.jsx | 3 + src/client/src/app/services/fetch-service.jsx | 3 + .../services/universal-dashboard-service.jsx | 55 +++++++++++++++++++ src/client/src/app/ud-dashboard.jsx | 5 +- 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/client/src/app/App.jsx b/src/client/src/app/App.jsx index c41ba088..11eb9a33 100644 --- a/src/client/src/app/App.jsx +++ b/src/client/src/app/App.jsx @@ -55,11 +55,14 @@ export default class App extends React.Component { } + var pluginRoutes = UniversalDashboard.provideRoutes(); + return (
+ {pluginRoutes}
) diff --git a/src/client/src/app/services/fetch-service.jsx b/src/client/src/app/services/fetch-service.jsx index 1e483ac4..8ce5b51a 100644 --- a/src/client/src/app/services/fetch-service.jsx +++ b/src/client/src/app/services/fetch-service.jsx @@ -5,6 +5,9 @@ export const fetchGet = function(url, success, history) { credentials: 'include' }) .then(function(response){ + + UniversalDashboard.invokeMiddleware('GET', url, history, response); + if (response.status === 401 && history) { window.sessionStorage.setItem("returnUrl", window.location.pathname + window.location.search); diff --git a/src/client/src/app/services/universal-dashboard-service.jsx b/src/client/src/app/services/universal-dashboard-service.jsx index 1496cd55..90db0c00 100644 --- a/src/client/src/app/services/universal-dashboard-service.jsx +++ b/src/client/src/app/services/universal-dashboard-service.jsx @@ -7,6 +7,10 @@ import toaster from './toaster'; export const UniversalDashboardService = { components: [], + plugins: [], + registerPlugin: function(plugin) { + this.plugins.push(plugin); + }, register: function(type, component) { var existingComponent = this.components.find(x => x.type === type); if (!existingComponent) this.components.push({ @@ -44,5 +48,56 @@ export const UniversalDashboardService = { } return internalRenderComponent(component, history); + }, + provideDashboardComponents: function(state) { + + var components = []; + + this.plugins.forEach(x => { + try + { + var pluginComponents = x.provideDashboardComponents(state); + + if (pluginComponents == null) { + return; + } + + if (Array.isArray(pluginComponents)) { + components = components.concat(pluginComponents); + } else { + components.push(pluginComponents); + } + } + catch + { + + } + }) + + return components; + }, + provideRoutes: function() { + return this.plugins.forEach(x => { + try + { + return x.provideRoutes(); + } + catch + { + + } + }) + }, + invokeMiddleware: function(method, url, history, response) { + this.plugins.forEach(x => { + try + { + x.invokeMiddleware(method, url, history, response); + } + catch + { + + } + }) } } \ No newline at end of file diff --git a/src/client/src/app/ud-dashboard.jsx b/src/client/src/app/ud-dashboard.jsx index 36f7f674..6c8fce24 100644 --- a/src/client/src/app/ud-dashboard.jsx +++ b/src/client/src/app/ud-dashboard.jsx @@ -350,6 +350,8 @@ export default class UdDashboard extends React.Component { design = } + var pluginComponents = UniversalDashboard.provideDashboardComponents(this.state); + var components = [
}.bind(this)}/>, - design + design, + pluginComponents ] if (!this.state.licensed) {