#21 Fixed / Sequential File Uploads Reset Bug Fixed
This commit is contained in:
@@ -74,6 +74,14 @@ var GlobalHostingContractDetailArray = new Array();
|
|||||||
var GlobalExtensionDuration;
|
var GlobalExtensionDuration;
|
||||||
/*END OF MISC GLOBAL VARIABLES*/
|
/*END OF MISC GLOBAL VARIABLES*/
|
||||||
|
|
||||||
|
function isWindows() {
|
||||||
|
return navigator.platform.indexOf('Win') > -1
|
||||||
|
}
|
||||||
|
|
||||||
|
var pathSymbol = "/";
|
||||||
|
if(isWindows()) {
|
||||||
|
pathSymbol = "\\";
|
||||||
|
}
|
||||||
|
|
||||||
fetch('https://api.coinmarketcap.com/v2/ticker/3452/').then(response => {
|
fetch('https://api.coinmarketcap.com/v2/ticker/3452/').then(response => {
|
||||||
return response.json();
|
return response.json();
|
||||||
@@ -444,6 +452,14 @@ function contractDurationChange(selectObj) {
|
|||||||
document.getElementById("contract-cost").innerHTML = round(ContractCost, 2);
|
document.getElementById("contract-cost").innerHTML = round(ContractCost, 2);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function contractModalSetup() {
|
||||||
|
var duration = document.getElementById('contract-duration').value;
|
||||||
|
GlobalContractDuration = duration;
|
||||||
|
var ContractCost = (((GlobalUploadSize / 1048576) * GlobalHostingCost) * (duration / 46522));
|
||||||
|
document.getElementById("contract-cost").innerHTML = round(ContractCost, 2);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
/*************************************************************************************************************/
|
/*************************************************************************************************************/
|
||||||
//MISC ROUNDING FUNCTION
|
//MISC ROUNDING FUNCTION
|
||||||
function round(value, decimals) {
|
function round(value, decimals) {
|
||||||
@@ -458,8 +474,12 @@ function finishUploadModal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resetUploadModal() {
|
function resetUploadModal() {
|
||||||
stopApplication();
|
var duration = document.getElementById('contract-duration').value;
|
||||||
resetUploadSystem();
|
GlobalContractDuration = duration;
|
||||||
|
var ContractCost = ((GlobalUploadSize / 1048576) * GlobalHostingCost) * (duration / 46522);
|
||||||
|
document.getElementById("contract-cost").innerHTML = round(ContractCost, 2);
|
||||||
|
document.getElementById("upload-hash").innerHTML = GlobalUploadHash;
|
||||||
|
document.getElementById("upload-size").innerHTML = GlobalUploadSize;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*************************************************************************************************************/
|
/*************************************************************************************************************/
|
||||||
@@ -857,19 +877,25 @@ function startUploadProcess() {
|
|||||||
const streamFiles = (files) => {
|
const streamFiles = (files) => {
|
||||||
const stream = node.addReadableStream()
|
const stream = node.addReadableStream()
|
||||||
stream.on('data', function (data) {
|
stream.on('data', function (data) {
|
||||||
console.log("Data...");
|
//console.log("Data...");
|
||||||
console.log(data);
|
//console.log(data);
|
||||||
GlobalHashArray.push(`${data.hash}`);
|
GlobalHashArray.push(`${data.hash}`);
|
||||||
GlobalSizeArray.push(`${data.size}`);
|
GlobalSizeArray.push(`${data.size}`);
|
||||||
GlobalPathArray.push(`${data.path}`);
|
GlobalPathArray.push(`${data.path}`);
|
||||||
GlobalUploadHash = `${data.hash}`;
|
GlobalUploadHash = `${data.hash}`;
|
||||||
GlobalUploadPath = `${data.path}`;
|
GlobalUploadPath = `${data.path}`;
|
||||||
var splitString = GlobalUploadPath.split("/")
|
console.log("Path: " + data.path + " Hash: " + data.hash);
|
||||||
|
//var comparePath = data.path.replace(pathSymbol, "/");
|
||||||
|
var comparePath = data.path.replace(/\\/g, '/');
|
||||||
|
console.log("Compare Path: " + comparePath);
|
||||||
|
var splitString = comparePath.split("/")
|
||||||
if (splitString.length == 1 || splitString[0] == "") {
|
if (splitString.length == 1 || splitString[0] == "") {
|
||||||
|
//if (splitString.length == 1) {
|
||||||
streamFinishCount++;
|
streamFinishCount++;
|
||||||
GlobalMainHashArray.push(`${data.hash}`);
|
GlobalMainHashArray.push(`${data.hash}`);
|
||||||
GlobalMainPathArray.push(`${data.path}`);
|
GlobalMainPathArray.push(`${data.path}`);
|
||||||
if (streamFinishCount == MainFileArray.length) {
|
if (streamFinishCount == MainFileArray.length) {
|
||||||
|
console.log("Finish Path: " + data.path + " Hash: " + data.hash);
|
||||||
createMainHash();
|
createMainHash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -946,18 +972,6 @@ function startUploadProcess() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateUploadProgress(width) {
|
|
||||||
var elem = document.getElementById("myBar");
|
|
||||||
width = round(width, 2);
|
|
||||||
if (width >= 100) {
|
|
||||||
width = 100;
|
|
||||||
elem.style.width = width + '%';
|
|
||||||
elem.innerHTML = width * 1 + '%';
|
|
||||||
}
|
|
||||||
elem.style.width = width + '%';
|
|
||||||
elem.innerHTML = width * 1 + '%';
|
|
||||||
}
|
|
||||||
|
|
||||||
function createMainHash() {
|
function createMainHash() {
|
||||||
var contentHashString = GlobalChannelString;
|
var contentHashString = GlobalChannelString;
|
||||||
for (i = 0; i < GlobalMainHashArray.length; i++) {
|
for (i = 0; i < GlobalMainHashArray.length; i++) {
|
||||||
@@ -1054,7 +1068,20 @@ function startUploadProcess() {
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateUploadProgress(width) {
|
||||||
|
var elem = document.getElementById("myBar");
|
||||||
|
width = round(width, 2);
|
||||||
|
if (width >= 100) {
|
||||||
|
width = 100;
|
||||||
|
elem.style.width = width + '%';
|
||||||
|
elem.innerHTML = width * 1 + '%';
|
||||||
|
}
|
||||||
|
elem.style.width = width + '%';
|
||||||
|
elem.innerHTML = width * 1 + '%';
|
||||||
|
}
|
||||||
|
|
||||||
function resetUploadProcess() {
|
function resetUploadProcess() {
|
||||||
|
resetFileTable();
|
||||||
updateUploadProgress(0);
|
updateUploadProgress(0);
|
||||||
$uploadMessage.innerText = "Preparing Upload";
|
$uploadMessage.innerText = "Preparing Upload";
|
||||||
document.getElementById("upload-status-message").textContent = "";
|
document.getElementById("upload-status-message").textContent = "";
|
||||||
@@ -1080,6 +1107,7 @@ function onFileUpload(event) {
|
|||||||
document.getElementById("upload-confirm-button").style.visibility = "hidden";
|
document.getElementById("upload-confirm-button").style.visibility = "hidden";
|
||||||
MainFileArray.push([]);
|
MainFileArray.push([]);
|
||||||
let dirSelected = event.target.files;
|
let dirSelected = event.target.files;
|
||||||
|
let dirName = dirSelected[0].name;
|
||||||
let dirPath = dirSelected[0].path;
|
let dirPath = dirSelected[0].path;
|
||||||
var streamCompareCount = 0;
|
var streamCompareCount = 0;
|
||||||
var totalUploadItems = 0;
|
var totalUploadItems = 0;
|
||||||
@@ -1099,7 +1127,7 @@ function onFileUpload(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleItem(filename, relativePath) {
|
function handleItem(filename, relativePath) {
|
||||||
var filepath = relativePath.concat('\\', filename);
|
var filepath = relativePath.concat(pathSymbol, filename);
|
||||||
fs.stat(filepath, function (err, stats) {
|
fs.stat(filepath, function (err, stats) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
if (stats.isDirectory()) {
|
if (stats.isDirectory()) {
|
||||||
@@ -1109,16 +1137,17 @@ function onFileUpload(event) {
|
|||||||
totalUploadItems++;
|
totalUploadItems++;
|
||||||
console.log("File Path: " + filepath);
|
console.log("File Path: " + filepath);
|
||||||
fs.readFile(filepath, function (err, file) {
|
fs.readFile(filepath, function (err, file) {
|
||||||
|
var updatedPath = filepath.replace(dirPath, dirName);
|
||||||
var filetowrite = {
|
var filetowrite = {
|
||||||
path: filepath,
|
path: updatedPath,
|
||||||
content: file
|
content: file
|
||||||
};
|
};
|
||||||
var filename = filepath;
|
var filename = updatedPath;
|
||||||
MainFileArray[MainFileArray.length - 1].push(filetowrite);
|
MainFileArray[MainFileArray.length - 1].push(filetowrite);
|
||||||
GlobalUploadSize += Number(stats.size);
|
GlobalUploadSize += Number(stats.size);
|
||||||
fileSize += Number(stats.size);
|
fileSize += Number(stats.size);
|
||||||
var totalUploadSizeMB = GlobalUploadSize / 1000000;
|
var totalUploadSizeMB = GlobalUploadSize / 1000000;
|
||||||
appendFile(filepath, filename, stats.size, null);
|
appendFile(updatedPath, filename, stats.size, null);
|
||||||
console.log("Path: " + filepath + " Size: " + stats.size + " Total Size: " + GlobalUploadSize);
|
console.log("Path: " + filepath + " Size: " + stats.size + " Total Size: " + GlobalUploadSize);
|
||||||
document.getElementById("upload-size").textContent = totalUploadSizeMB;
|
document.getElementById("upload-size").textContent = totalUploadSizeMB;
|
||||||
contractDurationChange(document.getElementById('contract-duration').value);
|
contractDurationChange(document.getElementById('contract-duration').value);
|
||||||
|
|||||||
@@ -130,7 +130,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<center>
|
<center>
|
||||||
<button type="button" class="btn bg-indigo waves-effect" data-toggle="modal" data-target="#defaultModal">
|
<button type="button" class="btn bg-indigo waves-effect" data-toggle="modal" data-target="#defaultModal" onclick="resetUploadProcess();">
|
||||||
<i class="material-icons">cloud_upload</i>
|
<i class="material-icons">cloud_upload</i>
|
||||||
<span>Upload to ethoFS now</span>
|
<span>Upload to ethoFS now</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -317,7 +317,7 @@
|
|||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-link waves-effect" data-dismiss="modal">CLOSE</button>
|
<button type="button" class="btn btn-link waves-effect" data-dismiss="modal">CLOSE</button>
|
||||||
<button type="button" class="btn btn-link waves-effect" data-toggle="modal" data-dismiss="modal"
|
<button type="button" class="btn btn-link waves-effect" data-toggle="modal" data-dismiss="modal"
|
||||||
data-target="#defaultModal3">NEXT</button>
|
data-target="#defaultModal3" onclick="resetUploadModal();">NEXT</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user