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

@@ -2,28 +2,29 @@
// Declare app level module which depends on views, and components
angular.module('myApp', [
'ngRoute',
'ui-notification',
'myApp.home',
'myApp.wallets',
'myApp.settings',
'myApp.version',
'myApp.buy',
'myApp.sell',
'myApp.stringUtils'
'ngRoute',
'ui-notification',
'myApp.home',
'myApp.wallets',
'myApp.settings',
'myApp.version',
'myApp.buy',
'myApp.sell',
'myApp.enabledExchanges',
'myApp.stringUtils'
]).
config(['$locationProvider', '$routeProvider' ,'NotificationProvider', function($locationProvider, $routeProvider, NotificationProvider) {
NotificationProvider.setOptions({
delay: 5000,
startTop: 60,
startRight: 10,
verticalSpacing: 10,
horizontalSpacing: 20,
positionX: 'right',
positionY: 'top'
});
$locationProvider.hashPrefix('!');
config(['$locationProvider', '$routeProvider', 'NotificationProvider', function($locationProvider, $routeProvider, NotificationProvider) {
NotificationProvider.setOptions({
delay: 5000,
startTop: 60,
startRight: 10,
verticalSpacing: 10,
horizontalSpacing: 20,
positionX: 'right',
positionY: 'top'
});
$routeProvider.otherwise({redirectTo: '/'});
}]);
$locationProvider.hashPrefix('!');
$routeProvider.otherwise({ redirectTo: '/' });
}]);

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

View File

@@ -2,69 +2,75 @@
<!--[if lt IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]-->
<!--[if gt IE 8]><!-->
<html lang="en" ng-app="myApp" class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>GoCrypto Trader</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/bower_components/html5-boilerplate/dist/css/normalize.css">
<link rel="stylesheet" href="/bower_components/html5-boilerplate/dist/css/main.css">
<link rel="stylesheet" href="/bower_components/angular-ui-notification/dist/angular-ui-notification.min.css">
<link rel="stylesheet" href="/app.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>GoCrypto Trader</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/bower_components/html5-boilerplate/dist/css/normalize.css">
<link rel="stylesheet" href="/bower_components/html5-boilerplate/dist/css/main.css">
<link rel="stylesheet" href="/bower_components/angular-ui-notification/dist/angular-ui-notification.min.css">
<link rel="stylesheet" href="/app.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="/bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="/bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation" >
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="/">
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="/">
GoCrypto Trader
</a>
</div>
<ul class="nav navbar-nav">
<li><a href="#!/">Dashboard</a></li>
<li><a href="#!/wallets">Wallets</a></li>
</ul>
<ul class="nav navbar-nav pull-right">
<li class=""><a href="#!/settings">Settings</a></li>
</ul>
</div>
<ul class="nav navbar-nav">
<li><a href="#!/">Dashboard</a></li>
<li><a href="#!/wallets">Wallets</a></li>
</ul>
<ul class="nav navbar-nav pull-right">
<li class=""><a href="#!/settings">Settings</a></li>
</ul>
</div>
</nav>
</nav>
<!--[if lt IE 7]>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div ng-view style="padding-top:60px;"></div>
<div ng-view style="padding-top:60px;"></div>
<p class="text-center text-muted">Copyright 2016 GoCrypto Trader</p>
<!-- In production use:
<p class="text-center text-muted">Copyright 2016 GoCrypto Trader</p>
<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<script src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-ui-notification/dist/angular-ui-notification.min.js"></script>
<script src="/bower_components/angular-route/angular-route.js"></script>
<script src="/app.js"></script>
<script src="/views/settings/settings.js"></script>
<script src="/views/home/home.js"></script>
<script src="/views/wallets/wallets.js"></script>
<script src="/components/buy/buy.js"></script>
<script src="/components/sell/sell.js"></script>
<script src="/components/version/version.js"></script>
<script src="/components/version/version-directive.js"></script>
<script src="/components/version/interpolate-filter.js"></script>
<script src="/components/helpers/stringUtils.js"></script>
<script src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-ui-notification/dist/angular-ui-notification.min.js"></script>
<script src="/bower_components/angular-route/angular-route.js"></script>
<script src="/app.js"></script>
<script src="/views/settings/settings.js"></script>
<script src="/views/home/home.js"></script>
<script src="/views/wallets/wallets.js"></script>
<script src="/components/buy/buy.js"></script>
<script src="/components/sell/sell.js"></script>
<script src="/components/enabled-exchanges/enabled-exchanges.js"></script>
<script src="/components/version/version.js"></script>
<script src="/components/version/version-directive.js"></script>
<script src="/components/version/interpolate-filter.js"></script>
<script src="/components/helpers/stringUtils.js"></script>
</body>
</html>
</html>

