Added Account section
This commit is contained in:
27
account/contact/contact.css
Normal file
27
account/contact/contact.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');
|
||||
|
||||
#contact {
|
||||
padding: 15px 15px 15px;
|
||||
}
|
||||
|
||||
tbody tr td:first-of-type {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
143
account/contact/contact.js
Normal file
143
account/contact/contact.js
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 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";
|
||||
import { countries } from "/account/contact/countries.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.address1 = "address1";
|
||||
elements.address2 = "address2";
|
||||
elements.city = "city";
|
||||
elements.company = "company";
|
||||
elements.country = "country";
|
||||
elements.email = "email";
|
||||
elements.firstName = "first-name";
|
||||
elements.lastName = "last-name";
|
||||
elements.phone = "phone";
|
||||
elements.saveButton = "save-button";
|
||||
elements.state = "state";
|
||||
elements.tax = "tax";
|
||||
elements.zip = "zip";
|
||||
|
||||
// Data received from API calls
|
||||
var data = {};
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.address1 = {};
|
||||
ui.address2 = {};
|
||||
ui.city = {};
|
||||
ui.company = {};
|
||||
ui.country = {};
|
||||
ui.email = {};
|
||||
ui.firstName = {};
|
||||
ui.lastName = {};
|
||||
ui.phone = {};
|
||||
ui.saveButton = {};
|
||||
ui.state = {};
|
||||
ui.tax = {};
|
||||
ui.zip = {};
|
||||
|
||||
// Callback for account details API call
|
||||
var displayAccount = function(response)
|
||||
{
|
||||
ui.company.value = response.company;
|
||||
ui.email.value = response.email;
|
||||
ui.firstName.value = response.first_name;
|
||||
ui.lastName.value = response.last_name;
|
||||
ui.address1.value = response.address_1;
|
||||
ui.address2.value = response.address_2;
|
||||
ui.city.value = response.city;
|
||||
ui.state.value = response.state;
|
||||
ui.zip.value = response.zip;
|
||||
ui.country.value = response.country;
|
||||
ui.tax.value = response.tax_id;
|
||||
ui.phone.value = response.phone;
|
||||
|
||||
ui.saveButton.disabled = false;
|
||||
};
|
||||
|
||||
// Click handler for save button
|
||||
var handleSave = function(event)
|
||||
{
|
||||
if (event.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
var req = {
|
||||
"company": ui.company.value,
|
||||
"email": ui.email.value,
|
||||
"first_name": ui.firstName.value,
|
||||
"last_name": ui.lastName.value,
|
||||
"address_1": ui.address1.value,
|
||||
"address_2": ui.address2.value,
|
||||
"city": ui.city.value,
|
||||
"state": ui.state.value,
|
||||
"zip": ui.zip.value,
|
||||
"country": ui.country.value,
|
||||
"tax": ui.tax.value,
|
||||
"phone": ui.phone.value
|
||||
};
|
||||
|
||||
apiPut("/account", req, function(response)
|
||||
{
|
||||
location.href = "/account";
|
||||
});
|
||||
};
|
||||
|
||||
// Initial setup
|
||||
var setup = function()
|
||||
{
|
||||
// Parse URL parameters
|
||||
data.params = parseParams();
|
||||
|
||||
setupHeader();
|
||||
|
||||
// Get element references
|
||||
ui.address1 = document.getElementById(elements.address1);
|
||||
ui.address2 = document.getElementById(elements.address2);
|
||||
ui.city = document.getElementById(elements.city);
|
||||
ui.company = document.getElementById(elements.company);
|
||||
ui.country = document.getElementById(elements.country);
|
||||
ui.email = document.getElementById(elements.email);
|
||||
ui.firstName = document.getElementById(elements.firstName);
|
||||
ui.lastName = document.getElementById(elements.lastName);
|
||||
ui.phone = document.getElementById(elements.phone);
|
||||
ui.saveButton = document.getElementById(elements.saveButton);
|
||||
ui.state = document.getElementById(elements.state);
|
||||
ui.tax = document.getElementById(elements.tax);
|
||||
ui.zip = document.getElementById(elements.zip);
|
||||
|
||||
// Populate country selector
|
||||
for (var i = 0; i < countries.length; i++) {
|
||||
var option = document.createElement("option");
|
||||
option.value = countries[i].code;
|
||||
option.innerHTML = countries[i]["name"];
|
||||
ui.country.appendChild(option);
|
||||
}
|
||||
|
||||
// Register event handlers
|
||||
ui.saveButton.addEventListener("click", handleSave);
|
||||
|
||||
// Get data from API
|
||||
apiGet("/account", displayAccount, null);
|
||||
};
|
||||
|
||||
// Attach onload handler
|
||||
window.addEventListener("load", setup);
|
||||
})();
|
1013
account/contact/countries.js
Normal file
1013
account/contact/countries.js
Normal file
File diff suppressed because it is too large
Load Diff
107
account/contact/index.shtml
Normal file
107
account/contact/index.shtml
Normal file
@ -0,0 +1,107 @@
|
||||
<!--
|
||||
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 // Contact Info</title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="contact.css" />
|
||||
<script src="contact.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="contact">
|
||||
<table class="lmc-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="3">Contact Information</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Company Name</td>
|
||||
<td><input id="company" type="text" size="30" maxLength="128" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Email</td>
|
||||
<td><input id="email" type="email" size="30" maxLength="128" /></td>
|
||||
<td class="info">Main point of contact and receives all emails.</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>First Name</td>
|
||||
<td><input id="first-name" type="text" size="30" maxLength="50" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Last Name</td>
|
||||
<td><input id="last-name" type="text" size="30" maxLength="50" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Address1</td>
|
||||
<td><input id="address1" type="text" size="30" maxLength="64" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Address2</td>
|
||||
<td><input id="address2" type="text" size="30" maxLength="64" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>City</td>
|
||||
<td><input id="city" type="text" size="30" maxLength="24" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>State</td>
|
||||
<td><input id="state" type="text" size="30" maxLength="24" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Zip</td>
|
||||
<td><input id="zip" type="text" size="30" maxLength="16" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Country</td>
|
||||
<td><select id="country"></select></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Tax ID</td>
|
||||
<td><input id="tax" type="text" size="30" maxLength="100" /></td>
|
||||
<td class="info">VAT, GST, etc. identification number</td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Phone1</td>
|
||||
<td><input id="phone" type="tel" size="30" maxLength="32" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td></td>
|
||||
<td colspan="2"><button disabled id="save-button" type="button">Save Changes</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user