diff --git a/config.go b/config.go index 1e1b45b3..1ba49714 100644 --- a/config.go +++ b/config.go @@ -164,10 +164,6 @@ func CheckExchangeConfigValues() error { } func CheckWebserverValues() error { - _, err := ioutil.ReadDir("web/") - if err != nil { - return errors.New(WarningWebserverRootWebFolderNotFound) - } if bot.config.Webserver.AdminUsername == "" || bot.config.Webserver.AdminPassword == "" { return errors.New(WarningWebserverCredentialValuesEmpty) diff --git a/configRoutes.go b/configRoutes.go new file mode 100644 index 00000000..604c7f79 --- /dev/null +++ b/configRoutes.go @@ -0,0 +1,24 @@ +package main + +import ( + "encoding/json" + "net/http" +) + +func getAllSettings(w http.ResponseWriter, r *http.Request) { + + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) + if err := json.NewEncoder(w).Encode(bot.config); err != nil { + panic(err) + } +} + +var configRoutes = Routes{ + Route{ + "GetAllSettings", + "GET", + "/config/all", + getAllSettings, + }, +} diff --git a/restfulRouter.go b/restfulRouter.go index 0ed2d18b..3cf23ef4 100644 --- a/restfulRouter.go +++ b/restfulRouter.go @@ -9,6 +9,7 @@ import ( func NewRouter(exchanges []IBotExchange) *mux.Router { router := mux.NewRouter().StrictSlash(true) allRoutes := append(routes, exchangeRoutes...) + allRoutes = append(allRoutes, configRoutes...) for _, route := range allRoutes { var handler http.Handler handler = route.HandlerFunc diff --git a/web/app/views/settings/settings.html b/web/app/views/settings/settings.html new file mode 100644 index 00000000..03ea571e --- /dev/null +++ b/web/app/views/settings/settings.html @@ -0,0 +1,28 @@ +

Settings

+

All enabled currencies

+
+

{{exchange.exchangeName}}

+ + + + + + + + + + + + + + + + + + + +
CurrencyLastHighLowVolumeBidAsk
{{value.CryptoCurrency}}{{value.Last}}{{value.High}}{{value.Low}}{{value.Volume}}{{value.Bid}}{{value.Ask}}
+
+ +
+
\ No newline at end of file diff --git a/web/app/views/settings/settings.js b/web/app/views/settings/settings.js new file mode 100644 index 00000000..d2412903 --- /dev/null +++ b/web/app/views/settings/settings.js @@ -0,0 +1,28 @@ +'use strict'; + +angular.module('myApp.home', ['ngRoute']) + +.config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/', { + templateUrl: '/views/home/home.html', + controller: 'HomeController' + }); +}]) + +.controller('HomeController', function ($scope, $http) { + $scope.getDashboardData = function() { + $http({ + method: 'GET', + url: '/data/all-enabled-currencies' + }). + success(function (data, status, headers, config) { + $scope.exchanges = data.data; + }). + error(function (data, status, headers, config) { + console.log('error'); + }); + }; + + $scope.getDashboardData(); + +}); \ No newline at end of file diff --git a/web/app/views/settings/settings_test.js b/web/app/views/settings/settings_test.js new file mode 100644 index 00000000..14ba79b4 --- /dev/null +++ b/web/app/views/settings/settings_test.js @@ -0,0 +1,16 @@ +'use strict'; + +describe('myApp.view1 module', function() { + + beforeEach(module('myApp.view1')); + + describe('view1 controller', function(){ + + it('should ....', inject(function($controller) { + //spec body + var view1Ctrl = $controller('View1Ctrl'); + expect(view1Ctrl).toBeDefined(); + })); + + }); +}); \ No newline at end of file