Implemented user profile settings, OAuth apps, and maintenance windows. Other minor fixes/improvements

This commit is contained in:
2021-03-11 10:37:07 -05:00
parent a020009c47
commit c58e2fc545
48 changed files with 3152 additions and 36 deletions

87
profile/lish/index.shtml Normal file
View File

@ -0,0 +1,87 @@
<!--
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 // Lish Settings</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="lish.css" />
<script src="lish.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="lish">
<p id="settings-saved">Settings saved.</p>
<table class="lmc-table">
<thead>
<tr>
<td colspan="3">Lish Authentication</td>
</tr>
<tr>
<td colspan="3">Authentication Methods</td>
</tr>
</thead>
<tbody>
<tr class="lmc-tr3">
<td>Authentication modes</td>
<td>
<select id="modes">
<option value="password_keys">Allow both password and key authentication</option>
<option value="keys_only">Allow key authentication only</option>
<option value="disabled">Disable Lish</option>
</select>
</td>
<td class="info">
This controls what authentication methods are allowed to connect to the<br />
Lish console servers. <a target="_blank" href="https://www.linode.com/docs/platform/manager/using-the-linode-shell-lish/">About the Lish console...</a>
</td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td colspan="2"><button disabled id="save-button" type="button">Save Setting</button></td>
</tr>
</tbody>
<tbody class="lmc-tbody-head">
<tr class="noshow">
<td colspan="3"></td>
</tr>
<tr>
<td colspan="3">Lish Keys</td>
</tr>
</tbody>
<tbody>
<tr class="lmc-tr3">
<td>Description</td>
<td colspan="2">Place your SSH public keys here for use with Lish console access.</td>
</tr>
<tr class="lmc-tr3">
<td>Lish Keys</td>
<td colspan="2"><textarea id="keys" cols="80" rows="2" wrap="soft"></textarea></td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td colspan="2"><button disabled id="submit-button" type="button">Submit Keys</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

39
profile/lish/lish.css Normal file
View File

@ -0,0 +1,39 @@
/*
* 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');
#lish {
padding: 15px 15px 15px;
}
#keys {
white-space: pre;
}
#settings-saved {
background-color: #ADD370;
display: none;
font-size: 16px;
margin-top: 0;
padding: 7px;
}
tbody:not(.lmc-tbody-head) tr td:first-of-type {
font-weight: bold;
text-align: right;
}

115
profile/lish/lish.js Normal file
View File

@ -0,0 +1,115 @@
/*
* 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, apiPut, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.keys = "keys";
elements.modes = "modes";
elements.saveButton = "save-button";
elements.settingsSaved = "settings-saved";
elements.submitButton = "submit-button";
// Data received from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.keys = {};
ui.modes = {};
ui.saveButton = {};
ui.settingsSaved = {};
ui.submitButton = {};
// Callback for profile API call
var displayProfile = function(response)
{
// Populate auth method settings
ui.modes.value = response.lish_auth_method;
ui.saveButton.disabled = false;
// Populate authorized keys
ui.keys.value = response.authorized_keys.join("\n");
ui.submitButton.disabled = false;
};
// Click handler for save button
var handleSave = function(event)
{
if (event.currentTarget.disabled)
return;
var req = {
"lish_auth_method": ui.modes.value
};
apiPut("/profile", req, function(response)
{
ui.settingsSaved.style.display = "block";
});
};
// Click handler for submit button
var handleSubmit = function(event)
{
if (event.currentTarget.disabled)
return;
var req = {
"authorized_keys": ui.keys.value.split("\n")
};
// Remove empty keys from the request
for (var i = req.authorized_keys.length - 1; i >= 0; i--) {
if (!req.authorized_keys[i].length)
req.authorized_keys.splice(i, 1);
}
apiPut("/profile", req, function(response)
{
ui.settingsSaved.style.display = "block";
});
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
setupHeader();
// Get element references
ui.keys = document.getElementById(elements.keys);
ui.modes = document.getElementById(elements.modes);
ui.saveButton = document.getElementById(elements.saveButton);
ui.settingsSaved = document.getElementById(elements.settingsSaved);
ui.submitButton = document.getElementById(elements.submitButton);
// Register event handlers
ui.saveButton.addEventListener("click", handleSave);
ui.submitButton.addEventListener("click", handleSubmit);
// Get data from API
apiGet("/profile", displayProfile, null);
};
// Attach onload handler
window.addEventListener("load", setup);
})();