Display active upload progress
This commit is contained in:
@@ -176,8 +176,9 @@
|
||||
<div class="hidden-element" id="upload_progress_window">
|
||||
<div class="box">
|
||||
<h1>Upload Progress</h1>
|
||||
<table style="width: 100%" id="ID_UploadProgressTable">
|
||||
<table style="width: 100%;height: auto" id="ID_UploadProgressTable">
|
||||
</table>
|
||||
<button id="ID_RenterUploadsOk" type="button">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
@@ -81,6 +81,7 @@
|
||||
}
|
||||
},
|
||||
setUploadProgress: (items) => {
|
||||
items = items || [];
|
||||
const table = document.getElementById('ID_UploadProgressTable');
|
||||
while (table.rows.length > items.length) {
|
||||
table.deleteRow(table.rows.length - 1);
|
||||
@@ -88,16 +89,15 @@
|
||||
for (const item of items) {
|
||||
const siaPath = item['SiaPath'];
|
||||
const progress = item['Progress'];
|
||||
const row = table.getElementById('ID_Progress_' + btoa(siaPath));
|
||||
const rid = window.btoa('progress_' + siaPath);
|
||||
const row = document.getElementById(rid);
|
||||
if (row) {
|
||||
row.cells[1].firstChild.value = progress;
|
||||
} else {
|
||||
const row = table.insertRow(table.rows.length);
|
||||
row.id = 'ID_Progress_' + btoa(siaPath);
|
||||
let cell = row.insertCell(0);
|
||||
cell.innerText = siaPath;
|
||||
cell = row.insertCell(1);
|
||||
cell.innerHTML = '<progress value="' + progress + '" max="100"></progress>';
|
||||
const r = table.insertRow(table.rows.length);
|
||||
r.insertCell(0).innerText = siaPath;
|
||||
r.insertCell(1).innerHTML = '<progress value="' + progress + '" max="100"></progress>';
|
||||
r.id = rid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,6 +264,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
function handleRenterUploads() {
|
||||
setMainWindow('upload_progress_window');
|
||||
|
||||
const okButton = document.getElementById('ID_RenterUploadsOk');
|
||||
okButton.onclick = () => {
|
||||
okButton.onclick = null;
|
||||
beginMainApplication();
|
||||
};
|
||||
}
|
||||
|
||||
function beginMainApplication() {
|
||||
AppActions.startApp();
|
||||
setMainWindow('app_window');
|
||||
@@ -272,6 +282,11 @@
|
||||
renterEditLink.onclick = null;
|
||||
handleRenterEditSettings();
|
||||
};
|
||||
const renterUploadsLink = document.getElementById('ID_Renter_Uploads');
|
||||
renterUploadsLink.onclick = () => {
|
||||
renterUploadsLink.onclick = null;
|
||||
handleRenterUploads();
|
||||
};
|
||||
const mountButton = document.getElementById('ID_MountButton');
|
||||
const mountSelect = document.getElementById('ID_MountDrives');
|
||||
|
||||
|
@@ -69,7 +69,7 @@ public:
|
||||
friend CSiaApi;
|
||||
friend _CSiaFileTree;
|
||||
|
||||
private:
|
||||
public:
|
||||
explicit _CSiaFile(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig, const json& fileJson);
|
||||
|
||||
public:
|
||||
|
@@ -475,16 +475,19 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
||||
|
||||
// Upload status
|
||||
auto uploadFileList = _siaDrive->GetUploadFileList();
|
||||
auto list = CefV8Value::CreateArray(uploadFileList->size());
|
||||
int idx = 0;
|
||||
for (const auto& file : *uploadFileList)
|
||||
if (uploadFileList)
|
||||
{
|
||||
auto f = global->CreateObject(nullptr, nullptr);
|
||||
f->SetValue("SiaPath", CefV8Value::CreateString(file->GetSiaPath().str()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
f->SetValue("Progress", CefV8Value::CreateUInt(std::max(100u, file->GetUploadProgress())), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
list->SetValue(idx++, f);
|
||||
auto list = CefV8Value::CreateArray(uploadFileList->size());
|
||||
int idx = 0;
|
||||
for (const auto& file : *uploadFileList)
|
||||
{
|
||||
auto f = CefV8Value::CreateObject(nullptr, nullptr);
|
||||
f->SetValue("SiaPath", CefV8Value::CreateString(file->GetSiaPath().str()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
f->SetValue("Progress", CefV8Value::CreateUInt(min(100u, file->GetUploadProgress())), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
list->SetValue(idx++, f);
|
||||
}
|
||||
ExecuteSetter(context, renterActions, "setUploadProgress", list);
|
||||
}
|
||||
ExecuteSetter(context, renterActions, "setUploadProgress", list);
|
||||
}
|
||||
|
||||
if (isOnline != wasOnline)
|
||||
|
@@ -572,7 +572,7 @@ public:
|
||||
#define UPLOAD_TABLE_COLUMNS L"id integer primary key autoincrement, sia_path text unique not null, file_path text unique not null, status integer not null, modified_time integer not null"
|
||||
#define QUERY_STATUS "select * from upload_table where sia_path=@sia_path order by id desc limit 1;"
|
||||
#define QUERY_UPLOADS_BY_STATUS "select * from upload_table where status=@status order by id desc limit 1;"
|
||||
#define QUERY_UPLOADS_BY_2_STATUS "select * from upload_table where status=@status1 or status=@status2 order by sia_path;"
|
||||
#define QUERY_UPLOADS_BY_2_STATUS "select * from upload_table where status=@status1 or status=@status2 order by sia_path desc;"
|
||||
#define QUERY_UPLOAD_COUNT_BY_STATUS "select count(id) from upload_table where status=@status;"
|
||||
#define QUERY_UPLOADS_BY_SIA_PATH "select * from upload_table where sia_path=@sia_path order by id desc limit 1;"
|
||||
#define QUERY_UPLOADS_BY_SIA_PATH_AND_STATUS "select * from upload_table where sia_path=@sia_path and status=@status order by id desc limit 1;"
|
||||
@@ -731,7 +731,22 @@ void CUploadManager::AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig
|
||||
return ptr->GetSiaPath() == siaPath;
|
||||
});
|
||||
|
||||
if (it != fileList->end())
|
||||
if (it == fileList->end())
|
||||
{
|
||||
// TODO Fix file size
|
||||
CSiaFilePtr ptr(new CSiaFile(siaCurl, siaDriveConfig,
|
||||
{
|
||||
{"siapath", siaPath},
|
||||
{"filesize", 0},
|
||||
{"available", false},
|
||||
{"renewing", false},
|
||||
{"redundancy", 0},
|
||||
{"uploadprogress", 0},
|
||||
{"expiration", 0}
|
||||
}));
|
||||
uploadFileList->push_back(ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
uploadFileList->push_back(*it);
|
||||
}
|
||||
@@ -806,7 +821,7 @@ void CUploadManager::AutoThreadCallback(const CSiaCurl& siaCurl, CSiaDriveConfig
|
||||
|
||||
json response;
|
||||
SiaCurlError cerror = siaCurl.Post(SString(L"/renter/upload/") + siaPath, { {L"source", filePath} }, response);
|
||||
if (ApiSuccess(cerror))
|
||||
if (ApiSuccess(cerror) || cerror.GetReason().Contains("already exists"))
|
||||
{
|
||||
SET_STATUS(UploadStatus::Uploading, UploadToSiaStarted, ModifyUploadStatusFailed)
|
||||
}
|
||||
|
Reference in New Issue
Block a user