Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
rough-in of callback chain vis
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaskruchten committed Apr 13, 2019
1 parent 9f318ec commit bf209af
Show file tree
Hide file tree
Showing 10 changed files with 6,335 additions and 3,702 deletions.
2,970 changes: 2,756 additions & 214 deletions dash_renderer/dash_renderer.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_renderer/dash_renderer.dev.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dash_renderer/dash_renderer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_renderer/dash_renderer.min.js.map

Large diffs are not rendered by default.

6,942 changes: 3,464 additions & 3,478 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"redux-actions": "^0.9.1",
"redux-thunk": "^2.0.1",
"uniqid": "^5.0.3",
"viz.js": "1.8.0",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-partial": "^1.2.0",
Expand Down
8 changes: 8 additions & 0 deletions src/components/error/CallbackGraph/CallbackGraphContainer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.dash-callback-dag--container {
position: absolute;
bottom: 110px;
right: 110px;
max-width: 80vw;
max-height: 80vh;
overflow: scroll;
}
73 changes: 73 additions & 0 deletions src/components/error/CallbackGraph/CallbackGraphContainer.react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, {Component} from 'react';
import './CallbackGraphContainer.css';

import viz from 'viz.js';

import PropTypes from 'prop-types';

class CallbackGraphContainer extends Component {
constructor(props) {
super(props);
}
render() {
const {dependenciesRequest} = this.props;
const elements = {};
const callbacks = [];
const links = dependenciesRequest.content.map(({inputs, output}, i) => {
callbacks.push(`cb${i};`);
function recordAndReturn([id, property]) {
elements[id] = elements[id] || {};
elements[id][property] = true;
return `"${id}.${property}"`;
}
const out_nodes = output
.replace(/^\.\./, '')
.replace(/\.\.$/, '')
.split('...')
.map(o => recordAndReturn(o.split('.')))
.join(', ');
const in_nodes = inputs
.map(({id, property}) => recordAndReturn([id, property]))
.join(', ');
return `{${in_nodes}} -> cb${i} -> {${out_nodes}};`;
});

const dot = `digraph G {
overlap = false; fontname="Arial"; fontcolor="#333333";
edge [color="#888888"];
node [shape=box, fontname="Arial", style=filled, color="#109DFF", fontcolor=white];
graph [penwidth=0];
subgraph callbacks {
node [shape=circle, width=0.3, label="", color="#00CC96"];
${callbacks.join('\n')} }
${Object.entries(elements)
.map(
([id, props], i) => `
subgraph cluster_${i} {
bgcolor="#B9C2CE";
${Object.keys(props)
.map(p => `"${id}.${p}" [label="${p}"];`)
.join('\n')}
label = "${id}"; }`
)
.join('\n')}
${links.join('\n')} }`;

return (
<div
className="dash-callback-dag--container"
dangerouslySetInnerHTML={{
__html: viz(dot, {format: 'svg'}),
}}
/>
);
}
}

CallbackGraphContainer.propTypes = {
dependenciesRequest: PropTypes.object,
};

export {CallbackGraphContainer};
5 changes: 4 additions & 1 deletion src/components/error/GlobalErrorContainer.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ class UnconnectedGlobalErrorContainer extends Component {
}

render() {
const {error, dispatch} = this.props;
const {error, dispatch, dependenciesRequest} = this.props;
return (
<div id="_dash-global-error-container">
<DebugMenu
error={error}
dependenciesRequest={dependenciesRequest}
dispatch={dispatch}
resolveError={this.resolveError}
>
Expand All @@ -38,12 +39,14 @@ class UnconnectedGlobalErrorContainer extends Component {
UnconnectedGlobalErrorContainer.propTypes = {
children: PropTypes.object,
error: PropTypes.object,
dependenciesRequest: PropTypes.object,
dispatch: PropTypes.func,
};

const GlobalErrorContainer = connect(
state => ({
error: state.error,
dependenciesRequest: state.dependenciesRequest,
}),
dispatch => ({dispatch})
)(Radium(UnconnectedGlobalErrorContainer));
Expand Down
30 changes: 25 additions & 5 deletions src/components/error/menu/DebugMenu.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import GraphIcon from '../icons/GraphIcon.svg';
import PropTypes from 'prop-types';
import {DebugAlertContainer} from './DebugAlertContainer.react';
import GlobalErrorOverlay from '../GlobalErrorOverlay.react';
import {CallbackGraphContainer} from '../CallbackGraph/CallbackGraphContainer.react';

class DebugMenu extends Component {
constructor(props) {
Expand All @@ -18,19 +19,30 @@ class DebugMenu extends Component {
this.state = {
opened: false,
alertsOpened: false,
callbackGraphOpened: false,
toastsEnabled: true,
};
}
render() {
const {opened, alertsOpened, toastsEnabled} = this.state;
const {error, resolveError, dispatch} = this.props;
const {
opened,
alertsOpened,
toastsEnabled,
callbackGraphOpened,
} = this.state;
const {error, resolveError, dispatch, dependenciesRequest} = this.props;

const menuClasses = opened
? 'dash-debug-menu dash-debug-menu--opened'
: 'dash-debug-menu dash-debug-menu--closed';

const menuContent = opened ? (
<div className="dash-debug-menu__content">
{callbackGraphOpened ? (
<CallbackGraphContainer
dependenciesRequest={dependenciesRequest}
/>
) : null}
{error.frontEnd.length > 0 || error.backEnd.length > 0 ? (
<div className="dash-debug-menu__button-container">
<DebugAlertContainer
Expand All @@ -43,7 +55,14 @@ class DebugMenu extends Component {
</div>
) : null}
<div className="dash-debug-menu__button-container">
<div className="dash-debug-menu__button">
<div
className="dash-debug-menu__button"
onClick={() =>
this.setState({
callbackGraphOpened: !callbackGraphOpened,
})
}
>
<GraphIcon className="dash-debug-menu__icon dash-debug-menu__icon--graph" />
</div>
<label className="dash-debug-menu__button-label">
Expand Down Expand Up @@ -125,8 +144,9 @@ class DebugMenu extends Component {
DebugMenu.propTypes = {
children: PropTypes.object,
error: PropTypes.object,
resolveError: PropTypes.function,
dispatch: PropTypes.function,
dependenciesRequest: PropTypes.object,
resolveError: PropTypes.any,
dispatch: PropTypes.any,
};

export {DebugMenu};

0 comments on commit bf209af

Please sign in to comment.