Added Account section
This commit is contained in:
27
user/edit/edit.css
Normal file
27
user/edit/edit.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');
|
||||
|
||||
#edit {
|
||||
padding: 15px 15px 15px;
|
||||
}
|
||||
|
||||
tbody:not(.lmc-tbody-head) tr td:first-of-type {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
118
user/edit/edit.js
Normal file
118
user/edit/edit.js
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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, md5, parseParams, setupHeader } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.email = "email";
|
||||
elements.pwReset = "pw-reset";
|
||||
elements.restrictedNo = "restricted-no";
|
||||
elements.restrictedYes = "restricted-yes";
|
||||
elements.saveButton = "save-button";
|
||||
elements.user = "user";
|
||||
elements.userLabel = "user-label";
|
||||
|
||||
// Data received from API calls
|
||||
var data = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.email = {};
|
||||
ui.pwReset = {};
|
||||
ui.restrictedNo = {};
|
||||
ui.restrictedYes = {};
|
||||
ui.saveButton = {};
|
||||
ui.user = {};
|
||||
ui.userLabel = {};
|
||||
|
||||
// Callback for user details API call
|
||||
var displayUser = function(response)
|
||||
{
|
||||
// Fill in form
|
||||
ui.user.value = response.username;
|
||||
ui.email.value = response.email;
|
||||
if (response.restricted)
|
||||
ui.restrictedYes.checked = true;
|
||||
else
|
||||
ui.restrictedNo.checked = true;
|
||||
ui.saveButton.disabled = false;
|
||||
};
|
||||
|
||||
// Click handler for save button
|
||||
var handleSave = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
var req = {
|
||||
"username": ui.user.value,
|
||||
"restricted": ui.restrictedYes.checked
|
||||
};
|
||||
|
||||
apiPut("/account/users/" + data.params.user, req, function(response)
|
||||
{
|
||||
location.href = "/user";
|
||||
});
|
||||
};
|
||||
|
||||
// Initial setup
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
// We need a username, so die if we don't have it
|
||||
if (!data.params.user) {
|
||||
alert("No username supplied!");
|
||||
return;
|
||||
}
|
||||
|
||||
setupHeader();
|
||||
|
||||
// Highlight the account nav link
|
||||
var navlinks = document.getElementsByClassName(elements.navlink);
|
||||
for (var i = 0; i < navlinks.length; i++) {
|
||||
if (navlinks[i].pathname == "/account/")
|
||||
navlinks[i].className = " " + elements.navlinkActive;
|
||||
}
|
||||
|
||||
// Get element references
|
||||
ui.email = document.getElementById(elements.email);
|
||||
ui.pwReset = document.getElementById(elements.pwReset);
|
||||
ui.restrictedNo = document.getElementById(elements.restrictedNo);
|
||||
ui.restrictedYes = document.getElementById(elements.restrictedYes);
|
||||
ui.saveButton = document.getElementById(elements.saveButton);
|
||||
ui.user = document.getElementById(elements.user);
|
||||
ui.userLabel = document.getElementById(elements.userLabel);
|
||||
|
||||
// Populate username where we need it
|
||||
ui.userLabel.innerHTML = data.params.user;
|
||||
ui.pwReset.href += data.params.user;
|
||||
document.title += " - " + data.params.user;
|
||||
|
||||
// Attach event handlers
|
||||
ui.saveButton.addEventListener("click", handleSave);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/account/users/" + data.params.user, displayUser, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
67
user/edit/index.shtml
Normal file
67
user/edit/index.shtml
Normal file
@ -0,0 +1,67 @@
|
||||
<!--
|
||||
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 User</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="edit.css" />
|
||||
<script src="edit.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="edit">
|
||||
<table class="lmc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="3">Edit User: <span id="user-label"></span></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Username</td>
|
||||
<td colspan="2"><input id="user" type="text" size="24" /></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Reset Password</td>
|
||||
<td colspan="2"><a id="pw-reset" href="https://login.linode.com/forgot/password?username=" target="_blank">Click here to reset this user's password</a></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Email</td>
|
||||
<td><input disabled id="email" type="email" size="24" /></td>
|
||||
<td class="info">You can change your email on the <a href="/profile">profile</a> page.</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Restricted User</td>
|
||||
<td colspan="2">
|
||||
<input id="restricted-yes" type="radio" name="restricted" /> <label for="restricted-yes">Yes - this user can only do what I specify</label><br />
|
||||
<input id="restricted-no" type="radio" name="restricted" /> <label for="restricted-no">No - this user has no access restrictions</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td></td>
|
||||
<td colspan="2"><button disabled id="save-button" type="button">Save Changes</button>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user