This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f318ec
commit 119cfc6
Showing
5 changed files
with
109 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/components/error/CallbackGraph/CallbackGraphContainer.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
73
src/components/error/CallbackGraph/CallbackGraphContainer.react.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters