1
0

Ui changes

This commit is contained in:
Scott E. Graves
2017-03-21 18:33:33 -05:00
parent ac4872557a
commit 87b0148865
7 changed files with 34 additions and 49 deletions

View File

@@ -3,7 +3,7 @@ set ROOT=%~dp0%
pushd "%ROOT%"
set CUR_PATH=%PATH%
call 3rd_party\CEF\create_debug.cmd
REM call 3rd_party\CEF\create_debug.cmd
set PATH=%CUR_PATH%
mkdir build

View File

@@ -3,7 +3,7 @@ set ROOT=%~dp0%
pushd "%ROOT%"
set CUR_PATH=%PATH%
call 3rd_party\CEF\create_release.cmd
REM call 3rd_party\CEF\create_release.cmd
set PATH=%CUR_PATH%
mkdir build

View File

@@ -59,6 +59,9 @@
Wallet: _wallet,
setBlockHeight: (height) => {
setInnerText('ID_BlockHeight', height);
},
setServerVersion: (version) => {
setInnerText('ID_ServerVersion', version);
}
};
})();
@@ -81,16 +84,11 @@
return window.uiState.isWalletLocked;
}
function _serverVersion() {
return window.uiState.serverVersion;
}
return {
clientVersion: _clientVersion,
isOnline: _isOnline,
isWalletConfigured: _isWalletConfigured,
isWalletLocked: _isWalletLocked,
serverVersion: _serverVersion
isWalletLocked: _isWalletLocked
};
})();
@@ -202,7 +200,7 @@
console.log('Main window load');
AppActions.stopApp();
document.getElementById('ID_SiaDrive').innerText = 'SiaDrive ' + UiState.clientVersion();
document.getElementById('ID_ServerVersion').innerText = UiState.serverVersion();
document.getElementById('ID_ServerVersion').innerText = '...';
if (UiState.isOnline()) {
if (UiState.isWalletConfigured()) {
if (UiState.isWalletLocked()) {

View File

@@ -27,6 +27,7 @@ private:
std::unique_ptr<Api::CSiaCurl> _siaCurl;
std::unique_ptr<Api::CSiaDriveConfig> _siaDriveConfig;
bool _appStarted = false;
SString _walletReceiveAddress;
public:
// CefApp methods:
@@ -46,6 +47,7 @@ public:
virtual void OnContextReleased(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;
private:
static void ExecuteSetter(CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> obj, const SString& method, const SString& value);
void SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const Api::CSiaCurl& siaCurl, Api::CSiaDriveConfig* siaDriveConfig);
private:

View File

@@ -1,5 +1,5 @@
@echo off
set ROOT=%~dp0%
set PATH=%ROOT%3rd_party\CEF\chromium_git\chromium\src\out\Debug_GN_x64;%PATH%
start build\debug\Debug\siadrive.exe
pushd "%ROOT%build\debug\dist\"
start siadrive.exe

View File

@@ -1,5 +1,5 @@
@echo off
set ROOT=%~dp0%
set PATH=%ROOT%3rd_party\CEF\chromium_git\chromium\src\out\Release_GN_x64;%PATH%
start build\release\Release\siadrive.exe
pushd "%ROOT%build\release\dist\"
start siadrive.exe

View File

@@ -154,6 +154,14 @@ CSiaDriveApp::CSiaDriveApp()
_siaApi.reset(new CSiaApi(hostConfig, _siaDriveConfig.get()));
}
void CSiaDriveApp::ExecuteSetter(CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> obj, const SString& method, const SString& value)
{
CefRefPtr<CefV8Value> setConfirmed = obj->GetValue(method.str());
CefV8ValueList args;
args.push_back(CefV8Value::CreateString(value.str()));
setConfirmed->ExecuteFunctionWithContext(context, nullptr, args);
}
void CSiaDriveApp::OnContextCreated(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
@@ -167,6 +175,7 @@ void CSiaDriveApp::OnContextCreated(
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("clientVersion", CefV8Value::CreateString(SIDRIVE_VERSION_STRING), V8_PROPERTY_ATTRIBUTE_NONE);
obj->SetValue("serverVersion", CefV8Value::CreateString("..."), V8_PROPERTY_ATTRIBUTE_NONE);
global->SetValue("uiState", obj, V8_PROPERTY_ATTRIBUTE_NONE);
CefRefPtr<FunctionHandler> handler(new FunctionHandler(*_siaApi, _appStarted));
@@ -258,54 +267,30 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
}
else if (_appStarted)
{
CefRefPtr<CefV8Value> uiActions = global->GetValue("uiUpdate");
auto uiActions = global->GetValue("uiUpdate");
ExecuteSetter(context, uiActions, "setServerVersion", _siaApi->GetServerVersion());
auto renterActions = uiActions->GetValue("Renter");
auto walletActions = uiActions->GetValue("Wallet");
// Display wallet data
CefRefPtr<CefV8Value> walletActions = uiActions->GetValue("Wallet");
auto confirmedBalance = _siaApi->GetWallet()->GetConfirmedBalance();
auto unconfirmedBalance = _siaApi->GetWallet()->GetUnconfirmedBalance();
auto totalBalance = confirmedBalance + unconfirmedBalance;
ExecuteSetter(context, walletActions, "setConfirmedBalance", SiaCurrencyToString(confirmedBalance));
ExecuteSetter(context, walletActions, "setUnconfirmedBalance", SiaCurrencyToString(unconfirmedBalance));
ExecuteSetter(context, walletActions, "setTotalBalance", SiaCurrencyToString(totalBalance));
if (_walletReceiveAddress.IsNullOrEmpty())
{
CefRefPtr<CefV8Value> setConfirmed = walletActions->GetValue("setConfirmedBalance");
CefV8ValueList args;
args.push_back(CefV8Value::CreateString(SiaCurrencyToString(confirmedBalance).str()));
CefRefPtr<CefV8Value> retval;
setConfirmed->ExecuteFunctionWithContext(context, nullptr, args);
}
{
CefRefPtr<CefV8Value> setUnconfirmed = walletActions->GetValue("setUnconfirmedBalance");
CefV8ValueList args;
args.push_back(CefV8Value::CreateString(SiaCurrencyToString(unconfirmedBalance).str()));
setUnconfirmed->ExecuteFunctionWithContext(context, nullptr, args);
}
{
CefRefPtr<CefV8Value> setTotalBal = walletActions->GetValue("setTotalBalance");
CefV8ValueList args;
args.push_back(CefV8Value::CreateString(SiaCurrencyToString(totalBalance).str()));
setTotalBal->ExecuteFunctionWithContext(context, nullptr, args);
}
{
CefRefPtr<CefV8Value> setReceiveAddress = walletActions->GetValue("setReceiveAddress");
CefV8ValueList args;
args.push_back(CefV8Value::CreateString(_siaApi->GetWallet()->GetReceiveAddress().str()));
setReceiveAddress->ExecuteFunctionWithContext(context, nullptr, args);
_walletReceiveAddress = _siaApi->GetWallet()->GetReceiveAddress();
ExecuteSetter(context, walletActions, "setReceiveAddress", _walletReceiveAddress);
}
// Display renter data
auto renterActions = uiActions->GetValue("Renter");
// Display block height
{
auto setBlockHeight = uiActions->GetValue("setBlockHeight");
CefV8ValueList args;
args.push_back(CefV8Value::CreateString(SString::FromUInt64(_siaApi->GetConsensus()->GetHeight()).str()));
setBlockHeight->ExecuteFunctionWithContext(context, nullptr, args);
}
ExecuteSetter(context, uiActions, "setBlockHeight", SString::FromUInt64(_siaApi->GetConsensus()->GetHeight()));
}
context->Exit();
}