1
0

Upload percentage

This commit is contained in:
Scott E. Graves
2017-02-18 22:06:50 -06:00
parent a782feefbe
commit 3c18bf8b69
7 changed files with 89 additions and 5 deletions

View File

@@ -141,6 +141,7 @@ public:
Property(std::uint64_t, Hosts, public, private)
Property(SiaCurrency, Unspent, public, private)
Property(std::uint64_t, TotalUsedBytes, public, private)
Property(std::uint32_t, TotalUploadProgress, public, private)
protected:
virtual void AutoThreadCallback(const CSiaCurl& siaCurl) override;

View File

@@ -51,7 +51,8 @@ CSiaApi::_CSiaRenter::_CSiaRenter(const CSiaCurl& siaCurl) :
_Funds(0),
_Hosts(0),
_Unspent(0),
_TotalUsedBytes(0)
_TotalUsedBytes(0),
_TotalUploadProgress(100)
{
StartAutoThread();
}
@@ -83,11 +84,19 @@ void CSiaApi::_CSiaRenter::AutoThreadCallback(const CSiaCurl& siaCurl)
{
return sz + file->GetFileSize();
});
SetTotalUsedBytes(total);
std::uint32_t totalProgress = std::accumulate(std::next(fileList.begin()), fileList.end(), fileList[0]->GetUploadProgress(), [](const std::uint32_t& progress, const CSiaFilePtr& file)
{
return progress + file->GetUploadProgress();
}) / fileList.size();
SetTotalUsedBytes(total);
SetTotalUploadProgress(totalProgress);
}
else
{
SetTotalUsedBytes(0);
SetTotalUploadProgress(100);
}
}
else
@@ -96,6 +105,7 @@ void CSiaApi::_CSiaRenter::AutoThreadCallback(const CSiaCurl& siaCurl)
SetHosts(0);
SetUnspent(0);
SetTotalUsedBytes(0);
SetTotalUploadProgress(100);
}
}

View File

@@ -131,6 +131,45 @@
button:hover {
background-color: #858595;
}
.tooltip {
position: relative;
width: 99%;
display: inline-block;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 1s;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
</style>
</head>
<body id="CSiaDriveDlg" class="padded">
@@ -198,7 +237,7 @@
<div id="ID_Tab_Renter" style="display: none">
<h3>Renter Settings <a href="javascript:void(0)" id="ID_Renter_Edit">edit</a></h3>
<table>
<table width="inherit">
<tr>
<td style="text-align: right">Total Funding:</td>
<td id="ID_Renter_AllocatedFunds"></td>
@@ -213,7 +252,11 @@
<td style="text-align: right">Host Count:</td>
<td id="ID_Renter_HostCount"></td>
</tr>
<tr><td><br/></td></tr>
<tr>
<td>
<br />
</td>
</tr>
<tr>
<td style="text-align: right">Total GB:</td>
<td id="ID_Renter_EstimatedSpace"></td>
@@ -236,6 +279,11 @@
<td id="ID_Renter_EstimatedUploadCost"></td>
</tr>
</table>
<div class="tooltip" id="ID_Progress" style="display: none;">
<progress style="width: 100%; margin: 0; padding: 0;" id="ID_UploadProgress" value="100" max="100">
</progress>
<span class="tooltiptext" id="ID_UploadProgressTooltip"></span>
</div>
</div>
<div id="ID_TabWindow" style="display: none">
@@ -262,7 +310,7 @@
<div class="footer">
<table class="fill">
<tr>
<td style="width: 70px;text-align: left"><b>Height:</b></td>
<td style="width: 70px; text-align: left"><b>Height:</b></td>
<td id="ID_BlockHeight">...</td>
<td style="text-align: right; vertical-align: bottom">
<button style="width: 100px" id="ButtonOK">OK</button>

Binary file not shown.

View File

@@ -475,6 +475,7 @@ void CSiaDriveDlg::ClearDisplay()
SetRenterTotalAvailable(0.0);
SetRenterTotalUsed(0);
SetRenterTotalRemain(0.0);
SetRenterTotalUploadProgress(100);
SetConsensusHeight(0);
}
@@ -729,6 +730,11 @@ void CSiaDriveDlg::SetRenterUsedFunds(const SiaCurrency& currency)
CallClientScript(L"setRenterUsedFunds", SiaCurrencyToString(currency), nullptr);
}
void CSiaDriveDlg::SetRenterTotalUploadProgress(const std::uint32_t& progress)
{
CallClientScript(L"setRenterTotalUploadProgress", std::to_wstring(progress), nullptr);
}
void CSiaDriveDlg::SetServerVersion(const String& version)
{
CallClientScript(L"setServerVersion", version, nullptr);
@@ -803,6 +809,7 @@ bool CSiaDriveDlg::UpdateSiaInfo()
auto a = (t / (allocatedFunds - unspentFunds) * allocatedFunds) * 1024.0;
SetRenterTotalAvailable(a.ToDouble());
SetRenterTotalRemain((a-t).ToDouble());
SetRenterTotalUploadProgress(_siaApi->GetRenter()->GetTotalUploadProgress());
SetConsensusHeight(_siaApi->GetConsensus()->GetHeight());
return true;

View File

@@ -89,6 +89,7 @@ private:
void SetRenterTotalUsed(const std::uint64_t& bytes);
void SetRenterTotalAvailable(const double& gb);
void SetRenterTotalRemain(const double& total);
void SetRenterTotalUploadProgress(const std::uint32_t& progress);
void QueueUiAction(std::function<void()> action);
void ProcessUiActionQueue();
void ClearDisplay();

View File

@@ -88,6 +88,23 @@ function setRenterTotalRemainGb(gb) {
setInnerText("ID_Renter_AvailablSpace", gb);
}
function setRenterTotalUploadProgress(progress) {
var i = parseInt(progress);
var progDiv = document.getElementById("ID_Progress");
var prog = document.getElementById("ID_UploadProgress");
var progToolTip = document.getElementById("ID_UploadProgressTooltip");
if (i < 100) {
progDiv.style.display = "inline-block";
prog.style.display = "block";
prog.value = progress;
progToolTip.innerText = "Uploading\n[" + progress + "%]";
} else {
progDiv.style.display = prog.style.display = "none";
prog.value = 100;
progToolTip.innerText = "";
}
}
function setAvailableDrives(driveList) {
driveList = Array.isArray(driveList) ? driveList : JSON.parse(driveList);