Require renter settings to mount
This commit is contained in:
@@ -9,6 +9,10 @@
|
|||||||
document.getElementById(id).value = value;
|
document.getElementById(id).value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getValue(id) {
|
||||||
|
return document.getElementById(id).value;
|
||||||
|
}
|
||||||
|
|
||||||
function setSelect(id, itemList) {
|
function setSelect(id, itemList) {
|
||||||
const select = document.getElementById(id);
|
const select = document.getElementById(id);
|
||||||
select.innerHTML = "";
|
select.innerHTML = "";
|
||||||
@@ -116,11 +120,16 @@
|
|||||||
return window.uiState.isWalletLocked;
|
return window.uiState.isWalletLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _allocatedRenterFunds() {
|
||||||
|
return window.uiState.allocatedRenterFunds
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
clientVersion: _clientVersion,
|
clientVersion: _clientVersion,
|
||||||
isOnline: _isOnline,
|
isOnline: _isOnline,
|
||||||
isWalletConfigured: _isWalletConfigured,
|
isWalletConfigured: _isWalletConfigured,
|
||||||
isWalletLocked: _isWalletLocked
|
isWalletLocked: _isWalletLocked,
|
||||||
|
allocatedRenterFunds: _allocatedRenterFunds
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -220,42 +229,65 @@
|
|||||||
const mountSelect = document.getElementById('ID_MountDrives');
|
const mountSelect = document.getElementById('ID_MountDrives');
|
||||||
|
|
||||||
_mountHandler = ()=> {
|
_mountHandler = ()=> {
|
||||||
mountButton.onclick = null;
|
if (UiState.allocatedRenterFunds() === '0') {
|
||||||
mountButton.disabled = true;
|
displayErrorPopup('Error', 'Renter funding must be configured before trying to mount.')
|
||||||
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 {
|
} else {
|
||||||
AppActions.unmountDrive((success, reason) => {
|
mountButton.onclick = null;
|
||||||
if (success) {
|
mountButton.disabled = true;
|
||||||
_notifyDriveUnmounted()
|
mountSelect.disabled = true;
|
||||||
} else {
|
if (mountButton.innerText === "Mount") {
|
||||||
displayErrorPopup('Unmount Failed', reason);
|
AppActions.mountDrive(mountSelect.value, (success, reason) => {
|
||||||
|
if (success) {
|
||||||
|
mountButton.innerText = "Unmount";
|
||||||
|
} else {
|
||||||
|
displayErrorPopup('Mount Failed', reason);
|
||||||
|
}
|
||||||
mountButton.onclick = _mountHandler;
|
mountButton.onclick = _mountHandler;
|
||||||
mountButton.disabled = false;
|
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;
|
mountButton.onclick = _mountHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRenterEditSettings() {
|
function handleRenterEditSettings() {
|
||||||
|
|
||||||
setMainWindow('renter_settings_window');
|
setMainWindow('renter_settings_window');
|
||||||
const cancelButton = document.getElementById('ID_RenterSettingsCancel');
|
const cancelButton = document.getElementById('ID_RenterSettingsCancel');
|
||||||
cancelButton.onclick = ()=> {
|
cancelButton.onclick = ()=> {
|
||||||
|
saveButton.onclick = null;
|
||||||
cancelButton.onclick = null;
|
cancelButton.onclick = null;
|
||||||
beginMainApplication();
|
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() {
|
function handleUnlockWallet() {
|
||||||
|
@@ -5,10 +5,6 @@
|
|||||||
#define SIDRIVE_VERSION_STRING "0.0.1"
|
#define SIDRIVE_VERSION_STRING "0.0.1"
|
||||||
#define COMPAT_SIAD_VERSION "1.1.2"
|
#define COMPAT_SIAD_VERSION "1.1.2"
|
||||||
|
|
||||||
const std::uint8_t SIA_BLOCKS_PER_MIN = 10;
|
|
||||||
const std::uint32_t MINUTES_PER_MONTH = (730 * 60);
|
|
||||||
const std::uint32_t SIA_BLOCKS_PER_MONTH = MINUTES_PER_MONTH / SIA_BLOCKS_PER_MIN;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Disable DLL-interface warnings
|
// Disable DLL-interface warnings
|
||||||
#pragma warning(disable: 4251)
|
#pragma warning(disable: 4251)
|
||||||
@@ -117,6 +113,13 @@ inline bool ApiSuccess(const T& t) {
|
|||||||
typedef ttmath::UInt<256> Hastings;
|
typedef ttmath::UInt<256> Hastings;
|
||||||
typedef ttmath::Big<1, 30> SiaCurrency;
|
typedef ttmath::Big<1, 30> SiaCurrency;
|
||||||
|
|
||||||
|
const std::uint8_t SIA_BLOCK_TIME_MINS = 10;
|
||||||
|
const std::uint32_t MINUTES_PER_MONTH = (730 * 60);
|
||||||
|
const std::uint32_t SIA_BLOCKS_PER_MONTH = MINUTES_PER_MONTH / SIA_BLOCK_TIME_MINS;
|
||||||
|
const std::uint32_t SIA_DEFAULT_HOST_COUNT = 24;
|
||||||
|
const std::uint32_t SIA_DEFAULT_RENEW_WINDOW = (SIA_BLOCK_TIME_MINS * (SIA_DEFAULT_HOST_COUNT * 2));
|
||||||
|
const SiaCurrency SIA_DEFAULT_MINIMUM_FUNDS = 4000;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
|
BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
|
||||||
BigNumber.config({ DECIMAL_PLACES: 30 })
|
BigNumber.config({ DECIMAL_PLACES: 30 })
|
||||||
|
@@ -274,6 +274,7 @@ void CSiaDriveApp::OnContextCreated(
|
|||||||
obj->SetValue("isWalletConfigured", CefV8Value::CreateBool(_siaApi->GetWallet()->GetCreated()), V8_PROPERTY_ATTRIBUTE_NONE);
|
obj->SetValue("isWalletConfigured", CefV8Value::CreateBool(_siaApi->GetWallet()->GetCreated()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
obj->SetValue("isOnline", CefV8Value::CreateBool(_siaApi->GetWallet()->GetConnected()), V8_PROPERTY_ATTRIBUTE_NONE);
|
obj->SetValue("isOnline", CefV8Value::CreateBool(_siaApi->GetWallet()->GetConnected()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
obj->SetValue("clientVersion", CefV8Value::CreateString(SIDRIVE_VERSION_STRING), V8_PROPERTY_ATTRIBUTE_NONE);
|
obj->SetValue("clientVersion", CefV8Value::CreateString(SIDRIVE_VERSION_STRING), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
obj->SetValue("allocatedRenterFunds", CefV8Value::CreateString(_siaApi->GetRenter()->GetFunds().ToString()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
global->SetValue("uiState", obj, V8_PROPERTY_ATTRIBUTE_NONE);
|
global->SetValue("uiState", obj, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
CefRefPtr<FunctionHandler> handler(new FunctionHandler(*_siaApi, _appStarted, _siaDriveConfig, _siaDrive, [this]() {this->ShutdownServices(); }, [this](CefRefPtr<CefV8Context> context) {this->SiaApiRefreshCallback(context, *_siaCurl, _siaDriveConfig.get()); }));
|
CefRefPtr<FunctionHandler> handler(new FunctionHandler(*_siaApi, _appStarted, _siaDriveConfig, _siaDrive, [this]() {this->ShutdownServices(); }, [this](CefRefPtr<CefV8Context> context) {this->SiaApiRefreshCallback(context, *_siaCurl, _siaDriveConfig.get()); }));
|
||||||
|
@@ -80,6 +80,13 @@ void CSiaApi::_CSiaRenter::Refresh(const CSiaCurl& siaCurl, CSiaDriveConfig* sia
|
|||||||
SetPeriod(period);
|
SetPeriod(period);
|
||||||
_currentAllowance = { funds, hosts, period, renewWindow };
|
_currentAllowance = { funds, hosts, period, renewWindow };
|
||||||
|
|
||||||
|
if (_currentAllowance.Funds == 0)
|
||||||
|
{
|
||||||
|
_currentAllowance.Funds = SIA_DEFAULT_MINIMUM_FUNDS;
|
||||||
|
_currentAllowance.Hosts = SIA_DEFAULT_HOST_COUNT;
|
||||||
|
_currentAllowance.Period = SIA_BLOCKS_PER_MONTH * 3;
|
||||||
|
_currentAllowance.RenewWindowInBlocks = SIA_DEFAULT_RENEW_WINDOW;
|
||||||
|
}
|
||||||
if (ApiSuccess(RefreshFileTree()))
|
if (ApiSuccess(RefreshFileTree()))
|
||||||
{
|
{
|
||||||
CSiaFileTreePtr fileTree;
|
CSiaFileTreePtr fileTree;
|
||||||
|
Reference in New Issue
Block a user