Ui changes
This commit is contained in:
@@ -3,7 +3,7 @@ set ROOT=%~dp0%
|
|||||||
pushd "%ROOT%"
|
pushd "%ROOT%"
|
||||||
|
|
||||||
set CUR_PATH=%PATH%
|
set CUR_PATH=%PATH%
|
||||||
call 3rd_party\CEF\create_debug.cmd
|
REM call 3rd_party\CEF\create_debug.cmd
|
||||||
set PATH=%CUR_PATH%
|
set PATH=%CUR_PATH%
|
||||||
|
|
||||||
mkdir build
|
mkdir build
|
||||||
|
@@ -3,7 +3,7 @@ set ROOT=%~dp0%
|
|||||||
pushd "%ROOT%"
|
pushd "%ROOT%"
|
||||||
|
|
||||||
set CUR_PATH=%PATH%
|
set CUR_PATH=%PATH%
|
||||||
call 3rd_party\CEF\create_release.cmd
|
REM call 3rd_party\CEF\create_release.cmd
|
||||||
set PATH=%CUR_PATH%
|
set PATH=%CUR_PATH%
|
||||||
|
|
||||||
mkdir build
|
mkdir build
|
||||||
|
@@ -59,6 +59,9 @@
|
|||||||
Wallet: _wallet,
|
Wallet: _wallet,
|
||||||
setBlockHeight: (height) => {
|
setBlockHeight: (height) => {
|
||||||
setInnerText('ID_BlockHeight', height);
|
setInnerText('ID_BlockHeight', height);
|
||||||
|
},
|
||||||
|
setServerVersion: (version) => {
|
||||||
|
setInnerText('ID_ServerVersion', version);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
@@ -81,16 +84,11 @@
|
|||||||
return window.uiState.isWalletLocked;
|
return window.uiState.isWalletLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _serverVersion() {
|
|
||||||
return window.uiState.serverVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
clientVersion: _clientVersion,
|
clientVersion: _clientVersion,
|
||||||
isOnline: _isOnline,
|
isOnline: _isOnline,
|
||||||
isWalletConfigured: _isWalletConfigured,
|
isWalletConfigured: _isWalletConfigured,
|
||||||
isWalletLocked: _isWalletLocked,
|
isWalletLocked: _isWalletLocked
|
||||||
serverVersion: _serverVersion
|
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -202,7 +200,7 @@
|
|||||||
console.log('Main window load');
|
console.log('Main window load');
|
||||||
AppActions.stopApp();
|
AppActions.stopApp();
|
||||||
document.getElementById('ID_SiaDrive').innerText = 'SiaDrive ' + UiState.clientVersion();
|
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.isOnline()) {
|
||||||
if (UiState.isWalletConfigured()) {
|
if (UiState.isWalletConfigured()) {
|
||||||
if (UiState.isWalletLocked()) {
|
if (UiState.isWalletLocked()) {
|
||||||
|
@@ -27,6 +27,7 @@ private:
|
|||||||
std::unique_ptr<Api::CSiaCurl> _siaCurl;
|
std::unique_ptr<Api::CSiaCurl> _siaCurl;
|
||||||
std::unique_ptr<Api::CSiaDriveConfig> _siaDriveConfig;
|
std::unique_ptr<Api::CSiaDriveConfig> _siaDriveConfig;
|
||||||
bool _appStarted = false;
|
bool _appStarted = false;
|
||||||
|
SString _walletReceiveAddress;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CefApp methods:
|
// CefApp methods:
|
||||||
@@ -46,6 +47,7 @@ public:
|
|||||||
virtual void OnContextReleased(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;
|
virtual void OnContextReleased(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||||
|
|
||||||
private:
|
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);
|
void SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const Api::CSiaCurl& siaCurl, Api::CSiaDriveConfig* siaDriveConfig);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
@echo off
|
@echo off
|
||||||
set ROOT=%~dp0%
|
set ROOT=%~dp0%
|
||||||
|
|
||||||
set PATH=%ROOT%3rd_party\CEF\chromium_git\chromium\src\out\Debug_GN_x64;%PATH%
|
pushd "%ROOT%build\debug\dist\"
|
||||||
start build\debug\Debug\siadrive.exe
|
start siadrive.exe
|
@@ -1,5 +1,5 @@
|
|||||||
@echo off
|
@echo off
|
||||||
set ROOT=%~dp0%
|
set ROOT=%~dp0%
|
||||||
|
|
||||||
set PATH=%ROOT%3rd_party\CEF\chromium_git\chromium\src\out\Release_GN_x64;%PATH%
|
pushd "%ROOT%build\release\dist\"
|
||||||
start build\release\Release\siadrive.exe
|
start siadrive.exe
|
@@ -154,6 +154,14 @@ CSiaDriveApp::CSiaDriveApp()
|
|||||||
_siaApi.reset(new CSiaApi(hostConfig, _siaDriveConfig.get()));
|
_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(
|
void CSiaDriveApp::OnContextCreated(
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
@@ -167,6 +175,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("serverVersion", CefV8Value::CreateString("..."), 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));
|
CefRefPtr<FunctionHandler> handler(new FunctionHandler(*_siaApi, _appStarted));
|
||||||
@@ -258,54 +267,30 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
|||||||
}
|
}
|
||||||
else if (_appStarted)
|
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
|
// Display wallet data
|
||||||
CefRefPtr<CefV8Value> walletActions = uiActions->GetValue("Wallet");
|
|
||||||
|
|
||||||
auto confirmedBalance = _siaApi->GetWallet()->GetConfirmedBalance();
|
auto confirmedBalance = _siaApi->GetWallet()->GetConfirmedBalance();
|
||||||
auto unconfirmedBalance = _siaApi->GetWallet()->GetUnconfirmedBalance();
|
auto unconfirmedBalance = _siaApi->GetWallet()->GetUnconfirmedBalance();
|
||||||
auto totalBalance = confirmedBalance + unconfirmedBalance;
|
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");
|
_walletReceiveAddress = _siaApi->GetWallet()->GetReceiveAddress();
|
||||||
CefV8ValueList args;
|
ExecuteSetter(context, walletActions, "setReceiveAddress", _walletReceiveAddress);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display renter data
|
// Display renter data
|
||||||
auto renterActions = uiActions->GetValue("Renter");
|
|
||||||
|
|
||||||
// Display block height
|
// Display block height
|
||||||
{
|
ExecuteSetter(context, uiActions, "setBlockHeight", SString::FromUInt64(_siaApi->GetConsensus()->GetHeight()));
|
||||||
auto setBlockHeight = uiActions->GetValue("setBlockHeight");
|
|
||||||
CefV8ValueList args;
|
|
||||||
args.push_back(CefV8Value::CreateString(SString::FromUInt64(_siaApi->GetConsensus()->GetHeight()).str()));
|
|
||||||
setBlockHeight->ExecuteFunctionWithContext(context, nullptr, args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
context->Exit();
|
context->Exit();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user