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