3
3
*
4
4
* A DCN topology viewer based on Leaflet Javascript library.
5
5
*
6
- * @copyright Copyright (c) 2019 RNP
6
+ * @copyright Copyright (c) 2022 RNP
7
7
* @license http://github.com/ufrgs-hyman/meican#license
8
8
* @author Mauricio Quatrin Guerreiro
9
9
*/
@@ -15,6 +15,7 @@ function LMap(canvasDivId) {
15
15
this . _canvasDivId = canvasDivId ;
16
16
this . _map ; // Leaflet Map
17
17
this . _nodes = [ ] ; // markers/nodes container
18
+ this . _stackDomainsToBeExpanded = [ ] ;
18
19
this . _nodesL = [ ] ;
19
20
this . _nodesN = [ ] ;
20
21
this . _links = [ ] ; // polylines/links/edges container
@@ -26,6 +27,7 @@ function LMap(canvasDivId) {
26
27
this . _nodeAutoInc = 1 ;
27
28
this . _linkAutoInc = 1 ;
28
29
this . _expandedDomainNodes = [ ] ;
30
+ this . _lockRoutine = false ;
29
31
} ;
30
32
31
33
LMap . prototype . show = function ( instantRefresh ) {
@@ -128,6 +130,38 @@ LMap.prototype.getPortsByLocation = function(location_name) {
128
130
return locations ;
129
131
}
130
132
133
+ LMap . prototype . getQtdPortsByDomain = function ( domain_id ) {
134
+ let qtd_ports = 0 ;
135
+
136
+ for ( let i = this . _topology [ 'ports' ] . length - 1 ; i >= 0 ; i -- )
137
+ if ( this . _topology [ 'ports' ] [ i ] . network . domain . id == domain_id )
138
+ qtd_ports ++ ;
139
+
140
+ return qtd_ports ;
141
+ }
142
+
143
+ LMap . prototype . getQtdPortsWithLocationByDomain = function ( domain_id ) {
144
+ let qtd_ports = 0 ;
145
+
146
+ for ( let i = this . _topology [ 'ports' ] . length - 1 ; i >= 0 ; i -- )
147
+ if ( this . _topology [ 'ports' ] [ i ] . network . domain . id == domain_id )
148
+ if ( this . _topology [ 'ports' ] [ i ] . lat != null )
149
+ if ( this . _topology [ 'ports' ] [ i ] . lng != null )
150
+ qtd_ports ++ ;
151
+
152
+ return qtd_ports ;
153
+ }
154
+
155
+ LMap . prototype . getQtdLocationsByDomain = function ( domain_id ) {
156
+ let qtd_ports = 0 ;
157
+
158
+ for ( let i = this . _topology [ 'locations' ] . length - 1 ; i >= 0 ; i -- )
159
+ if ( this . _topology [ 'locations' ] [ i ] . network . domain . id == domain_id )
160
+ qtd_ports ++ ;
161
+
162
+ return qtd_ports ;
163
+ }
164
+
131
165
LMap . prototype . addIntraLink = function ( location_link ) {
132
166
if ( ! location_link . source || ! location_link . destination )
133
167
return null ;
@@ -383,6 +417,11 @@ LMap.prototype.addNode = function(port, color, mode) {
383
417
384
418
this . _nodes . push ( node ) ;
385
419
this . _cluster . addLayer ( node ) ;
420
+ if ( ! flagPortLocation ) {
421
+ if ( port . network . domain . grouped_nodes == 0 ) {
422
+ this . _stackDomainsToBeExpanded . push ( node . options . id ) ;
423
+ }
424
+ }
386
425
387
426
var currentMap = this ;
388
427
@@ -410,7 +449,6 @@ LMap.prototype.addNode = function(port, color, mode) {
410
449
className : 'marker-icon-svg' ,
411
450
} ) ) ;
412
451
}
413
-
414
452
}
415
453
416
454
LMap . prototype . prepareLabels = function ( ) {
@@ -808,7 +846,18 @@ LMap.prototype.focusNodes = function() {
808
846
}
809
847
810
848
LMap . prototype . loadTopology = function ( withLinks ) {
849
+ var current = this ;
850
+
811
851
this . _loadDomains ( withLinks ) ;
852
+
853
+ // Expansion of locations of domains with this property
854
+ $ ( document ) . ajaxStop ( function ( ) {
855
+ while ( current . _stackDomainsToBeExpanded . length > 0 ) {
856
+ current . expandLocations ( current . _stackDomainsToBeExpanded . pop ( ) ) ;
857
+ current . removeLinks ( ) ;
858
+ current . _loadLinks ( ) ;
859
+ }
860
+ } ) ;
812
861
}
813
862
814
863
LMap . prototype . _loadDomains = function ( withLinks ) {
@@ -891,8 +940,9 @@ LMap.prototype._loadPorts = function(withLinks) {
891
940
}
892
941
893
942
for ( var i = current . _topology [ 'ports' ] . length - 1 ; i >= 0 ; i -- ) {
894
- if ( current . _topology [ 'ports' ] [ i ] . type == 'NSI' )
943
+ if ( current . _topology [ 'ports' ] [ i ] . type == 'NSI' ) {
895
944
current . addNode ( current . _topology [ 'ports' ] [ i ] ) ;
945
+ }
896
946
}
897
947
current . prepareLabels ( ) ;
898
948
if ( withLinks )
@@ -1044,17 +1094,21 @@ LMap.prototype.expandLocations = function(nodeId) {
1044
1094
let nodes = this . getNodes ( ) ;
1045
1095
let ports = this . getTopology ( ) [ 'ports' ] ;
1046
1096
let domainId = node . options . ports [ 0 ] . network . domain_id ;
1047
-
1048
- this . addExpandedDomainNode ( node ) ;
1049
1097
1050
- for ( var i = ports . length - 1 ; i >= 0 ; i -- ) {
1051
- if ( ports [ i ] . network . domain_id == domainId ) {
1052
- this . addNode (
1053
- ports [ i ]
1054
- ) ;
1098
+ if ( this . getQtdPortsWithLocationByDomain ( domainId ) > 0 ) {
1099
+ this . addExpandedDomainNode ( node ) ;
1100
+
1101
+ for ( var i = ports . length - 1 ; i >= 0 ; i -- ) {
1102
+ if ( ports [ i ] . network . domain_id == domainId ) {
1103
+ this . addNode (
1104
+ ports [ i ]
1105
+ ) ;
1106
+ }
1055
1107
}
1108
+ this . hideNode ( node ) ;
1056
1109
}
1057
- this . hideNode ( node ) ;
1110
+
1111
+ flagPortLocation = false ;
1058
1112
}
1059
1113
1060
1114
LMap . prototype . groupLocations = function ( nodeId ) {
0 commit comments