Require renter settings to mount
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
document.getElementById(id).value = value;
|
||||
}
|
||||
|
||||
function getValue(id) {
|
||||
return document.getElementById(id).value;
|
||||
}
|
||||
|
||||
function setSelect(id, itemList) {
|
||||
const select = document.getElementById(id);
|
||||
select.innerHTML = "";
|
||||
@@ -116,11 +120,16 @@
|
||||
return window.uiState.isWalletLocked;
|
||||
}
|
||||
|
||||
function _allocatedRenterFunds() {
|
||||
return window.uiState.allocatedRenterFunds
|
||||
}
|
||||
|
||||
return {
|
||||
clientVersion: _clientVersion,
|
||||
isOnline: _isOnline,
|
||||
isWalletConfigured: _isWalletConfigured,
|
||||
isWalletLocked: _isWalletLocked
|
||||
isWalletLocked: _isWalletLocked,
|
||||
allocatedRenterFunds: _allocatedRenterFunds
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -220,42 +229,65 @@
|
||||
const mountSelect = document.getElementById('ID_MountDrives');
|
||||
|
||||
_mountHandler = ()=> {
|
||||
mountButton.onclick = null;
|
||||
mountButton.disabled = true;
|
||||
mountSelect.disabled = true;
|
||||
if (mountButton.innerText === "Mount") {
|
||||
AppActions.mountDrive(mountSelect.value, (success, reason) => {
|
||||
if (success) {
|
||||
mountButton.innerText = "Unmount";
|
||||
} else {
|
||||
displayErrorPopup('Mount Failed', reason);
|
||||
}
|
||||
mountButton.onclick = _mountHandler;
|
||||
mountButton.disabled = false;
|
||||
});
|
||||
if (UiState.allocatedRenterFunds() === '0') {
|
||||
displayErrorPopup('Error', 'Renter funding must be configured before trying to mount.')
|
||||
} else {
|
||||
AppActions.unmountDrive((success, reason) => {
|
||||
if (success) {
|
||||
_notifyDriveUnmounted()
|
||||
} else {
|
||||
displayErrorPopup('Unmount Failed', reason);
|
||||
mountButton.onclick = null;
|
||||
mountButton.disabled = true;
|
||||
mountSelect.disabled = true;
|
||||
if (mountButton.innerText === "Mount") {
|
||||
AppActions.mountDrive(mountSelect.value, (success, reason) => {
|
||||
if (success) {
|
||||
mountButton.innerText = "Unmount";
|
||||
} else {
|
||||
displayErrorPopup('Mount Failed', reason);
|
||||
}
|
||||
mountButton.onclick = _mountHandler;
|
||||
mountButton.disabled = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
AppActions.unmountDrive((success, reason) => {
|
||||
if (success) {
|
||||
_notifyDriveUnmounted()
|
||||
} else {
|
||||
displayErrorPopup('Unmount Failed', reason);
|
||||
mountButton.onclick = _mountHandler;
|
||||
mountButton.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
mountButton.onclick = _mountHandler;
|
||||
}
|
||||
|
||||
function handleRenterEditSettings() {
|
||||
|
||||
setMainWindow('renter_settings_window');
|
||||
const cancelButton = document.getElementById('ID_RenterSettingsCancel');
|
||||
cancelButton.onclick = ()=> {
|
||||
saveButton.onclick = null;
|
||||
cancelButton.onclick = null;
|
||||
beginMainApplication();
|
||||
}
|
||||
};
|
||||
|
||||
const saveButton = document.getElementById('ID_RenterSettingsOK');
|
||||
saveButton.onclick = ()=> {
|
||||
saveButton.onclick = null;
|
||||
cancelButton.onclick = null;
|
||||
AppActions.setRenterAllowance({
|
||||
'Funds': getValue('ID_RenterSetFunds'),
|
||||
'Hosts': getValue('ID_RenterSetHosts'),
|
||||
'Period': getValue('ID_RenterSetPeriod'),
|
||||
'RenewWindowInBlocks': getValue('ID_RenterSetRenewWindow')
|
||||
}, (success, reason)=> {
|
||||
if (success) {
|
||||
beginMainApplication();
|
||||
} else {
|
||||
displayErrorPopup('Allocation Failed', reason);
|
||||
handleRenterEditSettings();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function handleUnlockWallet() {
|
||||
|
Reference in New Issue
Block a user