1
1
import React from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
3
import { withStyles } from '@material-ui/core/styles' ;
4
+ import Fade from '@material-ui/core/Fade' ;
5
+ import CircularProgress from '@material-ui/core/CircularProgress' ;
4
6
import { select as d3_select } from 'd3-selection' ;
5
7
import { selectAll as d3_selectAll } from 'd3-selection' ;
6
8
import { transition as d3_transition } from 'd3-transition' ;
@@ -18,6 +20,11 @@ const styles = {
18
20
flex : {
19
21
flexGrow : 1 ,
20
22
} ,
23
+ progress : {
24
+ position : 'absolute' ,
25
+ top : 'calc(64px + 2 * 12px + 2px)' ,
26
+ left : 'calc(100vw - 2 * 12px - 2 * 12px)' ,
27
+ } ,
21
28
} ;
22
29
23
30
function isNumeric ( n ) {
@@ -27,7 +34,9 @@ function isNumeric(n) {
27
34
class Graph extends React . Component {
28
35
constructor ( props ) {
29
36
super ( props ) ;
30
- this . state = { } ;
37
+ this . state = {
38
+ busy : false ,
39
+ } ;
31
40
this . createGraph = this . createGraph . bind ( this )
32
41
this . renderGraph = this . renderGraph . bind ( this )
33
42
this . isDrawingEdge = false ;
@@ -65,6 +74,7 @@ class Graph extends React.Component {
65
74
let line = errorMessage . replace ( / .* e r r o r i n l i n e ( [ 0 - 9 ] * ) .* \n / , '$1' ) ;
66
75
this . props . onError ( { message : errorMessage , line : line } ) ;
67
76
this . rendering = false ;
77
+ this . setState ( { busy : false } ) ;
68
78
if ( this . pendingUpdate ) {
69
79
this . pendingUpdate = false ;
70
80
this . render ( ) ;
@@ -126,6 +136,7 @@ class Graph extends React.Component {
126
136
return ;
127
137
}
128
138
this . rendering = true ;
139
+ this . setState ( { busy : true } ) ;
129
140
this . graphviz
130
141
. width ( width )
131
142
. height ( height )
@@ -149,6 +160,7 @@ class Graph extends React.Component {
149
160
this . dotGraph = this . prelDotGraph ;
150
161
this . addEventHandlers ( ) ;
151
162
this . rendering = false ;
163
+ this . setState ( { busy : false } ) ;
152
164
if ( ! this . renderGraphReady ) {
153
165
this . renderGraphReady = true ;
154
166
this . setZoomScale ( 1 , true ) ;
@@ -714,12 +726,33 @@ class Graph extends React.Component {
714
726
}
715
727
716
728
render ( ) {
717
- return < div
718
- ref = { div => this . div = d3_select ( div ) }
719
- onDragOver = { this . handleNodeShapeDragOver }
720
- onDrop = { this . handleNodeShapeDrop . bind ( this ) }
721
- >
722
- </ div > ;
729
+ const { classes } = this . props ;
730
+ return (
731
+ < React . Fragment >
732
+ < div
733
+ ref = { div => this . div = d3_select ( div ) }
734
+ onDragOver = { this . handleNodeShapeDragOver }
735
+ onDrop = { this . handleNodeShapeDrop . bind ( this ) }
736
+ >
737
+ </ div >
738
+ { this . state . busy && (
739
+ < Fade
740
+ in = { true }
741
+ style = { {
742
+ transitionDelay : '800ms' ,
743
+ } }
744
+ unmountOnExit
745
+ >
746
+ < CircularProgress
747
+ className = { classes . progress }
748
+ color = "secondary"
749
+ size = { 20 }
750
+ thickness = { 4.5 }
751
+ />
752
+ </ Fade >
753
+ ) }
754
+ </ React . Fragment >
755
+ ) ;
723
756
}
724
757
}
725
758
0 commit comments