View File

@@ -1,70 +1,40 @@
<h1>Dashboard</h1>
<div class="col-md-12">
<div class="col-md-8">
<div class="col-md-12">
<!-- This is to get a sense of scale, I don't intend on any hardcoded heights!' -->
<div class="col-md-6" style=" height: 300px;">
<h3>Sell orders</h3>
</div>
<div class="col-md-6" style=" height: 300px;">
<h3>Buy orders</h3>
</div>
</div>
<div class="col-md-12" style=" height: 300px;">
<h3>Market depth chart</h3>
</div>
<div class="col-md-4" >
<h4>Buy</h4>
<buy ng-show="selected.Currency.Last > 0" ></buy>
</div>
<div class="col-md-4" style=" height: 300px;">
<h4>Sell</h4>
<sell ng-show="selected.Currency.Last > 0" exchange="selected.Exchange" currency="selected.Currency"></sell>
</div>
<div class="col-md-4" style=" height: 300px;">
<h4>Wallet quick look</h4>
See current holding of selected currency
</div>
<div class="col-md-12">
<div class="col-md-6" style=" height: 400px;">
<h3>Trade History</h3>
</div>
<div class="col-md-6" style=" height: 400px;">
<h3>My Open Orders</h3>
</div>
</div>
</div>
<div class="col-md-4">
<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 class="col-md-8">
<div class="col-md-12">
<!-- This is to get a sense of scale, I don't intend on any hardcoded heights!' -->
<div class="col-md-6" style=" height: 300px;">
<h3>Sell orders</h3>
</div>
<div class="col-md-6" style=" height: 300px;">
<h3>Buy orders</h3>
</div>
</div>
<div class="col-md-12" style=" height: 300px;">
<h3>Market depth chart</h3>
</div>
<div class="col-md-4">
<h4>Buy</h4>
<buy></buy>
</div>
<div class="col-md-4" style=" height: 300px;">
<h4>Sell</h4>
<sell></sell>
</div>
<div class="col-md-4" style=" height: 300px;">
<h4>Wallet quick look</h4>
See current holding of selected currency
</div>
<div class="col-md-12">
<div class="col-md-6" style=" height: 400px;">
<h3>Trade History</h3>
</div>
<div class="col-md-6" style=" height: 400px;">
<h3>My Open Orders</h3>
</div>
</div>
</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 class="col-md-4">
<enabledexchanges></enabledexchanges>
</div>
</div>
</div>
</div>
</div>

View File

@@ -3,36 +3,13 @@
angular.module('myApp.home', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/', {
templateUrl: '/views/home/home.html',
controller: 'HomeController'
});
$routeProvider.when('/', {
templateUrl: '/views/home/home.html',
controller: 'HomeController'
});
}])
.controller('HomeController', 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');
});
};
.controller('HomeController', function() {
$scope.reloadDashboardWithExchangeCurrency = function (exchange, value) {
$scope.selected.Exchange = exchange;
$scope.selected.Currency = value;
$rootScope.$emit('CurrencyChanged', $scope.selected);
};
$scope.getDashboardData();
});