Skip to content

Commit

Permalink
added testnet indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
frozeman committed Feb 15, 2016
1 parent afc74e0 commit 7e7457c
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 47 deletions.
4 changes: 2 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The Mist Authors

Alexandre Van de Sande <[email protected]>
Alexander Van de Sande <[email protected]>
Bas van Kervel <[email protected]>
Fabian Vogelsteller <fabian@frozeman.de>
Fabian Vogelsteller <fabian[email protected]>
10 changes: 9 additions & 1 deletion interface/client/styles/onboardingScreen.import.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
flex-direction: column;
height: 100%;
position: relative;
// background: lighten(@colorOSBackgroundFocus, 10%);
// background: lighten(@colorOSBackgroundFocus, 10%);

.testnet-indicator {
position: absolute;
top: @gridWidth/2;
right: @gridHeight;
font-weight: 600;
opacity: 0.3;
}

.main-content {
z-index: 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<template name="popupWindows_onboardingScreen">
<div class="onboarding-screen {{mode}} active-{{TemplateVar.get 'currentActive'}} outgoing-{{TemplateVar.get 'lastActive'}} ">

{{#if TemplateVar.get "testnet"}}
<div class="testnet-indicator">TEST-NET</div>
{{/if}}

<div class="main-content">
<div class="onboarding-section onboarding-start">
<p class="description">{{i18n "mist.popupWindows.onboarding.description"}}</p>
Expand Down Expand Up @@ -136,7 +140,6 @@ <h2 style="display: block; text-align: center;">{{i18n "mist.popupWindows.onboar
{{else}}
<form action="about:blank" target="dapp-form-helper-iframe">
<input type="password" placeholder="{{i18n 'mist.popupWindows.requestAccount.enterPassword'}}" class="password">
<input type="password" placeholder="{{i18n 'mist.popupWindows.requestAccount.repeatPassword'}}" class='password-repeat'>
<br><br>
<button type="submit" style="margin-left: 15px;">{{i18n "mist.popupWindows.onboarding.buttons.importAccount"}}</button>
</form>
Expand Down
105 changes: 63 additions & 42 deletions interface/client/templates/popupWindows/onboardingScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ The onboardingScreen template
@constructor
*/

/**
Check if its the testnet
@method isTestnet
*/
var isTestnet = function(template){
// CHECK FOR NETWORK
web3.eth.getBlock(0, function(e, res){
if(!e){
switch(res.hash) {
case '0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303':
TemplateVar.set(template, 'testnet', true);
break;
case '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3':
TemplateVar.set(template, 'testnet', false);
break;
default:
TemplateVar.set(template, 'testnet', false);
}
}
});
}

/**
Update the peercount
Expand Down Expand Up @@ -74,28 +97,35 @@ Template['popupWindows_onboardingScreen'].onCreated(function(){
})

Template['popupWindows_onboardingScreen'].onRendered(function(){
var template = this;
// check which net it is
isTestnet(this);
})

Template['popupWindows_onboardingScreen'].events({
'click .goto-start': function(e){
if(TemplateVar.get('testnet')) {
ipc.send('onBoarding_changeNet', false);
TemplateVar.set('testnet', false);
// TODO: start syncing subscription
// TODO: re-start syncing subscription
}

TemplateVar.set('currentActive','start');
},
'click .goto-import-account': function(){
TemplateVar.set('currentActive','import-account');

// if testnet, make sure to switch to the mainnet
if(TemplateVar.get('testnet')) {
ipc.send('onBoarding_changeNet', false);
TemplateVar.set('testnet', false);
// TODO: re-start syncing subscription
}
},
'click .start-testnet': function(e, template){

ipc.send('onBoarding_changeNet', true);
TemplateVar.set('testnet', true);

// TODO: start syncing subscription
// TODO: re-start syncing subscription

TemplateVar.set('currentActive','testnet');
template.$('.onboarding-testnet input.password').focus();
Expand Down Expand Up @@ -200,54 +230,45 @@ Template['popupWindows_onboardingScreen_importAccount'].events({
@event submit form
*/
'submit form': function(e, template){
var pw = template.find('input.password').value,
pwRepeat = template.find('input.password-repeat').value;
var pw = template.find('input.password').value;

if(!pw || pw !== pwRepeat) {
GlobalNotification.warning({
content: TAPi18n.__('mist.popupWindows.requestAccount.errors.passwordMismatch'),
duration: 3
});

} else {
ipc.send('backendAction_importPresaleFile', TemplateVar.get('filePath'), pw);

ipc.send('backendAction_importPresaleFile', TemplateVar.get('filePath'), pw);
TemplateVar.set('importing', true);
ipc.on('uiAction_importedPresaleFile', function(e, address){
TemplateVar.set(template, 'importing', false);
TemplateVar.set(template, 'filePath', false);

TemplateVar.set('importing', true);
ipc.on('uiAction_importedPresaleFile', function(e, address){
TemplateVar.set(template, 'importing', false);
TemplateVar.set(template, 'filePath', false);
console.log('Imported account: ', address);

if(address) {
ipc.removeAllListeners('uiAction_importedPresaleFile');

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

if(address) {
ipc.removeAllListeners('uiAction_importedPresaleFile');

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

// otherwise simply close the window
} else {
ipc.send('backendAction_closePopupWindow');
}
// otherwise simply close the window
} else {
ipc.send('backendAction_closePopupWindow');
}


} else {
} else {

GlobalNotification.warning({
content: TAPi18n.__('mist.popupWindows.onboarding.errors.importFailed'),
duration: 4
});
}
});
GlobalNotification.warning({
content: TAPi18n.__('mist.popupWindows.onboarding.errors.importFailed'),
duration: 4
});
}
});

// clear form
template.find('input.password').value = '';
template.find('input.password-repeat').value = '';
pw = pwRepeat = null;
}
// clear form
template.find('input.password').value = '';
template.find('input.password-repeat').value = '';
pw = null;
}
});

Expand Down
4 changes: 3 additions & 1 deletion modules/ipcCommunicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ ipc.on('backendAction_importPresaleFile', function(e, path, pw) {

// file password
setTimeout(function(){
if(!error)
if(!error) {
nodeProcess.stdin.write(pw +"\r\n");
pw = null;
}
}, 10);
});

Expand Down

0 comments on commit 7e7457c

Please sign in to comment.