@@ -134,15 +134,6 @@ function onChangeRuleInterfaceOperState(labData) {
134134 if ( ! lab || ! Array . isArray ( lab . containers ) ) continue ;
135135 lab . containers . forEach ( container => {
136136 if ( typeof container . label !== "string" ) return ;
137- // Remove lab-specific prefix; adjust the regex as needed.
138- // const nodeName = container.label.replace(/^clab-.*?-/, '');
139-
140- // const nodeClabName = container.label
141-
142- // const getRouterName = (fullString, keyword) =>
143- // fullString.split(keyword)[1].replace(/^-/, '');
144-
145- // nodeName = getRouterName(nodeClabName, lab.name); // Outputs: router1
146137
147138 nodeClabNameShort = container . name_short
148139 nodeName = nodeClabNameShort
@@ -151,14 +142,10 @@ function onChangeRuleInterfaceOperState(labData) {
151142
152143 if ( ! Array . isArray ( container . interfaces ) ) return ;
153144 container . interfaces . forEach ( iface => {
154- // if (!iface || typeof iface.name !== "string") return;
155- // if (!iface || typeof iface.alias !== "string") return;
156145 if ( ! iface || typeof iface . label !== "string" ) return ; // aarafat-tag: intf.name is replaced with intf.label; why not intf.alias? intf.alias not available when default for interfaceName is used.
157146
158147 const description = iface . description || "" ;
159148 const state = description . toUpperCase ( ) . includes ( "UP" ) ? "Up" : "Down" ;
160- // const endpoint = iface.name;
161- // const endpoint = iface.alias;
162149 const endpoint = iface . label ;
163150
164151 const key = `${ nodeName } ::${ endpoint } ` ;
@@ -206,22 +193,22 @@ function onChangeHandlerInterfaceOperState(updateMessage) {
206193
207194 const { nodeName, monitoredObject, state, removed } = updateMessage ;
208195 const safeNodeName = typeof CSS !== "undefined" ? CSS . escape ( nodeName ) : nodeName ;
209- // const safeEndpoint = typeof CSS !== "undefined" ? CSS.escape(monitoredObject) : monitoredObject;
210196
211- const safeEndpoint =
212- typeof CSS !== "undefined"
213- ? CSS . escape ( monitoredObject ) . replace ( / \\ \/ / g, "/" )
214- : monitoredObject ;
197+ function customEscape ( str ) {
198+ return str . replace ( / [ " \\ [ \] ] / g, "\\$&" ) ;
199+ }
215200
201+ const safeEndpoint = customEscape ( monitoredObject ) ;
216202
217203 const edgeSelector = `edge[source="${ safeNodeName } "][sourceEndpoint="${ safeEndpoint } "]` ;
218204 const edges = cy . $ ( edgeSelector ) ;
219- console . log ( `managerOnChangeFramework | handler | safeNodeName: ${ safeNodeName } \n safeEndpoint: ${ safeEndpoint } \n edgeSelector: ${ edgeSelector } \n selectedEdges: ${ edges } ` ) ;
205+ console . log ( `managerOnChangeFramework | handler | safeNodeName: ${ safeNodeName } \n safeEndpoint: ${ safeEndpoint } \n edgeSelector: ${ edgeSelector } \n selectedEdges: ${ edges } \n removedStatus: ${ removed } ` ) ;
220206 // Example output:
221207 // managerOnChangeFramework | handler | safeNodeName: router1
222208 // safeEndpoint: ethernet-3\/1
223209 // edgeSelector: edge[source="router1"][sourceEndpoint="ethernet-3\/1"]
224210 // selectedEdges:
211+ // removedStatus:
225212
226213 edgeCollection = edges
227214 // Check if any matching edge was found and retrieve its id
0 commit comments