Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdriscoll committed Jun 18, 2019
1 parent ac14525 commit 0220d2e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/client/src/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ export default class App extends React.Component {
</div>
}

var pluginRoutes = UniversalDashboard.provideRoutes();

return (<Router>
<div className="ud-dashboard">
<Route path="/login" component={Login} />
<Route path="/signin" component={Login} />
<Route path="/license" component={License}/>
{pluginRoutes}
<Route path={regex} component={UdDashboard} />
</div>
</Router> )
Expand Down
3 changes: 3 additions & 0 deletions src/client/src/app/services/fetch-service.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
55 changes: 55 additions & 0 deletions src/client/src/app/services/universal-dashboard-service.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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
{

}
})
}
}
5 changes: 4 additions & 1 deletion src/client/src/app/ud-dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ export default class UdDashboard extends React.Component {
design = <UDDesign />
}

var pluginComponents = UniversalDashboard.provideDashboardComponents(this.state);

var components = [
<header>
<UdNavbar backgroundColor={this.state.dashboard.navBarColor}
Expand Down Expand Up @@ -382,7 +384,8 @@ export default class UdDashboard extends React.Component {
<UdPageCyclerComponent history={x.history} pages={this.state.dashboard.pages} cyclePages={this.state.dashboard.cyclePages && !this.state.pausePageCycle} cyclePagesInterval={this.state.dashboard.cyclePagesInterval} />
</Suspense>
}.bind(this)}/>,
design
design,
pluginComponents
]

if (!this.state.licensed) {
Expand Down

0 comments on commit 0220d2e

Please sign in to comment.