Skip to content

Commit

Permalink
Add feature dashboard filtering
Browse files Browse the repository at this point in the history
* #23 Add filter by asset and operation type for dashboard operations

* #23 Add operation text for Credit Offer Deal Expired

* #23 Fix credit offers fetch bug

* #23 Add operations-table directive/service

* #23 Replace operations on dashboard by operations-table

* #23 Move filter style to css

* #23 Replace operations view list by operations-table

* #23 Replace credit offers operations by operations-table

* #23 Replace account operations by operations-table

* #23 Replace pool operations by operations-table

* #23 Add pagination for operations

* #23 Add the load more button to fetch all possible data

* #23 Fix dates format

* #23 Fix load more data for filtered duplicates

* #23 Move filter parameters to groupBy

* #23 Remove all no longer used routes that were replaced by new universal history route

* fix: group_by -> filter_by

* #23 Add filters for responsive-table and use operations-table like an example

* #23 Remove table filters for operations-table

Co-authored-by: Stefan <[email protected]>
  • Loading branch information
ihorml and sschiessl-bcp authored Dec 8, 2022
1 parent bd1dc0c commit a12f936
Show file tree
Hide file tree
Showing 27 changed files with 633 additions and 544 deletions.
5 changes: 3 additions & 2 deletions app/branding.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function getAvailableEndpoints() {
translate: 'Mainnet',
url: 'https://api.bitshares.ws/openexplorer',
chainId: '4018d7844c78f6a6c41c6a552b898022310fc5dec06da467ee7905a8dad512c8',
isDefault: true,
isDefault: false,
},
{
key: "testnet",
Expand All @@ -21,7 +21,8 @@ export function getAvailableEndpoints() {
key: "local",
translate: 'Local',
url: 'http://localhost:5000/openexplorer',
chainId: '4018d7844c78f6a6c41c6a552b898022310fc5dec06da467ee7905a8dad512c8'
chainId: '4018d7844c78f6a6c41c6a552b898022310fc5dec06da467ee7905a8dad512c8',
isDefault: true,
}
];
}
Expand Down
21 changes: 21 additions & 0 deletions app/core/app.utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
object: (objectId) => ({
text: objectId,
href: `/#/objects/${objectId}`
}),
offer: (offerId) => ({
text: offerId,
href: `/#/credit-offers/${offerId}`
})
})

Expand Down Expand Up @@ -1559,6 +1563,23 @@
})
}

else if (operation_type === 74) { // Expired Credit Deal
console.log('debug expired', operation)
const operation_account = operation.borrower;
const unpaid = operation.unpaid_amount;
getAccount(operation_account).then((account_name) => {
getAsset(unpaid.asset_id, unpaid.amount).then((unpaidAsset) => {
operation_text = $filter('translateWithLinks')('Operation Credit Deal Expired', {
accountLink : getLink().account(account_name),
amount : unpaidAsset.amount,
offerLink : getLink().offer(operation.offer_id),
assetLink : getLink().asset(unpaidAsset.symbol),
});
callback(operation_text)
});
})
}

