Implemented user profile settings, OAuth apps, and maintenance windows. Other minor fixes/improvements
This commit is contained in:
27
profile/ssh/add/add.css
Normal file
27
profile/ssh/add/add.css
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of Linode Manager Classic.
|
||||
*
|
||||
* Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Linode Manager Classic 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@import url('/global.css');
|
||||
|
||||
#add {
|
||||
padding: 15px 15px 15px;
|
||||
}
|
||||
|
||||
tbody:not(.lmc-tbody-head) tr td:first-of-type {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
69
profile/ssh/add/add.js
Normal file
69
profile/ssh/add/add.js
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This file is part of Linode Manager Classic.
|
||||
*
|
||||
* Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Linode Manager Classic 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { settings, elements, apiPost, parseParams, setupHeader } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.addButton = "add-button";
|
||||
elements.key = "key";
|
||||
elements.label = "label";
|
||||
|
||||
// Data received from API calls
|
||||
var data = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.addButton = {};
|
||||
ui.key = {};
|
||||
ui.label = {};
|
||||
|
||||
// Click handler for add button
|
||||
var handleAdd = function(event)
|
||||
{
|
||||
var req = {
|
||||
"label": ui.label.value,
|
||||
"ssh_key": ui.key.value
|
||||
};
|
||||
|
||||
apiPost("/profile/sshkeys", req, function(response)
|
||||
{
|
||||
location.href = "/profile/ssh";
|
||||
});
|
||||
};
|
||||
|
||||
// Initial setup
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
setupHeader();
|
||||
|
||||
// Get element references
|
||||
ui.addButton = document.getElementById(elements.addButton);
|
||||
ui.key = document.getElementById(elements.key);
|
||||
ui.label = document.getElementById(elements.label);
|
||||
|
||||
// Register event handlers
|
||||
ui.addButton.addEventListener("click", handleAdd);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
55
profile/ssh/add/index.shtml
Normal file
55
profile/ssh/add/index.shtml
Normal file
@ -0,0 +1,55 @@
|
||||
<!--
|
||||
This file is part of Linode Manager Classic.
|
||||
|
||||
Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Linode Manager Classic 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>LMC - My Profile // Add SSH Key</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="add.css" />
|
||||
<script src="add.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--#include virtual="/include/header.html"-->
|
||||
<!--#include virtual="/include/profile_subnav.html"-->
|
||||
<div id="main-content" class="wrapper">
|
||||
<div id="add">
|
||||
<table class="lmc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="2">Add an SSH Key</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Label</td>
|
||||
<td><input id="label" type="text" size="50" /></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>SSH Public Key</td>
|
||||
<td><textarea id="key" cols="58" rows="10"></textarea></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td></td>
|
||||
<td><button id="add-button" type="button">Add SSH Key</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
51
profile/ssh/index.shtml
Normal file
51
profile/ssh/index.shtml
Normal file
@ -0,0 +1,51 @@
|
||||
<!--
|
||||
This file is part of Linode Manager Classic.
|
||||
|
||||
Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Linode Manager Classic 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>LMC - My Profile // SSH Keys</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="ssh.css" />
|
||||
<script src="ssh.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--#include virtual="/include/header.html"-->
|
||||
<!--#include virtual="/include/profile_subnav.html"-->
|
||||
<div id="main-content" class="wrapper">
|
||||
<div id="ssh">
|
||||
<table class="lmc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="4">SSH Keys</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Label</td>
|
||||
<td>Key</td>
|
||||
<td>Created</td>
|
||||
<td>Options</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="ssh-keys"></tbody>
|
||||
</table>
|
||||
<p class="sub-links">
|
||||
<a href="/profile/ssh/add">Add an SSH Key</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
36
profile/ssh/remove/index.shtml
Normal file
36
profile/ssh/remove/index.shtml
Normal file
@ -0,0 +1,36 @@
|
||||
<!--
|
||||
This file is part of Linode Manager Classic.
|
||||
|
||||
Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Linode Manager Classic 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>LMC - My Profile // Remove SSH Key</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="remove.css" />
|
||||
<script src="remove.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--#include virtual="/include/header.html"-->
|
||||
<!--#include virtual="/include/profile_subnav.html"-->
|
||||
<div id="main-content" class="wrapper">
|
||||
<div id="remove">
|
||||
<p>Are you sure you want to delete the key <strong id="label"></strong>?</p>
|
||||
<button disabled id="remove-button" type="button">Yes, delete this sucker</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
22
profile/ssh/remove/remove.css
Normal file
22
profile/ssh/remove/remove.css
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* This file is part of Linode Manager Classic.
|
||||
*
|
||||
* Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Linode Manager Classic 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@import url('/global.css');
|
||||
|
||||
#remove {
|
||||
padding: 15px 15px 15px;
|
||||
}
|
80
profile/ssh/remove/remove.js
Normal file
80
profile/ssh/remove/remove.js
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This file is part of Linode Manager Classic.
|
||||
*
|
||||
* Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Linode Manager Classic 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { settings, elements, apiDelete, apiGet, parseParams, setupHeader } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.label = "label";
|
||||
elements.removeButton = "remove-button";
|
||||
|
||||
// Data received from API calls
|
||||
var data = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.label = {};
|
||||
ui.removeButton = {};
|
||||
|
||||
// Callback for key API call
|
||||
var displayKey = function(response)
|
||||
{
|
||||
ui.label.innerHTML = response.label;
|
||||
ui.removeButton.disabled = false;
|
||||
};
|
||||
|
||||
// Click handler for remove button
|
||||
var handleRemove = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
apiDelete("/profile/sshkeys/" + data.params.kid, function(response)
|
||||
{
|
||||
location.href = "/profile/ssh";
|
||||
});
|
||||
};
|
||||
|
||||
// Initial setup
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
// We need a key ID, so die if we don't have it
|
||||
if (!data.params.kid) {
|
||||
alert("No key ID supplied!");
|
||||
return;
|
||||
}
|
||||
|
||||
setupHeader();
|
||||
|
||||
// Get element references
|
||||
ui.label = document.getElementById(elements.label);
|
||||
ui.removeButton = document.getElementById(elements.removeButton);
|
||||
|
||||
// Register event handlers
|
||||
ui.removeButton.addEventListener("click", handleRemove);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/profile/sshkeys/" + data.params.kid, displayKey, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
31
profile/ssh/ssh.css
Normal file
31
profile/ssh/ssh.css
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of Linode Manager Classic.
|
||||
*
|
||||
* Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Linode Manager Classic 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@import url('/global.css');
|
||||
|
||||
.hover-info {
|
||||
cursor: help;
|
||||
text-decoration: dotted underline;
|
||||
}
|
||||
|
||||
#ssh {
|
||||
padding: 15px 15px 15px;
|
||||
}
|
||||
|
||||
td:nth-of-type(4) {
|
||||
text-align: right;
|
||||
}
|
120
profile/ssh/ssh.js
Normal file
120
profile/ssh/ssh.js
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* This file is part of Linode Manager Classic.
|
||||
*
|
||||
* Linode Manager Classic is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Linode Manager Classic 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { settings, elements, apiGet, md5, parseParams, setupHeader, timeString } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.hoverInfo = "hover-info";
|
||||
elements.lmcRow = "lmc-tr1";
|
||||
elements.lmcRowAlt = "lmc-tr2";
|
||||
elements.sshKeys = "ssh-keys";
|
||||
|
||||
// Data received from API calls
|
||||
var data = {};
|
||||
data.keys = [];
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.sshKeys = {};
|
||||
|
||||
// Creates a row in the SSH keys table
|
||||
var createKeyRow = function(key, alt)
|
||||
{
|
||||
var row = document.createElement("tr");
|
||||
if (alt)
|
||||
row.className = elements.lmcRowAlt;
|
||||
else
|
||||
row.className = elements.lmcRow;
|
||||
|
||||
var label = document.createElement("td");
|
||||
label.innerHTML = key.label;
|
||||
row.appendChild(label);
|
||||
|
||||
var keyInfo = document.createElement("td");
|
||||
var start = document.createElement("span");
|
||||
start.className = elements.hoverInfo;
|
||||
start.title = key.ssh_key;
|
||||
start.innerHTML = key.ssh_key.substring(0, 26);
|
||||
keyInfo.appendChild(start);
|
||||
var br = document.createElement("br");
|
||||
keyInfo.appendChild(br);
|
||||
var fingerprint = document.createElement("span");
|
||||
try {
|
||||
fingerprint.innerHTML = "Fingerprint: " + md5(atob(key.ssh_key.split(" ")[1]), true);
|
||||
} catch (error) {
|
||||
fingerprint.innerHTML = "Invalid key";
|
||||
}
|
||||
keyInfo.appendChild(fingerprint);
|
||||
row.appendChild(keyInfo);
|
||||
|
||||
var created = document.createElement("td");
|
||||
var now = new Date();
|
||||
var createDate = new Date(key.created + "Z");
|
||||
created.innerHTML = timeString(now - createDate, true);
|
||||
row.appendChild(created);
|
||||
|
||||
var options = document.createElement("td");
|
||||
var removeLink = document.createElement("a");
|
||||
removeLink.href = "/profile/ssh/remove?kid=" + key.id;
|
||||
removeLink.innerHTML = "Remove";
|
||||
options.appendChild(removeLink);
|
||||
row.appendChild(options);
|
||||
|
||||
return row;
|
||||
};
|
||||
|
||||
// Callback for ssh keys API call
|
||||
var displayKeys = function(response)
|
||||
{
|
||||
data.keys = data.keys.concat(response.data);
|
||||
|
||||
// Request the next page if there are more
|
||||
if (response.page != response.pages) {
|
||||
apiGet("/profile/sshkeys?page=" + (response.page + 1), displayKeys, null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Redirect to add page if there are no keys
|
||||
if (!data.keys.length)
|
||||
location.href = "/profile/ssh/add";
|
||||
|
||||
// Add keys to table
|
||||
for (var i = 0; i < data.keys.length; i++)
|
||||
ui.sshKeys.appendChild(createKeyRow(data.keys[i], i % 2));
|
||||
};
|
||||
|
||||
// Initial setup
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
setupHeader();
|
||||
|
||||
// Get element references
|
||||
ui.sshKeys = document.getElementById(elements.sshKeys);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/profile/sshkeys", displayKeys, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
Reference in New Issue
Block a user