Initial commit. Implemented OAuth, Linodes, volumes, and images
This commit is contained in:
140
linodes/settings/index.shtml
Normal file
140
linodes/settings/index.shtml
Normal file
@ -0,0 +1,140 @@
|
||||
<!--
|
||||
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 - Settings</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="settings.css" />
|
||||
<script src="settings.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--#include virtual="/include/header.html"-->
|
||||
<!--#include virtual="/include/linode_subnav.html"-->
|
||||
<div id="main-content" class="wrapper">
|
||||
<div id="top-links"><a href="/linodes">Linodes</a> » <span id="linode-tag"><a id="linode-tag-link" href=""></a> » </span><a id="linode-label" href="/linodes/dashboard?lid=0"></a> » <span class="top-links-title">Settings</span></div>
|
||||
<div id="settings">
|
||||
<p id="lassie-saved" class="saved-message">Lassie setting saved.</p>
|
||||
<p id="alerts-saved" class="saved-message">Alert settings saved.</p>
|
||||
<table class="lmc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="3">Settings</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">Display Settings</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Linode Label</td>
|
||||
<td><input id="label" type="text" /></td>
|
||||
<td class="info">Rename your Linode</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Tags</td>
|
||||
<td><input id="tags" type="text" /> (comma-separated)</td>
|
||||
<td class="info">Group Linodes together on the Linodes tab using tags!</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td></td>
|
||||
<td colspan="2"><button disabled id="save-display" type="button">Save Changes</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody class="lmc-tbody-head">
|
||||
<tr class="noshow">
|
||||
<td colspan="3"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">Shutdown Watchdog</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Description</td>
|
||||
<td colspan="2">
|
||||
Lassie is a Shutdown Watchdog that monitors your Linode and will reboot it if it powers off unexpectedly. It works by issuing a boot job when your Linode powers off without a shutdown job being responsible.<br />
|
||||
<span class="info">To prevent a boot loop, Lassie will give up if there have been more than 5 boot jobs issued within 15 minutes.</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Lassie is currently</td>
|
||||
<td>
|
||||
<select id="lassie">
|
||||
<option value="enabled">Enabled</option>
|
||||
<option value="disabled">Disabled</option>
|
||||
</select>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td></td>
|
||||
<td colspan="2"><button disabled id="save-lassie" type="button">Save Changes</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody class="lmc-tbody-head">
|
||||
<tr class="noshow">
|
||||
<td colspan="3"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">Email Alert Thresholds</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Description</td>
|
||||
<td colspan="2">
|
||||
When an alert threshold is reached, an email is sent to all users that have "read" permissions on this Linode.<br />
|
||||
<span class="info">Thresholds are compared to values once per hour, 15 minutes after the hour.</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>CPU Usage</td>
|
||||
<td><label for="cpu-enabled">Enabled</label><input id="cpu-enabled" type="checkbox" /> | <input id="cpu-value" type="number" min="0" max="100" /> %</td>
|
||||
<td class="info">Average CPU usage over 2 hours exceeding this value triggers this alert.</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Disk IO Rate</td>
|
||||
<td><label for="io-enabled">Enabled</label><input id="io-enabled" type="checkbox" /> | <input id="io-value" type="number" min="0" /> IO Ops/sec</td>
|
||||
<td class="info">Average Disk IO ops/sec over 2 hours exceeding this value triggers this alert.</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Incoming Traffic</td>
|
||||
<td><label for="incoming-enabled">Enabled</label><input id="incoming-enabled" type="checkbox" /> | <input id="incoming-value" type="number" min="0" /> Mbit/s</td>
|
||||
<td class="info">Average incoming traffic over a 2 hour period exceeding this value triggers this alert.</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Outbound Traffic</td>
|
||||
<td><label for="outbound-enabled">Enabled</label><input id="outbound-enabled" type="checkbox" /> | <input id="outbound-value" type="number" min="0" /> Mbit/s</td>
|
||||
<td class="info">Average outbound traffic over a 2 hour period exceeding this value triggers this alert.</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Transfer Quota</td>
|
||||
<td><label for="transfer-enabled">Enabled</label><input id="transfer-enabled" type="checkbox" /> | <input id="transfer-value" type="number" min="0" max="100" /> %</td>
|
||||
<td class="info">Percentage of network transfer quota used being greater than this value will trigger this alert.</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td></td>
|
||||
<td colspan="2"><button disabled id="save-alerts" type="button">Save Changes</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
44
linodes/settings/settings.css
Normal file
44
linodes/settings/settings.css
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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');
|
||||
|
||||
input[type="number"] {
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
.saved-message {
|
||||
background-color: #ADD370;
|
||||
display: none;
|
||||
font-size: 16px;
|
||||
margin-top: 0;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
#settings {
|
||||
padding: 0px 15px 15px;
|
||||
}
|
||||
|
||||
tbody:not(.lmc-tbody-head) tr td:first-of-type {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
tbody:not(.lmc-tbody-head) tr:last-of-type {
|
||||
border: none;
|
||||
}
|
238
linodes/settings/settings.js
Normal file
238
linodes/settings/settings.js
Normal file
@ -0,0 +1,238 @@
|
||||
/*
|
||||
* 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.alertsSaved = "alerts-saved";
|
||||
elements.cpuEnabled = "cpu-enabled";
|
||||
elements.cpuValue = "cpu-value";
|
||||
elements.incomingEnabled = "incoming-enabled";
|
||||
elements.incomingValue = "incoming-value";
|
||||
elements.ioEnabled = "io-enabled";
|
||||
elements.ioValue = "io-value";
|
||||
elements.label = "label";
|
||||
elements.lassie = "lassie";
|
||||
elements.lassieSaved = "lassie-saved";
|
||||
elements.linodeLabel = "linode-label";
|
||||
elements.linodeTag = "linode-tag";
|
||||
elements.linodeTagLink = "linode-tag-link";
|
||||
elements.outboundEnabled = "outbound-enabled";
|
||||
elements.outboundValue = "outbound-value";
|
||||
elements.saveAlerts = "save-alerts";
|
||||
elements.saveDisplay = "save-display";
|
||||
elements.saveLassie = "save-lassie";
|
||||
elements.tags = "tags";
|
||||
elements.transferEnabled = "transfer-enabled";
|
||||
elements.transferValue = "transfer-value";
|
||||
|
||||
// Data recieved from API calls
|
||||
var data = {};
|
||||
data.linode = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.alertsSaved = {};
|
||||
ui.cpuEnabled = {};
|
||||
ui.cpuValue = {};
|
||||
ui.incomingEnabled = {};
|
||||
ui.incomingValue = {};
|
||||
ui.ioEnabled = {};
|
||||
ui.ioValue = {};
|
||||
ui.label = {};
|
||||
ui.lassie = {};
|
||||
ui.lassieSaved = {};
|
||||
ui.linodeLabel = {};
|
||||
ui.linodeTag = {};
|
||||
ui.linodeTagLink = {};
|
||||
ui.outboundEnabled = {};
|
||||
ui.outboundValue = {};
|
||||
ui.saveAlerts = {};
|
||||
ui.saveDisplay = {};
|
||||
ui.saveLassie = {};
|
||||
ui.tags = {};
|
||||
ui.transferEnabled = {};
|
||||
ui.transferValue = {};
|
||||
|
||||
// Callback for linode details API call
|
||||
var displayDetails = function(response)
|
||||
{
|
||||
data.linode = response;
|
||||
|
||||
// Set page title and header stuff
|
||||
document.title += " // " + data.linode.label;
|
||||
ui.linodeLabel.innerHTML = data.linode.label;
|
||||
if (data.linode.tags.length == 1) {
|
||||
ui.linodeTagLink.href = "/linodes?tag=" + data.linode.tags[0];
|
||||
ui.linodeTagLink.innerHTML = "(" + data.linode.tags[0] + ")";
|
||||
ui.linodeTag.style.display = "inline";
|
||||
}
|
||||
|
||||
// Fill in values
|
||||
ui.label.value = data.linode.label;
|
||||
ui.tags.value = data.linode.tags.join(",");
|
||||
ui.saveDisplay.disabled = false;
|
||||
if (data.linode.watchdog_enabled)
|
||||
ui.lassie.value = "enabled";
|
||||
else
|
||||
ui.lassie.value = "disabled";
|
||||
ui.saveLassie.disabled = false;
|
||||
ui.cpuEnabled.checked = data.linode.alerts.cpu;
|
||||
ui.cpuValue.value = data.linode.alerts.cpu;
|
||||
ui.ioEnabled.checked = data.linode.alerts.io;
|
||||
ui.ioValue.value = data.linode.alerts.io;
|
||||
ui.incomingEnabled.checked = data.linode.alerts.network_in;
|
||||
ui.incomingValue.value = data.linode.alerts.network_in;
|
||||
ui.outboundEnabled.checked = data.linode.alerts.network_out;
|
||||
ui.outboundValue.value = data.linode.alerts.network_out;
|
||||
ui.transferEnabled.checked = data.linode.alerts.transfer_quota;
|
||||
ui.transferValue.value = data.linode.alerts.transfer_quota;
|
||||
ui.saveAlerts.disabled = false;
|
||||
};
|
||||
|
||||
// Handler for alert settings save
|
||||
var handleSaveAlerts = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
var req = {
|
||||
"alerts": {
|
||||
"cpu": parseInt(ui.cpuValue.value),
|
||||
"io": parseInt(ui.ioValue.value),
|
||||
"network_in": parseInt(ui.incomingValue.value),
|
||||
"network_out": parseInt(ui.outboundValue.value),
|
||||
"transfer_quota": parseInt(ui.transferValue.value)
|
||||
}
|
||||
};
|
||||
|
||||
// Set values to 0 if not enabled
|
||||
if (!ui.cpuEnabled.checked)
|
||||
req.alerts.cpu = 0;
|
||||
if (!ui.ioEnabled.checked)
|
||||
req.alerts.io = 0;
|
||||
if (!ui.incomingEnabled.checked)
|
||||
req.alerts.network_in = 0;
|
||||
if (!ui.outboundEnabled.checked)
|
||||
req.alerts.network_out = 0;
|
||||
if (!ui.transferEnabled.checked)
|
||||
req.alerts.transfer_quota = 0;
|
||||
|
||||
var callback = function(response)
|
||||
{
|
||||
ui.alertsSaved.style.display = "block";
|
||||
};
|
||||
|
||||
apiPut("/linode/instances/" + data.params.lid, req, callback);
|
||||
};
|
||||
|
||||
// Handler for display settings save
|
||||
var handleSaveDisplay = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
var req = {
|
||||
"label": ui.label.value,
|
||||
"tags": []
|
||||
};
|
||||
|
||||
if (ui.tags.value.length)
|
||||
req.tags = ui.tags.value.split(",");
|
||||
|
||||
var callback = function(response)
|
||||
{
|
||||
location.reload();
|
||||
};
|
||||
|
||||
apiPut("/linode/instances/" + data.params.lid, req, callback);
|
||||
};
|
||||
|
||||
// Handler for Lassie settings save
|
||||
var handleSaveLassie = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
var req = {
|
||||
"watchdog_enabled": (ui.lassie.value == "enabled")
|
||||
};
|
||||
|
||||
var callback = function(response)
|
||||
{
|
||||
ui.lassieSaved.style.display = "block";
|
||||
};
|
||||
|
||||
apiPut("/linode/instances/" + data.params.lid, req, callback);
|
||||
};
|
||||
|
||||
// Initial setup
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
// We need a Linode ID, so die if we don't have it
|
||||
if (!data.params.lid) {
|
||||
alert("No Linode ID supplied!");
|
||||
return;
|
||||
}
|
||||
|
||||
setupHeader();
|
||||
|
||||
// Update links on page to include proper Linode ID
|
||||
var anchors = document.getElementsByTagName("a");
|
||||
for (var i = 0; i < anchors.length; i++)
|
||||
anchors[i].href = anchors[i].href.replace("lid=0", "lid=" + data.params.lid);
|
||||
|
||||
// Get element references
|
||||
ui.alertsSaved = document.getElementById(elements.alertsSaved);
|
||||
ui.cpuEnabled = document.getElementById(elements.cpuEnabled);
|
||||
ui.cpuValue = document.getElementById(elements.cpuValue);
|
||||
ui.incomingEnabled = document.getElementById(elements.incomingEnabled);
|
||||
ui.incomingValue = document.getElementById(elements.incomingValue);
|
||||
ui.ioEnabled = document.getElementById(elements.ioEnabled);
|
||||
ui.ioValue = document.getElementById(elements.ioValue);
|
||||
ui.label = document.getElementById(elements.label);
|
||||
ui.lassie = document.getElementById(elements.lassie);
|
||||
ui.lassieSaved = document.getElementById(elements.lassieSaved);
|
||||
ui.linodeLabel = document.getElementById(elements.linodeLabel);
|
||||
ui.linodeTag = document.getElementById(elements.linodeTag);
|
||||
ui.linodeTagLink = document.getElementById(elements.linodeTagLink);
|
||||
ui.outboundEnabled = document.getElementById(elements.outboundEnabled);
|
||||
ui.outboundValue = document.getElementById(elements.outboundValue);
|
||||
ui.saveAlerts = document.getElementById(elements.saveAlerts);
|
||||
ui.saveDisplay = document.getElementById(elements.saveDisplay);
|
||||
ui.saveLassie = document.getElementById(elements.saveLassie);
|
||||
ui.tags = document.getElementById(elements.tags);
|
||||
ui.transferEnabled = document.getElementById(elements.transferEnabled);
|
||||
ui.transferValue = document.getElementById(elements.transferValue);
|
||||
|
||||
// Attach event handlers
|
||||
ui.saveAlerts.addEventListener("click", handleSaveAlerts);
|
||||
ui.saveDisplay.addEventListener("click", handleSaveDisplay);
|
||||
ui.saveLassie.addEventListener("click", handleSaveLassie);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/linode/instances/" + data.params.lid, displayDetails, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
Reference in New Issue
Block a user