mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-02 23:16:51 +00:00
Converts enabled-exchanges to a component
This commit is contained in:
30
web/app/components/enabled-exchanges/enabled-exchanges.html
Normal file
30
web/app/components/enabled-exchanges/enabled-exchanges.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<div class="col-md-12">
|
||||
<h4>All enabled currencies</h4>
|
||||
<div class="panel-group" id="accordion">
|
||||
<div class="panel panel-default" ng-repeat="exchange in exchanges">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="javascript:;" data-toggle="collapse" data-parent="#accordion" data-target="#{{exchange.exchangeName | removeSpaces}}">
|
||||
{{exchange.exchangeName}}
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="{{exchange.exchangeName | removeSpaces}}" class="panel-collapse collapse" ng-class='{in:$first}'>
|
||||
<div class="panel-body">
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Currency</th>
|
||||
<th>Last</th>
|
||||
<th>Volume</th>
|
||||
</tr>
|
||||
<tr ng-repeat="value in exchange.exchangeValues">
|
||||
<td><a href="" ng-click="reloadDashboardWithExchangeCurrency(exchange,value)">{{value.CryptoCurrency}}</a></td>
|
||||
<td>{{value.Last}}</td>
|
||||
<td>{{value.Volume}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
29
web/app/components/enabled-exchanges/enabled-exchanges.js
Normal file
29
web/app/components/enabled-exchanges/enabled-exchanges.js
Normal file
@@ -0,0 +1,29 @@
|
||||
angular.module('myApp.enabledExchanges', []).component('enabledexchanges', {
|
||||
templateUrl: '/components/enabled-exchanges/enabled-exchanges.html',
|
||||
controller: 'EnabledExchangesController',
|
||||
controller: function($scope, $http, Notification, $rootScope) {
|
||||
$scope.selected = {};
|
||||
$scope.getDashboardData = function() {
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: '/data/all-enabled-currencies'
|
||||
}).
|
||||
success(function(data, status, headers, config) {
|
||||
$scope.exchanges = data.data;
|
||||
$scope.reloadDashboardWithExchangeCurrency($scope.exchanges[0], $scope.exchanges[0].exchangeValues[0]);
|
||||
Notification.info("Retrieved latest data");
|
||||
}).
|
||||
error(function(data, status, headers, config) {
|
||||
console.log('error');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reloadDashboardWithExchangeCurrency = function(exchange, value) {
|
||||
$scope.selected.Exchange = exchange;
|
||||
$scope.selected.Currency = value;
|
||||
$rootScope.$emit('CurrencyChanged', $scope.selected);
|
||||
|
||||
};
|
||||
$scope.getDashboardData();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user