This repository has been archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94e3e10
commit 1ecb62a
Showing
1 changed file
with
36 additions
and
28 deletions.
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 |
---|---|---|
@@ -1,66 +1,74 @@ | ||
angular.module( 'ripplecharts.validator', [ | ||
'use strict' | ||
|
||
angular.module('ripplecharts.validator', [ | ||
'ui.state', | ||
'ui.bootstrap', | ||
'ui.route' | ||
]) | ||
|
||
.config(function config( $stateProvider ) { | ||
.config(function config($stateProvider) { | ||
$stateProvider | ||
.state('validator', { | ||
url: '/validators/:pubkey', | ||
views: { | ||
"main": { | ||
main: { | ||
controller: 'ValidatorCtrl', | ||
templateUrl: 'validators/validator.tpl.html' | ||
} | ||
}, | ||
data:{ pageTitle: 'Rippled Validator' } | ||
}); | ||
data: {pageTitle: 'Rippled Validator'} | ||
}) | ||
}) | ||
|
||
.controller('ValidatorCtrl', function ValidatorCtrl( $scope, $state, $location) { | ||
var apiHandler = new ApiHandler(API); | ||
.controller('ValidatorCtrl', function ValidatorCtrl($scope, $state) { | ||
|
||
if (!$state.params.pubkey) { | ||
$state.transitionTo('validators') | ||
return | ||
} | ||
|
||
$scope.reports = []; | ||
$scope.loading = true; | ||
$scope.status = 'Loading...'; | ||
var apiHandler = new ApiHandler(API) | ||
|
||
$scope.reports = [] | ||
$scope.loading = true | ||
$scope.status = 'Loading...' | ||
|
||
$scope.validator = { | ||
pubkey: $state.params.pubkey | ||
}; | ||
} | ||
|
||
apiHandler.getValidator($scope.validator.pubkey, function(err, validator) { | ||
if (err) { | ||
console.log('err'); | ||
console.log('err') | ||
|
||
} else { | ||
$scope.validator.domain = validator.domain; | ||
$scope.validator.domain_state = validator.domain_state; | ||
$scope.$apply(); | ||
$scope.validator.domain = validator.domain | ||
$scope.validator.domain_state = validator.domain_state | ||
$scope.$apply() | ||
} | ||
}); | ||
}) | ||
|
||
apiHandler.getValidatorReports({ | ||
pubkey: $scope.validator.pubkey | ||
}, function(err, reports) { | ||
$scope.loading = false; | ||
$scope.status = err || ''; | ||
$scope.loading = false | ||
$scope.status = err || '' | ||
|
||
if (err) { | ||
console.log(err); | ||
console.log(err) | ||
} | ||
|
||
if (reports && reports.length) { | ||
reports.forEach(function(v) { | ||
v.date = moment.utc(v.date) | ||
.format('dddd, MMMM D YYYY'); | ||
var disagreement = v.total_ledgers - v.main_net_ledgers; | ||
disagreement /= v.total_ledgers; | ||
v.main_net_disagreement = disagreement.toFixed(5); | ||
}); | ||
.format('dddd, MMMM D YYYY') | ||
var disagreement = v.total_ledgers - v.main_net_ledgers | ||
disagreement /= v.total_ledgers | ||
v.main_net_disagreement = disagreement.toFixed(5) | ||
}) | ||
} | ||
|
||
$scope.reports = reports; | ||
$scope.$apply(); | ||
}); | ||
}); | ||
$scope.reports = reports | ||
$scope.$apply() | ||
}) | ||
}) |