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

View 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');
#app {
padding: 15px 15px 15px;
}
tbody:not(.lmc-tbody-head) tr td:first-of-type {
font-weight: bold;
text-align: right;
}

View File

@ -0,0 +1,137 @@
/*
* 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, apiPost, apiPut, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.callback = "callback";
elements.label = "label";
elements.pub = "public";
elements.saveButton = "save-button";
elements.thumbnail = "thumbnail";
// Data received from API calls
var data = {};
data.app = {};
// Static references to UI elements
var ui = {};
ui.callback = {};
ui.label = {};
ui.pub = {};
ui.saveButton = {};
ui.thumbnail = {};
// Temporary state
var state = {};
state.sentApp = false;
state.sentThumb = false;
// Callback for app details API call
var displayApp = function(response)
{
data.app = response;
ui.label.value = data.app.label;
ui.callback.value = data.app.redirect_uri;
ui.pub.checked = data.app.public;
ui.saveButton.disabled = false;
};
// Click handler for save button
var handleSave = function(event)
{
if (event.currentTarget.disabled)
return;
var req = {
"label": ui.label.value,
"redirect_uri": ui.callback.value
};
if (data.params.aid != "0") {
if (ui.thumbnail.files.length && ui.thumbnail.files[0].type.startsWith("image/")) {
apiPut("/account/oauth-clients/" + data.params.aid + "/thumbnail", ui.thumbnail.files[0], function(response)
{
state.sentThumb = true;
if (state.sentApp)
location.href = "/account/oauth_apps";
});
} else {
state.sentThumb = true;
}
apiPut("/account/oauth-clients/" + data.params.aid, req, function(response)
{
state.sentApp = true;
if (state.sentThumb)
location.href = "/account/oauth_apps";
});
} else {
req.public = ui.pub.checked;
apiPost("/account/oauth-clients", req, function(response)
{
alert("Here is your client secret! Store it securely, as it won't be shown again.\n" + response.secret);
if (ui.thumbnail.files.length && ui.thumbnail.files[0].type.startsWith("image/")) {
apiPut("/account/oauth-clients/" + response.id + "/thumbnail", ui.thumbnail.files[0], function(response)
{
location.href = "/account/oauth_apps";
});
} else {
location.href = "/account/oauth_apps";
}
});
}
ui.saveButton.disabled = true;
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
// Assume 0 if no app ID supplied
if (!data.params.aid)
data.params.aid = "0";
setupHeader();
// Get element references
ui.callback = document.getElementById(elements.callback);
ui.label = document.getElementById(elements.label);
ui.pub = document.getElementById(elements.pub);
ui.saveButton = document.getElementById(elements.saveButton);
ui.thumbnail = document.getElementById(elements.thumbnail);
// Fetch app details if specified
if (data.params.aid != "0") {
apiGet("/account/oauth-clients/" + data.params.aid, displayApp, null);
} else {
ui.pub.disabled = false;
ui.saveButton.disabled = false;
}
// Register event handlers
ui.saveButton.addEventListener("click", handleSave);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

View File

@ -0,0 +1,63 @@
<!--
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 - Account // Edit OAuth App</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="app.css" />
<script src="app.js" type="module"></script>
</head>
<body>
<!--#include virtual="/include/header.html"-->
<!--#include virtual="/include/account_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="app">
<table class="lmc-table">
<thead>
<tr>
<td colspan="2">Add/Edit an OAuth App</td>
</tr>
</thead>
<tbody>
<tr class="lmc-tr3">
<td>Label</td>
<td><input id="label" type="text" size="30" /></td>
</tr>
<tr class="lmc-tr3">
<td>Callback URL</td>
<td><input id="callback" type="text" size="30" /></td>
</tr>
<tr class="lmc-tr3">
<td>Public</td>
<td><input disabled id="public" type="checkbox" /></td>
</tr>
<tr class="lmc-tr3">
<td>Thumbnail</td>
<td><input id="thumbnail" type="file" accept="image/*" /></td>
</tr>
<tr class="lmc-tr3">
<td></td>
<td><button disabled id="save-button" type="button">Save Changes</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>