mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
Add protocol objects and parameters, migrate to those objects (rather than simple stub JSON).
This commit is contained in:
@@ -185,10 +185,10 @@ GuacAdmin.Field.ENUM = function(values) {
|
|||||||
|
|
||||||
// Create backing element
|
// Create backing element
|
||||||
var element = GuacUI.createElement("select");
|
var element = GuacUI.createElement("select");
|
||||||
for (var name in values) {
|
for (var i=0; i<values.length; i++) {
|
||||||
var option = GuacUI.createChildElement(element, "option");
|
var option = GuacUI.createChildElement(element, "option");
|
||||||
option.textContent = values[name];
|
option.textContent = values[i].title;
|
||||||
option.value = name;
|
option.value = values[i].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getValue = function() {
|
this.getValue = function() {
|
||||||
@@ -803,19 +803,20 @@ GuacAdmin.addConnection = function(connection) {
|
|||||||
var field;
|
var field;
|
||||||
switch (parameter.type) {
|
switch (parameter.type) {
|
||||||
|
|
||||||
case "text":
|
case GuacamoleService.Protocol.Parameter.TEXT:
|
||||||
|
case GuacamoleService.Protocol.Parameter.NUMERIC:
|
||||||
field = new GuacAdmin.Field.TEXT();
|
field = new GuacAdmin.Field.TEXT();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "password":
|
case GuacamoleService.Protocol.Parameter.PASSWORD:
|
||||||
field = new GuacAdmin.Field.PASSWORD();
|
field = new GuacAdmin.Field.PASSWORD();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "boolean":
|
case GuacamoleService.Protocol.Parameter.BOOLEAN:
|
||||||
field = new GuacAdmin.Field.CHECKBOX(parameter.value);
|
field = new GuacAdmin.Field.CHECKBOX(parameter.value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "enum":
|
case GuacamoleService.Protocol.Parameter.ENUM:
|
||||||
field = new GuacAdmin.Field.ENUM(parameter.options);
|
field = new GuacAdmin.Field.ENUM(parameter.options);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -739,6 +739,107 @@ GuacamoleService.Permissions = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representation of a protocol supported by Guacamole, having a given name,
|
||||||
|
* title, and set of parameters.
|
||||||
|
*/
|
||||||
|
GuacamoleService.Protocol = function(name, title, parameters) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unique name associated with this protocol. This is the name that is
|
||||||
|
* used to identify the protocol to Guacamole.
|
||||||
|
*/
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A human-readable title describing this protocol. This is what the user
|
||||||
|
* will use to identify the protocol.
|
||||||
|
*/
|
||||||
|
this.title = title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of all available parameters, in desired order of presentation.
|
||||||
|
* @type GuacamoleService.Protocol.Parameter[]
|
||||||
|
*/
|
||||||
|
this.parameters = parameters || [];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A parameter belonging to a protocol. Each parameter has a name which
|
||||||
|
* identifies the parameter to the protocol, a human-readable title, and a type
|
||||||
|
* which dictates its presentation to the user.
|
||||||
|
*/
|
||||||
|
GuacamoleService.Protocol.Parameter = function(name, title, type, options) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of this parameter.
|
||||||
|
*/
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A human-readable title describing this parameter.
|
||||||
|
*/
|
||||||
|
this.title = title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of this parameter.
|
||||||
|
*/
|
||||||
|
this.type = type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All available options, if applicable, in desired order of presentation.
|
||||||
|
* @type GuacamoleService.Protocol.Parameter.Option[]
|
||||||
|
*/
|
||||||
|
this.options = options || [];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An option for a parameter. A parameter has options if it only has a specified
|
||||||
|
* and enumerated legal set of values.
|
||||||
|
*/
|
||||||
|
GuacamoleService.Protocol.Parameter.Option = function(value, title) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value of this option. This is the value that will be assigned to the
|
||||||
|
* parameter if this option is chosen.
|
||||||
|
*/
|
||||||
|
this.value = value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The title of this option. This is the value that will be presented to the
|
||||||
|
* user for selection.
|
||||||
|
*/
|
||||||
|
this.title = title;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A free-form text field.
|
||||||
|
*/
|
||||||
|
GuacamoleService.Protocol.Parameter.TEXT = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A password field.
|
||||||
|
*/
|
||||||
|
GuacamoleService.Protocol.Parameter.PASSWORD = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A numeric field.
|
||||||
|
*/
|
||||||
|
GuacamoleService.Protocol.Parameter.NUMERIC = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A boolean (checkbox) field.
|
||||||
|
*/
|
||||||
|
GuacamoleService.Protocol.Parameter.BOOLEAN = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An enumerated (select) field.
|
||||||
|
*/
|
||||||
|
GuacamoleService.Protocol.Parameter.ENUM = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection of service functions which deal with protocols. Each function
|
* Collection of service functions which deal with protocols. Each function
|
||||||
* makes an explicit HTTP query to the server, and parses the response.
|
* makes an explicit HTTP query to the server, and parses the response.
|
||||||
@@ -756,86 +857,43 @@ GuacamoleService.Protocols = {
|
|||||||
* @param {String} parameters Any parameters which should be passed to the
|
* @param {String} parameters Any parameters which should be passed to the
|
||||||
* server for the sake of authentication
|
* server for the sake of authentication
|
||||||
* (optional).
|
* (optional).
|
||||||
* @return {Array} An array containing all available protocols.
|
* @return {GuacamoleService.Protocol[]} An array containing all available
|
||||||
|
* protocols.
|
||||||
*/
|
*/
|
||||||
"list" : function(parameters) {
|
"list" : function(parameters) {
|
||||||
|
|
||||||
|
var vnc = new GuacamoleService.Protocol(
|
||||||
|
"vnc", "VNC", [
|
||||||
|
|
||||||
|
new GuacamoleService.Protocol.Parameter(
|
||||||
|
"hostname", "Hostname",
|
||||||
|
GuacamoleService.Protocol.Parameter.TEXT),
|
||||||
|
|
||||||
|
new GuacamoleService.Protocol.Parameter(
|
||||||
|
"port", "Port",
|
||||||
|
GuacamoleService.Protocol.Parameter.NUMERIC),
|
||||||
|
|
||||||
|
new GuacamoleService.Protocol.Parameter(
|
||||||
|
"color-depth", "Color depth",
|
||||||
|
GuacamoleService.Protocol.Parameter.ENUM,
|
||||||
|
[
|
||||||
|
new GuacamoleService.Protocol.Parameter.Option(
|
||||||
|
"8", "256 colors"),
|
||||||
|
new GuacamoleService.Protocol.Parameter.Option(
|
||||||
|
"16", "High color (16-bit)"),
|
||||||
|
new GuacamoleService.Protocol.Parameter.Option(
|
||||||
|
"24", "True color (24-bit)")
|
||||||
|
]),
|
||||||
|
|
||||||
|
new GuacamoleService.Protocol.Parameter(
|
||||||
|
"read-only", "Read-only",
|
||||||
|
GuacamoleService.Protocol.Parameter.BOOLEAN)
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
// FIXME: STUB
|
// FIXME: STUB
|
||||||
return [{
|
return [vnc];
|
||||||
|
|
||||||
/* Unique name */
|
|
||||||
"name" : "vnc",
|
|
||||||
|
|
||||||
/* Display title */
|
|
||||||
"title" : "VNC",
|
|
||||||
|
|
||||||
/* All available parameters */
|
|
||||||
"parameters" : {
|
|
||||||
|
|
||||||
"hostname" : {
|
|
||||||
"title" : "Hostname",
|
|
||||||
"type" : "text"
|
|
||||||
},
|
|
||||||
|
|
||||||
"port" : {
|
|
||||||
"title" : "Port",
|
|
||||||
"type" : "text",
|
|
||||||
"value" : "5900"
|
|
||||||
},
|
|
||||||
|
|
||||||
"color-depth" : {
|
|
||||||
"title" : "Color depth",
|
|
||||||
"type" : "enum",
|
|
||||||
"options" : {
|
|
||||||
"8" : "256 colors",
|
|
||||||
"16": "High color (16-bit)",
|
|
||||||
"24": "True color (24-bit)"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"read-only" : {
|
|
||||||
"title" : "Read-only",
|
|
||||||
"type" : "boolean",
|
|
||||||
"value" : "true"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}, {
|
|
||||||
|
|
||||||
/* Unique name */
|
|
||||||
"name" : "rdp",
|
|
||||||
|
|
||||||
/* Display title */
|
|
||||||
"title" : "RDP",
|
|
||||||
|
|
||||||
/* All available parameters */
|
|
||||||
"parameters" : {
|
|
||||||
|
|
||||||
"hostname" : {
|
|
||||||
"title" : "Hostname",
|
|
||||||
"type" : "text"
|
|
||||||
},
|
|
||||||
|
|
||||||
"port" : {
|
|
||||||
"title" : "Port",
|
|
||||||
"type" : "text",
|
|
||||||
"value" : "3389"
|
|
||||||
},
|
|
||||||
|
|
||||||
"username" : {
|
|
||||||
"title" : "Username",
|
|
||||||
"type" : "text"
|
|
||||||
},
|
|
||||||
|
|
||||||
"password" : {
|
|
||||||
"title" : "Password",
|
|
||||||
"type" : "password"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user