From fb6b1134f6c41edc83ea8f52ac58af217c14d468 Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 29 Jan 2017 10:37:20 +1100 Subject: [PATCH] Adds stringUtils.js Updates "enabled currencies" section Updates buy component. --- web/app/app.js | 3 +- web/app/components/buy/buy.html | 21 ++++------- web/app/components/buy/buy.js | 36 ++++++++++++------ web/app/components/filters/stringUtils.js | 9 +++++ web/app/index.html | 1 + web/app/views/home/home.html | 46 +++++++++++++++-------- web/app/views/home/home.js | 5 +++ 7 files changed, 79 insertions(+), 42 deletions(-) create mode 100644 web/app/components/filters/stringUtils.js diff --git a/web/app/app.js b/web/app/app.js index 39305852..d23e2fd6 100644 --- a/web/app/app.js +++ b/web/app/app.js @@ -8,7 +8,8 @@ angular.module('myApp', [ 'myApp.wallets', 'myApp.settings', 'myApp.version', - 'myApp.buy' + 'myApp.buy', + 'myApp.stringUtils' ]). config(['$locationProvider', '$routeProvider' ,'NotificationProvider', function($locationProvider, $routeProvider, NotificationProvider) { NotificationProvider.setOptions({ diff --git a/web/app/components/buy/buy.html b/web/app/components/buy/buy.html index 1eb2f6b5..6d787233 100644 --- a/web/app/components/buy/buy.html +++ b/web/app/components/buy/buy.html @@ -1,30 +1,25 @@
-
+
- +
- + {{$ctrl.currency.CryptoCurrency}}
- +
- +
- +
-
+
-
- +
\ No newline at end of file diff --git a/web/app/components/buy/buy.js b/web/app/components/buy/buy.js index e4081a37..7af228b1 100644 --- a/web/app/components/buy/buy.js +++ b/web/app/components/buy/buy.js @@ -3,18 +3,30 @@ angular.module('myApp.buy',[]).component('buy', { templateUrl: '/components/buy/buy.html', controller:'BuyController', bindings: { - message: '=' - } -}).controller('BuyController', function ($http, Notification) { - //This contrioller will retrieve all enabled exchanges, - //their enabled currencies and the currency's latest ask - //This call will be used for selling too - // - //This will allow a user to make decisions based onthe latest information to them - //It will auto poll every X seconds (at least until a push method is implemented) - //When all fields are valid, a purchase order will be sent to and handle by gocryptoServer + exchange: '=', + currency:'=' + }, controller: function ($scope, $http, Notification) { + + $scope.GetLatestDataFromExchangeCurrency = function () { + $http.get('/GetLatestDataFromExchangeCurrency?exhange=' + $scope.exchange.exchangeName + '¤cy='+ $scope.currency.CryptoCurrency).success(function (data) { + $scope.currency.Last = data.Last; + $scope.currency.Volume = data.Volume; + }); + } - //Could also hard-type the exchange and currency via attributes on the component for quick use - //Or at lest controlled by passing data from other components/data + $scope.placeOrder = function () { + var obj = {}; + obj.ExchangeName = $scope.exchange.exchangeName; + obj.Currency = $scope.currency; + obj.Price = $scope.price; + obj.Amount = $scope.amount; + obj.Amount = $scope.amount; + $http.post('/Command/', obj).success(function (response) { + Notification.success("Successfully placed order"); + }); + }; + } }); + + diff --git a/web/app/components/filters/stringUtils.js b/web/app/components/filters/stringUtils.js new file mode 100644 index 00000000..ea4ead34 --- /dev/null +++ b/web/app/components/filters/stringUtils.js @@ -0,0 +1,9 @@ +angular.module('myApp.stringUtils', []) + .filter('removeSpaces', [function () { + return function (string) { + if (!angular.isString(string)) { + return string; + } + return string.replace(/[\s]/g, ''); + }; + }]); \ No newline at end of file diff --git a/web/app/index.html b/web/app/index.html index 0e93c805..8b1f80ff 100644 --- a/web/app/index.html +++ b/web/app/index.html @@ -64,5 +64,6 @@ + diff --git a/web/app/views/home/home.html b/web/app/views/home/home.html index 5e514d5e..f36eb379 100644 --- a/web/app/views/home/home.html +++ b/web/app/views/home/home.html @@ -16,7 +16,7 @@

Buy

- +

Sell

@@ -36,20 +36,34 @@

All enabled currencies

-
-
{{exchange.exchangeName}}
- - - - - - - - - - - -
CurrencyLastVolume
{{value.CryptoCurrency}}{{value.Last}}{{value.Volume}}
-
+
+
+ +
+
+ + + + + + + + + + + +
CurrencyLastVolume
{{value.CryptoCurrency}}{{value.Last}}{{value.Volume}}
+
+
+
+
+ +
\ No newline at end of file diff --git a/web/app/views/home/home.js b/web/app/views/home/home.js index eb4ac885..d8d6c260 100644 --- a/web/app/views/home/home.js +++ b/web/app/views/home/home.js @@ -24,6 +24,11 @@ angular.module('myApp.home', ['ngRoute']) }); }; + $scope.reloadDashboardWithExchangeCurrency = function (exchange, value) { + $scope.selectedExchange = exchange; + $scope.selectedCurrency = value; + }; + $scope.getDashboardData(); }); \ No newline at end of file