Get region names from API instead of hard-coding them
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { settings, elements, regionNames, apiGet, apiPost, parseParams, setupHeader, timeString } from "/global.js";
|
||||
import { settings, elements, apiGet, apiPost, parseParams, setupHeader, timeString } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { settings, elements, regionNames, apiGet, apiDelete, parseParams, setupHeader, timeString } from "/global.js";
|
||||
import { settings, elements, apiGet, apiDelete, parseParams, setupHeader, timeString } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { settings, elements, regionNames, apiGet, apiPut, parseParams, setupHeader, timeString } from "/global.js";
|
||||
import { settings, elements, apiGet, apiPut, parseParams, setupHeader, timeString } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { settings, elements, regionNames, apiGet, parseParams, setupHeader, timeString } from "/global.js";
|
||||
import { settings, elements, apiGet, parseParams, setupHeader, timeString } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
|
@ -46,7 +46,14 @@ along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
</tr>
|
||||
<tr class="lmc-tr3">
|
||||
<td>Region</td>
|
||||
<td><select id="region"></select></td>
|
||||
<td><select id="region">
|
||||
<optgroup id="na" label="North America"></optgroup>
|
||||
<optgroup id="eu" label="Europe"></optgroup>
|
||||
<optgroup id="ap" label="Asia/Pacific"></optgroup>
|
||||
<optgroup id="sa" label="South America"></optgroup>
|
||||
<optgroup id="af" label="Africa"></optgroup>
|
||||
<optgroup id="dc-other" label="Other"></optgroup>
|
||||
</select></td>
|
||||
<td class="info">
|
||||
For fastest initial upload, select the region that is geographically closest to you.<br />
|
||||
Once uploaded you will be able to deploy the image to other regions.
|
||||
|
@ -17,6 +17,10 @@
|
||||
|
||||
@import url('/global.css');
|
||||
|
||||
optgroup {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.step-2 {
|
||||
display: none;
|
||||
}
|
||||
|
@ -15,11 +15,12 @@
|
||||
* along with Linode Manager Classic. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { settings, elements, regionNames, apiGet, apiPost, objPut, parseParams, setupHeader } from "/global.js";
|
||||
import { settings, elements, regionNames, countryContinents, apiGet, apiPost, objPut, parseParams, setupHeader } from "/global.js";
|
||||
|
||||
(function()
|
||||
{
|
||||
// Element names specific to this page
|
||||
elements.dcOther = "dc-other";
|
||||
elements.description = "description";
|
||||
elements.imageFile = "image-file";
|
||||
elements.label = "label";
|
||||
@ -35,6 +36,7 @@ import { settings, elements, regionNames, apiGet, apiPost, objPut, parseParams,
|
||||
|
||||
// Static references to UI elements
|
||||
var ui = {};
|
||||
ui.dcOther = {};
|
||||
ui.description = {};
|
||||
ui.imageFile = {};
|
||||
ui.label = {};
|
||||
@ -49,11 +51,19 @@ import { settings, elements, regionNames, apiGet, apiPost, objPut, parseParams,
|
||||
for (var i = 0; i < response.data.length; i++) {
|
||||
var dc = document.createElement("option");
|
||||
dc.value = response.data[i].id;
|
||||
if (regionNames[response.data[i].id])
|
||||
if (response.data[i].label && response.data[i].label.length)
|
||||
dc.innerHTML = response.data[i].label;
|
||||
else if (regionNames[response.data[i].id])
|
||||
dc.innerHTML = regionNames[response.data[i].id];
|
||||
else
|
||||
dc.innerHTML = response.data[i].id;
|
||||
ui.region.appendChild(dc);
|
||||
var optgroup = null;
|
||||
if (countryContinents[response.data[i].country])
|
||||
optgroup = document.getElementById(countryContinents[response.data[i].country]);
|
||||
if (!optgroup)
|
||||
optgroup = ui.dcOther;
|
||||
optgroup.style.display = "initial";
|
||||
optgroup.appendChild(dc);
|
||||
}
|
||||
|
||||
ui.nextButton.disabled = false;
|
||||
@ -126,6 +136,7 @@ import { settings, elements, regionNames, apiGet, apiPost, objPut, parseParams,
|
||||
}
|
||||
|
||||
// Get element references
|
||||
ui.dcOther = document.getElementById(elements.dcOther);
|
||||
ui.description = document.getElementById(elements.description);
|
||||
ui.imageFile = document.getElementById(elements.imageFile);
|
||||
ui.label = document.getElementById(elements.label);
|
||||
|
Reference in New Issue
Block a user