Merge pull request #65 from newCodeRunner/master
Add Button to Delete addresses locally
This commit is contained in:
@@ -47,6 +47,9 @@
|
||||
<button type="button" class="btn btn-etho btnShowQRCode" data-address="{{address}}">
|
||||
<i class="fas fa-qrcode"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-etho btnDeleteAddress" data-wallet="{{address}}">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</td>
|
||||
<td>{{balance}}</td>
|
||||
</tr>
|
||||
|
||||
@@ -61,6 +61,32 @@ class Accounts {
|
||||
// file was written
|
||||
});
|
||||
}
|
||||
|
||||
deteteAccount(address) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const accPath = EthoAccounts.getKeyStoreLocation();
|
||||
|
||||
fs.readdir(accPath, function (err, files) {
|
||||
let deleteFilePath = null;
|
||||
if (err) reject(err);
|
||||
else {
|
||||
const searchStr = String(address).substring(2, String(address).length).toLowerCase();
|
||||
for (let filePath of files) {
|
||||
if (String(filePath).toLowerCase().indexOf(searchStr) > -1) {
|
||||
deleteFilePath = filePath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (deleteFilePath) {
|
||||
fs.unlink(path.join(accPath, deleteFilePath), function(error) {
|
||||
if (error) reject(error);
|
||||
else resolve(true);
|
||||
});
|
||||
} else resolve(true)
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.on("exportAccounts", (event, arg) => {
|
||||
@@ -96,4 +122,14 @@ ipcMain.on("saveAccount", (event, arg) => {
|
||||
event.returnValue = true;
|
||||
});
|
||||
|
||||
ipcMain.on("deteteAccount", (event, arg) => {
|
||||
EthoAccounts.deteteAccount(arg)
|
||||
.then((res) => {
|
||||
event.returnValue = res;
|
||||
})
|
||||
.catch((err) => {
|
||||
event.returnValue = err;
|
||||
});
|
||||
});
|
||||
|
||||
EthoAccounts = new Accounts();
|
||||
|
||||
@@ -178,6 +178,20 @@ $(document).on("render_wallets", function () {
|
||||
$("#dlgShowAddressQRCode").iziModal("close");
|
||||
});
|
||||
});
|
||||
|
||||
$(".btnDeleteAddress").off("click").on("click", function () {
|
||||
const address = $(this).attr("data-wallet");
|
||||
EthoMainGUI.showGeneralConfirmation(
|
||||
`Do you really want to delete Wallet with Address: ${address}? This action can not be reversed.`,
|
||||
function (result) {
|
||||
if (result) {
|
||||
const deleteResult = ipcRenderer.sendSync('deteteAccount', address);
|
||||
if (deleteResult !== true) EthoMainGUI.showGeneralError(deleteResult);
|
||||
setTimeout(EthoWallets.renderWalletsState, 1000);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
$(".btnChangWalletName").off("click").on("click", function () {
|
||||
var walletAddress = $(this).attr("data-wallet");
|
||||
@@ -279,4 +293,4 @@ $(document).on("onNewAccountTransaction", function () {
|
||||
}
|
||||
});
|
||||
|
||||
EthoWallets = new Wallets();
|
||||
EthoWallets = new Wallets();
|
||||
|
||||
Reference in New Issue
Block a user