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

Unify naming conventions - Closes #179 #199

Merged
merged 17 commits into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/components/delegates/delegates.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ app.component('delegates', {
passphrase: '<',
},
controller: class delegates {
constructor($scope, $rootScope, $peers, $mdDialog, $mdMedia,
constructor($scope, $rootScope, Peers, $mdDialog, $mdMedia,
dialog, $timeout, delegateService, Account) {
this.$scope = $scope;
this.$rootScope = $rootScope;
this.$peers = $peers;
this.peers = Peers;
this.delegateService = delegateService;
this.$mdDialog = $mdDialog;
this.$mdMedia = $mdMedia;
Expand Down Expand Up @@ -47,7 +47,7 @@ app.component('delegates', {
updateAll() {
this.delegates = [];
this.delegatesDisplayedCount = 20;
if (this.$peers.active) {
if (this.peers.active) {
this.delegateService.listAccountDelegates({
address: this.account.get().address,
}).then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/header/header.pug
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
md-content.header(layout='row', layout-align='center center', layout-padding)
img.logo(src=require('../../assets/images/LISK-nano.png'))
div(flex)
md-button.md-raised.md-primary.send(data-show-send-modal, ng-if='$root.logged') Send
md-button.md-raised.md-primary.transfer(data-show-transfer-modal, ng-if='$root.logged') Transfer
md-button.md-raised.md-secondary.logout(ng-click='$root.logout()', ng-if='$root.logged') Logout
md-menu.top-menu(ng-if='$root.logged', md-position-mode='target-right target', md-offset='14 0')
md-button.md-icon-button(ng-click='$mdOpenMenu()')
Expand All @@ -22,4 +22,4 @@ md-content.header(layout='row', layout-align='center center', layout-padding)
md-menu-item(ng-if='$root.logged && !$ctrl.account.get().isDelegate')
md-button(data-delegate-registration)
div(layout='row', flex='')
p(flex='') Delegate registration
p(flex='') Delegate registration
5 changes: 4 additions & 1 deletion src/app/components/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ app.component('login', {
/* eslint no-param-reassign: ["error", { "props": false }] */

constructor($scope, $rootScope, $timeout, $document, $mdMedia,
$cookies, $location, Passphrase, $state, Account) {
$cookies, $location, Passphrase, $state, Account, Peers) {
this.$scope = $scope;
this.$rootScope = $rootScope;
this.$timeout = $timeout;
Expand All @@ -18,6 +18,7 @@ app.component('login', {
this.$location = $location;
this.$state = $state;
this.account = Account;
this.peers = Peers;

this.Passphrase = Passphrase;
this.generatingNewPassphrase = false;
Expand Down Expand Up @@ -50,6 +51,8 @@ app.component('login', {

passConfirmSubmit(_passphrase = this.input_passphrase) {
if (this.Passphrase.normalize.constructor === Function) {
this.peers.setActive(this.network);

this.account.set({
passphrase: this.Passphrase.normalize(_passphrase),
network: this.network,
Expand Down
15 changes: 7 additions & 8 deletions src/app/components/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ app.component('main', {
template: require('./main.pug')(),
controllerAs: '$ctrl',
controller: class main {
constructor($scope, $rootScope, $timeout, $q, $state, $peers,
dialog, SendModal, Account) {
constructor($scope, $rootScope, $timeout, $q, $state, Peers,
dialog, TransferModal, Account, AccountApi) {
this.$scope = $scope;
this.$rootScope = $rootScope;
this.$timeout = $timeout;
this.$q = $q;
this.$peers = $peers;
this.peers = Peers;
this.dialog = dialog;
this.sendModal = SendModal;
this.transferModal = TransferModal;
this.$state = $state;
this.account = Account;
this.accountApi = AccountApi;

this.init();
}
Expand All @@ -31,8 +32,6 @@ app.component('main', {

this.$rootScope.prelogged = true;

this.$peers.setActive(this.account.get());

this.update()
.then(() => {
this.$rootScope.prelogged = false;
Expand All @@ -53,7 +52,7 @@ app.component('main', {

checkIfIsDelegate() {
if (this.account.get() && this.account.get().publicKey) {
this.$peers.active.sendRequest('delegates/get', {
this.peers.active.sendRequest('delegates/get', {
publicKey: this.account.get().publicKey,
}, (data) => {
if (data.success && data.delegate) {
Expand All @@ -68,7 +67,7 @@ app.component('main', {

update() {
this.$rootScope.reset();
return this.account.getAccountPromise(this.account.get().address)
return this.accountApi.get(this.account.get().address)
.then((res) => {
this.account.set(res);
})
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/main/setSecondPassDirective.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import './secondPass.less';

app.directive('setSecondPass', (setSecondPass, Account, $rootScope, dialog) => {
app.directive('setSecondPass', (setSecondPass, Account, $rootScope, dialog, AccountApi) => {
/* eslint no-param-reassign: ["error", { "props": false }] */
const SetSecondPassLink = function (scope, element) {
element.bind('click', () => {
setSecondPass.show();
});

scope.passConfirmSubmit = (secondsecret) => {
Account.setSecondSecret(secondsecret, Account.get().publicKey, Account.get().passphrase)
AccountApi.setSecondSecret(secondsecret, Account.get().publicKey, Account.get().passphrase)
.then(() => {
dialog.successAlert({ text: 'Your second passphrase was successfully registered.' });
})
Expand Down
16 changes: 0 additions & 16 deletions src/app/components/send/sendModalDirective.js

This file was deleted.

1 change: 1 addition & 0 deletions src/app/components/sign-verify/verify-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import lisk from 'lisk-js';

app.component('verifyMessage', {
template: require('./verify-message.pug')(),
controllerAs: '$ctrl',
controller: class verifyMessage {
constructor($mdDialog, Account) {
this.$mdDialog = $mdDialog;
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/top/top.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import './top.less';
app.component('top', {
template: require('./top.pug')(),
controller: class top {
constructor($peers, Account) {
this.$peers = $peers;
constructor(Peers, Account) {
this.peers = Peers;
this.account = Account;
}
},
Expand Down
10 changes: 5 additions & 5 deletions src/app/components/top/top.pug
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ md-content(layout='column', layout-gt-xs='row')
md-card.peer(flex-gt-xs=33)
md-card-content(layout='column', layout-align='center center')
span.status
i.material-icons.offline(ng-show='!$ctrl.$peers.online') error
i.material-icons.online(ng-show='$ctrl.$peers.online') check circle
i.material-icons.offline(ng-show='!$ctrl.peers.online') error
i.material-icons.online(ng-show='$ctrl.peers.online') check circle
span.md-title.title Peer
div.active-peer.value
span(ng-bind="$ctrl.$peers.active.currentPeer")
span(ng-if="$ctrl.$peers.active.port && $ctrl.$peers.active.port != '8000' ")
span(ng-bind="$ctrl.peers.active.currentPeer")
span(ng-if="$ctrl.peers.active.port && $ctrl.peers.active.port != '8000' ")
span :
span(ng-bind="$ctrl.$peers.active.port")
span(ng-bind="$ctrl.peers.active.port")
md-card.offline-hide(flex-gt-xs=33)
md-card-content(layout='column', layout-align='center center')
span.md-title.title Balance
Expand Down
7 changes: 4 additions & 3 deletions src/app/components/transactions/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ const UPDATE_INTERVAL = 20000;
app.component('transactions', {
template: require('./transactions.pug')(),
controller: class transactions {
constructor($scope, $rootScope, $timeout, $q, $peers, Account) {
constructor($scope, $rootScope, $timeout, $q, Peers, Account, AccountApi) {
this.$scope = $scope;
this.$rootScope = $rootScope;
this.$timeout = $timeout;
this.$q = $q;
this.$peers = $peers;
this.peers = Peers;
this.account = Account;
this.accountApi = AccountApi;

this.loaded = false;
this.transactions = [];
Expand Down Expand Up @@ -64,7 +65,7 @@ app.component('transactions', {
}

loadTransactions(limit) {
return this.account.listTransactions(this.account.get().address, limit)
return this.accountApi.transactions.get(this.account.get().address, limit)
.then(this._processTransactionsResponse.bind(this))
.catch(() => {
this.transactions = [];
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/transactions/transactions.pug
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ md-card.offline-hide
th(md-column) Time
th(md-column) Transaction ID
th(md-column) From / To
th(md-column) Send to this
th(md-column) Transfer to this
th(md-column) Amount
th(md-column) Fee
tbody(md-body, infinite-scroll='$ctrl.showMore()')
Expand All @@ -35,8 +35,8 @@ md-card.offline-hide
span(ng-bind='transaction.senderId', ng-if='transaction.senderId !== $ctrl.account.get().address')
span(ng-bind='transaction.recipientId', ng-if='transaction.senderId === $ctrl.account.get().address')
td(md-cell)
i.material-icons.expanding-button(ng-if='transaction.senderId !== $ctrl.account.get().address', data-show-send-modal, data-recipient-id='transaction.senderId') arrow_forward
i.material-icons.expanding-button(ng-if='transaction.senderId === $ctrl.account.get().address', data-show-send-modal, data-recipient-id='transaction.recipientId') arrow_forward
i.material-icons.expanding-button(ng-if='transaction.senderId !== $ctrl.account.get().address', data-show-transfer-modal, data-recipient-id='transaction.senderId') arrow_forward
i.material-icons.expanding-button(ng-if='transaction.senderId === $ctrl.account.get().address', data-show-transfer-modal, data-recipient-id='transaction.recipientId') arrow_forward
td(md-cell)
i.material-icons.in(ng-if='transaction.senderId !== $ctrl.account.get().address') call_received
i.material-icons.out(ng-if='transaction.senderId === $ctrl.account.get().address') call_made
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import './send.less';
import './transfer.less';

const ADDRESS_VALID_RE = '^[0-9]{1,21}[L|l]$';
const AMOUNT_VALID_RE = '^[0-9]+(.[0-9]{1,8})?$';

app.component('send', {
template: require('./send.pug')(),
app.component('transfer', {
template: require('./transfer.pug')(),
bindings: {
recipientId: '<',
transferAmount: '<',
},
controller: class send {
constructor($scope, $peers, lsk, dialog, $mdDialog, $q, $rootScope, Account) {
controller: class transfer {
constructor($scope, lsk, dialog, $mdDialog, $q, $rootScope, Account, AccountApi) {
this.$scope = $scope;
this.$peers = $peers;
this.dialog = dialog;
this.$mdDialog = $mdDialog;
this.$q = $q;
this.$rootScope = $rootScope;
this.account = Account;
this.accountApi = AccountApi;

this.recipient = {
regexp: ADDRESS_VALID_RE,
Expand All @@ -43,7 +43,7 @@ app.component('send', {

this.$scope.$watch('$ctrl.amount.value', () => {
if (this.amount.value) {
this.sendForm.amount.$setValidity('max', parseFloat(this.amount.value) <= parseFloat(this.amount.max));
this.transferForm.amount.$setValidity('max', parseFloat(this.amount.value) <= parseFloat(this.amount.max));
}
});
}
Expand All @@ -53,9 +53,10 @@ app.component('send', {
this.amount.value = '';
}

sendLSK() {
transfer() {
this.loading = true;
this.account.sendLSK(

this.accountApi.transactions.create(
this.recipient.value,
this.amount.raw,
this.account.get().passphrase,
Expand All @@ -70,12 +71,12 @@ app.component('send', {
fee: 10000000,
};
this.$rootScope.$broadcast('transaction-sent', transaction);
return this.dialog.successAlert({ text: `${this.amount.value} sent to ${this.recipient.value}` })
return this.dialog.successAlert({ text: `${this.amount.value} LSK was successfully transferred to ${this.recipient.value}` })
.then(() => {
this.reset();
});
}).catch((res) => {
this.dialog.errorAlert({ text: res && res.message ? res.message : 'An error occurred while sending the transaction.' });
this.dialog.errorAlert({ text: res && res.message ? res.message : 'An error occurred while creating the transaction.' });
}).finally(() => {
this.loading = false;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
send {
transfer {
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
div.dialog-send(aria-label='Send funds')
form(name='$ctrl.sendForm')
div.dialog-transfer(aria-label='Transfer funds')
form(name='$ctrl.transferForm')
md-toolbar
.md-toolbar-tools
h2 Send
h2 Transfer
md-dialog-content
.md-dialog-content
div
md-input-container.md-block
label Recipient Address
input(type='text', name='recipient', ng-model='$ctrl.recipient.value', required, ng-pattern='$ctrl.recipient.regexp', ng-disabled='$ctrl.loading')
div(ng-messages='$ctrl.sendForm.recipient.$error')
div(ng-messages='$ctrl.transferForm.recipient.$error')
div(ng-message='required') Required
div(ng-message='pattern') Invalid
div(layout="row")
md-input-container.md-block.flex-95
label Transaction Amount
input(type='text', name='amount', ng-model='$ctrl.amount.value', required, ng-pattern='$ctrl.amount.regexp', ng-disabled='$ctrl.loading')
div.fee(ng-show='$ctrl.amount.value') Fee: 0.1 LSK
div(ng-messages='$ctrl.sendForm.amount.$error')
div(ng-messages='$ctrl.transferForm.amount.$error')
div(ng-message='required') Required
div(ng-message='pattern') Invalid
div(ng-message='max') Insufficient funds
Expand All @@ -35,4 +35,4 @@ div.dialog-send(aria-label='Send funds')
md-dialog-actions(layout='row')
md-button.md-raised.md-secondary(ng-disabled='$ctrl.loading', ng-click='$ctrl.cancel()') {{ 'Cancel' }}
span(flex)
md-button.md-raised.md-primary(ng-disabled='!$ctrl.sendForm.$valid || $ctrl.loading', ng-click='$ctrl.sendLSK()') {{ $ctrl.loading ? 'Sending...' : 'Send' }}
md-button.md-raised.md-primary(ng-disabled='!$ctrl.transferForm.$valid || $ctrl.loading', ng-click='$ctrl.transfer()') {{ $ctrl.loading ? 'Transfering...' : 'Transfer' }}
16 changes: 16 additions & 0 deletions src/app/components/transfer/transferModalDirective.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
app.directive('showTransferModal', (TransferModal) => {
const ShowTransferModalLink = function (scope, element) {
element.bind('click', () => {
TransferModal.show(scope.recipientId, scope.amount);
});
};

return {
restrict: 'A',
scope: {
recipientId: '<',
amount: '<',
},
link: ShowTransferModalLink,
};
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
app.factory('SendModal', ($mdDialog) => {
app.factory('TransferModal', ($mdDialog) => {
const init = () => {
};

const hide = () => {
};

const show = (recipientId, amount) => ($mdDialog.show({
template: '<md-dialog flex="80" ><send recipient-id="ms.recipientId" transfer-amount="ms.amount"></send></md-dialog>',
parent: angular.element('#main'),
template: '<md-dialog flex="80" ><transfer recipient-id="ms.recipientId" transfer-amount="ms.amount"></transfer></md-dialog>',
locals: {
recipientId, amount,
},
Expand Down
Loading