<head>
<link rel="icon" type="image/png" href="images/guacamole-logo-64.png"/>
<link rel="stylesheet" type="text/css" href="styles/login.css"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi"/>
<title>Guacamole ${project.version}</title>
</head>
<!-- Connection list UI -->
<div id="connection-list-ui" style="display: none">
+ <div id="logout-panel">
+ <button id="logout">Logout</button>
+ </div>
+
<h1>
<img class="logo" src="images/guacamole-logo-64.png" alt=""/>
Available Connections
<table class="connections">
<thead>
<tr>
- <th>Name</th>
- <th>Protocol</th>
- <th>Description</th>
+ <th class="protocol"> </th>
+ <th class="name">Name</th>
</tr>
</thead>
- <tbody>
- <tr>
- <td>zhz@localhost</td>
- <td>vnc</td>
- <td class="description">Connect to test.guac-dev.org via vnc.</td>
- </tr>
- <tr>
- <td>zhz@localhost</td>
- <td>ssh</td>
- <td class="description">Connect to test.guac-dev.org via ssh.</td>
- </tr>
+ <tbody id="connections-tbody">
</tbody>
</table>
Guacamole ${project.version}
</div>
+ <script type="text/javascript" src="scripts/connections.js"></script>
+
<!-- Init -->
<script type="text/javascript"> /* <![CDATA[ */
+ function resetUI() {
+
+ var configs;
+ try {
+ configs = getConfigList();
+ }
+ catch (e) {
+
+ // Show login UI if unable to get configs
+ loginUI.style.display = "";
+ connectionListUI.style.display = "none";
+
+ return;
+
+ }
+
+ // If only one connection, redirect to that.
+ if (configs.length == 1) {
+ window.location.href = "client.xhtml?" + encodeURIComponent(configs[0].id);
+ return;
+ }
+
+ // Remove all rows from connections list
+ var tbody = document.getElementById("connections-tbody");
+ tbody.innerHTML = "";
+
+ // Add one row per connection
+ for (var i=0; i<configs.length; i++) {
+
+ // Create row and cells
+ var tr = document.createElement("tr");
+ var protocol = document.createElement("td");
+ var id = document.createElement("td");
+
+ var protocolIcon = document.createElement("div");
+ protocolIcon.className = "protocol icon " + configs[i].protocol;
+
+ // Set CSS
+ protocol.className = "protocol";
+ id.className = "name";
+
+ // Create link to client
+ var clientLink = document.createElement("a");
+ clientLink.setAttribute("href",
+ "client.xhtml?" + encodeURIComponent(configs[i].id));
+
+ // Set cell contents
+ protocol.appendChild(protocolIcon);
+ //protocol.textContent = configs[i].protocol;
+ clientLink.textContent = configs[i].id;
+ id.appendChild(clientLink);
+
+ // Add cells
+ tr.appendChild(protocol);
+ tr.appendChild(id);
+
+ // Add row
+ tbody.appendChild(tr);
+
+ }
+
+ // If configs could be retrieved, display list
+ loginUI.style.display = "none";
+ connectionListUI.style.display = "";
+
+ }
+
var loginForm = document.getElementById("login-form");
var loginUI = document.getElementById("login-ui");
var connectionListUI = document.getElementById("connection-list-ui");
+ var logout = document.getElementById("logout");
- // TODO: Get connection list
- // On no-auth fail, show login UI
+ logout.onclick = function() {
+ window.location.href = "logout";
+ };
loginForm.onsubmit = function() {
if (xhr.status != 200)
throw new Error("Invalid login");
- // Hide login UI, display connections
- loginUI.style.display = "none";
- connectionListUI.style.display = "";
+ resetUI();
}
catch (e) {
}
- loginUI.style.display = "";
+ resetUI();
/* ]]> */ </script>