Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Improve importer #1598

Merged
merged 17 commits into from
Jan 25, 2017
Merged
1 change: 0 additions & 1 deletion interface/client/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/



// BROWSER RELATED
// Contains the accounts
Tabs = new Mongo.Collection('tabs', {connection: null});
Expand Down
54 changes: 27 additions & 27 deletions interface/client/templates/popupWindows/onboardingScreen.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

{{> elements_networkIndicator}}

<div class="main-content">
<div class="main-content">
<div class="onboarding-section onboarding-start">
<p class="description">{{i18n "mist.popupWindows.onboarding.description"}}</p>
<p>
<button class="start-testnet"> {{i18n "mist.popupWindows.onboarding.goToTestnet"}} </button>
<p>
<button class="start-testnet"> {{i18n "mist.popupWindows.onboarding.goToTestnet"}} </button>
{{i18n "mist.popupWindows.onboarding.goToTestnetDescription"}}
</p>
<p>
<button class="goto-import-account"> {{i18n "mist.popupWindows.onboarding.gotoMainnet"}} </button>
<p>
<button class="goto-import-account"> {{i18n "mist.popupWindows.onboarding.gotoMainnet"}} </button>
{{i18n "mist.popupWindows.onboarding.gotoMainnetDescription"}}
</p>
</div>
Expand All @@ -20,8 +20,8 @@
{{> popupWindows_onboardingScreen_importAccount}}

<div class="col col-12 footer-buttons">
<button class="goto-start"> {{i18n "buttons.back"}} </button>
<button class="goto-password right-align"> {{i18n "buttons.skip"}} </button>
<button class="goto-start"> {{i18n "buttons.back"}} </button>
<button class="goto-password right-align"> {{i18n "buttons.skip"}} </button>
</div>
</div>

Expand Down Expand Up @@ -66,8 +66,8 @@ <h6> {{{i18n "mist.popupWindows.onboarding.viaShapeshift"}}} </h6>
{{/if}}
</div>
<div class="col col-12 footer-buttons">
<button class="goto-start"> {{i18n "buttons.back"}} </button>
<button class="goto-tutorial-1 right-align"> {{i18n "buttons.next"}} </button>
<button class="goto-start"> {{i18n "buttons.back"}} </button>
<button class="goto-tutorial-1 right-align"> {{i18n "buttons.next"}} </button>
</div>
</div>

Expand All @@ -79,8 +79,8 @@ <h1> {{i18n "mist.popupWindows.onboarding.learnIt"}} </h1>
</div>
<div class="col col-6 tutorial-token"></div>
<div class="col col-12 footer-buttons">
<button class="goto-start"> {{i18n "buttons.back"}} </button>
<button class="goto-tutorial-2 right-align"> {{i18n "buttons.next"}} </button>
<button class="goto-start"> {{i18n "buttons.back"}} </button>
<button class="goto-tutorial-2 right-align"> {{i18n "buttons.next"}} </button>
</div>
</div>

Expand All @@ -90,10 +90,10 @@ <h1> {{i18n "mist.popupWindows.onboarding.learnIt"}} </h1>
{{{i18n "mist.popupWindows.onboarding.tutorial2Description"}}}
<p><a href="https://www.ethereum.org/crowdsale" class="button" target="_blank">{{i18n "mist.popupWindows.onboarding.buttons.learnReceipt"}}</a></p>
</div>
<div class="col col-6 tutorial-crowdsale"></div>
<div class="col col-6 tutorial-crowdsale"></div>
<div class="col col-12 footer-buttons">
<button class="goto-tutorial-1"> {{i18n "buttons.back"}} </button>
<button class="goto-tutorial-3 right-align"> {{i18n "buttons.next"}} </button>
<button class="goto-tutorial-1"> {{i18n "buttons.back"}} </button>
<button class="goto-tutorial-3 right-align"> {{i18n "buttons.next"}} </button>
</div>
</div>

Expand All @@ -105,15 +105,15 @@ <h1> {{i18n "mist.popupWindows.onboarding.learnIt"}} </h1>
</div>
<div class="col col-6 tutorial-dao"></div>
<div class="col col-12 footer-buttons">
<button class="goto-tutorial-2"> {{i18n "buttons.back"}} </button>
<button class="goto-tutorial-2"> {{i18n "buttons.back"}} </button>
</div>
</div>
</div>

<footer>
<progress value="{{#with TemplateVar.get 'syncing'}}{{progress}}{{/with}}" max="100"></progress>
<progress class='stateBar' value="{{#with TemplateVar.get 'syncing'}}{{_displayStatesDownload}}{{/with}}" max="1"></progress>

