Added Account section

This commit is contained in:
2020-03-13 23:01:39 -04:00
parent dd1809473c
commit 396ca2366e
80 changed files with 5330 additions and 107 deletions

27
user/add/add.css Normal file
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');
#add {
padding: 15px 15px 15px;
}
tbody:not(.lmc-tbody-head) tr td:first-of-type {
font-weight: bold;
text-align: right;
}

80
user/add/add.js Normal file
View 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, apiPost, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.addButton = "add-button";
elements.email = "email";
elements.restrictedYes = "restricted-yes";
elements.user = "user";
// Data received from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.addButton = {};
ui.email = {};
ui.restrictedYes = {};
ui.user = {};
// Click handler for add button
var handleAdd = function(event)
{
var req = {
"username": ui.user.value,
"email": ui.email.value,
"restricted": ui.restrictedYes.checked
};
apiPost("/account/users", req, function(response)
{
location.href = "/user";
});
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
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.addButton = document.getElementById(elements.addButton);
ui.email = document.getElementById(elements.email);
ui.restrictedYes = document.getElementById(elements.restrictedYes);
ui.user = document.getElementById(elements.user);
// Attach event handlers
ui.addButton.addEventListener("click", handleAdd);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

66
user/add/index.shtml Normal file
View File

@ -0,0 +1,66 @@
<!--
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 // Add User</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/account_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="add">
<table class="lmc-table">
<thead>
<tr>
<td colspan="2">Add User</td>
</tr>
</thead>
<tbody>
<tr class="lmc-tr3">
<td>Username</td>
<td><input id="user" type="text" size="24" /></td>
</tr>
<tr class="lmc-tr3">
<td>Password</td>
<td>A password creation link will be emailed to the user</td>
</tr>
<tr class="lmc-tr3">
<td>Email</td>
<td><input id="email" type="email" size="24" /></td>
</tr>
<tr class="lmc-tr3">
<td>Restricted User</td>
<td>
<input checked 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><button id="add-button" type="button">Add User</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

27
user/edit/edit.css Normal file
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');
#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
View 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
View 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>

56
user/grants/grants.css Normal file
View File

@ -0,0 +1,56 @@
/*
* 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');
#grants {
padding: 15px 15px 15px;
}
h2 {
font-size: 18px;
}
table {
border-bottom: 1px solid #4C4C4C;
border-collapse: separate;
border-left: 1px solid #B2B2B2;
border-right: 1px solid #4C4C4C;
border-spacing: 2px;
border-top: 1px solid #B2B2B2;
margin-bottom: 30px;
}
table label {
display: block;
}
table tbody td {
text-align: center;
}
table tbody td:first-of-type {
text-align: left;
}
table td {
border-bottom: 1px solid #B2B2B2;
border-left: 1px solid #4C4C4C;
border-right: 1px solid #B2B2B2;
border-top: 1px solid #4C4C4C;
padding: 2px;
}

271
user/grants/grants.js Normal file
View File

@ -0,0 +1,271 @@
/*
* 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.billingNone = "billing-none";
elements.billingRO = "billing-ro";
elements.billingRW = "billing-rw";
elements.createDomain = "create-domain";
elements.createImage = "create-image";
elements.createLinode = "create-linode";
elements.createLV = "create-lv";
elements.createNB = "create-nb";
elements.createSS = "create-ss";
elements.createVolume = "create-volume";
elements.grantBox = "grant-box";
elements.grantTables = {};
elements.grantTables.domain = "dns-grants";
elements.grantTables.image = "image-grants";
elements.grantTables.linode = "linode-grants";
elements.grantTables.longview = "lv-grants";
elements.grantTables.nodebalancer = "nb-grants";
elements.grantTables.stackscript = "ss-grants";
elements.grantTables.volume = "volume-grants";
elements.modifyLV = "modify-lv";
elements.updateButton = "update-button";
// Data received from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.billingNone = {};
ui.billingRO = {};
ui.billingRW = {};
ui.createDomain = {};
ui.createImage = {};
ui.createLinode = {};
ui.createLV = {};
ui.createNB = {};
ui.createSS = {};
ui.createVolume = {};
ui.grantTables = {};
ui.grantTables.domain = {};
ui.grantTables.image = {};
ui.grantTables.linode = {};
ui.grantTables.longview = {};
ui.grantTables.nodebalancer = {};
ui.grantTables.stackscript = {};
ui.grantTables.volume = {};
ui.modifyLV = {};
ui.updateButton = {};
// Creates a row for a grant table
var createGrantRow = function(type, perm)
{
var row = document.createElement("tr");
var label = document.createElement("td");
label.innerHTML = perm.label;
row.appendChild(label);
var none = document.createElement("td");
var noneLabel = document.createElement("label");
noneLabel.for = type + "-none-" + perm.id;
var noneBox = document.createElement("input");
noneBox.id = type + "-none-" + perm.id;
noneBox.className = elements.grantBox;
noneBox.type = "radio";
noneBox.name = type + "-" + perm.id;
noneLabel.appendChild(noneBox);
none.appendChild(noneLabel);
row.appendChild(none);
var ro = document.createElement("td");
var roLabel = document.createElement("label");
roLabel.for = type + "-ro-" + perm.id;
var roBox = document.createElement("input");
roBox.id = type + "-ro-" + perm.id;
roBox.className = elements.grantBox;
roBox.type = "radio";
roBox.name = type + "-" + perm.id;
roLabel.appendChild(roBox);
ro.appendChild(roLabel);
row.appendChild(ro);
var rw = document.createElement("td");
var rwLabel = document.createElement("label");
rwLabel.for = type + "-rw-" + perm.id;
var rwBox = document.createElement("input");
rwBox.id = type + "-rw-" + perm.id;
rwBox.className = elements.grantBox;
rwBox.type = "radio";
rwBox.name = type + "-" + perm.id;
rwLabel.appendChild(rwBox);
rw.appendChild(rwLabel);
row.appendChild(rw);
switch (perm.permissions) {
case "read_only":
roBox.checked = true;
break;
case "read_write":
rwBox.checked = true;
break;
default:
noneBox.checked = true;
}
return row;
};
// Callback for user grants API call
var displayGrants = function(response)
{
// Set global grants
ui.createLinode.checked = response.global.add_linodes;
ui.createNB.checked = response.global.add_nodebalancers;
ui.createLV.checked = response.global.add_longview;
ui.modifyLV.checked = response.global.longview_subscription;
ui.createDomain.checked = response.global.add_domains;
ui.createSS.checked = response.global.add_stackscripts;
ui.createImage.checked = response.global.add_images;
ui.createVolume.checked = response.global.add_volumes;
// Billing grants
switch (response.global.account_access) {
case "read_only":
ui.billingRO.checked = true;
break;
case "read_write":
ui.billingRW.checked = true;
break;
default:
ui.billingNone.checked = true;
}
// Specific grants
for (var i in ui.grantTables) {
for (var j = 0; j < response[i].length; j++)
ui.grantTables[i].appendChild(createGrantRow(i, response[i][j]));
}
ui.updateButton.disabled = false;
};
// Click handler for update button
var handleUpdate = function(event)
{
if (event.currentTarget.disabled)
return;
var req = {};
// Add in global permissions
req.global = {
"add_linodes": ui.createLinode.checked,
"add_nodebalancers": ui.createNB.checked,
"add_longview": ui.createLV.checked,
"longview_subscription": ui.modifyLV.checked,
"add_domains": ui.createDomain.checked,
"add_stackscripts": ui.createSS.checked,
"add_images": ui.createImage.checked,
"add_volumes": ui.createVolume.checked
};
// Add in billing permissions
if (ui.billingRO.checked)
req.global.account_access = "read_only";
else if (ui.billingRW.checked)
req.global.account_access = "read_write";
else
req.global.account_access = null;
// Add in specific persmissions
for (var i in ui.grantTables)
req[i] = [];
var grantBoxes = document.getElementsByClassName(elements.grantBox);
for (var i = 0; i < grantBoxes.length; i++) {
if (!grantBoxes[i].checked)
continue;
// This will give us an array tuple of [type, permission, id]
var id = grantBoxes[i].id.split("-");
var perm = {};
perm.id = parseInt(id[2]);
if (id[1] == "ro")
perm.permissions = "read_only";
else if (id[1] == "rw")
perm.permissions = "read_write";
else
perm.permissions = null;
req[id[0]].push(perm);
}
apiPut("/account/users/" + data.params.user + "/grants", 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.billingNone = document.getElementById(elements.billingNone);
ui.billingRO = document.getElementById(elements.billingRO);
ui.billingRW = document.getElementById(elements.billingRW);
ui.createDomain = document.getElementById(elements.createDomain);
ui.createImage = document.getElementById(elements.createImage);
ui.createLinode = document.getElementById(elements.createLinode);
ui.createLV = document.getElementById(elements.createLV);
ui.createNB = document.getElementById(elements.createNB);
ui.createSS = document.getElementById(elements.createSS);
ui.createVolume = document.getElementById(elements.createVolume);
for (var i in ui.grantTables)
ui.grantTables[i] = document.getElementById(elements.grantTables[i]);
ui.modifyLV = document.getElementById(elements.modifyLV);
ui.updateButton = document.getElementById(elements.updateButton);
// Populate username where we need it
document.title += " - " + data.params.user;
// Attach event handlers
ui.updateButton.addEventListener("click", handleUpdate);
// Get data from API
apiGet("/account/users/" + data.params.user + "/grants", displayGrants, null);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

132
user/grants/index.shtml Normal file
View File

@ -0,0 +1,132 @@
<!--
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 // User Grants</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="grants.css" />
<script src="grants.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="grants">
<h2>Global Grants</h2>
<input id="create-linode" type="checkbox" /> <label for="create-linode">Can add Linodes to this account ($)</label><br />
<input id="create-nb" type="checkbox" /> <label for="create-nb">Can add NodeBalancers to this account ($)</label><br />
<input id="create-lv" type="checkbox" /> <label for="create-lv">Can add Longview clients to this account</label><br />
<input id="modify-lv" type="checkbox" /> <label for="modify-lv">Can modify this account's Longview subscription ($)</label><br />
<input id="create-domain" type="checkbox" /> <label for="create-domain">Can add Domains using the DNS Manager</label><br />
<input id="create-ss" type="checkbox" /> <label for="create-ss">Can create StackScripts under this account</label><br />
<input id="create-image" type="checkbox" /> <label for="create-image">Can create frozen Images under this account</label><br />
<input id="create-volume" type="checkbox" /> <label for="create-volume">Can add Block Storage Volumes to this account ($)</label>
<h2>Billing Access</h2>
<input id="billing-none" type="radio" name="billing" /> <label for="billing-none"><strong>None</strong> - Cannot view any billing information</label><br />
<input id="billing-ro" type="radio" name="billing" /> <label for="billing-ro"><strong>Read Only</strong> - Can view invoices, billing info, and will receive copies of all invoices and payment emails</label><br />
<input id="billing-rw" type="radio" name="billing" /> <label for="billing-rw"><strong>Read-Write</strong> - Can make payments, update contact and billing info, and will receive copies of all invoices and payment emails</label>
<h2>Linode Grants</h2>
<table>
<thead>
<tr>
<td>Linode</td>
<td>None</td>
<td>Read Only</td>
<td>Read-Write</td>
</tr>
</thead>
<tbody id="linode-grants"></tbody>
</table>
<h2>NodeBalancer Grants</h2>
<table>
<thead>
<tr>
<td>NodeBalancer</td>
<td>None</td>
<td>Read Only</td>
<td>Read-Write</td>
</tr>
</thead>
<tbody id="nb-grants"></tbody>
</table>
<h2>Longview Grants</h2>
<table>
<thead>
<tr>
<td>Server</td>
<td>None</td>
<td>Read Only</td>
<td>Read-Write</td>
</tr>
</thead>
<tbody id="lv-grants"></tbody>
</table>
<h2>DNS Zone Grants</h2>
<table>
<thead>
<tr>
<td>Zone</td>
<td>None</td>
<td>Read Only</td>
<td>Read-Write</td>
</tr>
</thead>
<tbody id="dns-grants"></tbody>
</table>
<h2>StackScript Grants</h2>
<table>
<thead>
<tr>
<td>StackScript</td>
<td>None</td>
<td>Read Only</td>
<td>Read-Write</td>
</tr>
</thead>
<tbody id="ss-grants"></tbody>
</table>
<h2>Image Grants</h2>
<table>
<thead>
<tr>
<td>Image</td>
<td>None</td>
<td>Read Only</td>
<td>Read-Write</td>
</tr>
</thead>
<tbody id="image-grants"></tbody>
</table>
<h2>Volume Grants</h2>
<table>
<thead>
<tr>
<td>Volume</td>
<td>None</td>
<td>Read Only</td>
<td>Read-Write</td>
</tr>
</thead>
<tbody id="volume-grants"></tbody>
</table>
<button disabled id="update-button" type="button">Update Grants</button>
</div>
</div>
</body>
</html>

53
user/index.shtml Normal file
View File

@ -0,0 +1,53 @@
<!--
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 // User Manager</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="user.css" />
<script src="user.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="user">
<table class="lmc-table">
<thead>
<tr>
<td colspan="4">User Manager</td>
</tr>
<tr>
<td>Username</td>
<td>Email</td>
<td>Restricted</td>
<td>Options</td>
</tr>
</thead>
<tbody id="user-table">
<tr id="loading" class="lmc-tr3">
<td colspan="4">Loading...</td>
</tr>
</tbody>
</table>
<p class="sub-links"><a href="/user/add">Add a user</a></p>
</div>
</div>
</body>
</html>

36
user/remove/index.shtml Normal file
View 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 - Account // Remove User</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/account_subnav.html"-->
<div id="main-content" class="wrapper">
<div id="remove">
<p>Are you sure you want to delete the user '<span id="user-label"></span>'?</p>
<button id="delete-button" type="button">Yes, Delete!</button> <button id="cancel-button" type="button">Cancel</button>
</div>
</div>
</body>
</html>

22
user/remove/remove.css Normal file
View 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;
}

84
user/remove/remove.js Normal file
View File

@ -0,0 +1,84 @@
/*
* 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, parseParams, setupHeader } from "/global.js";
(function()
{
// Element names specific to this page
elements.cancelButton = "cancel-button";
elements.deleteButton = "delete-button";
elements.userLabel = "user-label";
// Data received from API calls
var data = {};
// Static references to UI elements
var ui = {};
ui.cancelButton = {};
ui.deleteButton = {};
ui.userLabel = {};
// Click handler for delete button
var handleDelete = function(event)
{
apiDelete("/account/users/" + data.params.user, 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.cancelButton = document.getElementById(elements.cancelButton);
ui.deleteButton = document.getElementById(elements.deleteButton);
ui.userLabel = document.getElementById(elements.userLabel);
// Populate username where we need it
ui.userLabel.innerHTML = data.params.user;
// Attach event handlers
ui.cancelButton.addEventListener("click", function(event)
{
location.href = "/user";
});
ui.deleteButton.addEventListener("click", handleDelete);
};
// Attach onload handler
window.addEventListener("load", setup);
})();

32
user/user.css Normal file
View File

@ -0,0 +1,32 @@
/*
* 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');
.profile-img {
height: 36px;
vertical-align: middle;
width: 36px;
}
td:nth-of-type(4) {
text-align: center;
}
#user {
padding: 15px 15px 15px;
}

148
user/user.js Normal file
View File

@ -0,0 +1,148 @@
/*
* 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 } from "/global.js";
(function()
{
// Element names specific to this page
elements.info = "info";
elements.lmcRow = "lmc-tr1";
elements.lmcRowAlt = "lmc-tr2";
elements.loading = "loading";
elements.navlinkActive = "navlink-active";
elements.profileImg = "profile-img";
elements.userTable = "user-table";
// Data received from API calls
var data = {};
data.users = [];
// Static references to UI elements
var ui = {};
ui.loading = {};
ui.userTable = {};
// Generates a user table row
var createUserRow = function(user, alt)
{
var row = document.createElement("tr");
if (alt)
row.className = elements.lmcRowAlt;
else
row.className = elements.lmcRow;
var nameCell = document.createElement("td");
var imgLink = document.createElement("a");
imgLink.href = "/user/edit?user=" + user.username;
var img = document.createElement("img");
img.className = elements.profileImg;
img.src = "https://www.gravatar.com/avatar/" + md5(user.email);
img.alt = user.username;
imgLink.appendChild(img);
var separator = document.createElement("span");
separator.innerHTML = " ";
var nameLink = document.createElement("a");
nameLink.href = "/user/edit?user=" + user.username;
nameLink.innerHTML = user.username;
nameCell.appendChild(imgLink);
nameCell.appendChild(separator);
nameCell.appendChild(nameLink);
row.appendChild(nameCell);
var email = document.createElement("td");
email.innerHTML = user.email;
row.appendChild(email);
var restricted = document.createElement("td");
if (user.restricted) {
var yes = document.createElement("span");
yes.innerHTML = "Yes (";
var permsLink = document.createElement("a");
permsLink.href = "/user/grants?user=" + user.username;
permsLink.innerHTML = "edit permissions";
var close = document.createElement("span");
close.innerHTML = ")";
restricted.appendChild(yes);
restricted.appendChild(permsLink);
restricted.appendChild(close);
} else {
restricted.innerHTML = "No";
}
row.appendChild(restricted);
var options = document.createElement("td");
var editLink = document.createElement("a");
editLink.href = "/user/edit?user=" + user.username;
editLink.innerHTML = "Edit";
var pipe = document.createElement("span");
pipe.innerHTML = " | ";
var removeLink = document.createElement("a");
removeLink.href = "/user/remove?user=" + user.username;
removeLink.innerHTML = "Remove";
options.appendChild(editLink);
options.appendChild(pipe);
options.appendChild(removeLink);
row.appendChild(options);
return row;
};
// Callback for users API call
var displayUsers = function(response)
{
data.users = data.users.concat(response.data);
// Request the next page if there are more
if (response.page != response.pages) {
apiGet("/account/users?page=" + (response.page + 1), displayUsers, null);
return;
}
ui.loading.remove();
// Add users to table
for (var i = 0; i < data.users.length; i++)
ui.userTable.appendChild(createUserRow(data.users[i], ui.userTable.children.length % 2));
};
// Initial setup
var setup = function()
{
// Parse URL parameters
data.params = parseParams();
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.loading = document.getElementById(elements.loading);
ui.userTable = document.getElementById(elements.userTable);
// Get data from API
apiGet("/account/users", displayUsers, null);
};
// Attach onload handler
window.addEventListener("load", setup);
})();