1
0

Ui Changes

This commit is contained in:
Scott E. Graves
2017-05-02 23:16:35 -05:00
parent d7f7392fa3
commit 59f241dd1c
5 changed files with 45 additions and 109 deletions

View File

@@ -61,14 +61,13 @@ button {
background-color: #515151;
border: 1px solid #506b58;
color: white;
padding: 5px 15px;
padding: 6px;
margin: 0;
text-align: center;
vertical-align: middle;
text-decoration: none;
display: inline-block;
cursor: pointer;
font-size: var(--default-font-size);
max-font-size: 18px;
}
button:hover {
@@ -88,8 +87,8 @@ h1 {
}
h2 {
font-size: var(--default-header-font-size);
margin: 0;
font-size: var(--default-font-size);
margin: 0 0 5px;
padding: 0;
}
@@ -121,7 +120,7 @@ select {
outline: 1px;
background: rgba(64, 142, 62, 0.04);
color: var(--default-font-color);
padding: 5px;
padding: 6px;
font-size: var(--default-font-size);
-webkit-appearance: none;
-webkit-user-select: none;
@@ -140,7 +139,7 @@ td {
textarea {
font-family: monospace;
border: 1px solid #3b4b3d;
padding: 5px;
padding: 6px;
background: rgba(64, 142, 62, 0.04);
color: var(--default-font-color);
font-size: var(--default-font-size);

View File

@@ -83,25 +83,25 @@
</div>
</div>
<div class="box" id="receive_info">
<h1>Receive Address</h1>
<label id="ID_WalletReceiveAddress" style="text-align: center; width: inherit;display: block;">...</label>
<h1>Receive Address <a href="javascript:void(0)" id="ID_Wallet_Send">send</a></h1>
<label class="address" id="ID_WalletReceiveAddress" style="text-align: center; width: inherit;display: block;">...</label>
</div>
<div class="box" id="renter_info">
<h1>Renter Settings <a href="javascript:void(0)" id="ID_Renter_Edit">edit</a>&nbsp;<a href="javascript:void(0)" id="ID_Renter_Uploads">uploads</a></h1>
<table width="inherit" style="margin: 0 auto">
<tr>
<td style="text-align: right">Total Funding:</td>
<td id="ID_Renter_AllocatedFunds" style="min-width:120px; word-wrap: break-word;"></td>
<td class="amount" id="ID_Renter_AllocatedFunds" style="min-width:120px; word-wrap: break-word;"></td>
<td colspan="50%"></td>
<td style="text-align: right">Used Funding:</td>
<td id="ID_Renter_UsedFunds" style="min-width:120px; word-wrap: break-word;"></td>
<td class="amount" id="ID_Renter_UsedFunds" style="min-width:120px; word-wrap: break-word;"></td>
</tr>
<tr>
<td style="text-align: right">Available Funding:</td>
<td id="ID_Renter_AvailableFunds"></td>
<td class="amount" id="ID_Renter_AvailableFunds"></td>
<td colspan="50%"></td>
<td style="text-align: right">Host Count:</td>
<td id="ID_Renter_HostCount"></td>
<td class="amount" id="ID_Renter_HostCount"></td>
</tr>
<tr>
<td colspan="100%">
@@ -110,24 +110,24 @@
</tr>
<tr>
<td style="text-align: right">Total:</td>
<td id="ID_Renter_EstimatedSpace"></td>
<td class="amount" id="ID_Renter_EstimatedSpace"></td>
<td colspan="50%"></td>
<td style="text-align: right">Price (per GB):</td>
<td id="ID_Renter_EstimatedCost"></td>
<td class="amount" id="ID_Renter_EstimatedCost"></td>
</tr>
<tr>
<td style="text-align: right">Available:</td>
<td id="ID_Renter_AvailablSpace"></td>
<td class="amount" id="ID_Renter_AvailablSpace"></td>
<td colspan="50%"></td>
<td style="text-align: right">Download (per GB):</td>
<td id="ID_Renter_EstimatedDownloadCost"></td>
<td class="amount" id="ID_Renter_EstimatedDownloadCost"></td>
</tr>
<tr>
<td style="text-align: right">Used:</td>
<td id="ID_Renter_UsedSpace"></td>
<td class="amount" id="ID_Renter_UsedSpace"></td>
<td colspan="50%"></td>
<td style="text-align: right">Upload (per GB):</td>
<td id="ID_Renter_EstimatedUploadCost"></td>
<td class="amount" id="ID_Renter_EstimatedUploadCost"></td>
</tr>
</table>
<div class="tooltip" id="ID_Progress" style="display: none;">
@@ -163,13 +163,13 @@
<p>You need to allocate funds to upload and download on Sia. Your allowance remains locked for 3 months. Unspent funds are then refunded*. You can increase your allowance at any time.</p>
<p>Your storage allowance automatically refills every 6 weeks. Your computer must be online with your wallet unlocked to complete the refill. If Sia fails to refill the allowance by the end of the lock-in period, your data may be lost.</p>
<p class="footnote">*contract fees are non-refundable. They will be subtracted from the allowance that you set.</p>
<h2>Allocated Funds</h2>
<h1>Allocated Funds</h1>
<input type="number" id="ID_RenterSetFunds">&nbsp;<label id="ID_RenterCalcStorage"></label><br><br>
<h2>Number of Hosts</h2>
<h1>Number of Hosts</h1>
<input type="number" id="ID_RenterSetHosts"><br><br>
<h2>Contract Period</h2>
<h1>Contract Period</h1>
<input type="number" id="ID_RenterSetPeriod"><br><br>
<h2>Renew Window</h2>
<h1>Renew Window</h1>
<input type="number" id="ID_RenterSetRenewWindow"><br><br>
<button id="ID_RenterSettingsDefaults" type="button">Defaults</button>
<button id="ID_RenterSettingsOK" type="button">Save</button>
@@ -196,13 +196,12 @@
</div>
<div class="hidden-element" id="upload_progress_window" style="height: inherit;">
<div style="display: flex; flex-direction: column; height: inherit;">
<div class="box" style="flex-grow: 1; display: flex;">
<h1 style="flex-grow: 0;">Upload Progress</h1>
<div class="box" style="flex-grow: 1; display: flex; flex-direction: column;">
<h1 style="flex-grow: 0;">Upload Progress <a href="javascript:void(0)" id="ID_RenterUploadsOk">back</a></h1>
<div style="padding: 0; margin: 0; flex-grow: 1; display: flex; overflow-x: hidden; overflow-y: scroll;">
<table style="flex-grow: 1;" id="ID_UploadProgressTable"></table>
<table style="flex-grow: 1;white-space: nowrap;" id="ID_UploadProgressTable"></table>
</div>
</div>
<button id="ID_RenterUploadsOk" style="margin-left: 10px; margin-bottom: 10px; flex-grow: 0; width: 110px" type="button">Back</button>
</div>
</div>
<div id="shutdown_window" class="hidden-element" style="padding: 0; margin: 0;position: fixed; height: 100%; width: 100%;background-image: url(./images/shutdown.gif); background-size: 100% 100%; background-repeat: no-repeat; z-index: 99999"></div>

View File

@@ -19,7 +19,7 @@ class CSiaDriveHandler :
public CefLoadHandler
{
public:
explicit CSiaDriveHandler(const bool& useViews);
explicit CSiaDriveHandler();
~CSiaDriveHandler();
@@ -55,12 +55,9 @@ public:
bool IsClosing() const { return _isClosing; }
bool GetUseViews() const { return _useViews; }
private:
void PlatformTitleChange(CefRefPtr<CefBrowser> browser, const CefString& title);
private:
const bool _useViews;
bool _isClosing;
bool _active;
std::shared_ptr<Api::CSiaDriveConfig> _siaDriveConfig;

View File

@@ -246,41 +246,6 @@ public:
IMPLEMENT_REFCOUNTING(FunctionHandler);
};
class SimpleWindowDelegate :
public CefWindowDelegate
{
public:
explicit SimpleWindowDelegate(CefRefPtr<CefBrowserView> browserView) :
_browserView(browserView)
{
}
void OnWindowCreated(CefRefPtr<CefWindow> window) OVERRIDE
{
window->AddChildView(_browserView);
window->Show();
_browserView->RequestFocus();
}
void OnWindowDestroyed(CefRefPtr<CefWindow> window) OVERRIDE
{
_browserView = nullptr;
}
bool CanClose(CefRefPtr<CefWindow> window) OVERRIDE
{
CefRefPtr<CefBrowser> browser = _browserView->GetBrowser();
return (browser) ? browser->GetHost()->TryCloseBrowser() : true;
}
private:
CefRefPtr<CefBrowserView> _browserView;
IMPLEMENT_REFCOUNTING(SimpleWindowDelegate);
DISALLOW_COPY_AND_ASSIGN(SimpleWindowDelegate);
};
CSiaDriveApp::CSiaDriveApp()
{
}
@@ -373,34 +338,17 @@ void CSiaDriveApp::OnContextInitialized()
{
CEF_REQUIRE_UI_THREAD();
CefBrowserSettings browserSettings;
SString url = "file:///./htdocs/index.html";
CefRefPtr<CefCommandLine> commandLine = CefCommandLine::GetGlobalCommandLine();
#if defined(OS_WIN) || defined(OS_LINUX)
const bool useViews = commandLine->HasSwitch("use-views");
#else
const bool useViews = false;
#endif
CefRefPtr<CSiaDriveHandler> _handler(new CSiaDriveHandler(useViews));
if (_handler->GetUseViews())
{
CefRefPtr<CefBrowserView> browserView = CefBrowserView::CreateBrowserView(_handler, url.str(), browserSettings, nullptr, nullptr);
CefWindow::CreateTopLevelWindow(new SimpleWindowDelegate(browserView));
}
else
{
CefWindowInfo windowInfo;
CefWindowInfo windowInfo;
#ifdef _WIN32
windowInfo.SetAsPopup(nullptr, "SiaDrive");
windowInfo.SetAsPopup(nullptr, "SiaDrive");
#endif
windowInfo.width = 800;
windowInfo.height = 690;
windowInfo.width = 800;
windowInfo.height = 690;
CefBrowserHost::CreateBrowser(windowInfo, _handler, url.str(), browserSettings, nullptr);
}
CefRefPtr<CSiaDriveHandler> _handler(new CSiaDriveHandler());
SString url = "file:///./htdocs/index.html";
CefBrowserSettings browserSettings;
CefBrowserHost::CreateBrowser(windowInfo, _handler, url.str(), browserSettings, nullptr);
}
void CSiaDriveApp::ShutdownServices(CefRefPtr<CefBrowser> browser)
@@ -477,7 +425,6 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
bool created = _siaApi->GetWallet()->GetCreated();
// Update UI state, server version and settings
ExecuteSetter(context, uiActions, "setServerVersion", _siaApi->GetServerVersion());
uiState->SetValue("isWalletLocked", CefV8Value::CreateBool(locked), V8_PROPERTY_ATTRIBUTE_NONE);
uiState->SetValue("isWalletConfigured", CefV8Value::CreateBool(created), V8_PROPERTY_ATTRIBUTE_NONE);
if (created && !locked)
@@ -597,6 +544,11 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
CefRefPtr<CefV8Value> reloadApplication = global->GetValue("uiUpdate")->GetValue("reloadApplication");
CefV8ValueList args;
reloadApplication->ExecuteFunctionWithContext(context, nullptr, args);
if (isOnline)
{
auto uiActions = global->GetValue("uiUpdate");
ExecuteSetter(context, uiActions, "setServerVersion", _siaApi->GetServerVersion());
}
if (!isOnline && _siaDrive)
{

View File

@@ -117,8 +117,7 @@ static LRESULT CALLBACK SiaWndProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lpa
}
#endif
CSiaDriveHandler::CSiaDriveHandler(const bool& useViews) :
_useViews(useViews),
CSiaDriveHandler::CSiaDriveHandler( ) :
_isClosing(false),
_active(true),
_siaDriveConfig(new CSiaDriveConfig(false))
@@ -141,20 +140,7 @@ void CSiaDriveHandler::OnTitleChange(CefRefPtr<CefBrowser> browser, const CefStr
{
CEF_REQUIRE_UI_THREAD();
if (_useViews)
{
CefRefPtr<CefBrowserView> browserView = CefBrowserView::GetForBrowser(browser);
if (browserView)
{
CefRefPtr<CefWindow> window = browserView->GetWindow();
if (window)
window->SetTitle(title);
}
}
else
{
PlatformTitleChange(browser, title);
}
PlatformTitleChange(browser, title);
}
bool CSiaDriveHandler::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId source_process, CefRefPtr<CefProcessMessage> message)
@@ -179,9 +165,12 @@ void CSiaDriveHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser)
CEF_REQUIRE_UI_THREAD();
#ifdef _WIN32
HWND hwnd = browser->GetHost()->GetWindowHandle();
auto style = ::GetWindowLongPtr(hwnd, GWL_STYLE) & ~WS_MAXIMIZEBOX;
::SetWindowLongPtr(hwnd, GWL_STYLE, style);
g_defProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hwnd, GWLP_WNDPROC));
::SetWindowLongPtr(hwnd, GWLP_WNDPROC,reinterpret_cast<LONG_PTR>(SiaWndProc));
HINSTANCE hinstance = ::GetModuleHandle(nullptr);
HICON icon = ::LoadIcon(hinstance, L"IDI_ICON");