This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Add documentation, Fixes #30 #240
Merged
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8628b1d
Describing function params
reyraa 7b473bf
Merge branch 'development' of https://github.com/LiskHQ/lisk-nano int…
reyraa f2ba1fa
Add YuiDocs
reyraa b282268
Merge branch 'development' of https://github.com/LiskHQ/lisk-nano int…
reyraa 4e7b997
Remove redundant vriable definitions.
reyraa d6633e6
Remove the duplicated license
reyraa cf8071a
Replace the misusage of Array.map with Array.forEach
reyraa 083fa7b
Use moment.set instead of format to maintain consistency in output type
reyraa d0d092e
Return the value of current state instead of internal assignment
reyraa 653c0b9
Remove the unnecessary method used for Api call
reyraa 7cd22ff
Add time factor to sync event parameters
reyraa 9b15b01
Split parameters for cleaner documentation
reyraa 628668f
Add comments based on JSDocs
reyraa d827adf
Eslint fixings and test adaptions
reyraa 81697a2
Fix conflicts
reyraa ad03de2
Fix eslint bugs
reyraa 9888572
Fix many typos
reyraa 4c62cf7
Fix the typo
reyraa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,5 @@ | |
"win": { | ||
"target": "nsis" | ||
} | ||
}, | ||
"license": "GPL-3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,24 @@ import './delegates.less'; | |
|
||
const UPDATE_INTERVAL = 10000; | ||
|
||
/** | ||
* The delegates tab component | ||
* | ||
* @module app | ||
* @submodule delegates | ||
*/ | ||
app.component('delegates', { | ||
template: require('./delegates.pug')(), | ||
bindings: { | ||
account: '=', | ||
passphrase: '<', | ||
}, | ||
/** | ||
* The delegates tab component constructor class | ||
* | ||
* @class delegates | ||
* @constructor | ||
*/ | ||
controller: class delegates { | ||
constructor($scope, $rootScope, Peers, $mdDialog, $mdMedia, | ||
dialog, $timeout, delegateService, Account) { | ||
|
@@ -44,6 +56,11 @@ app.component('delegates', { | |
}); | ||
} | ||
|
||
/** | ||
* Updates the lists of delegates and voted delegates | ||
* | ||
* @method updateAll | ||
*/ | ||
updateAll() { | ||
this.delegates = []; | ||
this.delegatesDisplayedCount = 20; | ||
|
@@ -60,24 +77,45 @@ app.component('delegates', { | |
} | ||
} | ||
|
||
loadDelegates(offset, search, replace) { | ||
/** | ||
* Fetches a list of delegates based on the given search phrase | ||
* | ||
* @method loadDelegates | ||
* @param {Number} offset - The strating index of for the results | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. strating - typo? |
||
* @param {String} search - The search phrase to match with the delegate name | ||
* @param {Boolean} replace - Passed to addDelegates, defines if the results | ||
* should replace the old delegates list | ||
* @param {Number} limit - The maximum number of results | ||
*/ | ||
loadDelegates(offset, search, replace, limit = 100) { | ||
this.loading = true; | ||
this.delegateService.listDelegates({ | ||
offset, | ||
limit: '100', | ||
limit: limit.toString(), | ||
q: search, | ||
}).then((data) => { | ||
this.addDelegates(data, replace); | ||
}); | ||
this.lastSearch = search; | ||
} | ||
|
||
/** | ||
* Fiils the list of delegates, sets their voted and changed status | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: Fiils |
||
* | ||
* @method addDelegates | ||
* @param {Object} data - The result of delegateService.listDelegates Api call | ||
* @param {Boolean} replace - defines if the results should replace | ||
* the old delegates list | ||
*/ | ||
addDelegates(data, replace) { | ||
if (data.success) { | ||
if (replace) { | ||
this.delegates = []; | ||
this.delegates = data.delegates; | ||
} else { | ||
this.delegates = this.delegates.concat(data.delegates); | ||
} | ||
this.delegates = this.delegates.concat(data.delegates.map((delegate) => { | ||
|
||
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; | ||
|
@@ -86,13 +124,18 @@ app.component('delegates', { | |
voted, | ||
changed, | ||
}; | ||
return delegate; | ||
})); | ||
}); | ||
|
||
this.delegatesTotalCount = data.totalCount; | ||
this.loading = false; | ||
} | ||
} | ||
|
||
/** | ||
* Needs summery | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'summery' -> 'summary' |
||
* | ||
* @method showMore | ||
*/ | ||
showMore() { | ||
if (this.delegatesDisplayedCount < this.delegates.length) { | ||
this.delegatesDisplayedCount += 20; | ||
|
@@ -104,6 +147,12 @@ app.component('delegates', { | |
} | ||
} | ||
|
||
/** | ||
* Needs summery | ||
* | ||
* @method selectionChange | ||
* @param {any} delegate | ||
*/ | ||
selectionChange(delegate) { | ||
// eslint-disable-next-line no-param-reassign | ||
delegate.status.changed = delegate.status.voted !== delegate.status.selected; | ||
|
@@ -115,10 +164,21 @@ app.component('delegates', { | |
} | ||
} | ||
|
||
/** | ||
* Needs summery | ||
* | ||
* @method clearSearch | ||
*/ | ||
clearSearch() { | ||
this.$scope.search = ''; | ||
} | ||
|
||
/** | ||
* Adds deelgates to vote delegates list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: deelgates |
||
* | ||
* @method addToUnvoteList | ||
* @param {Object} vote - The delegate to add to voted delegates list | ||
*/ | ||
addToUnvoteList(vote) { | ||
const delegate = this.delegates.filter(d => d.username === vote.username)[0] || vote; | ||
if (delegate.status.selected) { | ||
|
@@ -127,6 +187,11 @@ app.component('delegates', { | |
delegate.status.selected = false; | ||
} | ||
|
||
/** | ||
* Needs summery | ||
* | ||
* @method setPendingVotes | ||
*/ | ||
setPendingVotes() { | ||
this.voteList.forEach((delegate) => { | ||
/* eslint-disable no-param-reassign */ | ||
|
@@ -146,6 +211,13 @@ app.component('delegates', { | |
this.checkPendingVotes(); | ||
} | ||
|
||
/** | ||
* Fetches the lisy of delegates we've voted for (voted delegates), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: lisy |
||
* and updates the list and removes the confirmed votes from votePendingList | ||
* | ||
* @method checkPendingVotes | ||
* @todo Use Sync service and remove recursive timeout | ||
*/ | ||
checkPendingVotes() { | ||
this.$timeout(() => { | ||
this.delegateService.listAccountDelegates(this.account.get().address, | ||
|
@@ -178,14 +250,27 @@ app.component('delegates', { | |
}, UPDATE_INTERVAL); | ||
} | ||
|
||
/** | ||
* Needs summery | ||
* | ||
* @method parseVoteListFromInput | ||
*/ | ||
parseVoteListFromInput() { | ||
this._parseListFromInput('voteList'); | ||
} | ||
|
||
/** | ||
* Needs summery | ||
* | ||
* @method parseUnvoteListFromInput | ||
*/ | ||
parseUnvoteListFromInput() { | ||
this._parseListFromInput('unvoteList'); | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
_parseListFromInput(listName) { | ||
const list = this[listName]; | ||
this.invalidUsernames = []; | ||
|
@@ -203,6 +288,9 @@ app.component('delegates', { | |
} | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
_selectFinish(success, list) { | ||
if (list.length !== 0) { | ||
this.usernameListActive = false; | ||
|
@@ -213,6 +301,9 @@ app.component('delegates', { | |
} | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
_setSelected(username, list) { | ||
const delegate = this.delegates.filter(d => d.username === username)[0]; | ||
if (delegate) { | ||
|
@@ -232,7 +323,6 @@ app.component('delegates', { | |
}); | ||
} | ||
} | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
_selectDelegate(delegate, list) { | ||
// eslint-disable-next-line no-param-reassign | ||
|
@@ -244,6 +334,12 @@ app.component('delegates', { | |
} | ||
} | ||
|
||
/** | ||
* Uses mdDialog to show vote list directive. | ||
* | ||
* @method openVoteDialog | ||
* @todo Use a general dialog service instead. | ||
*/ | ||
openVoteDialog() { | ||
this.$mdDialog.show({ | ||
controllerAs: '$ctrl', | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'client' -> 'account'