/* * Guacamole - Clientless Remote Desktop * Copyright (C) 2010 Michael Jumper * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ /** * General set of UI elements and UI-related functions regarding * administration. */ var GuacAdmin = { "containers" : { "connection_list" : document.getElementById("connection-list"), "user_list" : document.getElementById("user-list"), "user_list_buttons" : document.getElementById("user-list-buttons"), }, "buttons" : { "back" : document.getElementById("back"), "logout" : document.getElementById("logout"), "add_connection" : document.getElementById("add-connection"), "add_connection_group" : document.getElementById("add-connection-group"), "add_user" : document.getElementById("add-user") }, "fields" : { "username" : document.getElementById("username") }, "cached_permissions" : null, "cached_protocols" : null, "cached_root_group" : null }; /** * An arbitrary input field. * * @constructor */ GuacAdmin.Field = function() { /** * Returns the DOM Element representing this field. * * @return {Element} The DOM Element representing this field. */ this.getElement = function() {}; /** * Returns the value of this field. * * @return {String} The value of this field. */ this.getValue = function() {}; /** * Sets the value of this field. * * @param {String} value The value of this field. */ this.setValue = function(value) {}; }; /** * Simple HTML input field. * * @augments GuacAdmin.Field * @param {String} type The type of HTML field. */ GuacAdmin.Field._HTML_INPUT = function(type) { // Call parent constructor GuacAdmin.Field.apply(this); // Create backing element var element = GuacUI.createElement("input"); element.setAttribute("type", type); this.getValue = function() { return element.value; }; this.getElement = function() { return element; }; this.setValue = function(value) { element.value = value; }; }; GuacAdmin.Field._HTML_INPUT.prototype = new GuacAdmin.Field(); /** * A basic text field. * * @augments GuacAdmin.Field._HTML_INPUT */ GuacAdmin.Field.TEXT = function() { GuacAdmin.Field._HTML_INPUT.apply(this, ["text"]); }; GuacAdmin.Field.TEXT.prototype = new GuacAdmin.Field._HTML_INPUT(); /** * A basic password field. * * @augments GuacAdmin.Field._HTML_INPUT */ GuacAdmin.Field.PASSWORD = function() { GuacAdmin.Field._HTML_INPUT.apply(this, ["password"]); }; GuacAdmin.Field.PASSWORD.prototype = new GuacAdmin.Field._HTML_INPUT(); /** * A basic numeric field, leveraging the new HTML5 field types. * * @augments GuacAdmin.Field._HTML_INPUT */ GuacAdmin.Field.NUMERIC = function() { GuacAdmin.Field._HTML_INPUT.apply(this, ["number"]); }; GuacAdmin.Field.NUMERIC.prototype = new GuacAdmin.Field._HTML_INPUT(); /** * Simple checkbox. * * @augments GuacAdmin.Field */ GuacAdmin.Field.CHECKBOX = function(value) { // Call parent constructor GuacAdmin.Field.apply(this); // Create backing element var element = GuacUI.createElement("input"); element.setAttribute("type", "checkbox"); element.setAttribute("value", value); this.getValue = function() { if (element.checked) return value; else return ""; }; this.getElement = function() { return element; }; this.setValue = function(new_value) { if (new_value == value) element.checked = true; else element.checked = false; }; }; GuacAdmin.Field.CHECKBOX.prototype = new GuacAdmin.Field(); /** * Enumerated field type. * * @augments GuacAdmin.Field */ GuacAdmin.Field.ENUM = function(values) { // Call parent constructor GuacAdmin.Field.apply(this); // Create backing element var element = GuacUI.createElement("select"); for (var i=0; i 0) { // History section var history_section = GuacUI.createChildElement(sections, "dd"); var history_table = GuacUI.createChildElement(history_section, "table", "history section"); var history_table_header = GuacUI.createChildElement( history_table, "tr"); GuacUI.createChildElement(history_table_header, "th").textContent = "Username"; GuacUI.createChildElement(history_table_header, "th").textContent = "Start Time"; GuacUI.createChildElement(history_table_header, "th").textContent = "Duration"; // Paginated body of history var history_buttons = GuacUI.createChildElement(history_section, "div", "list-pager-buttons"); var history_body = GuacUI.createChildElement(history_table, "tbody"); var history_pager = new GuacUI.Pager(history_body); // Add history for (i=0; i