Settings
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<div class="padded" id="main_window" style="padding-top: 0;"></div>
|
||||
<div class="hidden-element" id="app_window">
|
||||
<div class="box" id="general_info">
|
||||
<h1>Sia Information</h1>
|
||||
<h1>Sia Information <a href="javascript:void(0)" id="ID_Sia_Settings_Edit">settings</a></h1>
|
||||
<div style="float: right;">
|
||||
<table>
|
||||
<tr>
|
||||
@@ -173,6 +173,20 @@
|
||||
<button id="ID_RenterSettingsCancel" type="button">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden-element" id="sia_settings_window">
|
||||
<div class="box" id="sia_settings">
|
||||
<h1>Sia Settings</h1>
|
||||
<h2>Lock Wallet on Application Exit</h2>
|
||||
<input type="checkbox" id="ID_SettingsLockWalletOnExit"><br><br>
|
||||
<h2>Auto-start on Logon</h2>
|
||||
<input type="checkbox" id="ID_SettingsAutoStart"><br><br>
|
||||
<h2>Use Bundled siad</h2>
|
||||
<input type="checkbox" id="ID_SettingsLaunchServer"><br><br>
|
||||
<button id="ID_SiaSettingsDefaults" type="button">Defaults</button>
|
||||
<button id="ID_SiaSettingsOK" type="button">Save</button>
|
||||
<button id="ID_SiaSettingsCancel" type="button">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden-element" id="upload_progress_window">
|
||||
<div class="box">
|
||||
<h1>Upload Progress</h1>
|
||||
|
@@ -8,6 +8,10 @@
|
||||
document.getElementById(id).value = value;
|
||||
}
|
||||
|
||||
function setChecked(id, value) {
|
||||
document.getElementById(id)["checked"] = value;
|
||||
}
|
||||
|
||||
function getValue(id) {
|
||||
return document.getElementById(id).value;
|
||||
}
|
||||
@@ -117,6 +121,11 @@
|
||||
},
|
||||
setReceiveAddress: (address) => {
|
||||
setInnerText('ID_WalletReceiveAddress', address);
|
||||
},
|
||||
setLockWalletOnExit: (lock) => {
|
||||
if (document.getElementById('sia_settings_window').classList.contains('hidden-element')) {
|
||||
setChecked('ID_SettingsLockWalletOnExit', lock);
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -134,7 +143,17 @@
|
||||
setSelect('ID_MountDrives', drives);
|
||||
},
|
||||
notifyDriveUnmounted: _notifyDriveUnmounted,
|
||||
reloadApplication: reloadApplication
|
||||
reloadApplication: reloadApplication,
|
||||
setAutoStartOnLogon: (start) => {
|
||||
if (document.getElementById('sia_settings_window').classList.contains('hidden-element')) {
|
||||
setChecked('ID_SettingsAutoStart', start);
|
||||
}
|
||||
},
|
||||
setLaunchBundledSiad: (launch) => {
|
||||
if (document.getElementById('sia_settings_window').classList.contains('hidden-element')) {
|
||||
setChecked('ID_SettingsLaunchServer', launch);
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -274,9 +293,23 @@
|
||||
};
|
||||
}
|
||||
|
||||
function handleSiaEditSettings() {
|
||||
setMainWindow('sia_settings_window');
|
||||
const cancelButton = document.getElementById('ID_SiaSettingsCancel');
|
||||
cancelButton.onclick = () => {
|
||||
cancelButton.onclick = null;
|
||||
beginMainApplication();
|
||||
};
|
||||
}
|
||||
|
||||
function beginMainApplication() {
|
||||
AppActions.startApp();
|
||||
setMainWindow('app_window');
|
||||
const settingsEditLink = document.getElementById('ID_Sia_Settings_Edit');
|
||||
settingsEditLink.onclick = () => {
|
||||
settingsEditLink.onclick = null;
|
||||
handleSiaEditSettings();
|
||||
};
|
||||
const renterEditLink = document.getElementById('ID_Renter_Edit');
|
||||
renterEditLink.onclick = () => {
|
||||
renterEditLink.onclick = null;
|
||||
|
@@ -109,7 +109,9 @@ set_access:\
|
||||
get_access:\
|
||||
type Get##name() const { return json_doc[#name].get<type>();}\
|
||||
set_access:\
|
||||
type Set##name(const type& value) { json_doc[#name] = value; return value; }
|
||||
type Set##name(const type& value) { json_doc[#name] = value; return value; }\
|
||||
protected:\
|
||||
bool Check##name() { return json_doc.find(#name) != json_doc.end(); }
|
||||
|
||||
template<typename T>
|
||||
class CSiaError
|
||||
|
@@ -20,13 +20,16 @@ public:
|
||||
JProperty(std::string, CacheFolder, public, public, _configDocument)
|
||||
JProperty(std::uint16_t, HostPort, public, public, _configDocument)
|
||||
JProperty(std::uint8_t, MaxUploadCount, public, public, _configDocument)
|
||||
JProperty(std::string, HostNameOrIp, public, public, _configDocument)
|
||||
JProperty(std::string, HostNameOrIp, public, public, _configDocument)
|
||||
JProperty(bool, LockWalletOnExit, public, public, _configDocument)
|
||||
JProperty(bool, AutoStartOnLogon, public, public, _configDocument)
|
||||
JProperty(bool, LaunchBundledSiad, public, public, _configDocument)
|
||||
|
||||
private:
|
||||
json _configDocument;
|
||||
|
||||
private:
|
||||
void LoadDefaults();
|
||||
bool LoadDefaults();
|
||||
|
||||
void Load( );
|
||||
|
||||
|
@@ -407,11 +407,13 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
||||
auto renterActions = uiActions->GetValue("Renter");
|
||||
auto walletActions = uiActions->GetValue("Wallet");
|
||||
|
||||
// Update UI state and server version
|
||||
// Update UI state, server version and settings
|
||||
ExecuteSetter(context, uiActions, "setServerVersion", _siaApi->GetServerVersion());
|
||||
uiState->SetValue("isWalletLocked", CefV8Value::CreateBool(_siaApi->GetWallet()->GetLocked()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
uiState->SetValue("isWalletConfigured", CefV8Value::CreateBool(_siaApi->GetWallet()->GetCreated()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
uiState->SetValue("allocatedRenterFunds", CefV8Value::CreateString(_siaApi->GetRenter()->GetFunds().ToString()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
ExecuteSetter(context, uiActions, "setAutoStartOnLogon", CefV8Value::CreateBool(_siaDriveConfig->GetAutoStartOnLogon()));
|
||||
ExecuteSetter(context, uiActions, "setLaunchBundledSiad", CefV8Value::CreateBool(_siaDriveConfig->GetLaunchBundledSiad()));
|
||||
|
||||
// Display wallet data
|
||||
auto confirmedBalance = _siaApi->GetWallet()->GetConfirmedBalance();
|
||||
@@ -420,7 +422,7 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
||||
ExecuteSetter(context, walletActions, "setConfirmedBalance", SiaCurrencyToString(confirmedBalance));
|
||||
ExecuteSetter(context, walletActions, "setUnconfirmedBalance", SiaCurrencyToString(unconfirmedBalance));
|
||||
ExecuteSetter(context, walletActions, "setTotalBalance", SiaCurrencyToString(totalBalance));
|
||||
|
||||
ExecuteSetter(context, walletActions, "setLockWalletOnExit", CefV8Value::CreateBool(_siaDriveConfig->GetLockWalletOnExit()));
|
||||
if (_walletReceiveAddress.IsNullOrEmpty())
|
||||
{
|
||||
_walletReceiveAddress = _siaApi->GetWallet()->GetReceiveAddress();
|
||||
|
@@ -19,8 +19,10 @@ CSiaApi::CSiaApi(const SiaHostConfig& hostConfig, CSiaDriveConfig* siaDriveConfi
|
||||
CSiaApi::~CSiaApi()
|
||||
{
|
||||
_refreshThread->StopAutoThread();
|
||||
//TODO Make this an option to lock on exit
|
||||
//_wallet->Lock();
|
||||
if (_siaDriveConfig->GetLockWalletOnExit())
|
||||
{
|
||||
_wallet->Lock();
|
||||
}
|
||||
}
|
||||
|
||||
void CSiaApi::Refresh(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig)
|
||||
|
@@ -20,20 +20,67 @@ CSiaDriveConfig::~CSiaDriveConfig()
|
||||
Save();
|
||||
}
|
||||
|
||||
void CSiaDriveConfig::LoadDefaults()
|
||||
bool CSiaDriveConfig::LoadDefaults()
|
||||
{
|
||||
SetRenter_UploadDbFilePath(static_cast<SString>(FilePath(DEFAULT_RENTER_DB_FILE_PATH).Resolve()));
|
||||
bool changed = false;
|
||||
if (!CheckRenter_UploadDbFilePath())
|
||||
{
|
||||
SetRenter_UploadDbFilePath(static_cast<SString>(FilePath(DEFAULT_RENTER_DB_FILE_PATH).Resolve()));
|
||||
changed = true;
|
||||
}
|
||||
|
||||
FilePath tempFolder = FilePath::GetTempDirectory();
|
||||
SetTempFolder(static_cast<SString>(tempFolder));
|
||||
if (!CheckTempFolder())
|
||||
{
|
||||
FilePath tempFolder = FilePath::GetTempDirectory();
|
||||
SetTempFolder(static_cast<SString>(tempFolder));
|
||||
changed = true;
|
||||
}
|
||||
|
||||
FilePath cacheFolder(FilePath::GetAppDataDirectory(), "siadrive");
|
||||
cacheFolder.Append("cache");
|
||||
SetCacheFolder(static_cast<SString>(cacheFolder));
|
||||
if (!CheckCacheFolder())
|
||||
{
|
||||
FilePath cacheFolder(FilePath::GetAppDataDirectory(), "siadrive");
|
||||
cacheFolder.Append("cache");
|
||||
SetCacheFolder(static_cast<SString>(cacheFolder));
|
||||
changed = true;
|
||||
}
|
||||
|
||||
SetHostNameOrIp("localhost");
|
||||
SetHostPort(9980);
|
||||
SetMaxUploadCount(20);
|
||||
if (!CheckHostNameOrIp())
|
||||
{
|
||||
SetHostNameOrIp("localhost");
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!CheckHostPort())
|
||||
{
|
||||
SetHostPort(9980);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!CheckMaxUploadCount())
|
||||
{
|
||||
SetMaxUploadCount(20);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!CheckLockWalletOnExit())
|
||||
{
|
||||
SetLockWalletOnExit(true);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!CheckAutoStartOnLogon())
|
||||
{
|
||||
SetAutoStartOnLogon(false);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!CheckLaunchBundledSiad())
|
||||
{
|
||||
SetLaunchBundledSiad(true);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
void CSiaDriveConfig::Load( )
|
||||
@@ -48,9 +95,9 @@ void CSiaDriveConfig::Load( )
|
||||
_configDocument = json::parse(jsonTxt.begin(), jsonTxt.end());
|
||||
myfile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadDefaults();
|
||||
|
||||
if (LoadDefaults())
|
||||
{
|
||||
Save();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user