@@ -678,6 +678,7 @@ export default {
678
678
}
679
679
}
680
680
},
681
+
681
682
/**
682
683
* Get a nested object of families
683
684
* @property {Family} store - nested object of families
@@ -706,6 +707,7 @@ export default {
706
707
}
707
708
return store
708
709
},
710
+
709
711
/**
710
712
* Removes a node from an array of nodes
711
713
* @property {String} nodeName - name of node to be removed
@@ -720,6 +722,7 @@ export default {
720
722
})
721
723
return nodesFiltered
722
724
},
725
+
723
726
/**
724
727
* Creates an edge from the name and cycle of source and target nodes
725
728
* @property {String} edgeType - config option 'noCollapsed'|'collapsedTarget'|'collapsedSource'|'collapsedSourceAndTarget'
@@ -768,6 +771,7 @@ export default {
768
771
},
769
772
}
770
773
},
774
+
771
775
/**
772
776
* Removes an edge from an array of edges
773
777
* @property {String} sourceName - name of source node of edge to be removed
@@ -785,6 +789,7 @@ export default {
785
789
(edge ) => edge .id .indexOf (edgeSearchTerm) === - 1
786
790
)
787
791
},
792
+
788
793
/**
789
794
* Removes an edges from an array of edges based on source node
790
795
* @property {Node[]} edgeCheckSource - array of edges that have been identified as needing removal from the graph
@@ -806,6 +811,7 @@ export default {
806
811
}
807
812
return [edges, removedEdges]
808
813
},
814
+
809
815
/**
810
816
* Removes an edges from an array of edges based on target node
811
817
* @property {Node[]} edgeCheckTarget - array of edges that have been identified as needing removal from the graph
@@ -827,6 +833,7 @@ export default {
827
833
}
828
834
return [edges, removedEdges]
829
835
},
836
+
830
837
/**
831
838
* Filters edges array based on source node
832
839
* @property {String} sourceName - name of source node of edge to be removed
@@ -843,6 +850,7 @@ export default {
843
850
})
844
851
return edgeSearch
845
852
},
853
+
846
854
/**
847
855
* Filters edges array based on target node
848
856
* @property {String} targetName - name of target node of edge to be removed
@@ -859,6 +867,7 @@ export default {
859
867
})
860
868
return edgeSearch
861
869
},
870
+
862
871
/**
863
872
* Check if node is collapsed by family or ancestor
864
873
* If not collapsed return null
@@ -889,6 +898,7 @@ export default {
889
898
return null
890
899
}
891
900
},
901
+
892
902
mountSVGPanZoom () {
893
903
// Check the SVG is ready:
894
904
// * The SVG document must be rendered with something in it before we can
@@ -938,9 +948,11 @@ export default {
938
948
// Center the view after load:
939
949
this .reset ()
940
950
},
951
+
941
952
setOption (option , value ) {
942
953
this [option] = value
943
954
},
955
+
944
956
updateTimer () {
945
957
// turn the timer on or off depending on the value of autoRefresh
946
958
// if initialLoad is true we want to set a refresh interval
@@ -952,14 +964,17 @@ export default {
952
964
this .refreshTimer = null
953
965
}
954
966
},
967
+
955
968
increaseSpacing () {
956
969
// increase graph layout node spacing by 10%
957
970
this .spacing = this .spacing * 1.1
958
971
},
972
+
959
973
decreaseSpacing () {
960
974
// decrease graph layout node spacing by 10%
961
975
this .spacing = this .spacing * (10 / 11 )
962
976
},
977
+
963
978
getGraphNodes () {
964
979
// list graph nodes from the store (non reactive list)
965
980
const ret = []
@@ -972,6 +987,7 @@ export default {
972
987
}
973
988
return ret
974
989
},
990
+
975
991
getGraphEdges () {
976
992
// list graph edges from the store (non reactive list)
977
993
const ret = []
@@ -982,6 +998,7 @@ export default {
982
998
}
983
999
return ret
984
1000
},
1001
+
985
1002
/**
986
1003
* Get the dimensions of currently rendered graph nodes
987
1004
* (we feed these dimensions into the GraphViz dot code to improve layout).
@@ -1003,6 +1020,7 @@ export default {
1003
1020
}
1004
1021
return ret
1005
1022
},
1023
+
1006
1024
/**
1007
1025
* Get the nodes binned by cycle point
1008
1026
*
@@ -1015,6 +1033,7 @@ export default {
1015
1033
return x
1016
1034
}, {})
1017
1035
},
1036
+
1018
1037
/**
1019
1038
* Recursive function that adds a subgraph to the dot code
1020
1039
*
@@ -1108,6 +1127,7 @@ export default {
1108
1127
}
1109
1128
}
1110
1129
},
1130
+
1111
1131
getDotCode (nodeDimensions , nodes , edges , cycles ) {
1112
1132
// return GraphViz dot code for the given nodes, edges and dimensions
1113
1133
const ret = [' digraph {' ]
@@ -1228,19 +1248,22 @@ export default {
1228
1248
ret .push (' }' )
1229
1249
return ret .join (' \n ' )
1230
1250
},
1251
+
1231
1252
hashGraph (nodes , edges ) {
1232
1253
// generate a hash for this list of nodes and edges
1233
1254
return nonCryptoHash (
1234
1255
nodes .map (n => n .id ).reduce ((x , y ) => { return x + y }) +
1235
1256
(edges || []).map (n => n .id ).reduce ((x , y ) => { return x + y }, 1 )
1236
1257
)
1237
1258
},
1259
+
1238
1260
reset () {
1239
1261
// pan / zoom so that the graph is centered and in frame
1240
1262
this .panZoomTo (
1241
1263
this .$refs .graph .getElementsByClassName (' svg-pan-zoom_viewport' )[0 ]
1242
1264
)
1243
1265
},
1266
+
1244
1267
panZoomTo (ele ) {
1245
1268
// pan / zoom so that the provided SVG element is centered and in frame
1246
1269
// Acknowledgment: Code adapted from suggestion from @iftahh in
@@ -1264,6 +1287,31 @@ export default {
1264
1287
const desiredWidth = 50 * Math .sqrt (bbox .width / 25 ) * 11 * realZoom
1265
1288
this .panZoomWidget .zoom (relativeZoom * width / desiredWidth)
1266
1289
},
1290
+
1291
+ edgeHasCollapsedTargetFamilyOnly (targetFirstFamily , sourceFirstFamily ) {
1292
+ const target = this .isNodeCollapsedByFamily (targetFirstFamily)
1293
+ if (target && ! this .isNodeCollapsedByFamily (sourceFirstFamily)) {
1294
+ return { target }
1295
+ }
1296
+ },
1297
+
1298
+ edgeHasCollapsedSourceFamilyOnly (targetFirstFamily , sourceFirstFamily ) {
1299
+ const source = this .isNodeCollapsedByFamily (sourceFirstFamily)
1300
+ if (source && ! this .isNodeCollapsedByFamily (targetFirstFamily)) {
1301
+ return { source }
1302
+ }
1303
+ },
1304
+
1305
+ edgeHasCollapsedTargetandSourceFamily (targetFirstFamily , sourceFirstFamily ) {
1306
+ const target = this .isNodeCollapsedByFamily (targetFirstFamily)
1307
+ if (target) {
1308
+ const source = this .isNodeCollapsedByFamily (sourceFirstFamily)
1309
+ if (source) {
1310
+ return { target, source }
1311
+ }
1312
+ }
1313
+ },
1314
+
1267
1315
async refresh () {
1268
1316
// refresh the graph layout if required
1269
1317
if (this .updating ) {
@@ -1322,39 +1370,6 @@ export default {
1322
1370
}
1323
1371
}
1324
1372
1325
- const edgeHasCollapsedTargetFamilyOnly = (targetFirstFamily , sourceFirstFamily ) => {
1326
- if (this .isNodeCollapsedByFamily (targetFirstFamily) && ! this .isNodeCollapsedByFamily (sourceFirstFamily)) {
1327
- return {
1328
- target: this .isNodeCollapsedByFamily (targetFirstFamily),
1329
- source: undefined
1330
- }
1331
- } else {
1332
- return false
1333
- }
1334
- }
1335
-
1336
- const edgeHasCollapsedSourceFamilyOnly = (targetFirstFamily , sourceFirstFamily ) => {
1337
- if (! this .isNodeCollapsedByFamily (targetFirstFamily) && this .isNodeCollapsedByFamily (sourceFirstFamily)) {
1338
- return {
1339
- target: undefined ,
1340
- source: this .isNodeCollapsedByFamily (sourceFirstFamily)
1341
- }
1342
- } else {
1343
- return false
1344
- }
1345
- }
1346
-
1347
- const edgeHasCollapsedTargetandSourceFamily = (targetFirstFamily , sourceFirstFamily ) => {
1348
- if (this .isNodeCollapsedByFamily (targetFirstFamily) && this .isNodeCollapsedByFamily (sourceFirstFamily)) {
1349
- return {
1350
- target: this .isNodeCollapsedByFamily (targetFirstFamily),
1351
- source: this .isNodeCollapsedByFamily (sourceFirstFamily)
1352
- }
1353
- } else {
1354
- return false
1355
- }
1356
- }
1357
-
1358
1373
// ...this node is collapsed so need to remove any of its children (nodes and edges) from the graph if it has any...
1359
1374
for (const config of this .allChildrenLookUp [indexSearch .id ]) {
1360
1375
const edgeCheckSource = this .checkForEdgeBySource (config .name , cycle, removedEdges)
@@ -1366,18 +1381,16 @@ export default {
1366
1381
const sourceFamilyName = this .cylcTree .$index [edge .node .source ].node .firstParent .name
1367
1382
const targetFamilyName = this .cylcTree .$index [edge .node .target ].node .firstParent .name
1368
1383
1369
- if (edgeHasCollapsedSourceFamilyOnly (targetFamilyName, sourceFamilyName )) {
1370
- if ( ! this .collapseCycle . includes (sourceCycle)) {
1371
- const familyData = edgeHasCollapsedSourceFamilyOnly (targetFamilyName, sourceFamilyName)
1384
+ if (! this . collapseCycle . includes (sourceCycle )) {
1385
+ const familyData = this .edgeHasCollapsedSourceFamilyOnly (targetFamilyName, sourceFamilyName)
1386
+ if (familyData) {
1372
1387
this .edgeTemplate = this .createEdge (' noCollapsed' , familyData .source , targetName, sourceCycle, targetCycle)
1373
1388
edges .push (this .edgeTemplate )
1374
1389
}
1375
- }
1376
1390
1377
- if (edgeHasCollapsedTargetandSourceFamily (targetFamilyName, sourceFamilyName)) {
1378
- if (! this .collapseCycle .includes (sourceCycle) && ! this .collapseCycle .includes (targetCycle)) {
1379
- const familyData = edgeHasCollapsedTargetandSourceFamily (targetFamilyName, sourceFamilyName)
1380
- if (familyData .source !== familyData .target || sourceCycle !== targetCycle) {
1391
+ if (! this .collapseCycle .includes (targetCycle)) {
1392
+ const familyData = this .edgeHasCollapsedTargetandSourceFamily (targetFamilyName, sourceFamilyName)
1393
+ if (familyData && (familyData .source !== familyData .target || sourceCycle !== targetCycle)) {
1381
1394
this .edgeTemplate = this .createEdge (' noCollapsed' , familyData .source , familyData .target , sourceCycle, targetCycle)
1382
1395
edges .push (this .edgeTemplate )
1383
1396
}
@@ -1394,18 +1407,16 @@ export default {
1394
1407
const sourceFamilyName = this .cylcTree .$index [edge .node .source ].node .firstParent .name
1395
1408
const targetFamilyName = this .cylcTree .$index [edge .node .target ].node .firstParent .name
1396
1409
1397
- if (edgeHasCollapsedTargetFamilyOnly (targetFamilyName, sourceFamilyName )) {
1398
- if ( ! this .collapseCycle . includes (targetCycle)) {
1399
- const familyData = edgeHasCollapsedTargetFamilyOnly (targetFamilyName, sourceFamilyName)
1410
+ if (! this . collapseCycle . includes (targetCycle )) {
1411
+ const familyData = this .edgeHasCollapsedTargetFamilyOnly (targetFamilyName, sourceFamilyName)
1412
+ if (familyData) {
1400
1413
this .edgeTemplate = this .createEdge (' noCollapsed' , sourceName, familyData .target , sourceCycle, targetCycle)
1401
1414
edges .push (this .edgeTemplate )
1402
1415
}
1403
- }
1404
1416
1405
- if (edgeHasCollapsedTargetandSourceFamily (targetFamilyName, sourceFamilyName)) {
1406
- if (! this .collapseCycle .includes (sourceCycle) && ! this .collapseCycle .includes (targetCycle)) {
1407
- const familyData = edgeHasCollapsedTargetandSourceFamily (targetFamilyName, sourceFamilyName)
1408
- if (familyData .source !== familyData .target || sourceCycle !== targetCycle) {
1417
+ if (! this .collapseCycle .includes (sourceCycle)) {
1418
+ const familyData = this .edgeHasCollapsedTargetandSourceFamily (targetFamilyName, sourceFamilyName)
1419
+ if (familyData && (familyData .source !== familyData .target || sourceCycle !== targetCycle)) {
1409
1420
this .edgeTemplate = this .createEdge (' noCollapsed' , familyData .source , familyData .target , sourceCycle, targetCycle)
1410
1421
edges .push (this .edgeTemplate )
1411
1422
}
@@ -1588,6 +1599,7 @@ export default {
1588
1599
this .graphID = graphID
1589
1600
this .updating = false
1590
1601
},
1602
+
1591
1603
async waitFor (callback , retries = 10 ) {
1592
1604
// wait for things to render
1593
1605
// Will return when the callback returns something truthy.
@@ -1599,6 +1611,7 @@ export default {
1599
1611
await this .$nextTick ()
1600
1612
}
1601
1613
},
1614
+
1602
1615
/**
1603
1616
* Re-layout the graph after any new nodes have been rendered.
1604
1617
*
0 commit comments