Upload table changes
This commit is contained in:
@@ -219,7 +219,7 @@
|
||||
<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;white-space: nowrap;" id="ID_UploadProgressTable"></table>
|
||||
<table style="flex-grow: 1;white-space: nowrap;" class="display" id="ID_UploadProgressTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -1,5 +1,13 @@
|
||||
// Main
|
||||
(() => {
|
||||
$.fn.dataTableExt.oApi.fnStandingRedraw = (settings) => {
|
||||
const before = settings._iDisplayStart;
|
||||
settings.oApi._fnReDraw(settings);
|
||||
settings._iDisplayStart = before;
|
||||
settings.oApi._fnCalculateEnd(settings);
|
||||
settings.oApi._fnDraw(settings);
|
||||
};
|
||||
|
||||
function copyToClipboard(text) {
|
||||
const clip = document.createElement('input');
|
||||
clip.id = 'clipper';
|
||||
@@ -115,25 +123,10 @@
|
||||
}
|
||||
},
|
||||
setUploadProgress: (items) => {
|
||||
items = items || [];
|
||||
const table = document.getElementById('ID_UploadProgressTable');
|
||||
while (table.rows.length > items.length) {
|
||||
table.deleteRow(table.rows.length - 1);
|
||||
}
|
||||
for (const item of items) {
|
||||
const siaPath = item['SiaPath'];
|
||||
const progress = item['Progress'];
|
||||
const rid = window.btoa('progress_' + siaPath);
|
||||
const row = document.getElementById(rid);
|
||||
if (row) {
|
||||
row.cells[1].firstChild.value = progress;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
const table = $('#ID_UploadProgressTable').dataTable();
|
||||
table.clear();
|
||||
table.rows.add(items || []);
|
||||
table.fnStandingRedraw();
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -706,6 +699,16 @@
|
||||
window.addEventListener('load', ()=> {
|
||||
console.log('Main window load');
|
||||
document.getElementById('ID_ServerVersion').innerText = '...';
|
||||
$('#ID_UploadProgressTable').DataTable( {
|
||||
data: [],
|
||||
columns: [
|
||||
{ title: "SiaPath" },
|
||||
{ title: "Progress" }
|
||||
],
|
||||
scrollY: 200,
|
||||
deferRender: true,
|
||||
scroller: true
|
||||
} );
|
||||
reloadApplication(true);
|
||||
});
|
||||
})();
|
@@ -55,7 +55,7 @@ private:
|
||||
const CSiaApi& _siaApi;
|
||||
SQLite::Database _uploadDatabase;
|
||||
std::mutex _uploadMutex;
|
||||
std::shared_ptr<std::vector<CSiaFilePtr>> _uploadFileList;
|
||||
std::shared_ptr<json> _uploadFileList;
|
||||
|
||||
private:
|
||||
void CleanUploadDatabase(CSiaDriveConfig* siaDriveConfig);
|
||||
@@ -76,14 +76,12 @@ public:
|
||||
CSiaError<_UploadErrorCode> Remove(const SString& siaPath);
|
||||
CSiaError<_UploadErrorCode> RenameFile(const SString& siaPath, const SString& newSiaPath);
|
||||
CSiaError<_UploadErrorCode> RenameFolder(const SString& siaPath, const SString& newSiaPath);
|
||||
std::shared_ptr<std::vector<CSiaFilePtr>> GetUploadFileList() const;
|
||||
std::shared_ptr<json> GetUploadFileList() const;
|
||||
};
|
||||
|
||||
typedef CUploadManager::_UploadStatus UploadStatus;
|
||||
typedef CUploadManager::_UploadErrorCode UploadErrorCode;
|
||||
typedef CSiaError<CUploadManager::_UploadErrorCode> UploadError;
|
||||
typedef std::vector<CSiaFilePtr> UploadFileList;
|
||||
typedef std::shared_ptr<UploadFileList> UploadFileListPtr;
|
||||
|
||||
NS_END(2)
|
||||
|
||||
|
@@ -49,7 +49,7 @@ private:
|
||||
|
||||
public:
|
||||
void ClearCache();
|
||||
UploadFileListPtr GetUploadFileList() const;
|
||||
std::shared_ptr<json> GetUploadFileList() const;
|
||||
bool IsMounted() const;
|
||||
void Mount(const wchar_t& driveLetter, const SString& cacheLocation, const std::uint64_t& maxCacheSizeBytes);
|
||||
void Unmount(const bool& clearCache = false);
|
||||
|
@@ -1071,7 +1071,7 @@ void CUploadManager::AutoThreadCallback(CSiaDriveConfig* siaDriveConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
UploadFileListPtr uploadFileList(new UploadFileList());
|
||||
std::shared_ptr<json> uploadFileList(new json);
|
||||
std::lock_guard<std::mutex> l(_uploadMutex);
|
||||
SQLite::Statement query(_uploadDatabase, QUERY_UPLOADS_BY_2_STATUS);
|
||||
query.bind("@status1", static_cast<unsigned>(UploadStatus::Queued));
|
||||
@@ -1085,30 +1085,15 @@ void CUploadManager::AutoThreadCallback(CSiaDriveConfig* siaDriveConfig)
|
||||
return ptr->GetSiaPath() == siaPath;
|
||||
});
|
||||
|
||||
if (it == fileList->end())
|
||||
{
|
||||
// TODO Fix file size
|
||||
CSiaFilePtr ptr(new CSiaFile(siaDriveConfig,
|
||||
{
|
||||
{"siapath", siaPath},
|
||||
{"filesize", 0},
|
||||
{"available", false},
|
||||
{"renewing", false},
|
||||
{"redundancy", 0},
|
||||
{"uploadprogress", 0},
|
||||
{"expiration", 0}
|
||||
}));
|
||||
uploadFileList->push_back(ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
uploadFileList->push_back(*it);
|
||||
}
|
||||
uploadFileList->push_back(
|
||||
{ {"siapath", siaPath},
|
||||
{"uploadprogress", ((it == fileList->end()) ? 0 : (*it)->GetUploadProgress())}
|
||||
});
|
||||
}
|
||||
|
||||
std::sort(uploadFileList->begin(), uploadFileList->end(), [](const CSiaFilePtr& a, const CSiaFilePtr& b)
|
||||
std::sort(uploadFileList->begin(), uploadFileList->end(), [](const json& a, const json& b)
|
||||
{
|
||||
return a->GetUploadProgress() > b->GetUploadProgress();
|
||||
return a["uploadprogress"].get<std::uint32_t>() > b["uploadprogress"].get<std::uint32_t>();
|
||||
});
|
||||
_uploadFileList = uploadFileList;
|
||||
}
|
||||
@@ -1383,7 +1368,7 @@ UploadError CUploadManager::Remove(const SString& siaPath)
|
||||
return ret;
|
||||
}
|
||||
|
||||
UploadFileListPtr CUploadManager::GetUploadFileList() const
|
||||
std::shared_ptr<json> CUploadManager::GetUploadFileList() const
|
||||
{
|
||||
return _uploadFileList;
|
||||
}
|
@@ -2631,7 +2631,7 @@ public:
|
||||
return (_siaApi != nullptr);
|
||||
}
|
||||
|
||||
static UploadFileListPtr GetUploadFileList()
|
||||
static std::shared_ptr<json> GetUploadFileList()
|
||||
{
|
||||
auto uploadManager = _uploadManager;
|
||||
if (uploadManager)
|
||||
@@ -2639,7 +2639,7 @@ public:
|
||||
return uploadManager->GetUploadFileList();
|
||||
}
|
||||
|
||||
return std::make_shared<UploadFileList>();
|
||||
return std::make_shared<json>();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2697,7 +2697,7 @@ void CSiaDokanDrive::ClearCache()
|
||||
std::lock_guard<std::mutex> l(_startStopMutex);
|
||||
}
|
||||
|
||||
UploadFileListPtr CSiaDokanDrive::GetUploadFileList() const
|
||||
std::shared_ptr<json> CSiaDokanDrive::GetUploadFileList() const
|
||||
{
|
||||
return DokanImpl::GetUploadFileList();
|
||||
}
|
||||
|
Reference in New Issue
Block a user