Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #397 from LiskHQ/1.0.0-rc.3
Browse files Browse the repository at this point in the history
Bumping version - 1.0.0-rc.3
  • Loading branch information
Isabella Dell authored Jun 13, 2017
2 parents 61460c5 + 507ebc9 commit ffdfd83
Show file tree
Hide file tree
Showing 44 changed files with 415 additions and 421 deletions.
4 changes: 1 addition & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
environment {
ON_JENKINS = 'TRUE'
}
node('lisk-nano-01'){
lock(resource: "lisk-nano-01", inversePrecedence: true) {
stage ('Cleanup Orphaned Processes') {
Expand Down Expand Up @@ -70,6 +67,7 @@ node('lisk-nano-01'){
stage ('Run Tests') {
try {
sh '''
export ON_JENKINS=true
# Run test
cd $WORKSPACE
npm run test
Expand Down
10 changes: 6 additions & 4 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@ app.on('window-all-closed', () => {
});

// This will override the values defined in the app’s .plist file (macOS)
app.setAboutPanelOptions({
applicationName: 'Lisk Nano',
copyright,
});
if (process.platform === 'darwin') {
app.setAboutPanelOptions({
applicationName: 'Lisk Nano',
copyright,
});
}

app.on('activate', () => {
if (win === null) {
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lisk-nano",
"version": "1.0.0-rc.2",
"version": "1.0.0-rc.3",
"description": "Lisk Nano",
"main": "main.js",
"author":{
Expand Down
1 change: 1 addition & 0 deletions features/login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Feature: Login page
Scenario: should allow to create a new account
Given I'm on login page
When I click "new account button"
And I click on "next button"
And I 250 times move mouse randomly
And I remember passphrase, click "yes its save button", fill in missing word
And I click "ok button"
Expand Down
1 change: 1 addition & 0 deletions features/menu.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Feature: Top right menu
Scenario: should allow to set 2nd passphrase
Given I'm logged in as "second passphrase candidate"
When I click "register second passphrase" in main menu
And I click "next button"
And I 250 times move mouse randomly
And I remember passphrase, click "yes its save button", fill in missing word
And I click "ok button"
Expand Down
9 changes: 3 additions & 6 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ preprocessors[testLibs] = ['webpack'];
preprocessors[test] = ['webpack'];

const opts = {
onTravis: process.env.ON_TRAVIS,
onJenkins: process.env.ON_JENKINS,
live: process.env.LIVE,
};
Expand Down Expand Up @@ -44,7 +43,7 @@ module.exports = function (config) {
// Rest results reporter to use
// Possible values: 'dots', 'progress'
// Available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['coverage', 'mocha'].concat(opts.onTravis ? ['coveralls'] : []).concat(opts.onJenkins ? ['coveralls'] : []),
reporters: ['coverage', 'mocha'].concat(opts.onJenkins ? ['coveralls'] : []),

preprocessors,

Expand Down Expand Up @@ -74,17 +73,14 @@ module.exports = function (config) {
autoWatch: opts.live,

ngHtml2JsPreprocessor: {
stripPrefix: 'app/components/',
stripPrefix: 'src/app/components/',
moduleName: 'my.templates',
},

coverageReporter: {
reporters: [{
type: 'text',
dir: 'coverage/',
}, {
type: opts.onTravis ? 'lcov' : 'html',
dir: 'coverage/',
}, {
type: opts.onJenkins ? 'lcov' : 'html',
dir: 'coverage/',
Expand Down Expand Up @@ -112,6 +108,7 @@ module.exports = function (config) {
'karma-chrome-launcher',
'karma-ng-html2js-preprocessor',
'karma-mocha-reporter',
'karma-jenkins-reporter',
'karma-coverage',
'karma-coveralls',
'karma-phantomjs-launcher',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lisk-nano",
"version": "1.0.0-rc.2",
"version": "1.0.0-rc.3",
"description": "Lisk Nano",
"homepage": "https://github.com/LiskHQ/lisk-nano",
"bugs": "https://github.com/LiskHQ/lisk-nano/issues",
Expand Down Expand Up @@ -38,7 +38,7 @@
"debug": "=2.2.0",
"jasmine-spec-reporter": "=3.3.0",
"jquery": "=2.2.4",
"lisk-js": "=0.4.1",
"lisk-js": "=0.4.2",
"lodash": "=4.16.4",
"moment": "=2.15.1",
"ng-infinite-scroll": "=1.3.0",
Expand Down
12 changes: 9 additions & 3 deletions src/components/delegateRegistration/delegateRegistration.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ import './delegateRegistration.less';
*/
app.component('delegateRegistration', {
template: require('./delegateRegistration.pug')(),
controller($scope, $mdDialog, delegateApi, Account, dialog, $rootScope) {
bindings: {
closeDialog: '&',
},
controller($scope, delegateApi, Account, dialog, $rootScope) {
$scope.account = Account;

function checkPendingRegistration() {
delegateApi.getDelegate({
username: $scope.username,
}).then((data) => {
Account.set({
isDelegate: true,
username: data.delegate.username,
delegate: data.delegate,
});
$scope.pendingRegistrationListener();
});
Expand All @@ -42,7 +48,7 @@ app.component('delegateRegistration', {
checkPendingRegistration();
});
$scope.reset(form);
$mdDialog.hide();
this.closeDialog();
});
})
.catch((error) => {
Expand Down Expand Up @@ -74,7 +80,7 @@ app.component('delegateRegistration', {
*/
$scope.cancel = (form) => {
$scope.reset(form);
// $mdDialog.hide();
this.closeDialog();
};
},
});
8 changes: 4 additions & 4 deletions src/components/delegateRegistration/delegateRegistration.pug
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ div.dialog-delegate-registration(aria-label='Vote for delegates')
form(name='delegateRegistrationForm', ng-submit='form.onSubmit(delegateRegistrationForm)')
md-toolbar
.md-toolbar-tools
h2 Delegate Registration
h2 Register as delegate
span(flex='')
md-button.md-icon-button(ng-click='cancel(delegateRegistrationForm)', aria-label='Close dialog')
i.material-icons close
Expand All @@ -14,9 +14,9 @@ div.dialog-delegate-registration(aria-label='Vote for delegates')
input.username(type='text', name='delegateName', ng-model='form.name', required, ng-disabled='loading', md-autofocus)
div(ng-messages='delegateRegistrationForm.name.$error')
div(ng-message='required') Required
md-input-container.md-block(ng-if='!$ctrl.account.get().secondSignature')
div.fee Fee: {{$ctrl.form.fee}} LSK
md-input-container.md-block(ng-if='$ctrl.account.get().secondSignature')
md-input-container.md-block(ng-if='!account.get().secondSignature')
div.fee Fee: {{form.fee}} LSK
md-input-container.md-block(ng-if='account.get().secondSignature')
label Second Passphrase
input(type='password', ng-model='form.secondPassphrase', required)
md-input-container.md-block
Expand Down
154 changes: 32 additions & 122 deletions src/components/delegates/delegates.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ app.component('delegates', {
* @constructor
*/
controller: class delegates {
constructor($scope, $rootScope, Peers, $mdDialog, $mdMedia,
dialog, $timeout, delegateApi, Account) {
constructor($scope, $rootScope, Peers, dialog, $mdMedia,
$timeout, delegateApi, Account) {
this.$scope = $scope;
this.$rootScope = $rootScope;
this.peers = Peers;
this.delegateApi = delegateApi;
this.$mdDialog = $mdDialog;
this.$mdMedia = $mdMedia;
this.dialog = dialog;
this.$mdMedia = $mdMedia;
this.$timeout = $timeout;
this.account = Account;

this.$scope.search = '';
this.voteList = [];
this.votedDict = {};
this.delegateStateByAddress = {};
this.votedList = [];
this.unvoteList = [];
this.loading = true;
Expand Down Expand Up @@ -66,9 +66,8 @@ app.component('delegates', {
this.delegates = [];
this.delegatesDisplayedCount = 20;
if (this.peers.active) {
this.delegateApi.listAccountDelegates({
address: this.account.get().address,
}).then((data) => {
this.delegateApi.listAccountDelegates(this.account.get().address,
).then((data) => {
this.votedList = data.delegates || [];
this.votedList.forEach((delegate) => {
this.votedDict[delegate.username] = delegate;
Expand Down Expand Up @@ -118,16 +117,7 @@ app.component('delegates', {
this.delegates = this.delegates.concat(data.delegates);
}

data.delegates.forEach((delegate) => {
const voted = this.votedDict[delegate.username] !== undefined;
const changed = this.voteList.concat(this.unvoteList)
.map(d => d.username).indexOf(delegate.username) !== -1;
delegate.status = { // eslint-disable-line no-param-reassign
selected: (voted && !changed) || (!voted && changed),
voted,
changed,
};
});
this.delegates = this.delegates.map(delegate => this.setDelegateStatus(delegate));

this.delegatesTotalCount = data.totalCount;
this.loading = false;
Expand Down Expand Up @@ -199,13 +189,15 @@ app.component('delegates', {
setPendingVotes() {
this.voteList.forEach((delegate) => {
/* eslint-disable no-param-reassign */
delegate = this.setDelegateStatus(delegate);
delegate.status.changed = false;
delegate.status.voted = true;
delegate.status.pending = true;
});
this.votePendingList = this.voteList.splice(0, this.voteList.length);

this.unvoteList.forEach((delegate) => {
delegate = this.setDelegateStatus(delegate);
delegate.status.changed = false;
delegate.status.voted = false;
delegate.status.pending = true;
Expand All @@ -215,6 +207,25 @@ app.component('delegates', {
this.checkPendingVotes();
}

/**
* Sets deleagte.status to be always the same object for given delegate.address
*
* @method setDelegateStatus
*/
setDelegateStatus(delegate) {
const voted = this.votedDict[delegate.username] !== undefined;
const changed = this.voteList.concat(this.unvoteList)
.map(d => d.username).indexOf(delegate.username) !== -1;
this.delegateStateByAddress[delegate.address] =
this.delegateStateByAddress[delegate.address] || {
selected: (voted && !changed) || (!voted && changed),
voted,
changed,
};
delegate.status = this.delegateStateByAddress[delegate.address];
return delegate;
}

/**
* Fetches the list of delegates we've voted for (voted delegates),
* and updates the list and removes the confirmed votes from votePendingList
Expand Down Expand Up @@ -255,115 +266,14 @@ app.component('delegates', {
}

/**
* Needs summary
*
* @method parseVoteListFromInput
*/
parseVoteListFromInput() {
this._parseListFromInput('voteList');
}

/**
* Needs summary
*
* @method parseUnvoteListFromInput
*/
parseUnvoteListFromInput() {
this._parseListFromInput('unvoteList');
}

/**
* @private
*/
_parseListFromInput(listName) {
const list = this[listName];
this.invalidUsernames = [];
this.pendingRequests = 0;
this.usernameList = this.usernameInput.trim().split(this.usernameSeparator);
this.usernameList.forEach((username) => {
if ((listName === 'voteList' && !this.votedDict[username.trim()]) ||
(listName === 'unvoteList' && this.votedDict[username.trim()])) {
this._setSelected(username.trim(), list);
}
});

if (this.pendingRequests === 0) {
this._selectFinish(true, list);
}
}

/**
* @private
*/
_selectFinish(success, list) {
if (list.length !== 0) {
this.usernameListActive = false;
this.usernameInput = '';
this.openVoteDialog();
} else {
this.dialog.errorToast('No delegate usernames could be parsed from the input');
}
}

/**
* @private
*/
_setSelected(username, list) {
const delegate = this.delegates.filter(d => d.username === username)[0];
if (delegate) {
this._selectDelegate(delegate, list);
} else {
this.pendingRequests++;
this.delegateApi.getDelegate(username,
).then((data) => {
this._selectDelegate(data.delegate, list);
}).catch(() => {
this.invalidUsernames.push(username);
}).finally(() => {
this.pendingRequests--;
if (this.pendingRequests === 0) {
this._selectFinish(this.invalidUsernames.length === 0, list);
}
});
}
}
// eslint-disable-next-line class-methods-use-this
_selectDelegate(delegate, list) {
// eslint-disable-next-line no-param-reassign
delegate.status = delegate.status || {};
// eslint-disable-next-line no-param-reassign
delegate.status.selected = true;
if (list.indexOf(delegate) === -1) {
list.push(delegate);
}
}

/**
* Uses mdDialog to show vote list directive.
* Uses dialog.modal to show vote list directive.
*
* @method openVoteDialog
* @todo Use a general dialog service instead.
*/
openVoteDialog() {
this.$mdDialog.show({
controllerAs: '$ctrl',
controller: class voteDialog {
constructor($scope, voteList, unvoteList) {
this.$scope = $scope;
this.$scope.voteList = voteList;
this.$scope.unvoteList = unvoteList;
}
},
template:
'<md-dialog flex="80">' +
'<vote vote-list="voteList" unvote-list="unvoteList">' +
'</vote>' +
'</md-dialog>',
fullscreen: (this.$mdMedia('sm') || this.$mdMedia('xs')) && this.$scope.customFullscreen,
locals: {
voteList: this.voteList,
unvoteList: this.unvoteList,
},
this.dialog.modal('vote', {
'vote-list': this.voteList,
'unvote-list': this.unvoteList,
}).then((() => {
this.setPendingVotes();
}));
Expand Down
Loading

0 comments on commit ffdfd83

Please sign in to comment.