else {

operation_text = $filter('translate')('Operation Beautifier Missing Description', {
Expand Down
41 changes: 0 additions & 41 deletions app/core/service.account.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,47 +287,6 @@
callback(results);
}
},
getAccountHistory: function(account_id, limit, from, callback) {
return $http.get(appConfig.urls.elasticsearch_wrapper() + "/account_history"
+ "?account_id=" + account_id
+ "&offset=" + from
+ "&limit=" + limit
+ (from == 0 ? "&from_date=now-1y" : "&from_date=2015-10-10")
).then(response => {
let last_ops = [];

// only add if the op id is not already added (transfer appears in both accounts!)
const unique_data = response.data.filter((v,i,a)=>a.findIndex(t=>(t.operation_id_num === v.operation_id_num))===i);

angular.forEach(unique_data, function (value) {
let operation = {};
operation.block_num = value.block_data.block_num;
operation.operation_id = value.account_history.operation_id;
operation.operation_id_num = value.operation_id_num;
operation.time = value.block_data.block_time;
operation.witness = value.witness;
operation.sequence = value.account_history.sequence;

let parsed_op = value.operation_history.op_object;
if (parsed_op == undefined)
parsed_op = JSON.parse(value.operation_history.op)[1];
if (parsed_op.amount)
parsed_op.amount_ = parsed_op.amount;
const _with_result = {...parsed_op, result: value.operation_history.operation_result};
if (typeof _with_result.result === "string") _with_result.result = JSON.parse(value.operation_history.operation_result);
utilities.opText(appConfig, $http, value.operation_type, _with_result, function(returnData) {
operation.operation_text = returnData;
});

const type_res = utilities.operationType(value.operation_type);
operation.type = type_res[0];
operation.color = type_res[1];

last_ops.push(operation);
});
callback(last_ops);
});
},
exportAccountHistory: function(account_id, premium_code = null, document=null) {
let url = appConfig.urls.elasticsearch_wrapper() + "/export/account_history"
+ "?account_id=" + account_id
Expand Down
82 changes: 0 additions & 82 deletions app/core/service.market.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,47 +169,6 @@
callback(response.data);
});
},
getLiquidityPoolHistory: function(pool_id, limit, from, callback) {
return $http.get(appConfig.urls.elasticsearch_wrapper() + "/pool_operation_history"
+ "?pool_id=" + pool_id
+ "&offset=" + from
+ "&limit=" + limit
+ (from == 0 ? "&from_date=now-1y" : "&from_date=2015-10-10")
).then(response => {
let last_ops = [];

// only add if the op id is not already added (transfer appears in both accounts!)
const unique_data = response.data.filter((v,i,a)=>a.findIndex(t=>(t.operation_id_num === v.operation_id_num))===i);

angular.forEach(unique_data, function (value) {
let operation = {};
operation.block_num = value.block_data.block_num;
operation.operation_id = value.account_history.operation_id;
operation.operation_id_num = value.operation_id_num;
operation.time = value.block_data.block_time;
operation.witness = value.witness;
operation.sequence = value.account_history.sequence;

let parsed_op = value.operation_history.op_object;
if (parsed_op == undefined)
parsed_op = JSON.parse(value.operation_history.op)[1];
if (parsed_op.amount)
parsed_op.amount_ = parsed_op.amount;
const _with_result = {...parsed_op, result: value.operation_history.operation_result};
if (typeof _with_result.result === "string") _with_result.result = JSON.parse(value.operation_history.operation_result);
utilities.opText(appConfig, $http, value.operation_type, _with_result, function(returnData) {
operation.operation_text = returnData;
});

const type_res = utilities.operationType(value.operation_type);
operation.type = type_res[0];
operation.color = type_res[1];

last_ops.push(operation);
});
callback(last_ops);
});
},
getCreditOffers: function () {
return $http.get(appConfig.urls.python_backend() + "/creditoffers").then((response) => {
const data = response && response.data;
Expand All @@ -223,47 +182,6 @@
})
})
},
getCreditOfferOperationsHistory: function (credit_offer_id, limit, offset, from) {
let last_ops = [];

return $http.get(appConfig.urls.python_backend() + "/creditoffer_operation_history", { params: {
creditoffer_id: credit_offer_id,
offset: offset,
limit: limit,
from: (from == 0 ? "&from_date=now-1y" : "&from_date=2015-10-10")
}}).then((response) => {
const unique_data = response.data.filter((v,i,a)=>a.findIndex(t=>(t.operation_id_num === v.operation_id_num))===i);

angular.forEach(unique_data, function (value) {
let operation = {};
operation.block_num = value.block_data.block_num;
operation.operation_id = value.account_history.operation_id;
operation.operation_id_num = value.operation_id_num;
operation.time = value.block_data.block_time;
operation.witness = value.witness;
operation.sequence = value.account_history.sequence;

let parsed_op = value.operation_history.op_object;
if (parsed_op == undefined)
parsed_op = JSON.parse(value.operation_history.op)[1];
if (parsed_op.amount)
parsed_op.amount_ = parsed_op.amount;
const _with_result = {...parsed_op, result: value.operation_history.operation_result};
if (typeof _with_result.result === "string") _with_result.result = JSON.parse(value.operation_history.operation_result);
utilities.opText(appConfig, $http, value.operation_type, _with_result, function(returnData) {
operation.operation_text = returnData;
});

const type_res = utilities.operationType(value.operation_type);
operation.type = type_res[0];
operation.color = type_res[1];

last_ops.push(operation);
});

return last_ops
})
}
};
}

