Skip to content

Commit

Permalink
upgrade account and harvest page
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-chang committed Mar 20, 2018
1 parent 0bc1776 commit 9e3d5f7
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 97 deletions.
6 changes: 4 additions & 2 deletions app/controllers/account.server.controller.js
Expand Up @@ -61,7 +61,7 @@ module.exports = {
page = parseInt(req.body.page);
}
let Account = mongoose.model('Account');
Account.find().sort({blocks: -1}).skip(LISTSIZE*(page-1)).limit(LISTSIZE).exec((err, doc) => {
Account.find({blocks: {$gt: 0}}).sort({blocks: -1}).skip(LISTSIZE*(page-1)).limit(LISTSIZE).exec((err, doc) => {
if(err) {
console.info(err);
return res.json([]);
Expand Down Expand Up @@ -118,8 +118,10 @@ module.exports = {
r_account.remoteStatus = meta.remoteStatus;
r_account.harvestedBlocks = account.harvestedBlocks;
r_account.vestedBalance = account.vestedBalance;
if(account.multisigInfo && account.multisigInfo.minCosignatories)
if(account.multisigInfo)
r_account.minCosignatories = account.multisigInfo.minCosignatories;
if(r_account.minCosignatories==0)
r_account.minCosignatories = meta.cosignatories.length;
if(meta.cosignatories && meta.cosignatories.length>0){
r_account.multisig = 1;
r_account.cosignatories = "";
Expand Down
27 changes: 5 additions & 22 deletions app/controllers/namespace.server.controller.js
@@ -1,5 +1,6 @@
import namespaceDB from '../db/namespaceDB';
import nis from '../utils/nisRequest';
import mosaicController from '../controllers/mosaic.server.controller';

const LISTSIZE = 100;
const namespaceListLimit = 50;
Expand Down Expand Up @@ -127,33 +128,15 @@ module.exports = {
if(data_mosaic.data[i].mosaicId.namespaceId=="nem")
continue;
r_mosaic = {};
r_mosaic.mosaic = data_mosaic.data[i].mosaicId.namespaceId + ":" + data_mosaic.data[i].mosaicId.name;
r_mosaic.mosaic = data_mosaic.data[i].mosaicId.name;
r_mosaic.quantity = data_mosaic.data[i].quantity;
r_mosaic.namespace = data_mosaic.data[i].mosaicId.namespaceId;
r_mosaic.id = data_mosaic.data[i].mosaicId.name;
r_mosaicList.push(r_mosaic);
}
let quantityFixCount = 0;
for(let i in r_mosaicList){
nis.allMosaicDefinitionListByNamespace(r_mosaicList[i].namespace, null, [], data_definition => {
for(let j in data_definition){
if(data_definition[j].mosaic.id.name==r_mosaicList[i].id){
let divisibility = 0;
for(let k in data_definition[j].mosaic.properties){
if(data_definition[j].mosaic.properties[k].name=="divisibility"){
divisibility = data_definition[j].mosaic.properties[k].value;
break;
}
}
if(r_mosaicList[i].quantity!=0)
r_mosaicList[i].quantity = r_mosaicList[i].quantity/Math.pow(10, parseInt(divisibility));
}
}
quantityFixCount++;
if(quantityFixCount==r_mosaicList.length)
res.json(r_mosaicList);
});
}
mosaicController.setMosaicTXDivisibility(r_mosaicList, mosaicTXs => {
res.json(mosaicTXs);
});
});
} catch (e) {
console.error(e);
Expand Down
49 changes: 26 additions & 23 deletions public/accountlist.html
@@ -1,25 +1,28 @@
<div id="content" class="container" style="padding-bottom:70px;">
<table class="table table-striped table-hover fontSize12">
<thead>
<tr>
<th>#</th>
<th>Address</th>
<th>Balance</th>
<th>Importance</th>
<th>Last Timestamp</th>
<th>Info</th>
</tr>
</thead>
<tbody class="well well-large">
<tr ng-repeat="account in accountList">
<td width="40" ng-bind=$index+1></td>
<td width="340"><a href="#s_account?account={{account.address}}" target="_blank"><span ng-bind="account.address"></span></a></td>
<td width="110" ng-bind="account.balance"></td>
<td width="80" ng-bind="account.importance"></td>
<td width="130" ng-bind="account.timeStamp"></td>
<td ng-bind="account.remark"></td>
</tr>
</tbody>
</table>
<button type="button" class="btn btn-default btn-sm btn-block" ng-class="{hidden:hideMore, disabled:loadingMore}" ng-click="loadMore()">Load more</button>
<div infinite-scroll="loadMore()" infinite-scroll-immediate-check="false" infinite-scroll-disabled="loadingFlag">
<table class="table table-striped table-hover fontSize12">
<thead>
<tr>
<th>#</th>
<th>Address</th>
<th>Balance</th>
<th>Importance</th>
<th>Last Timestamp</th>
<th>Info</th>
</tr>
</thead>
<tbody class="well well-large">
<tr ng-repeat="account in accountList">
<td width="40" ng-bind=$index+1></td>
<td width="340"><a href="#s_account?account={{account.address}}" target="_blank"><span ng-bind="account.address"></span></a></td>
<td width="110" ng-bind="account.balance"></td>
<td width="80" ng-bind="account.importance"></td>
<td width="130" ng-bind="account.timeStamp"></td>
<td ng-bind="account.remark"></td>
</tr>
</tbody>
</table>
</div>
<div class="text-center" ng-if="loadingFlag"><img src="views/images/loading.gif"/></div>
<div class="text-center" ng-if="endFlag">This is the end</div>
</div>
39 changes: 23 additions & 16 deletions public/controllers/account.client.controller.js
Expand Up @@ -6,8 +6,10 @@ const mosaicTXListLimit = 50;

function AccountController($scope, AccountService){
$scope.page = 1;
$scope.hideMore = false;
$scope.loadingFlag = false;
$scope.endFlag = false;
$scope.getAccountList = function(){
$scope.loadingFlag = true;
AccountService.accountList({"page": $scope.page}, function(r_accountList){
for(let i in r_accountList){
let account = r_accountList[i];
Expand All @@ -17,20 +19,19 @@ function AccountController($scope, AccountService){
if(account.remark && account.remark.length>60)
account.remark = account.remark.substring(0, 59) + "..";
}
if($scope.accountList){
if($scope.accountList)
$scope.accountList = $scope.accountList.concat(r_accountList);
} else {
else
$scope.accountList = r_accountList;
}
if(r_accountList.length==0 || r_accountList.length<100){
$scope.hideMore = true;
}
$scope.loadingMore = false;
if(r_accountList.length==0 || r_accountList.length<100)
$scope.endFlag = true;
$scope.loadingFlag = false;
});
}
$scope.loadMore = function(){
if($scope.loadingFlag==true)
return;
$scope.page++;
$scope.loadingMore = true;
$scope.getAccountList();
};
$scope.getAccountList();
Expand All @@ -55,7 +56,6 @@ function SearchAccountController($scope, $timeout, $location, AccountService, Na
$scope.searchAccount = account;
let params = {address: account};
AccountService.detail(params, function(data) {
console.info(data);
if(!data || !data.address){
$scope.accountItems = [{label: "Not Found", content: ""}];
return;
Expand All @@ -76,8 +76,13 @@ function SearchAccountController($scope, $timeout, $location, AccountService, Na
}
if(data.cosignatories!=null && data.cosignatories!=""){
list.push({label: "Multisig account", content: "Yes"});
list.push({label: "Min signatures", content: ""+data.minCosignatories});
list.push({label: "Cosignatories", content: data.cosignatories});
if(data.minCosignatories==0){
list.push({label: "Min signatures", content: ""+data.minCosignatories});
list.push({label: "Cosignatories", content: data.cosignatories});
} else {
list.push({label: "Min signatures", content: ""+data.minCosignatories});
list.push({label: "Cosignatories", content: data.cosignatories});
}
}
$scope.accountItems = list;
//load harvest info
Expand Down Expand Up @@ -232,9 +237,8 @@ function SearchAccountController($scope, $timeout, $location, AccountService, Na
$scope.showNamespace = function(){
let params = {address: $scope.searchAccount};
NamespaceService.namespaceListByAddress(params, function(data) {
if(!data || data.length==0){
if(!data || data.length==0)
return;
}
$scope.showNamespaceFlag = true;
$scope.namespaceList = data;
});
Expand All @@ -243,11 +247,14 @@ function SearchAccountController($scope, $timeout, $location, AccountService, Na
$scope.showMosaic = function(){
let params = {address: $scope.searchAccount};
NamespaceService.mosaicListByAddress(params, function(data) {
if(!data || data.length==0){
if(!data || data.length==0)
return;
}
$scope.showMosaicFlag = true;
$scope.mosaicList = data;
$scope.mosaicList.forEach(m => {
m.quantity = fmtMosaic(m.quantity, m.div);
m.mosaic = m.namespace + ":" + m.mosaic;
});
});
};
$scope.loadTransactions();
Expand Down
21 changes: 12 additions & 9 deletions public/controllers/harvest.client.controller.js
Expand Up @@ -3,28 +3,31 @@ angular.module("webapp").controller("HarvestingCalculatorController", ["$scope",

function HarvesterController($scope, AccountService){
$scope.page = 1;
$scope.hideMore = false;
$scope.loadingFlag = false;
$scope.endFlag = false;
$scope.getHarvesterList = function(){
$scope.loadingFlag = true;
AccountService.harvesterList({"page": $scope.page}, function(r_harvesterList){
for(let i in r_harvesterList){
let account = r_harvesterList[i];
account.fees = fmtXEM(account.fees);
account.importance = fmtPOI(account.importance);
if(account.remark && account.remark.length>60)
account.remark = account.remark.substring(0, 59) + "..";
}
if($scope.harvesterList){
if($scope.harvesterList)
$scope.harvesterList = $scope.harvesterList.concat(r_harvesterList);
} else {
else
$scope.harvesterList = r_harvesterList;
}
if(r_harvesterList.length==0 || r_harvesterList.length<100){
$scope.hideMore = true;
}
$scope.loadingMore = false;
if(r_harvesterList.length==0 || r_harvesterList.length<100)
$scope.endFlag = true;
$scope.loadingFlag = false;
});
}
$scope.loadMore = function(){
if($scope.loadingFlag==true)
return;
$scope.page++;
$scope.loadingMore = true;
$scope.getHarvesterList();
};
$scope.getHarvesterList();
Expand Down
53 changes: 28 additions & 25 deletions public/harvesterlist.html
@@ -1,27 +1,30 @@
<div id="content" class="container" style="padding-bottom:70px;">
<table class="table table-striped table-hover fontSize12">
<thead>
<tr>
<th>#</th>
<th>Address</th>
<th>Harvested Blocks</th>
<th>Harvested Fees</th>
<th>Last Block</th>
<th>Importance</th>
<th>Info</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="harvester in harvesterList">
<td width="40" ng-bind="$index+1"></td>
<td width="340"><a href="#s_account?account={{harvester.address}}" target="_blank"><span ng-bind="harvester.address"></span></a></td>
<td width="120" ng-bind="harvester.blocks"></td>
<td width="110" ng-bind="harvester.fees"></td>
<td width="80" ng-bind="harvester.lastBlock"></td>
<td width="80" ng-bind="harvester.importance"></td>
<td ng-bind="harvester.remark"></td>
</tr>
</tbody>
</table>
<button type="button" class="btn btn-default btn-sm btn-block" ng-class="{hidden:hideMore, disabled:loadingMore}" ng-click="loadMore()">Load more</button>
<div infinite-scroll="loadMore()" infinite-scroll-immediate-check="false" infinite-scroll-disabled="loadingFlag">
<table class="table table-striped table-hover fontSize12">
<thead>
<tr>
<th>#</th>
<th>Address</th>
<th>Harvested Blocks</th>
<th>Harvested Fees</th>
<th>Last Block</th>
<th>Importance</th>
<th>Info</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="harvester in harvesterList">
<td width="40" ng-bind="$index+1"></td>
<td width="340"><a href="#s_account?account={{harvester.address}}" target="_blank"><span ng-bind="harvester.address"></span></a></td>
<td width="120" ng-bind="harvester.blocks"></td>
<td width="110" ng-bind="harvester.fees"></td>
<td width="80" ng-bind="harvester.lastBlock"></td>
<td width="80" ng-bind="harvester.importance"></td>
<td ng-bind="harvester.remark"></td>
</tr>
</tbody>
</table>
</div>
<div class="text-center" ng-if="loadingFlag"><img src="views/images/loading.gif"/></div>
<div class="text-center" ng-if="endFlag">This is the end</div>
</div>

0 comments on commit 9e3d5f7

Please sign in to comment.