Skip to content

Commit

Permalink
#23 Replace operations on dashboard by operations-table
Browse files Browse the repository at this point in the history
  • Loading branch information
ihorml committed Nov 9, 2022
1 parent abb53c6 commit 494a029
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 133 deletions.
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.
96 changes: 2 additions & 94 deletions app/sections/dashboard/dashboard.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
'use strict';

angular.module('app').controller('DashboardCtrl', ['$scope', 'Notify', '$timeout', '$window', 'networkService',
'chartService', 'appConfig', '$filter', 'utilities', DashboardCtrl])
'chartService', 'appConfig', '$filter', DashboardCtrl])

.filter('to_trusted', ['$sce', function($sce){
return function(text) {
return $sce.trustAsHtml(text);
};
}]);

function DashboardCtrl($scope, Notify, $timeout, $window, networkService, chartService, appConfig, $filter, utilities) {
function DashboardCtrl($scope, Notify, $timeout, $window, networkService, chartService, appConfig, $filter) {

networkService.getHeader(function (returnData) {
$scope.dynamic = returnData;
Expand All @@ -19,95 +19,7 @@
});

$scope.branding = appConfig.branding;

$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.userOpenedFirstPageTime = null;

$scope.select = function(page_operations) {
const page = page_operations -1;
const limit = 20;
const from = page * limit;
const operationType = $scope.operationTypeFilter !== '-1' ? $scope.operationTypeFilter : undefined;
const assetId = $scope.assetNameOrSymbolFilter && $scope.assetNameOrSymbolFilter.length ? $scope.assetNameOrSymbolFilter.toUpperCase() : undefined

if(page_operations === 1 || !$scope.userOpenedFirstPageTime) { // if user switches back from page Y (Y>1) to page 1 we need to fetch new transactions and update time range
$scope.userOpenedFirstPageTime = new Date();
}

const date_to = $scope.userOpenedFirstPageTime.toISOString();

$scope.operationsLoading = true;
$scope.operationsLoadingError = false;
networkService.getLastOperations({limit, from, operationType, assetId, date_to}, function (returnData) {
$scope.operationsLoading = false;
if(returnData && returnData.asset_not_found) {
return Notify.warning({
key: 'httpAssetNotFound',
title: $filter('translate')('Asset not found', {
asset: assetId
}),
message: $filter('translate')('Please check the asset name'),
allowMultiple: true
});
} else {
$scope.operations = returnData;
$scope.currentPage = page_operations;
if (page_operations == 1) {
if (returnData.length > 0) {
$scope.total_ops = returnData[0].operation_id_num;
} else {
$scope.total_ops = 0;
}
}
}
}).catch(err => {
$scope.operationsLoadingError = true;
});
};
$scope.select(1);

$scope.operationTypes = new Array(75).fill('#').map((item, key) => {
const name = utilities.operationType(key)[0]
if(!name)
return false;
return {
id: key,
name,
}
}).filter((item) => !!item);

$scope.operationTypeFilter = '-1';
$scope.assetNameOrSymbolFilter = '';
$scope.assetNameOrSymbolFilterModelOptions = {
debounce: 500,
getterSetter: true
};

$scope.chartsData = {
operations_chart: chartService.loadingChart(),
proxies_chart: chartService.loadingChart(),
Expand All @@ -116,10 +28,6 @@
uias_chart: chartService.loadingChart(),
holders_chart: chartService.loadingChart(),
};

$scope.$watchGroup(["operationTypeFilter", "assetNameOrSymbolFilter"], () => {
$scope.select(1)
});

// lazy load on tab change
$scope.loadTabsCharts = function(tabName) {
Expand Down
44 changes: 5 additions & 39 deletions app/sections/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,47 +137,13 @@
</div>
</div>
<div class="panel panel-default">
<div class="panel-body table-responsive">

<div class="dashboard-operations-filters">
<div>
<input type="text" ng-model-options="assetNameOrSymbolFilterModelOptions" ng-model="assetNameOrSymbolFilter" placeholder="Type asset name or id" class="form-control" style="width: 200px" ng-model="asset_id">
</div>
<div>
<select class="form-control" style="width: 200px" ng-model="operationTypeFilter">
<option value="-1">Filter by operation type</option>
<option value="{{operationType.id}}" ng-repeat="operationType in operationTypes">
{{ operationType.name }}
</option>
</select>
</div>
</div>
<div class="panel-heading">
<span data-translate="Last operations"></span>
<img src="images/filter.svg" style="width: 18px;cursor: pointer;" ng-click="showFilters = !showFilters"/>
</div>

<responsive-table data-data="operations"
data-columns="operationsColumns"
data-template="dashboard-operations-table.html"
data-loading="operationsLoading"
data-loading-error="operationsLoadingError">
</responsive-table>
<operations-table total-items="total_ops" show-filters="showFilters"/>

<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="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>
</div>
</div>

0 comments on commit 494a029

Please sign in to comment.