mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-20 15:10:10 +00:00
Removes "/web" folder requirement when running app.
[WIP]Adds config route to modify settings within app.
This commit is contained in:
@@ -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)
|
||||
|
||||
24
configRoutes.go
Normal file
24
configRoutes.go
Normal file
@@ -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,
|
||||
},
|
||||
}
|
||||
@@ -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
|
||||
|
||||
28
web/app/views/settings/settings.html
Normal file
28
web/app/views/settings/settings.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<h2>Settings</h2>
|
||||
<h3>All enabled currencies</h3>
|
||||
<div ng-repeat="exchange in exchanges">
|
||||
<h4>{{exchange.exchangeName}}</h4>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Currency</th>
|
||||
<th>Last</th>
|
||||
<th>High</th>
|
||||
<th>Low</th>
|
||||
<th>Volume</th>
|
||||
<th>Bid</th>
|
||||
<th>Ask</th>
|
||||
</tr>
|
||||
<tr ng-repeat="value in exchange.exchangeValues">
|
||||
<td>{{value.CryptoCurrency}}</td>
|
||||
<td>{{value.Last}}</td>
|
||||
<td>{{value.High}}</td>
|
||||
<td>{{value.Low}}</td>
|
||||
<td>{{value.Volume}}</td>
|
||||
<td>{{value.Bid}}</td>
|
||||
<td>{{value.Ask}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div ng-repeat="value in exchange.exchangeValues">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
28
web/app/views/settings/settings.js
Normal file
28
web/app/views/settings/settings.js
Normal file
@@ -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();
|
||||
|
||||
});
|
||||
16
web/app/views/settings/settings_test.js
Normal file
16
web/app/views/settings/settings_test.js
Normal file
@@ -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();
|
||||
}));
|
||||
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user