1
0

Fix drive list

This commit is contained in:
Scott E. Graves
2017-04-12 10:22:03 -05:00
parent 3f26144975
commit 342989e4d1

View File

@@ -14,12 +14,24 @@
function setSelect(id, itemList) {
const select = document.getElementById(id);
select.innerHTML = "";
const allowChange = select['allow_change'] !== false;
for (const item of itemList) {
const opt = document.createElement('option');
opt.innerText = item;
select.appendChild(opt);
if (allowChange) {
while (select.options.length > itemList.length) {
select.removeChild(select.options[select.options.length - 1]);
}
for (let i = 0; i < itemList.length; i++) {
if (select.options[i]) {
if (select.options[i].text !== itemList[i]) {
select.options[i].text = itemList[i];
}
} else {
const opt = document.createElement('option');
opt.text = itemList[i];
select.appendChild(opt);
}
}
}
}
@@ -98,9 +110,7 @@
setInnerText('ID_ServerVersion', version);
},
setAvailableDriveLetters: (drives) => {
if (document.getElementById('ID_MountButton').innerText !== 'Unmount') {
setSelect('ID_MountDrives', drives);
}
setSelect('ID_MountDrives', drives);
},
notifyDriveUnmounted: _notifyDriveUnmounted,
reloadApplication: reloadApplication
@@ -229,6 +239,7 @@
mountButton.onclick = _mountHandler;
mountButton.disabled = false;
mountSelect.disabled = false;
mountSelect['allow_change'] = true;
}
}
@@ -244,6 +255,7 @@
const mountSelect = document.getElementById('ID_MountDrives');
_mountHandler = () => {
mountSelect['allow_change'] = false;
if (UiState.allocatedRenterFunds() === '0') {
displayErrorPopup('Error', 'Renter funding must be configured before trying to mount.')
} else {
@@ -268,6 +280,7 @@
displayErrorPopup('Unmount Failed', reason);
mountButton.onclick = _mountHandler;
mountButton.disabled = false;
mountSelect['allow_change'] = true;
}
});
}