Converts enabled-exchanges to a component

This commit is contained in:
Scott
2017-01-29 21:15:07 +11:00
parent 6bad3e566a
commit 7ba0cdaf53
6 changed files with 179 additions and 166 deletions

View 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>

View 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();
}
});