mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 21:51:23 +00:00
#268: Implement admin component stubs.
This commit is contained in:
@@ -495,218 +495,3 @@ GuacUI.Connection = function(connection) {
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* An arbitrary table-based form.
|
||||
*/
|
||||
GuacUI.Form = function() {
|
||||
|
||||
var element = GuacUI.createElement("table");
|
||||
|
||||
/**
|
||||
* Returns the DOM element representing this form.
|
||||
*/
|
||||
this.getElement = function() {
|
||||
return element;
|
||||
};
|
||||
|
||||
this.addField = function(title, type, value) {
|
||||
|
||||
// Add elements
|
||||
var row = GuacUI.createChildElement(element, "tr");
|
||||
var header = GuacUI.createChildElement(row, "th");
|
||||
var cell = GuacUI.createChildElement(row, "td");
|
||||
var input = GuacUI.createChildElement(cell, "input");
|
||||
|
||||
// Set title
|
||||
header.textContent = title;
|
||||
|
||||
// Set type and value
|
||||
input.setAttribute("type", type);
|
||||
if (value) input.setAttribute("value", value);
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* A user UI object.
|
||||
*/
|
||||
GuacUI.User = function(username) {
|
||||
|
||||
/**
|
||||
* This user's username.
|
||||
*/
|
||||
this.username = username;
|
||||
|
||||
var user_type = "normal";
|
||||
|
||||
// Create connection display elements
|
||||
var element = GuacUI.createElement("div", "user");
|
||||
var caption = GuacUI.createChildElement(element ,"div", "caption");
|
||||
var type = GuacUI.createChildElement(caption, "div", "type");
|
||||
var name = GuacUI.createChildElement(caption, "span", "name");
|
||||
GuacUI.createChildElement(type, "div", "icon " + user_type);
|
||||
|
||||
// Get URL
|
||||
var url = "user.xhtml?name=" + encodeURIComponent(username);
|
||||
|
||||
// Create link to client
|
||||
element.onclick = function() {
|
||||
|
||||
// Attempt to focus existing window
|
||||
var current = window.open(null, username);
|
||||
|
||||
// If window did not already exist, set up as
|
||||
// Guacamole client
|
||||
if (!current.GuacUI)
|
||||
window.open(url, username);
|
||||
|
||||
};
|
||||
|
||||
// Set name
|
||||
name.textContent = username;
|
||||
|
||||
/**
|
||||
* Returns the DOM element representing this connection.
|
||||
*/
|
||||
this.getElement = function() {
|
||||
return element;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* An editable user UI object.
|
||||
*/
|
||||
GuacUI.EditableUser = function(username) {
|
||||
|
||||
/**
|
||||
* This user's username.
|
||||
*/
|
||||
this.username = username;
|
||||
|
||||
/**
|
||||
* Current status of edit mode.
|
||||
*/
|
||||
this.edit = false;
|
||||
|
||||
// Create contained user
|
||||
var user = new GuacUI.User(username);
|
||||
var element = user.getElement();
|
||||
GuacUI.addClass(element, "editable");
|
||||
|
||||
// Fields
|
||||
var fields = GuacUI.createChildElement(element, "div", "fields");
|
||||
var form = new GuacUI.Form();
|
||||
|
||||
// Add form
|
||||
fields.appendChild(form.getElement());
|
||||
|
||||
// Add fields
|
||||
form.addField("Password:", "password", "123412341234");
|
||||
form.addField("Re-enter Password:", "password", "123412341234");
|
||||
|
||||
// Buttons
|
||||
var buttons = GuacUI.createChildElement(fields, "div", "object-buttons");
|
||||
|
||||
var save = GuacUI.createChildElement(buttons, "button", "save");
|
||||
save.textContent = "Save";
|
||||
|
||||
var cancel = GuacUI.createChildElement(buttons, "button", "cancel");
|
||||
cancel.textContent = "Cancel";
|
||||
|
||||
var del = GuacUI.createChildElement(buttons, "button", "delete");
|
||||
del.textContent = "Delete";
|
||||
|
||||
/**
|
||||
* Returns the DOM element representing this connection.
|
||||
*/
|
||||
this.getElement = function() {
|
||||
return element;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets/unsets edit mode. When edit mode is on, the user's properties
|
||||
* will be visible and editable.
|
||||
*/
|
||||
this.setEditMode = function(enabled) {
|
||||
|
||||
// Set edit mode
|
||||
this.edit = enabled;
|
||||
|
||||
// Alter class accordingly
|
||||
if (enabled)
|
||||
GuacUI.addClass(element, "edit");
|
||||
else
|
||||
GuacUI.removeClass(element, "edit");
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* An editable connection UI object.
|
||||
*/
|
||||
GuacUI.EditableConnection = function(connection) {
|
||||
|
||||
/**
|
||||
* Current status of edit mode.
|
||||
*/
|
||||
this.edit = false;
|
||||
|
||||
// Create contained connection
|
||||
var conn = new GuacUI.Connection(connection);
|
||||
var element = conn.getElement();
|
||||
GuacUI.addClass(element, "editable");
|
||||
|
||||
// Fields
|
||||
var fields = GuacUI.createChildElement(element, "div", "fields");
|
||||
var form = new GuacUI.Form();
|
||||
|
||||
// Add form
|
||||
fields.appendChild(form.getElement());
|
||||
|
||||
// Add fields
|
||||
form.addField("Password:", "password", "123412341234");
|
||||
form.addField("Re-enter Password:", "password", "123412341234");
|
||||
|
||||
// Buttons
|
||||
var buttons = GuacUI.createChildElement(fields, "div", "object-buttons");
|
||||
|
||||
var save = GuacUI.createChildElement(buttons, "button", "save");
|
||||
save.textContent = "Save";
|
||||
|
||||
var cancel = GuacUI.createChildElement(buttons, "button", "cancel");
|
||||
cancel.textContent = "Cancel";
|
||||
|
||||
var del = GuacUI.createChildElement(buttons, "button", "delete");
|
||||
del.textContent = "Delete";
|
||||
|
||||
/**
|
||||
* Returns the DOM element representing this connection.
|
||||
*/
|
||||
this.getElement = function() {
|
||||
return element;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets/unsets edit mode. When edit mode is on, the connection's properties
|
||||
* will be visible and editable.
|
||||
*/
|
||||
this.setEditMode = function(enabled) {
|
||||
|
||||
// Set edit mode
|
||||
this.edit = enabled;
|
||||
|
||||
// Alter class accordingly
|
||||
if (enabled)
|
||||
GuacUI.addClass(element, "edit");
|
||||
else
|
||||
GuacUI.removeClass(element, "edit");
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user