{{syncStatus}}
{{#if TemplateVar.get 'readyToLaunch'}}
<button class="launch-app"> {{i18n "mist.popupWindows.onboarding.buttons.launchApp"}} </button>
Expand All @@ -132,7 +132,7 @@ <h1> {{i18n "mist.popupWindows.onboarding.learnIt"}} </h1>
{{/with}}
{{/if}}

</footer>
</footer>
</div>
</template>

Expand All @@ -148,14 +148,14 @@ <h1>{{i18n "mist.popupWindows.onboarding.doYouHaveAWalletFile"}}</h1>
<span class="dapp-identicon dapp-icon-loading"></span>
<h2 style="display: block; text-align: center;">{{i18n "mist.popupWindows.onboarding.importing"}}</h2>
{{else}}
<form action="about:blank" target="dapp-form-helper-iframe">
<input type="{{showPassword}}" placeholder="{{i18n 'mist.popupWindows.requestAccount.enterPassword'}}" class="password">
<br><br>
<input type="checkbox" name="elements_input_bool" class="show-password abi-input">
<label for="show-password">{{i18n "mist.popupWindows.onboarding.buttons.showPassword"}}</label>
<br><br>
<button type="submit" style="margin-left: 15px;">{{i18n "mist.popupWindows.onboarding.buttons.importAccount"}}</button>
</form>
<form action="about:blank" target="dapp-form-helper-iframe">
<input type="{{showPassword}}" placeholder="{{i18n 'mist.popupWindows.requestAccount.enterPassword'}}" class="password">
<br><br>
<input type="checkbox" name="elements_input_bool" class="show-password abi-input">
<label for="show-password">{{i18n "mist.popupWindows.onboarding.buttons.showPassword"}}</label>
<br><br>
<button type="submit" style="margin-left: 15px;">{{i18n "mist.popupWindows.onboarding.buttons.importAccount"}}</button>
</form>
{{/if}}
</div>
{{else}}
Expand Down Expand Up @@ -184,11 +184,11 @@ <h2 style="display: block; text-align: center;">{{i18n "mist.popupWindows.onboar
</div>

<div class="col col-12 footer-buttons">
<button class="goto-start" type="button"> {{i18n "buttons.back"}} </button>
<button class="goto-start" type="button"> {{i18n "buttons.back"}} </button>
{{#if TemplateVar.get "passwordsNotEmpty"}}
<button class="create-account right-align" type="submit"> {{i18n "buttons.next"}} </button>
{{else}}
<button class="goto-tutorial-1 right-align"> {{i18n "buttons.skip"}} </button>
<button class="goto-tutorial-1 right-align"> {{i18n "buttons.skip"}} </button>
{{/if}}
</div>
</form>
Expand Down
71 changes: 44 additions & 27 deletions interface/client/templates/popupWindows/onboardingScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ Template['popupWindows_onboardingScreen'].helpers({
// Create an interval to quickly iterate trough the numbers
template._intervalId = Meteor.setInterval(function(){
// load the sync information
var syncing = TemplateVar.get(template, 'syncing');
var syncing = TemplateVar.get(template, 'syncing');

if (syncing) {
// If it's syncing, then it's not ready
TemplateVar.set(template, 'readyToLaunch', false);

// Calculates a block t display that is always getting a few % closer to target
syncing._displayBlock = (syncing._displayBlock + 2*(syncing.currentBlock - syncing._displayBlock) / 100 ) || Number(syncing.startingBlock);
syncing._displayBlock = (syncing._displayBlock + 2*(syncing.currentBlock - syncing._displayBlock) / 100 ) || Number(syncing.startingBlock);

syncing._displayStatesDownload = Number(syncing._displayStatesDownload + (syncing.pulledStates/(1 +syncing.knownStates) - syncing._displayStatesDownload) / 100 ) || Number(syncing.pulledStates)/Number(syncing.knownStates + 1);

Expand Down Expand Up @@ -140,7 +140,7 @@ Template['popupWindows_onboardingScreen'].helpers({
@method syncStatusMessage
*/
'syncStatusMessage' : function() {
return TemplateVar.get("syncStatusMessageLive");
return TemplateVar.get("syncStatusMessageLive");
}
});

Expand All @@ -162,7 +162,7 @@ Template['popupWindows_onboardingScreen'].events({
if(!TemplateVar.get('testnet')) {
ipc.send('onBoarding_changeNet', true);
TemplateVar.set('testnet', true);
TemplateVar.set('syncing', null);
TemplateVar.set('syncing', null);
}

TemplateVar.set('currentActive','testnet');
Expand All @@ -177,17 +177,17 @@ Template['popupWindows_onboardingScreen'].events({
},
'click .goto-tutorial-1': function(){
TemplateVar.set('currentActive','tutorial-1');
if (!TemplateVar.get('syncing'))
if (!TemplateVar.get('syncing'))
TemplateVar.set('readyToLaunch', true);
},
'click .goto-tutorial-2': function(){
TemplateVar.set('currentActive','tutorial-2');
if (!TemplateVar.get('syncing'))
if (!TemplateVar.get('syncing'))
TemplateVar.set('readyToLaunch', true);
},
'click .goto-tutorial-3': function(){
TemplateVar.set('currentActive','tutorial-3');
if (!TemplateVar.get('syncing'))
if (!TemplateVar.get('syncing'))
TemplateVar.set('readyToLaunch', true);
},
/**
Expand Down Expand Up @@ -250,18 +250,35 @@ Template['popupWindows_onboardingScreen_importAccount'].events({

@event drop .dropable
*/
'drop .dropable': function(e, template){
'drop .dropable': function(e, template) {
e.preventDefault();

if(e.originalEvent.dataTransfer && e.originalEvent.dataTransfer.files.length) {
TemplateVar.set('filePath', e.originalEvent.dataTransfer.files[0].path);
Tracker.afterFlush(function(){
template.$('.password').focus();
});
} else {
GlobalNotification.warning({
content: TAPi18n.__('mist.popupWindows.onboarding.errors.unknownFile'),
duration: 4
if (e.originalEvent.dataTransfer) files = e.originalEvent.dataTransfer.files;

if (files.length) {
ipc.send('backendAction_checkWalletFile', files[0].path);

ipc.on('uiAction_checkedWalletFile', function(e, error, type) {
switch (type) {
case 'presale':
TemplateVar.set(template, 'filePath', files[0].path);
Tracker.afterFlush(function() {
template.$('.password').focus();
});
break;
case 'web3':
TemplateVar.set(template, 'filePath', files[0].path);
TemplateVar.set(template, 'importing', true);
setTimeout(function() {
ipc.send('backendAction_closePopupWindow');
}, 750);
break;
default:
GlobalNotification.warning({
content: TAPi18n.__('mist.popupWindows.onboarding.errors.unknownFile'),
duration: 4
});
}
});
}

Expand All @@ -285,29 +302,29 @@ Template['popupWindows_onboardingScreen_importAccount'].events({
},
/**
Checks the password match sends the file path and password to the mist backend to import

@event submit form
*/
'submit form': function(e, template){
var pw = template.find('input.password').value;


ipc.send('backendAction_importPresaleFile', TemplateVar.get('filePath'), pw);
ipc.send('backendAction_importWalletFile', TemplateVar.get('filePath'), pw);

TemplateVar.set('importing', true);
ipc.on('uiAction_importedPresaleFile', function(e, error, address){
ipc.on('uiAction_importedWalletFile', function(e, error, address){
TemplateVar.set(template, 'importing', false);
TemplateVar.set(template, 'filePath', false);

if(address) {
ipc.removeAllListeners('uiAction_importedPresaleFile');
ipc.removeAllListeners('uiAction_importedWalletFile');
console.log('Imported account: ', address);

// move to add account screen, when in the onboarding window
if($('.onboarding-start')[0]) {
TemplateVar.setTo('.onboarding-account', 'newAccount', web3.toChecksumAddress(address));
TemplateVar.setTo('.onboarding-screen', 'currentActive', 'account');

// otherwise simply close the window
} else {
ipc.send('backendAction_closePopupWindow');
Expand Down Expand Up @@ -361,7 +378,7 @@ Template['popupWindows_onboardingScreen_password'].helpers({
Template['popupWindows_onboardingScreen_password'].events({
/**
Clear the form

@event click button[type="button"]
*/
'click button[type="button"]': function(e, template){
Expand All @@ -378,7 +395,7 @@ Template['popupWindows_onboardingScreen_password'].events({
},
/**
Password checks

@event click button[type="button"]
*/
'input input, change input': function(e, template){
Expand All @@ -391,7 +408,7 @@ Template['popupWindows_onboardingScreen_password'].events({
},
/**
Checks the password match and creates a new account

@event submit form
*/
'submit form': function(e, template){
Expand All @@ -416,7 +433,7 @@ Template['popupWindows_onboardingScreen_password'].events({
if(!e) {
TemplateVar.setTo('.onboarding-account', 'newAccount', web3.toChecksumAddress(res));
TemplateVar.setTo('.onboarding-screen', 'currentActive', 'account');

// clear form
pw = pwRepeat = null;

Expand All @@ -429,4 +446,4 @@ Template['popupWindows_onboardingScreen_password'].events({
});
}
}
});
});
1 change: 1 addition & 0 deletions interface/client/templates/popupWindows/splashScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Template['popupWindows_splashScreen'].onCreated(function(){
if (status === 'inProgress') {
TemplateVar.set(template, 'showStartAppButton', true);
TemplateVar.set(template, 'startAppButtonText', TAPi18n.__('mist.startScreen.launchApp'));
ipc.send('backendAction_skipSync');

if (data !== false) {
// if state is "in progress" and we have data
Expand Down
4 changes: 2 additions & 2 deletions interface/i18n/mist.de.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"accounts": {
"label": "Konten",
"importPresale": "Pre-sale-Konto importieren",
"importPresale": "Konto importieren",
"newAccount": "Neues Konto",
"backup": "Sicherung",
"backupKeyStore": "Konten",
Expand Down Expand Up @@ -203,7 +203,7 @@
"gotoMainnet": "Verwende das Hauptnetz",
"gotoMainnetDescription": " Sie werden etwas Ether benötigen, um Verträge anzulegen und auszuführen. Wir werden Ihnen helfen, etwas zu bekommen ...",
"doYouHaveAWalletFile": "Haben Sie eine Wallet-Datei?",
"walletFileDescription": "<p>Wenn Sie 2014 am Ethereum-Pre-sale teilgenommen haben, sollten Sie über eine Datei mit dem Dateinamen <code>ethereum_wallet_backup.json</code> verfügen. Sie wurde nach dem Kauf heruntergeladen und Ihnen auch per E-Mail geschickt.</p>",
"walletFileDescription": "<p>Wallet-Datei zum importieren in dieses Fenster ziehen.<br>Wenn Sie 2014 am Ethereum-Pre-sale teilgenommen haben, sollten Sie über eine Datei mit dem Dateinamen <code>ethereum_wallet_backup.json</code> verfügen. Sie wurde nach dem Kauf heruntergeladen und Ihnen auch per E-Mail geschickt.</p>",
"dropFilesHere": "Pre-sale Datei hochladen",
"creating": "Erstellen...",
"importing": "Importieren...",
Expand Down
6 changes: 3 additions & 3 deletions interface/i18n/mist.en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"accounts": {
"label": "Accounts",
"importPresale": "Import Pre-sale Accounts",
"importPresale": "Import Accounts",
"newAccount": "New account",
"backup": "Backup",
"backupKeyStore": "Accounts",
Expand Down Expand Up @@ -237,8 +237,8 @@
"gotoMainnet" : "Use the main network",
"gotoMainnetDescription" : "You’ll need some Ether in order to create and execute contracts. Don't worry, we'll help you get some...",
"doYouHaveAWalletFile" : "Do you have a wallet file?",
"walletFileDescription" : "<p>If you participated on the Ethereum Pre-sale 2014, you should have a file named <code>ethereum_wallet_backup.json</code>. It was downloaded after the sale and also sent to your email</p>",
"dropFilesHere" : "Drop pre-sale file",
"walletFileDescription" : "<p>Move any wallet file here to import.<br>If you participated on the Ethereum Pre-sale 2014, you should have a file named <code>ethereum_wallet_backup.json</code>. It was downloaded after the sale and also sent to your email</p>",
"dropFilesHere" : "Drop wallet file",
"creating": "Creating...",
"importing": "Importing...",
"skip" : "Skip this step",
Expand Down
2 changes: 1 addition & 1 deletion interface/i18n/mist.es.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"accounts": {
"label": "Cuentas",
"importPresale": "Importar Cuentas de la Pre-venta",
"importPresale": "Importar Cuentas",
"newAccount": "Nueva cuenta",
"backup": "Copia de seguridad",
"backupKeyStore": "Cuentas",
Expand Down
2 changes: 1 addition & 1 deletion interface/i18n/mist.fa.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"accounts": {
"label": "Accounts",
"importPresale": "Import Pre-sale Accounts",
"importPresale": "Import Accounts",
"newAccount": "New account",
"backup": "Backup",
"backupKeyStore": "Accounts",
Expand Down
2 changes: 1 addition & 1 deletion interface/i18n/mist.fr.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"accounts": {
"label": "Comptes",
"importPresale": "Importer les comptes de prévente",
"importPresale": "Importer les comptes",
"newAccount": "Nouveau compte",
"backup": "Sauvegarder",
"backupKeyStore": "Comptes",
Expand Down
Loading