@@ -50,7 +50,7 @@ const SUPPORTED_OPERATION_CATEGORIES = ['Trench', 'ExcavationArea'];
5050 */ 
5151export  class  MatrixViewComponent  implements  OnInit  { 
5252
53-     // The latest svg calculated with GraphViz via DotBuilder based on our component's current settings. 
53+     public   dotGraph :  string | undefined ; 
5454    public  graph : string | undefined ; 
5555
5656    public  graphFromSelection : boolean  =  false ; 
@@ -59,12 +59,11 @@ export class MatrixViewComponent implements OnInit {
5959    public  operations : Array < FieldDocument >  =  [ ] ; 
6060    public  selectedOperation : FieldDocument | undefined ; 
6161    public  configuredOperationCategories : string [ ]  =  [ ] ; 
62+     public  graphvizFailure : boolean  =  false ; 
6263
63-     private  graphviz : Graphviz ; 
6464    private  featureDocuments : Array < FeatureDocument >  =  [ ] ; 
6565    private  totalFeatureDocuments : Array < FeatureDocument >  =  [ ] ; 
6666    private  operationsLoaded : boolean  =  false ; 
67-     private  dotGraph : string ; 
6867
6968
7069    constructor ( private  projectConfiguration : ProjectConfiguration , 
@@ -114,7 +113,6 @@ export class MatrixViewComponent implements OnInit {
114113
115114    async  ngOnInit ( )  { 
116115
117-         this . graphviz  =  await  Graphviz . load ( ) ; 
118116        await  this . matrixState . load ( ) ; 
119117        await  this . populateOperations ( ) ; 
120118
@@ -169,39 +167,57 @@ export class MatrixViewComponent implements OnInit {
169167
170168    public  async  calculateGraph ( )  { 
171169
170+         this . dotGraph  =  undefined ; 
172171        this . graph  =  undefined ; 
172+         this . graphvizFailure  =  false ; 
173+         let  dotGraph : string ; 
173174
174175        this . loading . start ( ) ; 
175-         await  AngularUtility . refresh ( 100 ) ; 
176176
177-         const  edges : {  [ resourceId : string ] : Edges  }  =  EdgesBuilder . build ( 
178-             this . featureDocuments , 
179-             this . totalFeatureDocuments , 
180-             MatrixViewComponent . getRelationConfiguration ( this . matrixState . getRelationsMode ( ) ) 
181-         ) ; 
182- 
183-         this . dotGraph  =  DotBuilder . build ( 
184-             this . projectConfiguration , 
185-             this . getPeriodMap ( this . featureDocuments ,  this . matrixState . getClusterMode ( ) ) , 
186-             edges , 
187-             this . matrixState . getLineMode ( )  ===  'curved' 
188-         ) ; 
189- 
190-         this . graph  =  this . graphviz . dot ( this . dotGraph ) ; 
177+         await  AngularUtility . blurActiveElement ( ) ; 
178+         await  AngularUtility . refresh ( 500 ) ; 
191179
192-         this . loading . stop ( ) ; 
180+         try  { 
181+             const  edges : {  [ resourceId : string ] : Edges  }  =  EdgesBuilder . build ( 
182+                 this . featureDocuments , 
183+                 this . totalFeatureDocuments , 
184+                 MatrixViewComponent . getRelationConfiguration ( this . matrixState . getRelationsMode ( ) ) 
185+             ) ; 
186+     
187+             dotGraph  =  DotBuilder . build ( 
188+                 this . projectConfiguration , 
189+                 this . getPeriodMap ( this . featureDocuments ,  this . matrixState . getClusterMode ( ) ) , 
190+                 edges , 
191+                 this . matrixState . getLineMode ( )  ===  'curved' 
192+             ) ; 
193+         }  catch  ( err )  { 
194+             console . error ( err ) ; 
195+             this . messages . add ( [ M . MATRIX_ERROR_GENERIC ] ) ; 
196+             return  this . loading . stop ( ) ; 
197+         } 
198+   
199+         try  { 
200+             const  graphviz : Graphviz  =  await  Graphviz . load ( ) ; 
201+             this . graph  =  graphviz . dot ( dotGraph ) ; 
202+         }  catch  ( err )  { 
203+             this . graphvizFailure  =  true ; 
204+         }  finally  { 
205+             Graphviz . unload ( ) ; 
206+             this . dotGraph  =  dotGraph ; 
207+             this . loading . stop ( ) ; 
208+         } 
193209    } 
194210
195- 
196211    public  async  exportGraph ( )  { 
197212
213+         if  ( ! this . dotGraph )  return ; 
214+ 
198215        try  { 
199216            await  exportGraph ( 
200217                this . dotGraph , 
201218                this . settingsProvider . getSettings ( ) . selectedProject , 
202219                this . selectedOperation . resource . identifier , 
203220                this . appState , 
204-                 this . graphviz , 
205221                this . modalService , 
206222                $localize  `:@@matrix.export.dotFile:Graphviz-Dot-Datei` 
207223            ) ;  
0 commit comments