Updating ethoFS Login System
This commit is contained in:
@@ -50,6 +50,7 @@ var GlobalControllerABI = JSON.parse('[ { "constant": true, "inputs": [], "name"
|
|||||||
const $miningMessage = document.querySelector('.mining-message')
|
const $miningMessage = document.querySelector('.mining-message')
|
||||||
|
|
||||||
/*START OF MISC GLOBAL VARIABLES*/
|
/*START OF MISC GLOBAL VARIABLES*/
|
||||||
|
var web3;
|
||||||
var privateKeyLogin = false;
|
var privateKeyLogin = false;
|
||||||
var GlobalPrivateKey;
|
var GlobalPrivateKey;
|
||||||
var minimumContractCost = 10000000000000000;
|
var minimumContractCost = 10000000000000000;
|
||||||
@@ -74,9 +75,9 @@ var GlobalHostingContractDetailArray = new Array();
|
|||||||
var GlobalExtensionDuration;
|
var GlobalExtensionDuration;
|
||||||
/*END OF MISC GLOBAL VARIABLES*/
|
/*END OF MISC GLOBAL VARIABLES*/
|
||||||
|
|
||||||
var elem = document.querySelector('.modal');
|
//var elem = document.querySelector('.modal');
|
||||||
var instance = M.Modal.init(elem);
|
//var instance = M.Modal.init(elem);
|
||||||
instance.open();
|
//instance.open();
|
||||||
|
|
||||||
function isWindows() {
|
function isWindows() {
|
||||||
return navigator.platform.indexOf('Win') > -1
|
return navigator.platform.indexOf('Win') > -1
|
||||||
@@ -94,25 +95,47 @@ fetch('https://api.coinmarketcap.com/v2/ticker/3452/').then(response => {
|
|||||||
document.getElementById("ethoprice").textContent = round(ethoPriceUSD, 4);
|
document.getElementById("ethoprice").textContent = round(ethoPriceUSD, 4);
|
||||||
}).catch(err => {});
|
}).catch(err => {});
|
||||||
|
|
||||||
if (typeof web3 == 'undefined') {
|
function beforeLoginState() {
|
||||||
var web3 = new Web3()
|
var statsRow = document.getElementById("stats-row");
|
||||||
|
statsRow.style.display = "none";
|
||||||
|
var uploadButton = document.getElementById("main-upload-button");
|
||||||
|
uploadButton.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function afterLoginState() {
|
||||||
|
var statsRow = document.getElementById("stats-row");
|
||||||
|
statsRow.style.display = "block";
|
||||||
|
var uploadButton = document.getElementById("main-upload-button");
|
||||||
|
uploadButton.style.display = "block";
|
||||||
|
var loginButton = document.getElementById("main-login-button");
|
||||||
|
loginButton.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkLogin() {
|
||||||
|
if (web3 == null) {
|
||||||
|
beforeLoginState();
|
||||||
|
web3 = new Web3()
|
||||||
web3.setProvider(new Web3.providers.WebsocketProvider("ws://localhost:8546"));
|
web3.setProvider(new Web3.providers.WebsocketProvider("ws://localhost:8546"));
|
||||||
$('#ethofsLoginModal').modal({dismissible: true});
|
//$('#ethofsLoginModal').modal({dismissible: true});
|
||||||
$('#ethofsLoginModal').modal('open');
|
//$('#ethofsLoginModal').modal('show');
|
||||||
} else {
|
} else {
|
||||||
ethofsLogin("");
|
ethofsLogin(GlobalPrivateKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ethofsLogin(privateKey) {
|
function ethofsLogin(privateKey) {
|
||||||
|
afterLoginState();
|
||||||
$('#ethofsLoginModal').modal('close');
|
$('#ethofsLoginModal').modal('close');
|
||||||
$('#ethofsRegistrationModal').modal({dismissible: true});
|
$('#ethofsRegistrationModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#ethofsRegistrationModal').modal('close');
|
$('#ethofsRegistrationModal').modal('close');
|
||||||
//CREATE ETHER-1 CHAIN CONNECTION AND LOOK FOR EXISTING USER ACCOUNT
|
//CREATE ETHER-1 CHAIN CONNECTION AND LOOK FOR EXISTING USER ACCOUNT
|
||||||
if (privateKey != "") {
|
if (privateKey != "") {
|
||||||
GlobalPrivateKey = privateKey;
|
GlobalPrivateKey = privateKey;
|
||||||
privateKeyLogin = true;
|
privateKeyLogin = true;
|
||||||
web3.eth.net.isListening()
|
web3.eth.net.isListening()
|
||||||
.then(function() {
|
.then(function () {
|
||||||
console.log('ethoFS is connected')
|
console.log('ethoFS is connected')
|
||||||
let account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
|
let account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
|
||||||
console.log(account);
|
console.log(account);
|
||||||
@@ -123,7 +146,7 @@ function ethofsLogin(privateKey) {
|
|||||||
} else {
|
} else {
|
||||||
privateKeyLogin = false;
|
privateKeyLogin = false;
|
||||||
web3 = new Web3(web3.currentProvider);
|
web3 = new Web3(web3.currentProvider);
|
||||||
web3.eth.getAccounts(function(err, accounts) {
|
web3.eth.getAccounts(function (err, accounts) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
console.error("An error occurred: " + err);
|
console.error("An error occurred: " + err);
|
||||||
outputNoAddressContractTable();
|
outputNoAddressContractTable();
|
||||||
@@ -147,11 +170,11 @@ function startEthofs() {
|
|||||||
console.log("Starting ethoFS");
|
console.log("Starting ethoFS");
|
||||||
GlobalUserAddress = web3.eth.defaultAccount;
|
GlobalUserAddress = web3.eth.defaultAccount;
|
||||||
var ethoFSAccounts = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress);
|
var ethoFSAccounts = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress);
|
||||||
ethoFSAccounts.methods.CheckAccountExistence(GlobalUserAddress).call(function(error, result) {
|
ethoFSAccounts.methods.CheckAccountExistence(GlobalUserAddress).call(function (error, result) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (result) {
|
if (result) {
|
||||||
document.getElementById("accountaddress").textContent = web3.eth.defaultAccount;
|
document.getElementById("accountaddress").textContent = web3.eth.defaultAccount;
|
||||||
ethoFSAccounts.methods.GetUserAccountName(GlobalUserAddress).call(function(error, result) {
|
ethoFSAccounts.methods.GetUserAccountName(GlobalUserAddress).call(function (error, result) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (result) {
|
if (result) {
|
||||||
getBlockHeight(web3);
|
getBlockHeight(web3);
|
||||||
@@ -192,13 +215,15 @@ function AddNewUser(userName) {
|
|||||||
};
|
};
|
||||||
var privateKey = '0x' + GlobalPrivateKey;
|
var privateKey = '0x' + GlobalPrivateKey;
|
||||||
web3.eth.accounts.signTransaction(tx, privateKey)
|
web3.eth.accounts.signTransaction(tx, privateKey)
|
||||||
.then(function(signedTransactionData) {
|
.then(function (signedTransactionData) {
|
||||||
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function(error, result) {
|
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function (error, result) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (result) {
|
if (result) {
|
||||||
$('#minedBlockTrackerModal').modal({dismissible: true});
|
$('#minedBlockTrackerModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#minedBlockTrackerModal').modal('open');
|
$('#minedBlockTrackerModal').modal('open');
|
||||||
waitForReceipt(result, function(receipt) {
|
waitForReceipt(result, function (receipt) {
|
||||||
console.log("Transaction Has Been Mined: " + receipt);
|
console.log("Transaction Has Been Mined: " + receipt);
|
||||||
$('#minedBlockTrackerModal').modal('close');
|
$('#minedBlockTrackerModal').modal('close');
|
||||||
ethofsLogin(GlobalPrivateKey);
|
ethofsLogin(GlobalPrivateKey);
|
||||||
@@ -212,12 +237,12 @@ function AddNewUser(userName) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
controller.methods.AddNewUserPublic(userName).send(function(error, result) {
|
controller.methods.AddNewUserPublic(userName).send(function (error, result) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (result) {
|
if (result) {
|
||||||
document.getElementById("wait").innerHTML = 'Waiting For Add User Confirmation.';
|
document.getElementById("wait").innerHTML = 'Waiting For Add User Confirmation.';
|
||||||
$('#minedBlockTrackerModal').modal('open');
|
$('#minedBlockTrackerModal').modal('open');
|
||||||
waitForReceipt(result, function(receipt) {
|
waitForReceipt(result, function (receipt) {
|
||||||
console.log("Transaction Has Been Mined: " + receipt);
|
console.log("Transaction Has Been Mined: " + receipt);
|
||||||
$('#minedBlockTrackerModal').modal('close');
|
$('#minedBlockTrackerModal').modal('close');
|
||||||
ethofsLogin("");
|
ethofsLogin("");
|
||||||
@@ -236,7 +261,7 @@ function AddNewUser(userName) {
|
|||||||
/*************************************************************************************************************/
|
/*************************************************************************************************************/
|
||||||
function getBlockHeight(web3) {
|
function getBlockHeight(web3) {
|
||||||
console.log("Starting Block Height Detection..");
|
console.log("Starting Block Height Detection..");
|
||||||
web3.eth.getBlockNumber(function(err, data) {
|
web3.eth.getBlockNumber(function (err, data) {
|
||||||
document.getElementById("blocknumber").textContent = data;
|
document.getElementById("blocknumber").textContent = data;
|
||||||
console.log("ETHO Block Number: " + data);
|
console.log("ETHO Block Number: " + data);
|
||||||
});
|
});
|
||||||
@@ -244,7 +269,7 @@ function getBlockHeight(web3) {
|
|||||||
/*************************************************************************************************************/
|
/*************************************************************************************************************/
|
||||||
function getBalance(web3) {
|
function getBalance(web3) {
|
||||||
console.log("Starting Balance Detection..");
|
console.log("Starting Balance Detection..");
|
||||||
web3.eth.getBalance(web3.eth.defaultAccount, function(err, data) {
|
web3.eth.getBalance(web3.eth.defaultAccount, function (err, data) {
|
||||||
var balance = "ETHO Balance: " + Number(web3.utils.fromWei(data, "ether")).toFixed(2);
|
var balance = "ETHO Balance: " + Number(web3.utils.fromWei(data, "ether")).toFixed(2);
|
||||||
document.getElementById("ethobalance").textContent = balance;
|
document.getElementById("ethobalance").textContent = balance;
|
||||||
console.log("ETHO Balance: " + data);
|
console.log("ETHO Balance: " + data);
|
||||||
@@ -262,10 +287,10 @@ function calculateCost(contractSize, contractDuration, hostingCost) {
|
|||||||
/*************************************************************************************************************/
|
/*************************************************************************************************************/
|
||||||
//CHECK FOR TX - BLOCK TO BE MINED
|
//CHECK FOR TX - BLOCK TO BE MINED
|
||||||
function waitForReceipt(hash, cb) {
|
function waitForReceipt(hash, cb) {
|
||||||
web3.eth.getTransactionReceipt(hash, function(err, receipt) {
|
web3.eth.getTransactionReceipt(hash, function (err, receipt) {
|
||||||
document.getElementById("mining-status-message").textContent = "In Progress";
|
document.getElementById("mining-status-message").textContent = "In Progress";
|
||||||
$miningMessage.innerText = "Waiting For Transaction Confirmation";
|
$miningMessage.innerText = "Waiting For Transaction Confirmation";
|
||||||
web3.eth.getBlock('latest', function(e, res) {
|
web3.eth.getBlock('latest', function (e, res) {
|
||||||
if (!e) {
|
if (!e) {
|
||||||
document.getElementById("block-height").textContent = res.number;
|
document.getElementById("block-height").textContent = res.number;
|
||||||
}
|
}
|
||||||
@@ -281,7 +306,7 @@ function waitForReceipt(hash, cb) {
|
|||||||
cb(receipt);
|
cb(receipt);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
waitForReceipt(hash, cb);
|
waitForReceipt(hash, cb);
|
||||||
}, 10000);
|
}, 10000);
|
||||||
}
|
}
|
||||||
@@ -301,14 +326,16 @@ function RemoveContract(hostingAddress, contentHash) {
|
|||||||
var privateKey = '0x' + GlobalPrivateKey;
|
var privateKey = '0x' + GlobalPrivateKey;
|
||||||
console.log("Private Key: " + privateKey);
|
console.log("Private Key: " + privateKey);
|
||||||
web3.eth.accounts.signTransaction(tx, privateKey)
|
web3.eth.accounts.signTransaction(tx, privateKey)
|
||||||
.then(function(signedTransactionData) {
|
.then(function (signedTransactionData) {
|
||||||
console.log("Signed TX Data: " + signedTransactionData.rawTransaction);
|
console.log("Signed TX Data: " + signedTransactionData.rawTransaction);
|
||||||
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function(error, result) {
|
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function (error, result) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (result) {
|
if (result) {
|
||||||
$('#minedBlockTrackerModal').modal({dismissible: true});
|
$('#minedBlockTrackerModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#minedBlockTrackerModal').modal('open');
|
$('#minedBlockTrackerModal').modal('open');
|
||||||
waitForReceipt(result, function(receipt) {
|
waitForReceipt(result, function (receipt) {
|
||||||
console.log("Transaction Has Been Mined: " + receipt);
|
console.log("Transaction Has Been Mined: " + receipt);
|
||||||
$('#minedBlockTrackerModal').modal('close');
|
$('#minedBlockTrackerModal').modal('close');
|
||||||
updateContractTable();
|
updateContractTable();
|
||||||
@@ -326,12 +353,14 @@ function RemoveContract(hostingAddress, contentHash) {
|
|||||||
to: GlobalControllerContractAddress,
|
to: GlobalControllerContractAddress,
|
||||||
from: GlobalUserAddress,
|
from: GlobalUserAddress,
|
||||||
};
|
};
|
||||||
pinRemoving.methods.RemoveHostingContract(hostingAddress, contentHash).send(tx, function(error, result) {
|
pinRemoving.methods.RemoveHostingContract(hostingAddress, contentHash).send(tx, function (error, result) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (result) {
|
if (result) {
|
||||||
$('#minedBlockTrackerModal').modal({dismissible: true});
|
$('#minedBlockTrackerModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#minedBlockTrackerModal').modal('open');
|
$('#minedBlockTrackerModal').modal('open');
|
||||||
waitForReceipt(result, function(receipt) {
|
waitForReceipt(result, function (receipt) {
|
||||||
console.log("Transaction Has Been Mined: " + receipt);
|
console.log("Transaction Has Been Mined: " + receipt);
|
||||||
$('#minedBlockTrackerModal').modal('close');
|
$('#minedBlockTrackerModal').modal('close');
|
||||||
updateContractTable();
|
updateContractTable();
|
||||||
@@ -353,14 +382,14 @@ function updateContractTable() {
|
|||||||
var hostingContracts = "";
|
var hostingContracts = "";
|
||||||
var TotalContractCount = 0;
|
var TotalContractCount = 0;
|
||||||
var blockHeight = 0;
|
var blockHeight = 0;
|
||||||
web3.eth.getBlockNumber(function(error, result) {
|
web3.eth.getBlockNumber(function (error, result) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
blockHeight = result;
|
blockHeight = result;
|
||||||
} else
|
} else
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
var ethoFSAccounts = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress);
|
var ethoFSAccounts = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress);
|
||||||
ethoFSAccounts.methods.GetUserAccountTotalContractCount(web3.eth.defaultAccount).call(function(error, result) {
|
ethoFSAccounts.methods.GetUserAccountTotalContractCount(web3.eth.defaultAccount).call(function (error, result) {
|
||||||
TotalContractCount = result;
|
TotalContractCount = result;
|
||||||
GlobalTotalContractCount = result;
|
GlobalTotalContractCount = result;
|
||||||
const getContractData = async (ethoFSAccounts, account, TotalContractCount) => {
|
const getContractData = async (ethoFSAccounts, account, TotalContractCount) => {
|
||||||
@@ -477,7 +506,9 @@ function round(value, decimals) {
|
|||||||
}
|
}
|
||||||
/*************************************************************************************************************/
|
/*************************************************************************************************************/
|
||||||
function finishUploadModal() {
|
function finishUploadModal() {
|
||||||
$('#uploadTrackerModal').modal({dismissible: true});
|
$('#uploadTrackerModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#uploadTrackerModal').modal('close');
|
$('#uploadTrackerModal').modal('close');
|
||||||
stopApplication();
|
stopApplication();
|
||||||
resetUploadSystem();
|
resetUploadSystem();
|
||||||
@@ -497,7 +528,9 @@ function resetUploadModal() {
|
|||||||
//CHECK FOR PROPAGATED & AVAILABLE DATA ON NETWORK - FINAL VERIFICATION FOR UPLOADED CONTENT
|
//CHECK FOR PROPAGATED & AVAILABLE DATA ON NETWORK - FINAL VERIFICATION FOR UPLOADED CONTENT
|
||||||
function checkForUploadedContentAvailability(HostingContractName) {
|
function checkForUploadedContentAvailability(HostingContractName) {
|
||||||
document.getElementById("upload-check-button").style.visibility = "hidden";
|
document.getElementById("upload-check-button").style.visibility = "hidden";
|
||||||
$('#uploadTrackerModal').modal({dismissible: true});
|
$('#uploadTrackerModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#uploadTrackerModal').modal('open');
|
$('#uploadTrackerModal').modal('open');
|
||||||
document.getElementById("upload-hash").innerHTML = HostingContractName;
|
document.getElementById("upload-hash").innerHTML = HostingContractName;
|
||||||
return false;
|
return false;
|
||||||
@@ -608,7 +641,9 @@ function showHostingContractDetails(counter) {
|
|||||||
resetContractExtensionChange();
|
resetContractExtensionChange();
|
||||||
|
|
||||||
GlobalHostingContractDetailArray = GlobalHostingContractArray[counter];
|
GlobalHostingContractDetailArray = GlobalHostingContractArray[counter];
|
||||||
$('#contractDetailModal').modal({dismissible: true});
|
$('#contractDetailModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#contractDetailModal').modal('open');
|
$('#contractDetailModal').modal('open');
|
||||||
document.getElementById("contract-detail-name").innerHTML = GlobalHostingContractDetailArray['name'];
|
document.getElementById("contract-detail-name").innerHTML = GlobalHostingContractDetailArray['name'];
|
||||||
var hashOutputString = "";
|
var hashOutputString = "";
|
||||||
@@ -688,16 +723,20 @@ function contractExtensionConfirmation() {
|
|||||||
var privateKey = '0x' + GlobalPrivateKey;
|
var privateKey = '0x' + GlobalPrivateKey;
|
||||||
console.log("Private Key: " + privateKey);
|
console.log("Private Key: " + privateKey);
|
||||||
web3.eth.accounts.signTransaction(tx, privateKey)
|
web3.eth.accounts.signTransaction(tx, privateKey)
|
||||||
.then(function(signedTransactionData) {
|
.then(function (signedTransactionData) {
|
||||||
console.log("Signed TX Data: " + signedTransactionData.rawTransaction);
|
console.log("Signed TX Data: " + signedTransactionData.rawTransaction);
|
||||||
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function(error, result) {
|
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function (error, result) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (result) {
|
if (result) {
|
||||||
$('#contractDetailModal').modal({dismissible: true});
|
$('#contractDetailModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#contractDetailModal').modal('close');
|
$('#contractDetailModal').modal('close');
|
||||||
$('#minedBlockTrackerModal').modal({dismissible: true});
|
$('#minedBlockTrackerModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#minedBlockTrackerModal').modal('open');
|
$('#minedBlockTrackerModal').modal('open');
|
||||||
waitForReceipt(result, function(receipt) {
|
waitForReceipt(result, function (receipt) {
|
||||||
console.log("Transaction Has Been Mined: " + receipt);
|
console.log("Transaction Has Been Mined: " + receipt);
|
||||||
$('#minedBlockTrackerModal').modal('close');
|
$('#minedBlockTrackerModal').modal('close');
|
||||||
updateContractTable();
|
updateContractTable();
|
||||||
@@ -712,12 +751,12 @@ function contractExtensionConfirmation() {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ethoFSController.methods.ExtendContract(GlobalHostingContractDetailArray['address'], extensionDuration).send(transactionObject, function(error, result) {
|
ethoFSController.methods.ExtendContract(GlobalHostingContractDetailArray['address'], extensionDuration).send(transactionObject, function (error, result) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (result) {
|
if (result) {
|
||||||
$('#contractDetailModal').modal('close');
|
$('#contractDetailModal').modal('close');
|
||||||
$('#minedBlockTrackerModal').modal('open');
|
$('#minedBlockTrackerModal').modal('open');
|
||||||
waitForReceipt(result, function(receipt) {
|
waitForReceipt(result, function (receipt) {
|
||||||
console.log("Transaction Has Been Mined: " + receipt);
|
console.log("Transaction Has Been Mined: " + receipt);
|
||||||
$('#minedBlockTrackerModal').modal('close');
|
$('#minedBlockTrackerModal').modal('close');
|
||||||
updateContractTable();
|
updateContractTable();
|
||||||
@@ -752,7 +791,7 @@ function UpdateHealthCheckInfo(healthMessage) {
|
|||||||
var availableStorageTotal = 0;
|
var availableStorageTotal = 0;
|
||||||
var activeHistory = 0;
|
var activeHistory = 0;
|
||||||
var nodeCounter = 0;
|
var nodeCounter = 0;
|
||||||
splitMessage.forEach(function(nodeMessage, index) {
|
splitMessage.forEach(function (nodeMessage, index) {
|
||||||
var nodeSplitMessage = nodeMessage.split(":");
|
var nodeSplitMessage = nodeMessage.split(":");
|
||||||
activeHistory = Number(nodeSplitMessage[5]);
|
activeHistory = Number(nodeSplitMessage[5]);
|
||||||
if (activeHistory >= 5) {
|
if (activeHistory >= 5) {
|
||||||
@@ -787,7 +826,7 @@ function UpdateHealthCheckInfo(healthMessage) {
|
|||||||
function calculateStorageAverages(usedStorageArray, availableStorageArray, nodeCountArray) {
|
function calculateStorageAverages(usedStorageArray, availableStorageArray, nodeCountArray) {
|
||||||
|
|
||||||
var sumAvailableStorage = 0;
|
var sumAvailableStorage = 0;
|
||||||
availableStorageArray.forEach(function(value, index) {
|
availableStorageArray.forEach(function (value, index) {
|
||||||
sumAvailableStorage += value;
|
sumAvailableStorage += value;
|
||||||
if (index == (availableStorageArray.length - 1)) {
|
if (index == (availableStorageArray.length - 1)) {
|
||||||
averageAvailableStorageTotal = (sumAvailableStorage / availableStorageArray.length);
|
averageAvailableStorageTotal = (sumAvailableStorage / availableStorageArray.length);
|
||||||
@@ -795,7 +834,7 @@ function UpdateHealthCheckInfo(healthMessage) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
var sumNodeCount = 0;
|
var sumNodeCount = 0;
|
||||||
nodeCountArray.forEach(function(value, index) {
|
nodeCountArray.forEach(function (value, index) {
|
||||||
sumNodeCount += value;
|
sumNodeCount += value;
|
||||||
if (index == (nodeCountArray.length - 1)) {
|
if (index == (nodeCountArray.length - 1)) {
|
||||||
var averageNodeCount = (sumNodeCount / nodeCountArray.length) + 19;
|
var averageNodeCount = (sumNodeCount / nodeCountArray.length) + 19;
|
||||||
@@ -886,13 +925,15 @@ const onDragLeave = () => $dragContainer.classList.remove('dragging')
|
|||||||
|
|
||||||
function startUploadProcess() {
|
function startUploadProcess() {
|
||||||
console.log("Starting Upload Process..");
|
console.log("Starting Upload Process..");
|
||||||
$('#preparingUploadModal').modal({dismissible: true});
|
$('#preparingUploadModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#preparingUploadModal').modal('open');
|
$('#preparingUploadModal').modal('open');
|
||||||
var streamFinishCount = 0;
|
var streamFinishCount = 0;
|
||||||
for (var i = 0; i < MainFileArray.length; i++) {
|
for (var i = 0; i < MainFileArray.length; i++) {
|
||||||
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}`);
|
||||||
@@ -935,8 +976,8 @@ function startUploadProcess() {
|
|||||||
console.log("Sending Immediate Pin Request: " + MainHashArray[i]);
|
console.log("Sending Immediate Pin Request: " + MainHashArray[i]);
|
||||||
publishImmediatePin(MainHashArray[i]);
|
publishImmediatePin(MainHashArray[i]);
|
||||||
}
|
}
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
hashVerificationArray.forEach(function(hash) {
|
hashVerificationArray.forEach(function (hash) {
|
||||||
verifyDataUpload(hash);
|
verifyDataUpload(hash);
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 5000);
|
||||||
@@ -966,7 +1007,7 @@ function startUploadProcess() {
|
|||||||
} else {
|
} else {
|
||||||
var confirmationPercentage = Math.ceil((hashConfirmationCount / hashVerificationArray.length) * 100);
|
var confirmationPercentage = Math.ceil((hashConfirmationCount / hashVerificationArray.length) * 100);
|
||||||
if (confirmationPercentage < 99) {
|
if (confirmationPercentage < 99) {
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
verifyDataUpload(hash)
|
verifyDataUpload(hash)
|
||||||
}, 2000);
|
}, 2000);
|
||||||
} else {
|
} else {
|
||||||
@@ -978,7 +1019,7 @@ function startUploadProcess() {
|
|||||||
console.log("Data Confirmation Error: " + error.status);
|
console.log("Data Confirmation Error: " + error.status);
|
||||||
var confirmationPercentage = Math.ceil((hashConfirmationCount / hashVerificationArray.length) * 100);
|
var confirmationPercentage = Math.ceil((hashConfirmationCount / hashVerificationArray.length) * 100);
|
||||||
if (confirmationPercentage < 99) {
|
if (confirmationPercentage < 99) {
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
verifyDataUpload(hash)
|
verifyDataUpload(hash)
|
||||||
}, 2000);
|
}, 2000);
|
||||||
} else {
|
} else {
|
||||||
@@ -1034,21 +1075,29 @@ function startUploadProcess() {
|
|||||||
var privateKey = '0x' + GlobalPrivateKey;
|
var privateKey = '0x' + GlobalPrivateKey;
|
||||||
console.log("Private Key: " + privateKey);
|
console.log("Private Key: " + privateKey);
|
||||||
web3.eth.accounts.signTransaction(tx, privateKey)
|
web3.eth.accounts.signTransaction(tx, privateKey)
|
||||||
.then(function(signedTransactionData) {
|
.then(function (signedTransactionData) {
|
||||||
console.log("Signed TX Data: " + signedTransactionData.rawTransaction);
|
console.log("Signed TX Data: " + signedTransactionData.rawTransaction);
|
||||||
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function(error, result) {
|
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function (error, result) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (result) {
|
if (result) {
|
||||||
console.log("Result: " + result);
|
console.log("Result: " + result);
|
||||||
$('#minedBlockTrackerModal').modal({dismissible: true});
|
$('#minedBlockTrackerModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#minedBlockTrackerModal').modal('open');
|
$('#minedBlockTrackerModal').modal('open');
|
||||||
$('#preparingUploadModal').modal({dismissible: true});
|
$('#preparingUploadModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#preparingUploadModal').modal('close');
|
$('#preparingUploadModal').modal('close');
|
||||||
waitForReceipt(result, function(receipt) {
|
waitForReceipt(result, function (receipt) {
|
||||||
console.log("Transaction Has Been Mined: " + receipt);
|
console.log("Transaction Has Been Mined: " + receipt);
|
||||||
$('#minedBlockTrackerModal').modal({dismissible: true});
|
$('#minedBlockTrackerModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#minedBlockTrackerModal').modal('close');
|
$('#minedBlockTrackerModal').modal('close');
|
||||||
$('#nodeModal').modal({dismissible: true});
|
$('#nodeModal').modal({
|
||||||
|
dismissible: true
|
||||||
|
});
|
||||||
$('#nodeModal').modal('close');
|
$('#nodeModal').modal('close');
|
||||||
var filesForStream = MainFileArray;
|
var filesForStream = MainFileArray;
|
||||||
streamFilesExternally(filesForStream, MainHashArray);
|
streamFilesExternally(filesForStream, MainHashArray);
|
||||||
@@ -1063,12 +1112,12 @@ function startUploadProcess() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
pinAdding.methods.AddNewContract(GlobalMainContentHash, HostingContractName, HostingContractDuration, pinSize, pinSize, contentHashString, contentPathString).send(transactionObject, function(error, result) {
|
pinAdding.methods.AddNewContract(GlobalMainContentHash, HostingContractName, HostingContractDuration, pinSize, pinSize, contentHashString, contentPathString).send(transactionObject, function (error, result) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (result) {
|
if (result) {
|
||||||
$('#minedBlockTrackerModal').modal('open');
|
$('#minedBlockTrackerModal').modal('open');
|
||||||
$('#preparingUploadModal').modal('close');
|
$('#preparingUploadModal').modal('close');
|
||||||
waitForReceipt(result, function(receipt) {
|
waitForReceipt(result, function (receipt) {
|
||||||
console.log("Transaction Has Been Mined: " + receipt);
|
console.log("Transaction Has Been Mined: " + receipt);
|
||||||
$('#minedBlockTrackerModal').modal('close');
|
$('#minedBlockTrackerModal').modal('close');
|
||||||
$('#nodeModal').modal('close');
|
$('#nodeModal').modal('close');
|
||||||
@@ -1135,7 +1184,7 @@ function onFileUpload(event) {
|
|||||||
|
|
||||||
function readDirectoryContents(directory) {
|
function readDirectoryContents(directory) {
|
||||||
console.log("Directory Path: " + directory);
|
console.log("Directory Path: " + directory);
|
||||||
fs.readdir(directory, function(err, filesUploaded) {
|
fs.readdir(directory, function (err, filesUploaded) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
for (let i = 0; filesUploaded.length > i; i++) {
|
for (let i = 0; filesUploaded.length > i; i++) {
|
||||||
handleItem(filesUploaded[i], directory);
|
handleItem(filesUploaded[i], directory);
|
||||||
@@ -1148,7 +1197,7 @@ function onFileUpload(event) {
|
|||||||
|
|
||||||
function handleItem(filename, relativePath) {
|
function handleItem(filename, relativePath) {
|
||||||
var filepath = relativePath.concat(pathSymbol, 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()) {
|
||||||
readDirectoryContents(filepath)
|
readDirectoryContents(filepath)
|
||||||
@@ -1156,7 +1205,7 @@ function onFileUpload(event) {
|
|||||||
streamCompareCount++;
|
streamCompareCount++;
|
||||||
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 updatedPath = filepath.replace(dirPath, dirName);
|
||||||
var filetowrite = {
|
var filetowrite = {
|
||||||
path: updatedPath,
|
path: updatedPath,
|
||||||
@@ -1225,7 +1274,7 @@ function onDrop(event) {
|
|||||||
getFile(entry);
|
getFile(entry);
|
||||||
|
|
||||||
function getFile(entry) {
|
function getFile(entry) {
|
||||||
entry.file(function(file) {
|
entry.file(function (file) {
|
||||||
readFileContents(file)
|
readFileContents(file)
|
||||||
.then((buffer) => {
|
.then((buffer) => {
|
||||||
var filePath = entry.fullPath;
|
var filePath = entry.fullPath;
|
||||||
@@ -1252,10 +1301,10 @@ function onDrop(event) {
|
|||||||
|
|
||||||
} else if (entry.isDirectory) {
|
} else if (entry.isDirectory) {
|
||||||
let directoryReader = entry.createReader();
|
let directoryReader = entry.createReader();
|
||||||
directoryReader.readEntries(function(entries) {
|
directoryReader.readEntries(function (entries) {
|
||||||
streamCompareCount += entries.length - 1;
|
streamCompareCount += entries.length - 1;
|
||||||
totalItemCount += entries.length - 1;
|
totalItemCount += entries.length - 1;
|
||||||
entries.forEach(function(newEntry) {
|
entries.forEach(function (newEntry) {
|
||||||
handleEntry(newEntry);
|
handleEntry(newEntry);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,14 +27,15 @@
|
|||||||
<section class="content">
|
<section class="content">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="block-header">
|
<div class="block-header">
|
||||||
<h2>DASHBOARD -
|
<h2>
|
||||||
<span id="accountaddress" style="word-break: break-word;"></span> -
|
<span id="accountaddress" style="word-break: break-word;"></span>
|
||||||
<span id="welcome-name"></span>
|
<span id="welcome-name">
|
||||||
|
</span>
|
||||||
<span id="ethobalance"></span>
|
<span id="ethobalance"></span>
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<!-- Widgets -->
|
<!-- Widgets -->
|
||||||
<div class="row clearfix">
|
<div class="row clearfix" id="stats-row">
|
||||||
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
|
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
|
||||||
<div class="info-box bg-pink hover-expand-effect">
|
<div class="info-box bg-pink hover-expand-effect">
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
@@ -127,9 +128,13 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<center>
|
<center>
|
||||||
<button type="button" class="btn bg-indigo waves-effect" data-toggle="modal" data-target="#defaultModal" onclick="resetUploadProcess();">
|
<button type="button" class="btn bg-indigo waves-effect" id="main-upload-button" 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</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn bg-indigo waves-effect" id="main-login-button" data-toggle="modal" data-target="#ethofsLoginModal" onclick="checkLogin();">
|
||||||
|
<i class="material-icons">fingerprint</i>
|
||||||
|
<span>Login To ethoFS</span>
|
||||||
</button>
|
</button>
|
||||||
</center>
|
</center>
|
||||||
<h1></h1>
|
<h1></h1>
|
||||||
@@ -386,7 +391,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-dismiss="modal" id="upload-confirm-button" onclick="startUploadProcess();">CONFIRM</button>
|
<button type="button" class="btn btn-link waves-effect" data-dismiss="modal" id="upload-confirm-button" data-target="#preparingUploadModal" onclick="startUploadProcess();">CONFIRM</button>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
@@ -692,11 +697,14 @@
|
|||||||
<script src="assets/dashboard/plugins/jquery-countto/jquery.countTo.js"></script>
|
<script src="assets/dashboard/plugins/jquery-countto/jquery.countTo.js"></script>
|
||||||
<!-- Custom Js -->
|
<!-- Custom Js -->
|
||||||
<script src="assets/dashboard/js/admin.js"></script>
|
<script src="assets/dashboard/js/admin.js"></script>
|
||||||
<script src="assets/dashboard/js/bundle.js"></script>
|
|
||||||
<script src="assets/dashboard/js/app.js"></script>
|
<script src="assets/dashboard/js/app.js"></script>
|
||||||
|
<script src="assets/dashboard/js/bundle.js"></script>
|
||||||
<!-- Demo Js -->
|
<!-- Demo Js -->
|
||||||
<script src="assets/dashboard/js/demo.js"></script>
|
<script src="assets/dashboard/js/demo.js"></script>
|
||||||
<script src="assets/dashboard/js/medium.js"></script>
|
<script src="assets/dashboard/js/medium.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
checkLogin();
|
||||||
|
</script>
|
||||||
<script>
|
<script>
|
||||||
MediumWidget.Init({
|
MediumWidget.Init({
|
||||||
renderTo: '#medium-widget',
|
renderTo: '#medium-widget',
|
||||||
|
|||||||
Reference in New Issue
Block a user