1
0

Renter changes

This commit is contained in:
Scott E. Graves
2017-02-17 23:51:03 -06:00
parent 9b44d435f8
commit bac3fad30c
5 changed files with 225 additions and 91 deletions

View File

@@ -12,9 +12,16 @@
margin: 0; margin: 0;
} }
label {
margin: 0;
padding: 0;
border: 0;
}
h3 { h3 {
margin-bottom: 2px; margin-bottom: 2px;
padding: 0; padding: 0;
border: 0;
} }
p { p {
@@ -35,6 +42,24 @@
width: 98%; width: 98%;
} }
div.popup {
position: fixed;
color: whitesmoke;
background-color: rgb(0, 0, 0); /* Fallback color */
background-color: rgba(0, 0, 0, 0.7);
margin: 0 auto;
padding-top: 0;
top: 0;
left: 25%;
width: 50%;
padding-right: 15px;
padding-bottom: 30px;
padding-left: 15px;
border: 1px solid #112311;
z-index: 100;
display: table;
}
table { table {
padding: 0; padding: 0;
margin: 0; margin: 0;
@@ -128,16 +153,54 @@
<button id="ConfirmSeedButton">Done</button> <button id="ConfirmSeedButton">Done</button>
</div> </div>
<div id="tab_view" style="display: none" class="fill"> <div id="ID_Tab_Renter" style="display: none">
<h3>Receive Address</h3> <h3>Renter Settings <a href="javascript:void(0)" id="ID_Renter_Edit">edit</a></h3>
<label id="ID_WalletReceiveAddress"></label><br/><br/> <table>
<table class="fill">
<tr> <tr>
<td style="text-align: center; vertical-align: top"> <td style="text-align: right">Funding:</td>
<td id="ID_Renter_AllocatedFunds"></td>
<td colspan="50%"></td>
<td style="text-align: right">Hosts:</td>
<td id="ID_Renter_HostCount"></td>
</tr>
<tr>
<td style="text-align: right">Total Space:</td>
<td id="ID_Renter_EstimatedSpace"></td>
<td colspan="50%"></td>
<td style="text-align: right">Price (per GB):</td>
<td id="ID_Renter_EstimatedCost"></td>
</tr>
<tr>
<td style="text-align: right">Available Space:</td>
<td id="ID_Renter_AvailablSpace"></td>
<td colspan="50%"></td>
<td style="text-align: right">Download (per GB):</td>
<td id="ID_Renter_EstimatedDownlodCost"></td>
</tr>
<tr>
<td style="text-align: right">Used Space:</td>
<td id="ID_Renter_UsedSpace"></td>
<td colspan="50%"></td>
<td style="text-align: right">Upload (per GB):</td>
<td id="ID_Renter_EstimatedUploadCost"></td>
</tr>
</table>
</div>
<div id="ID_TabWindow" style="display: none" class="fill">
<h3>Receive Address</h3>
<label id="ID_WalletReceiveAddress"></label>
<div id="ID_ActiveTab"></div>
</div>
<div class="fill">
<h3>Mounting</h3>
<p>Choose an available drive letter and click 'Mount'</p>
<table>
<tr>
<td style="text-align: left; vertical-align: top">
<select id="ID_MountDrives"></select> <select id="ID_MountDrives"></select>
<input id="MountButton" type="button" value="Mount"/> <input id="ID_MountButton" type="button" value="Mount" />
<input id="wallet_btn" type="button" value="Wallet" />
<input id="host_btn" type="button" value="Host" />
</td> </td>
</tr> </tr>
</table> </table>
@@ -156,6 +219,24 @@
</table> </table>
</div> </div>
</div> </div>
<div class="popup" style="display: none" id="ID_Edit_Renter_Popup">
<h3>Configure Renter Settings</h3>
<table>
<tr>
<td>Funding:</td>
<td><input type="number" /></td>
</tr>
<tr>
<td>Hosts:</td>
<td><input type="number" /></td>
</tr>
<tr>
<td><button type="button" onclick="closePopUp();">OK</button></td>
</tr>
</table>
</div>
<script src="res:/JS/#136" type="text/javascript"></script> <script src="res:/JS/#136" type="text/javascript"></script>
</body> </body>
</html> </html>

Binary file not shown.

View File

@@ -78,12 +78,13 @@ END_MESSAGE_MAP()
// CSiaDriveDlg dialog // CSiaDriveDlg dialog
BEGIN_DHTML_EVENT_MAP(CSiaDriveDlg) BEGIN_DHTML_EVENT_MAP(CSiaDriveDlg)
DHTML_EVENT_ONCLICK(_T("ID_Renter_Edit"), OnButtonRenterEdit)
DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK) DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK)
DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel) DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel)
DHTML_EVENT_ONCLICK(_T("CreateWalletButton"), OnButtonCreateWallet) DHTML_EVENT_ONCLICK(_T("CreateWalletButton"), OnButtonCreateWallet)
DHTML_EVENT_ONCLICK(_T("ConfirmSeedButton"), OnButtonConfirmSeed) DHTML_EVENT_ONCLICK(_T("ConfirmSeedButton"), OnButtonConfirmSeed)
DHTML_EVENT_ONCLICK(_T("UnlockWalletButton"), OnButtonUnlockWallet) DHTML_EVENT_ONCLICK(_T("UnlockWalletButton"), OnButtonUnlockWallet)
DHTML_EVENT_ONCLICK(_T("MountButton"), OnButtonMount) DHTML_EVENT_ONCLICK(_T("ID_MountButton"), OnButtonMount)
END_DHTML_EVENT_MAP() END_DHTML_EVENT_MAP()
@@ -242,13 +243,12 @@ BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, const String& data, CC
BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, const json& json, CComVariant* pOutVarRes) BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, const json& json, CComVariant* pOutVarRes)
{ {
String data = CA2W(json.dump().c_str()); String data = CA2W(json.dump().c_str()).m_psz;
return CallClientScript(pStrFuncName, data, pOutVarRes); return CallClientScript(pStrFuncName, data, pOutVarRes);
} }
BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, CComVariant* pOutVarRes) BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, CComVariant* pOutVarRes)
{ {
BOOL bRes = FALSE; BOOL bRes = FALSE;
CComVariant vaResult; CComVariant vaResult;
CComPtr<IHTMLDocument2> pIDoc2; CComPtr<IHTMLDocument2> pIDoc2;
@@ -347,6 +347,17 @@ HRESULT CSiaDriveDlg::OnButtonMount(IHTMLElement* /*pElement*/)
return S_OK; return S_OK;
} }
HRESULT CSiaDriveDlg::OnButtonRenterEdit(IHTMLElement* /*pElement*/)
{
DisplayPopUp(L"ID_Edit_Renter_Popup");
return S_FALSE;
}
void CSiaDriveDlg::DisplayPopUp(const String& name)
{
CallClientScript(L"displayPopUp", name, nullptr);
}
bool IsRefreshKeyMessage(const MSG *message) bool IsRefreshKeyMessage(const MSG *message)
{ {
return message return message
@@ -599,6 +610,11 @@ void CSiaDriveDlg::DisplayCreateWallet()
SetMainWindow(L"create_wallet"); SetMainWindow(L"create_wallet");
} }
void CSiaDriveDlg::DisplayRenterTab()
{
SetTabWindow(L"ID_Tab_Renter");
}
void CSiaDriveDlg::ConfigureWallet() void CSiaDriveDlg::ConfigureWallet()
{ {
if (_siaApi.GetWallet()->GetCreated()) if (_siaApi.GetWallet()->GetCreated())
@@ -611,13 +627,13 @@ void CSiaDriveDlg::ConfigureWallet()
else else
{ {
CallClientScript(L"setAvailableDrives", json(GetAvailableDrives()), nullptr); CallClientScript(L"setAvailableDrives", json(GetAvailableDrives()), nullptr);
SetMainWindow(L"tab_view"); SetMainWindow(L"ID_TabWindow");
switch (_siaConfig.GetUI_Main_TabIndex()) switch (_siaConfig.GetUI_Main_TabIndex())
{ {
case WALLET_TAB: case RENTER_TAB:
{ {
//DisplayWalletTab(); DisplayRenterTab();
} }
break; break;
@@ -645,10 +661,10 @@ void CSiaDriveDlg::DisplayUnlockWallet()
SetFocusToElement(L"ID_WalletUnlockPwd"); SetFocusToElement(L"ID_WalletUnlockPwd");
} }
void CSiaDriveDlg::SetMainWindow(const String& name) void CSiaDriveDlg::SetChildWindow(const String& parentName, const String& name)
{ {
CComPtr<IHTMLDOMNode> mainNode; CComPtr<IHTMLDOMNode> mainNode;
if (SUCCEEDED(GetDomNodeById(L"main_window", mainNode))) if (SUCCEEDED(GetDomNodeById(parentName, mainNode)))
{ {
CComPtr<IHTMLDOMNode> child; CComPtr<IHTMLDOMNode> child;
if (SUCCEEDED(mainNode->get_firstChild(&child))) if (SUCCEEDED(mainNode->get_firstChild(&child)))
@@ -700,6 +716,16 @@ void CSiaDriveDlg::SetMainWindow(const String& name)
} }
} }
void CSiaDriveDlg::SetMainWindow(const String& name)
{
SetChildWindow(L"main_window", name);
}
void CSiaDriveDlg::SetTabWindow(const String& name)
{
SetChildWindow(L"ID_ActiveTab", name);
}
HRESULT CSiaDriveDlg::OnButtonCreateWallet(IHTMLElement* pElement) HRESULT CSiaDriveDlg::OnButtonCreateWallet(IHTMLElement* pElement)
{ {
if (!_seedCreation) if (!_seedCreation)

View File

@@ -29,6 +29,7 @@ public:
HRESULT OnButtonConfirmSeed(IHTMLElement* pElement); HRESULT OnButtonConfirmSeed(IHTMLElement* pElement);
HRESULT OnButtonUnlockWallet(IHTMLElement* pElement); HRESULT OnButtonUnlockWallet(IHTMLElement* pElement);
HRESULT OnButtonMount(IHTMLElement* pElement); HRESULT OnButtonMount(IHTMLElement* pElement);
HRESULT OnButtonRenterEdit(IHTMLElement* pElement);
// Implementation // Implementation
protected: protected:
@@ -47,7 +48,9 @@ protected:
virtual BOOL PreTranslateMessage(MSG* pMsg) override; virtual BOOL PreTranslateMessage(MSG* pMsg) override;
private: private:
void DisplayPopUp(const String& name);
void DisplayCreateWallet(); void DisplayCreateWallet();
void DisplayRenterTab();
void DisplaySeedCreated(const String& seed); void DisplaySeedCreated(const String& seed);
bool UpdateSiaInfo(); bool UpdateSiaInfo();
void DisplayUnlockWallet(); void DisplayUnlockWallet();
@@ -55,7 +58,9 @@ private:
void RemoveCreateWalletItems(); void RemoveCreateWalletItems();
void RemoveDomNodeById(const String& id); void RemoveDomNodeById(const String& id);
void SetMainWindow(const String& name); void SetMainWindow(const String& name);
void SetTabWindow(const String& name);
bool UpdateUi(const bool& refresh = true); bool UpdateUi(const bool& refresh = true);
void SetChildWindow(const String& parentName, const String& name);
HRESULT GetDomNodeAndElementById(const String& id, CComPtr<IHTMLDOMNode>& node, CComPtr<IHTMLElement>& elem); HRESULT GetDomNodeAndElementById(const String& id, CComPtr<IHTMLDOMNode>& node, CComPtr<IHTMLElement>& elem);
HRESULT GetDomNodeById(const String& id, CComPtr<IHTMLDOMNode>& node); HRESULT GetDomNodeById(const String& id, CComPtr<IHTMLDOMNode>& node);
BOOL CallClientScript(LPCTSTR pStrFuncName, const json& json, CComVariant* pOutVarRes); BOOL CallClientScript(LPCTSTR pStrFuncName, const json& json, CComVariant* pOutVarRes);
@@ -88,5 +93,5 @@ private:
bool _seedCreation = false; bool _seedCreation = false;
static const UINT IDT_UPDATE = 1; static const UINT IDT_UPDATE = 1;
static const UINT IDT_UI_ACTION_QUEUE = 2; static const UINT IDT_UI_ACTION_QUEUE = 2;
static const std::uint8_t WALLET_TAB = 0; static const std::uint8_t RENTER_TAB = 0;
}; };

View File

@@ -1,4 +1,4 @@
var popup;
function setValue(elementName, data) { function setValue(elementName, data) {
var elem = document.getElementById(elementName); var elem = document.getElementById(elementName);
@@ -76,3 +76,25 @@ function setAvailableDrives(driveList) {
} }
} }
function displayPopUp(id) {
var elem = document.getElementById(id);
if (elem) {
var elem2 = document.getElementById("ID_DisabledOverlay");
elem2.style.display = "block";
elem.style.display = "block";
popup = id;
}
}
function closePopUp() {
var elem = document.getElementById(popup);
if (elem) {
elem.style.display = "none";
elem = document.getElementById("ID_DisabledOverlay");
elem.style.display = "none";
popup = "";
}
}