UI changes
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="css/general.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/sidenav.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/tab_page.css">
|
||||
<script src="js/external_actions.js"></script>
|
||||
<script src="js/actions.js"></script>
|
||||
<script src="js/index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
@@ -23,11 +23,18 @@
|
||||
|
||||
const UiActions = (() => {
|
||||
function _unlockWallet(pwd, cb) {
|
||||
console.log('Unlock wallet');
|
||||
return window.uiActions.unlockWallet(pwd, cb);
|
||||
}
|
||||
|
||||
function _createWallet(cb) {
|
||||
console.log('Create wallet');
|
||||
return window.uiActions.createWallet(cb);
|
||||
}
|
||||
|
||||
return {
|
||||
unlockWallet: _unlockWallet
|
||||
unlockWallet: _unlockWallet,
|
||||
createWallet: _createWallet
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -67,8 +74,7 @@
|
||||
if (success) {
|
||||
setMainWindow('app_window');
|
||||
} else {
|
||||
location.reload();
|
||||
displayErrorPopup('Failed to unlock wallet', reason, ()=> {
|
||||
displayErrorPopup('Error', reason, ()=> {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
@@ -81,6 +87,18 @@
|
||||
}
|
||||
} else {
|
||||
setMainWindow('create_window');
|
||||
const createButton = document.getElementById('ID_CreateWalletButton');
|
||||
createButton.onclick = () => {
|
||||
UiActions.createWallet((success, reasonOrSeed) => {
|
||||
if (success) {
|
||||
setMainWindow('display_seed_window');
|
||||
} else {
|
||||
displayErrorPopup('Error', reasonOrSeed, ()=> {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
} else {
|
||||
setMainWindow('offline_window');
|
||||
|
@@ -30,7 +30,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
CefSettings settings;
|
||||
settings.no_sandbox = true;
|
||||
settings.remote_debugging_port = 8080;
|
||||
settings.single_process = false;
|
||||
settings.single_process = true;
|
||||
CefInitialize(mainArgs, settings, app, nullptr);
|
||||
|
||||
CefRunMessageLoop();
|
||||
|
@@ -2,12 +2,13 @@
|
||||
#include <include/views/cef_browser_view.h>
|
||||
#include <include/views/cef_window.h>
|
||||
#include <include/wrapper/cef_helpers.h>
|
||||
#include <include/wrapper/cef_closure_task.h>
|
||||
#include <autothread.h>
|
||||
#include <siaapi.h>
|
||||
#include <siacurl.h>
|
||||
#include <siadriveconfig.h>
|
||||
#include "siadrivehandler.h"
|
||||
#include <include/wrapper/cef_closure_task.h>
|
||||
|
||||
using namespace Sia;
|
||||
using namespace Sia::Api;
|
||||
|
||||
@@ -24,12 +25,33 @@ private:
|
||||
const CSiaApi& _siaApi;
|
||||
|
||||
private:
|
||||
void UnlockCallback(CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> cb, const SString& password)
|
||||
void UnlockCallback(CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> cb, const SString& password) const
|
||||
{
|
||||
SiaApiError error = _siaApi.GetWallet()->Unlock(password);
|
||||
CefV8ValueList args;
|
||||
args.push_back(CefV8Value::CreateBool(false));
|
||||
args.push_back(CefV8Value::CreateString("Invalid password entered"));
|
||||
args.push_back(CefV8Value::CreateBool(ApiSuccess(error)));
|
||||
if (!args[0]->GetBoolValue())
|
||||
{
|
||||
args.push_back(CefV8Value::CreateString("Failed to unlock wallet"));
|
||||
}
|
||||
cb->ExecuteFunctionWithContext(context, nullptr, args);
|
||||
}
|
||||
//wetsuit inline reorder agreed jabbed gnaw fever adjust object incur cousin jogger sack fading syllabus tufts stellar rays woes october nagged nasty warped sifting fountain gorilla mohawk yoyo afield
|
||||
void CreateWalletCallback(CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> cb) const
|
||||
{
|
||||
SString seed;
|
||||
SiaApiError error = _siaApi.GetWallet()->Create(SiaSeedLanguage::English, seed);
|
||||
|
||||
CefV8ValueList args;
|
||||
args.push_back(CefV8Value::CreateBool(ApiSuccess(error)));
|
||||
if (args[0]->GetBoolValue())
|
||||
{
|
||||
args.push_back(CefV8Value::CreateString(seed.str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
args.push_back(CefV8Value::CreateString("Failed to create new wallet"));
|
||||
}
|
||||
cb->ExecuteFunctionWithContext(context, nullptr, args);
|
||||
}
|
||||
|
||||
@@ -50,6 +72,15 @@ public:
|
||||
CefPostTask(TID_RENDERER, base::Bind(&FunctionHandler::UnlockCallback, this, context, cb, password));
|
||||
return true;
|
||||
}
|
||||
else if (name == "createWallet")
|
||||
{
|
||||
retval = CefV8Value::CreateBool(true);
|
||||
CefRefPtr<CefV8Value> cb = arguments[0];
|
||||
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
||||
|
||||
CefPostTask(TID_RENDERER, base::Bind(&FunctionHandler::CreateWalletCallback, this, context, cb));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Function does not exist.
|
||||
return false;
|
||||
@@ -127,6 +158,7 @@ void CSiaDriveApp::OnContextCreated(
|
||||
CefRefPtr<FunctionHandler> handler(new FunctionHandler(*_siaApi));
|
||||
obj = CefV8Value::CreateObject(nullptr, nullptr);
|
||||
obj->SetValue("unlockWallet", CefV8Value::CreateFunction("unlockWallet", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
obj->SetValue("createWallet", CefV8Value::CreateFunction("createWallet", 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)
|
||||
|
Reference in New Issue
Block a user