Expand Down
21 changes: 14 additions & 7 deletions app/core/service.network.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,20 @@

});
},
getLastOperations: function(limit, from, date_to = (new Date().toISOString()), callback) {
return $http.get(appConfig.urls.elasticsearch_wrapper() + "/account_history"
+ "?limit=" + limit
+ "&offset=" + from
+ (from < 1000000 ? "&from_date=now-1M" : "&from_date=2015-10-10")
+ "&to_date=" + date_to
).then(response => {
getLastOperations: function({ limit = 10, from = 0, assetId = undefined, operationType = undefined, date_to = (new Date().toISOString()) }, callback) {
return $http.get(appConfig.urls.elasticsearch_wrapper() + "/account_history", {
params: {
"limit": limit,
"offset": from,
"from_date": (from < 1000000 ? "now-1M" : "2015-10-10"),
"asset_id": assetId,
"operation_type": operationType,
"to_date": date_to,
}
}).then(response => {
if(response && response.data && response.data.asset_not_found) {
return callback(response.data)
}
let last_ops = [];

// only add if the op id is not already added (transfer appears in both accounts!)
Expand Down
6 changes: 5 additions & 1 deletion app/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"Operation Credit Offer Update": "{{accountLink}} update a credit offer #{{offerId}}",
"Operation Credit Offer Accept": "{{accountLink}} borrows {{amount}} {{assetLink}} from credit offer #{{offerId}}",
"Operation Credit Deal Repay": "{{accountLink}} repays {{amount}} {{assetLink}} to credit offer with fee {{feeAmount}} {{feeAssetLink}}",
"Operation Credit Deal Expired": "{{accountLink}} create a credit offer of {{amount}} {{assetLink}} with fee rate {{fee}}%",
"Operation Credit Deal Expired": "{{accountLink}} credit deal for offer {{offerLink}} has expired. Unpaid amount: {{amount}} {{assetLink}}",
"Operation Ticket Create Description": "{{accountLink}} locked away {{amount}} {{assetLink}} in a voting ticket",
"Operation Ticket Update Description": "{{accountLink}} changed the locked away amount to {{amount}} {{assetLink}} of ticket {{ticket}}",

Expand Down Expand Up @@ -211,6 +211,10 @@
"Daily DEX Volume Chart Series Title": "{{symbol}} Volume",
"Block number symbol": "Block #",
"Operations Count": "Operations Count",
"Asset not found": "Asset {{asset}} not found",
"Account not found": "Account {{account}} not found",
"Please check the asset name": "Please check the asset name or use the id",
"Please check the account name": "Please check the account name or use the id",

"Committee members": "Committee members",
"Current active committee members": "Current active committee members",
Expand Down
3 changes: 3 additions & 0 deletions app/images/filter-on.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/images/filter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 10 additions & 29 deletions app/sections/accounts/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@
<div class="panel-heading clearfix">
<h3 class="panel-title pull-left">
<span data-translate="Full account history"></span>
<img src="images/filter.svg" ng-click="showFilters = !showFilters" class="operations-filter"/>
</h3>
<div class="pull-right">
<div class="input-group">
Expand All @@ -526,34 +527,14 @@ <h3 class="panel-title pull-left">
</div>
</div>
</div>
<div class="panel-body table-responsive">

<responsive-table data-data="operations"
data-columns="operationsColumns"
data-loading="operationsLoading"
data-template="account-operations-table.html"
data-loading-error="operationsLoadingError"
></responsive-table>

<footer class="table-footer">
<div class="row">
<div class="col-md-6 page-num-info">
</div>
<div class="col-md-6 text-right pagination-container">
<ul
uib-pagination class="pagination-sm"
ng-model="currentPage"
total-items="account.total_ops"
max-size="4"
ng-change="currentPage===undefined || select(currentPage)"
items-per-page="20"
rotate="false"
previous-text="&lsaquo;" next-text="&rsaquo;"
boundary-links="true"
></ul>
</div>
</div>
</footer>
</div>

<loading ng-if="!account.name"></loading>
<operations-table ng-if="!!account.name"
show-filters="showFilters"
group-by-account-id="account.id"
default-date-from="now-1y"
filters-date-from="now-1y"
filter-by-account-id-enabled="false"
/>
</div>
</div>
63 changes: 0 additions & 63 deletions app/sections/accounts/accounts.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,69 +77,6 @@ import {sha256} from "js-sha256";
$scope.account = new_account;
}

$scope.operationsColumns = [
{
title: $filter('translate')('Operation'),
index: 'operation_text',
},
{
title: $filter('translate')('ID'),
index: 'operation_id',
},
{
title: $filter('translate')('Date and time'),
index: 'time',
hidden: ['xs']
},
{
title: $filter('translate')('Block'),
index: 'block_num',
hidden: ['xs', 'sm']
},
{
title: $filter('translate')('Type'),
index: 'type',
hidden: ['xs', 'sm', 'md']
}
];
$scope.select = function(page_operations) {
const page = page_operations - 1;
const limit = 20;
const from = page * limit;

$scope.operationsLoading = true;
$scope.operationsLoadingError = false;
accountService.getAccountHistory(fullAccount.account.id, limit, from, function (returnData) {
$scope.operationsLoading = false;
$scope.operations = returnData;
$scope.currentPage = page_operations;
if (page_operations == 1) {
let new_account = {
total_ops: 0
};
if (returnData.length > 0) {
new_account.total_ops = returnData[0].sequence;
}
if ($scope.account) {
$scope.account = Object.assign(new_account, $scope.account);
} else {
$scope.account = new_account;
}
}
}).catch(err => {
$scope.operationsLoadingError = true;
let new_account = {
total_ops: -1,
};
if ($scope.account) {
$scope.account = Object.assign(new_account, $scope.account);
} else {
$scope.account = new_account;
}
throw err;
});
}
$scope.select(1);
// initial sort of fullAccount.balances by balance
fullAccount.balances = $filter("orderBy")(fullAccount.balances, 'float_balance', true);

Expand Down
Loading

0 comments on commit a12f936

Please sign in to comment.