Continue UI
This commit is contained in:
2
3rd_party/CEF/depot_tools
vendored
2
3rd_party/CEF/depot_tools
vendored
Submodule 3rd_party/CEF/depot_tools updated: ecf3dbe49f...e86f6de842
@@ -3,11 +3,11 @@
|
||||
--h2-font-size: 18px;
|
||||
--h3-font-size: 16px;
|
||||
--default-font-size: 14px;
|
||||
--h1-color: #70b991;
|
||||
--h1-color: #64aa82;
|
||||
--app-header-font-size: 25px;
|
||||
--default-animation-time: .5s;
|
||||
--default-font-color: #c2c2c2;
|
||||
--default-header-color: #a7b6bf;
|
||||
--default-header-color: #a5b3c0;
|
||||
--default-amount-color: #a5b3c0;
|
||||
--default-padding: 0 0 8px 0;
|
||||
}
|
||||
|
@@ -10,7 +10,10 @@
|
||||
<script src="js/index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="padded" id="main_window"></div>
|
||||
<div class="padded" style="padding-bottom: 0;">
|
||||
<h1 style="font-size: 24px;padding-bottom: 0;"> SiaDrive v0.0.1</h1>
|
||||
</div>
|
||||
<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>
|
||||
@@ -128,10 +131,16 @@
|
||||
<div class="box">
|
||||
<h1>Enter Password</h1>
|
||||
<p>Enter wallet password and click 'Unlock' to continue.</p>
|
||||
<input type="password" id="ID_WalletUnlockPwd" style="width: inherit"/><br/><br/>
|
||||
<input type="password" id="ID_WalletUnlockPwd" style="width: 100%"/><br/><br/>
|
||||
<button id="ID_UnlockWalletButton">Unlock</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden-element" id="unlocking_window">
|
||||
<div class="box">
|
||||
<h1>Please Wait</h1>
|
||||
<p>SiaDrive will refresh once unlocking is complete. This may take several minutes, so please be patient.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden-element" id="create_window">
|
||||
<div class="box">
|
||||
<h1>Create New Wallet</h1>
|
||||
|
@@ -21,6 +21,16 @@
|
||||
};
|
||||
})();
|
||||
|
||||
const UiActions = (() => {
|
||||
function _unlockWallet(pwd, cb) {
|
||||
return window.uiActions.unlockWallet(pwd, cb);
|
||||
}
|
||||
|
||||
return {
|
||||
unlockWallet: _unlockWallet
|
||||
};
|
||||
})();
|
||||
|
||||
function setMainWindow(name) {
|
||||
console.log('Setting main window: ' + name);
|
||||
const elem = document.getElementById(name);
|
||||
@@ -37,12 +47,34 @@
|
||||
mainWindow.appendChild(elem);
|
||||
}
|
||||
|
||||
function displayErrorPopup(title, msg, cb) {
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('load', ()=> {
|
||||
console.log('Main window load');
|
||||
if (UiState.isOnline()) {
|
||||
if (UiState.isWalletConfigured()) {
|
||||
if (UiState.isWalletLocked()) {
|
||||
setMainWindow('unlock_window');
|
||||
const unlockButton = document.getElementById('ID_UnlockWalletButton');
|
||||
unlockButton.onclick = ()=> {
|
||||
const password = document.getElementById('ID_WalletUnlockPwd');
|
||||
if (UiActions.unlockWallet(password.value, (success, reason) => {
|
||||
password.value = '';
|
||||
if (success) {
|
||||
setMainWindow('app_window');
|
||||
} else {
|
||||
displayErrorPopup('Failed to unlock wallet', reason, ()=> {
|
||||
window.reload();
|
||||
});
|
||||
}
|
||||
})) {
|
||||
setMainWindow('unlocking_window');
|
||||
}
|
||||
};
|
||||
} else {
|
||||
setMainWindow('app_window');
|
||||
}
|
||||
|
@@ -13,14 +13,48 @@
|
||||
using namespace Sia;
|
||||
using namespace Sia::Api;
|
||||
|
||||
class FunctionHandler :
|
||||
public CefV8Handler
|
||||
{
|
||||
public:
|
||||
FunctionHandler(const CSiaApi& siaApi) :
|
||||
_siaApi(siaApi)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
const CSiaApi& _siaApi;
|
||||
|
||||
public:
|
||||
virtual bool Execute(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) OVERRIDE
|
||||
{
|
||||
if (name == "unlockWallet")
|
||||
{
|
||||
retval = CefV8Value::CreateBool(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Function does not exist.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Provide the reference counting implementation for this class.
|
||||
IMPLEMENT_REFCOUNTING(FunctionHandler);
|
||||
};
|
||||
|
||||
// When using the Views framework this object provides the delegate
|
||||
// implementation for the CefWindow that hosts the Views-based browser.
|
||||
class SimpleWindowDelegate :
|
||||
public CefWindowDelegate
|
||||
{
|
||||
public:
|
||||
explicit SimpleWindowDelegate(CefRefPtr<CefBrowserView> browserView)
|
||||
: _browserView(browserView)
|
||||
explicit SimpleWindowDelegate(CefRefPtr<CefBrowserView> browserView) :
|
||||
_browserView(browserView)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -78,6 +112,11 @@ void CSiaDriveApp::OnContextCreated(
|
||||
obj->SetValue("isOnline", CefV8Value::CreateBool(_siaApi->GetWallet()->GetConnected()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
global->SetValue("uiState", obj, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
CefRefPtr<FunctionHandler> handler(new FunctionHandler(*_siaApi));
|
||||
obj = CefV8Value::CreateObject(nullptr, nullptr);
|
||||
obj->SetValue("unlockWallet", CefV8Value::CreateFunction("unlockWallet", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
global->SetValue("uiActions", obj, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
_refreshThread.reset(new CAutoThread(*_siaCurl, _siaDriveConfig.get(), [this, context](const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig)
|
||||
{
|
||||
this->SiaApiRefreshCallback(context, siaCurl, siaDriveConfig);
|
||||
|
Reference in New Issue
Block a user