mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	Store parent group in Connection and ConnectionGroup.
This commit is contained in:
		| @@ -51,6 +51,14 @@ GuacamoleService.ConnectionGroup = function(type, id, name) { | ||||
|      */ | ||||
|     this.name = name; | ||||
|  | ||||
|     /** | ||||
|      * The parent connection group of this group. If this group is the root | ||||
|      * group, this will be null. | ||||
|      *  | ||||
|      * @type GuacamoleService.ConnectionGroup | ||||
|      */ | ||||
|     this.parent = null; | ||||
|  | ||||
|     /** | ||||
|      * All connection groups contained within this group. | ||||
|      * @type GuacamoleService.ConnectionGroup[] | ||||
| @@ -105,6 +113,12 @@ GuacamoleService.Connection = function(protocol, id, name) { | ||||
|      */ | ||||
|     var guac_connection = this; | ||||
|  | ||||
|     /** | ||||
|      * The parent connection group of this connection. | ||||
|      * @type GuacamoleService.ConnectionGroup | ||||
|      */ | ||||
|     this.parent = null; | ||||
|  | ||||
|     /** | ||||
|      * The protocol associated with this connection. | ||||
|      */ | ||||
| @@ -357,11 +371,13 @@ GuacamoleService.Connections = { | ||||
|          * Parse the contents of the given connection element within XML, | ||||
|          * returning a corresponding GuacamoleService.Connection. | ||||
|          *  | ||||
|          * @param {Element} element | ||||
|          * @param {GuacamoleService.ConnectionGroup} The connection group | ||||
|          *                                           containing this connection. | ||||
|          * @param {Element} element The element being parsed. | ||||
|          * @return {GuacamoleService.Connection} The connection represented by | ||||
|          *                                       the element just parsed. | ||||
|          */ | ||||
|         function parseConnection(element) { | ||||
|         function parseConnection(parent, element) { | ||||
|  | ||||
|             var i; | ||||
|  | ||||
| @@ -371,6 +387,9 @@ GuacamoleService.Connections = { | ||||
|                 element.getAttribute("name") | ||||
|             ); | ||||
|  | ||||
|             // Set parent | ||||
|             connection.parent = parent; | ||||
|  | ||||
|             // Add parameter values for each parmeter received | ||||
|             var paramElements = element.getElementsByTagName("param"); | ||||
|             for (i=0; i<paramElements.length; i++) { | ||||
| @@ -416,12 +435,14 @@ GuacamoleService.Connections = { | ||||
|          * Recursively parse the contents of the given group element within XML, | ||||
|          * returning a corresponding GuacamoleService.ConnectionGroup. | ||||
|          *  | ||||
|          * @param {Element} element | ||||
|          * @param {GuacamoleService.ConnectionGroup} The connection group | ||||
|          *                                           containing this group. | ||||
|          * @param {Element} element The element being parsed. | ||||
|          * @return {GuacamoleService.ConnectionGroup} The connection group | ||||
|          *                                            represented by the element | ||||
|          *                                            just parsed. | ||||
|          */ | ||||
|         function parseGroup(element) { | ||||
|         function parseGroup(parent, element) { | ||||
|  | ||||
|             var id   = element.getAttribute("id"); | ||||
|             var name = element.getAttribute("name"); | ||||
| @@ -437,6 +458,9 @@ GuacamoleService.Connections = { | ||||
|             // Create corresponding group | ||||
|             var group = new GuacamoleService.ConnectionGroup(type, id, name); | ||||
|  | ||||
|             // Set parent | ||||
|             group.parent = parent; | ||||
|  | ||||
|             // For each child element | ||||
|             var current = element.firstChild; | ||||
|             while (current !== null) { | ||||
| @@ -450,7 +474,7 @@ GuacamoleService.Connections = { | ||||
|                     for (i=0; i<children.length; i++) { | ||||
|                         var child = children[i]; | ||||
|                         if (child.localName === "connection") | ||||
|                             group.connections.push(parseConnection(child)); | ||||
|                             group.connections.push(parseConnection(group, child)); | ||||
|                     } | ||||
|                      | ||||
|                 } | ||||
| @@ -460,7 +484,7 @@ GuacamoleService.Connections = { | ||||
|                     for (i=0; i<children.length; i++) { | ||||
|                         var child = children[i]; | ||||
|                         if (child.localName === "group") | ||||
|                             group.groups.push(parseGroup(child)); | ||||
|                             group.groups.push(parseGroup(group, child)); | ||||
|                     } | ||||
|   | ||||
|                 } | ||||
| @@ -490,7 +514,7 @@ GuacamoleService.Connections = { | ||||
|  | ||||
|         // Handle response | ||||
|         GuacamoleService.handleResponse(xhr); | ||||
|         return parseGroup(xhr.responseXML.documentElement); | ||||
|         return parseGroup(null, xhr.responseXML.documentElement); | ||||
|   | ||||
|     }, | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user