mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
Initial stab at fixing the CRUD servlets and service JS.
This commit is contained in:
@@ -47,8 +47,8 @@ public class Create extends AuthenticatingHttpServlet {
|
||||
HttpServletRequest request, HttpServletResponse response)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Get ID and protocol
|
||||
String identifier = request.getParameter("id");
|
||||
// Get name and protocol
|
||||
String name = request.getParameter("name");
|
||||
String protocol = request.getParameter("protocol");
|
||||
|
||||
// Attempt to get connection directory
|
||||
@@ -75,7 +75,7 @@ public class Create extends AuthenticatingHttpServlet {
|
||||
|
||||
// Create connection skeleton
|
||||
Connection connection = new DummyConnection();
|
||||
connection.setIdentifier(identifier);
|
||||
connection.setName(name);
|
||||
connection.setConfiguration(config);
|
||||
|
||||
// Add connection
|
||||
|
@@ -126,6 +126,7 @@ public class List extends AuthenticatingHttpServlet {
|
||||
// Write connection
|
||||
xml.writeStartElement("connection");
|
||||
xml.writeAttribute("id", identifier);
|
||||
xml.writeAttribute("name", connection.getName());
|
||||
xml.writeAttribute("protocol",
|
||||
connection.getConfiguration().getProtocol());
|
||||
|
||||
|
@@ -47,9 +47,10 @@ public class Update extends AuthenticatingHttpServlet {
|
||||
HttpServletRequest request, HttpServletResponse response)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Get ID and protocol
|
||||
// Get ID, name, and protocol
|
||||
String identifier = request.getParameter("id");
|
||||
String protocol = request.getParameter("protocol");
|
||||
String name = request.getParameter("name");
|
||||
String protocol = request.getParameter("protocol");
|
||||
|
||||
// Attempt to get connection directory
|
||||
Directory<String, Connection> directory =
|
||||
@@ -75,6 +76,7 @@ public class Update extends AuthenticatingHttpServlet {
|
||||
|
||||
// Create connection skeleton
|
||||
Connection connection = directory.get(identifier);
|
||||
connection.setName(name);
|
||||
connection.setConfiguration(config);
|
||||
|
||||
// Update connection
|
||||
|
@@ -71,7 +71,7 @@
|
||||
</p>
|
||||
|
||||
<div id="connection-add-form">
|
||||
<div class="icon connection add"/><input type="text" id="connection-id" class="name" placeholder="Add connection"/><button id="add-connection">Add</button>
|
||||
<div class="icon connection add"/><input type="text" id="connection-name" class="name" placeholder="Add connection"/><button id="add-connection">Add</button>
|
||||
</div>
|
||||
|
||||
<div id="connection-list">
|
||||
|
@@ -37,8 +37,8 @@ var GuacAdmin = {
|
||||
},
|
||||
|
||||
"fields" : {
|
||||
"connection_id" : document.getElementById("connection-id"),
|
||||
"username" : document.getElementById("username")
|
||||
"connection_name" : document.getElementById("connection-name"),
|
||||
"username" : document.getElementById("username")
|
||||
},
|
||||
|
||||
"cached_permissions" : null,
|
||||
@@ -661,7 +661,7 @@ GuacAdmin.connectionPager = null;
|
||||
*/
|
||||
GuacAdmin.addConnection = function(connection, parameters) {
|
||||
|
||||
var item = new GuacAdmin.ListItem("connection", connection.id);
|
||||
var item = new GuacAdmin.ListItem("connection", connection.name);
|
||||
var item_element = item.getElement();
|
||||
GuacAdmin.connectionPager.addElement(item_element);
|
||||
|
||||
@@ -676,7 +676,7 @@ GuacAdmin.addConnection = function(connection, parameters) {
|
||||
// Create form base elements
|
||||
var form_element = GuacUI.createElement("div", "form");
|
||||
var connection_header = GuacUI.createChildElement(form_element, "h2");
|
||||
connection_header.textContent = connection.id;
|
||||
connection_header.textContent = connection.name;
|
||||
|
||||
var sections = GuacUI.createChildElement(
|
||||
GuacUI.createChildElement(form_element, "div", "settings section"),
|
||||
@@ -885,7 +885,8 @@ GuacAdmin.addConnection = function(connection, parameters) {
|
||||
// Build connection
|
||||
var updated_connection = new GuacamoleService.Connection(
|
||||
protocol_field.value,
|
||||
connection.id
|
||||
connection.id,
|
||||
connection.name
|
||||
);
|
||||
|
||||
// Populate parameters
|
||||
@@ -930,7 +931,7 @@ GuacAdmin.addConnection = function(connection, parameters) {
|
||||
|
||||
// Delete connection upon confirmation
|
||||
if (confirm("Are you sure you want to delete the connection \""
|
||||
+ connection.id + "\"?")) {
|
||||
+ connection.name + "\"?")) {
|
||||
|
||||
// Attempt to delete connection
|
||||
try {
|
||||
@@ -1004,9 +1005,9 @@ GuacAdmin.reset = function() {
|
||||
// Try to create connection
|
||||
try {
|
||||
var connection = new GuacamoleService.Connection(
|
||||
GuacAdmin.cached_protocols[0].name, GuacAdmin.fields.connection_id.value);
|
||||
GuacAdmin.cached_protocols[0].name, null, GuacAdmin.fields.connection_name.value);
|
||||
GuacamoleService.Connections.create(connection, parameters);
|
||||
GuacAdmin.fields.connection_id.value = "";
|
||||
GuacAdmin.fields.connection_name.value = "";
|
||||
GuacAdmin.reset();
|
||||
}
|
||||
|
||||
|
@@ -28,8 +28,9 @@ var GuacamoleService = GuacamoleService || {};
|
||||
* @constructor
|
||||
* @param {String} protocol The protocol used by this connection.
|
||||
* @param {String} id The ID associated with this connection.
|
||||
* @param {String} name The human-readable name associated with this connection.
|
||||
*/
|
||||
GuacamoleService.Connection = function(protocol, id) {
|
||||
GuacamoleService.Connection = function(protocol, id, name) {
|
||||
|
||||
/**
|
||||
* Reference to this connection.
|
||||
@@ -58,7 +59,7 @@ GuacamoleService.Connection = function(protocol, id) {
|
||||
*
|
||||
* @type String[]
|
||||
*/
|
||||
this.path = id.split("/");
|
||||
this.path = name.split("/");
|
||||
|
||||
/**
|
||||
* The name of this connection. This name is arbitrary and local to the
|
||||
@@ -251,7 +252,7 @@ GuacamoleService.Connections = {
|
||||
* Comparator which compares two GuacamoleService.Connection objects.
|
||||
*/
|
||||
"comparator" : function(a, b) {
|
||||
return a.id.localeCompare(b.id);
|
||||
return a.name.localeCompare(b.name);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -288,7 +289,8 @@ GuacamoleService.Connections = {
|
||||
var connectionElement = connectionElements[i];
|
||||
var connection = new GuacamoleService.Connection(
|
||||
connectionElement.getAttribute("protocol"),
|
||||
connectionElement.getAttribute("id")
|
||||
connectionElement.getAttribute("id"),
|
||||
connectionElement.getAttribute("name")
|
||||
)
|
||||
|
||||
var j;
|
||||
@@ -352,7 +354,7 @@ GuacamoleService.Connections = {
|
||||
"create" : function(connection, parameters) {
|
||||
|
||||
// Construct request URL
|
||||
var users_url = "connections/create?id=" + encodeURIComponent(connection.id);
|
||||
var users_url = "connections/create?name=" + encodeURIComponent(connection.name);
|
||||
if (parameters) users_url += "&" + parameters;
|
||||
|
||||
// Init POST data
|
||||
@@ -389,7 +391,9 @@ GuacamoleService.Connections = {
|
||||
if (parameters) users_url += "&" + parameters;
|
||||
|
||||
// Init POST data
|
||||
var data = "protocol=" + encodeURIComponent(connection.protocol);
|
||||
var data =
|
||||
"name=" + encodeURIComponent(connection.name)
|
||||
+ "&protocol=" + encodeURIComponent(connection.protocol);
|
||||
|
||||
// Add parameters
|
||||
for (var name in connection.parameters)
|
||||
|
Reference in New Issue
Block a user