diff --git a/.gitignore b/.gitignore
index 6439d473c..ad2c2fb9e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -123,3 +123,5 @@ config\.json
*.csv
*.ods
+
+temp_config\.json
diff --git a/config/cst.py b/config/cst.py
index 3f750ad35..84c9ae333 100644
--- a/config/cst.py
+++ b/config/cst.py
@@ -68,6 +68,7 @@
CONFIG_PORTFOLIO_TOTAL = "total"
# Notification
+CONFIG_NOTIFICATION_TYPE = "notification_type"
CONFIG_NOTIFICATION_INSTANCE = "notifier"
CONFIG_CATEGORY_NOTIFICATION = "notification"
CONFIG_NOTIFICATION_GLOBAL_INFO = "global_info"
@@ -224,6 +225,11 @@
STRATEGIES_REQUIRED_EVALUATORS = "required_evaluators"
TRADING_MODE_REQUIRED_STRATEGIES = "required_strategies"
+# Web interface
+UPDATED_CONFIG_SEPARATOR = "_"
+GLOBAL_CONFIG_KEY = "global_config"
+EVALUATOR_CONFIG_KEY = "evaluator_config"
+
class TentacleManagerActions(Enum):
INSTALL = 1
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 1d25e2330..a78d515b3 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -6,6 +6,7 @@ Changelog for 0.1.5_2-beta
**Warning** :
- You have to encrypt your exchange token : **please run python tools/temp_encrypt_tool.py**
+- Notification type key changed from "type" to "notification_type"
# Concerned issues :
#269 [Tool] Implement ConfigManager
diff --git a/interfaces/web/controllers/configuration.py b/interfaces/web/controllers/configuration.py
index 7c7e198d7..c4261d862 100644
--- a/interfaces/web/controllers/configuration.py
+++ b/interfaces/web/controllers/configuration.py
@@ -2,12 +2,12 @@
from flask import render_template, request, jsonify
from config.cst import CONFIG_EXCHANGES, CONFIG_CATEGORY_SERVICES, CONFIG_CATEGORY_NOTIFICATION, \
- CONFIG_TRADER, CONFIG_SIMULATOR, CONFIG_CRYPTO_CURRENCIES
+ CONFIG_TRADER, CONFIG_SIMULATOR, CONFIG_CRYPTO_CURRENCIES, GLOBAL_CONFIG_KEY, EVALUATOR_CONFIG_KEY
from interfaces import get_bot
from interfaces.web import server_instance
from interfaces.web.models.configuration import get_evaluator_config, update_evaluator_config, \
- get_evaluator_startup_config, get_services_list, get_symbol_list
+ get_evaluator_startup_config, get_services_list, get_symbol_list, update_global_config, get_global_config
from interfaces.web.util.flask_util import get_rest_reply
@@ -15,18 +15,26 @@
@server_instance.route('/config', methods=['GET', 'POST'])
def config():
if request.method == 'POST':
- update_type = request.args["update_type"]
- if update_type == "evaluator_config":
- request_data = request.get_json()
- success = False
-
- if request_data:
- success = update_evaluator_config(request_data)
-
- if success:
- return get_rest_reply(jsonify(get_evaluator_config()))
- else:
- return get_rest_reply('{"update": "ko"}', 500)
+ request_data = request.get_json()
+ success = False
+
+ if request_data:
+ # update global config if required
+ if GLOBAL_CONFIG_KEY in request_data and request_data[GLOBAL_CONFIG_KEY]:
+ success = update_global_config(request_data[GLOBAL_CONFIG_KEY])
+
+ # update evaluator config if required
+ if EVALUATOR_CONFIG_KEY in request_data and request_data[EVALUATOR_CONFIG_KEY]:
+ success = update_evaluator_config(request_data[EVALUATOR_CONFIG_KEY])
+
+ if success:
+ # return get_rest_reply(jsonify({
+ # GLOBAL_CONFIG_KEY: get_global_config(),
+ # EVALUATOR_CONFIG_KEY: get_evaluator_config()
+ # }))
+ return get_rest_reply("")
+ else:
+ return get_rest_reply('{"update": "ko"}', 500)
else:
g_config = get_bot().get_config()
user_exchanges = [e for e in g_config[CONFIG_EXCHANGES]]
diff --git a/interfaces/web/models/configuration.py b/interfaces/web/models/configuration.py
index 53ce4d517..0103b8a00 100644
--- a/interfaces/web/models/configuration.py
+++ b/interfaces/web/models/configuration.py
@@ -6,6 +6,14 @@
from tools.config_manager import ConfigManager
+def get_global_config():
+ return get_bot().get_config()
+
+
+def get_global_startup_config():
+ return get_bot().get_startup_config()
+
+
def get_evaluator_config():
return get_bot().get_config()[CONFIG_EVALUATOR]
@@ -15,7 +23,7 @@ def get_evaluator_startup_config():
def update_evaluator_config(new_config):
- current_config = get_bot().get_config()[CONFIG_EVALUATOR]
+ current_config = get_evaluator_config()
try:
ConfigManager.update_evaluator_config(new_config, current_config)
return True
@@ -23,6 +31,15 @@ def update_evaluator_config(new_config):
return False
+def update_global_config(new_config):
+ current_config = get_global_config()
+ # try:
+ ConfigManager.update_global_config(new_config, current_config)
+ return True
+ # except Exception:
+ # return False
+
+
def get_services_list():
return [
service().get_type()
diff --git a/interfaces/web/static/js/common/cst.js b/interfaces/web/static/js/common/cst.js
index f74ac5153..541738e1e 100644
--- a/interfaces/web/static/js/common/cst.js
+++ b/interfaces/web/static/js/common/cst.js
@@ -4,7 +4,7 @@ var config_value_attr = "config-value";
var current_value_attr = "current-value";
var startup_value_attr = "startup-config-value";
var update_url_attr = "update-url";
-var config_type_attr = "config_type";
+var config_type_attr = "config-type";
var config_root_class = "config-root";
var config_container_class = "config-container";
var config_element_class = "config-element";
@@ -27,8 +27,4 @@ var deactivated = "Deactivated";
// utility functions
function log(text){
window.console&&console.log(text);
-}
-
-function replace_eol_by_html(str){
- return str.replace(/(?:\r\n|\r|\n)/g, '
');
}
\ No newline at end of file
diff --git a/interfaces/web/static/js/common/util.js b/interfaces/web/static/js/common/util.js
index cce9d51da..011807e14 100644
--- a/interfaces/web/static/js/common/util.js
+++ b/interfaces/web/static/js/common/util.js
@@ -6,4 +6,12 @@ function handle_editable(){
$(".editable").each(function(){
$(this).editable();
});
+}
+
+function replace_break_line(str, replacement=""){
+ return str.replace(/(?:\r\n|\r|\n)/g, replacement);
+}
+
+function replace_spaces(str, replacement=""){
+ return str.replace(/ /g, replacement);
}
\ No newline at end of file
diff --git a/interfaces/web/static/js/components/configuration.js b/interfaces/web/static/js/components/configuration.js
index 2480f4a68..cf0262daf 100644
--- a/interfaces/web/static/js/components/configuration.js
+++ b/interfaces/web/static/js/components/configuration.js
@@ -15,9 +15,21 @@ function handle_save_buttons(){
var update_url = full_config.attr(update_url_attr);
full_config.find("."+config_element_class).each(function(){
- var new_value = $(this).attr(current_value_attr)
+ var new_value = "";
+ var config_type = $(this).attr(config_type_attr);
+
+ if(!(config_type in updated_config)){
+ updated_config[config_type] = {};
+ }
+
+ if($(this)[0].hasAttribute(current_value_attr)){
+ new_value = $(this).attr(current_value_attr);
+ }else{
+ new_value = replace_spaces(replace_break_line($(this).text()));
+ }
+
if(new_value.toLowerCase() != $(this).attr(config_value_attr).toLowerCase() ){
- updated_config[$(this).attr(config_key_attr)]=new_value;
+ updated_config[config_type][$(this).attr(config_key_attr)] = new_value;
}
})
@@ -62,6 +74,9 @@ function handle_evaluator_configuration_editor(){
});
}
+function handle_global_configuration_editor(){
+}
+
function reset_configuration_element(element){
var full_config = get_active_tab_config();
full_config.find("."+ config_element_class).each(function(){
diff --git a/interfaces/web/templates/components/config/currency_card.html b/interfaces/web/templates/components/config/currency_card.html
index 3777c13ce..e3fac5fbc 100644
--- a/interfaces/web/templates/components/config/currency_card.html
+++ b/interfaces/web/templates/components/config/currency_card.html
@@ -11,8 +11,7 @@
{% if crypto_currency in config_symbols %} @@ -22,7 +21,6 @@
- API Key : *********
- API Secret : ************
+ API Key :
+ *********
+
+ API Secret :
+ ************
Websocket : - {% if "web_socket" in exchange and exchange["web_socket"] == True %} - - {% else %} - - {% endif %} + {% if "web_socket" in exchange and exchange["web_socket"] == True %} + + {% endif %} +
-