fixed before branching
This commit is contained in:
@@ -61,6 +61,11 @@
|
|||||||
|
|
||||||
<script src="/static/js/libs/mousetrap.min.js"></script>
|
<script src="/static/js/libs/mousetrap.min.js"></script>
|
||||||
|
|
||||||
|
<!-- EXPERIMENT pro test navic tyto fajly pro select -->
|
||||||
|
<!-- <script src="https://cdn.datatables.net/select/1.7.0/js/select.bootstrap5.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdn.datatables.net/select/1.7.0/css/select.bootstrap5.css">
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- <script src="https://cdn.datatables.net/select/1.6.2/js/dataTables.select.min.js"></script> -->
|
<!-- <script src="https://cdn.datatables.net/select/1.6.2/js/dataTables.select.min.js"></script> -->
|
||||||
<!-- <script src="/static/js/fast-toml.js" type="text/javascript"></script> -->
|
<!-- <script src="/static/js/fast-toml.js" type="text/javascript"></script> -->
|
||||||
<!-- <script src="/static/js/libs/j-toml/j-toml.min.js" type="module">
|
<!-- <script src="/static/js/libs/j-toml/j-toml.min.js" type="module">
|
||||||
@@ -317,7 +322,9 @@
|
|||||||
<button title="For selected batch creates heatmap for optimal profit/loss cutoffs" id="button_analyze" class="btn btn-outline-success btn-sm">Optimal cutoffs</button>
|
<button title="For selected batch creates heatmap for optimal profit/loss cutoffs" id="button_analyze" class="btn btn-outline-success btn-sm">Optimal cutoffs</button>
|
||||||
<!-- <button id="button_stopall" class="btn btn-outline-success btn-sm">Stop All</button>
|
<!-- <button id="button_stopall" class="btn btn-outline-success btn-sm">Stop All</button>
|
||||||
<button id="button_refresh" class="btn btn-outline-success btn-sm">Refresh</button> -->
|
<button id="button_refresh" class="btn btn-outline-success btn-sm">Refresh</button> -->
|
||||||
|
<div id="buttons-container"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <div>
|
<!-- <div>
|
||||||
Toggle column: <a class="toggle-vis" data-column="0">Name</a> - <a class="toggle-vis" data-column="1">Position</a> - <a class="toggle-vis" data-column="2">Office</a> - <a class="toggle-vis" data-column="3">Age</a> - <a class="toggle-vis" data-column="4">Start date</a> - <a class="toggle-vis" data-column="5">Salary</a>
|
Toggle column: <a class="toggle-vis" data-column="0">Name</a> - <a class="toggle-vis" data-column="1">Position</a> - <a class="toggle-vis" data-column="2">Office</a> - <a class="toggle-vis" data-column="3">Age</a> - <a class="toggle-vis" data-column="4">Start date</a> - <a class="toggle-vis" data-column="5">Salary</a>
|
||||||
</div> -->
|
</div> -->
|
||||||
@@ -854,5 +861,6 @@
|
|||||||
<script src="/static/js/mytables.js"></script>
|
<script src="/static/js/mytables.js"></script>
|
||||||
<script src="/static/js/testlist.js"></script>
|
<script src="/static/js/testlist.js"></script>
|
||||||
<script src="/static/js/configform.js"></script>
|
<script src="/static/js/configform.js"></script>
|
||||||
|
<!-- <script src="/static/js/dynamicbuttons.js"></script> -->
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,9 +1,19 @@
|
|||||||
//JS code for using config value on the frontend
|
//JS code for using config value on the frontend
|
||||||
//TODO zvazit presunuti do TOML z JSONu
|
//TODO zvazit presunuti do TOML z JSONu
|
||||||
|
|
||||||
|
// CREATE TABLE "config_table" (
|
||||||
|
// "id" INTEGER,
|
||||||
|
// "item_name" TEXT NOT NULL,
|
||||||
|
// "json_data" JSON NOT NULL,
|
||||||
|
// "item_lang" TEXT NOT NULL, //not implemented yet
|
||||||
|
// PRIMARY KEY("id" AUTOINCREMENT)
|
||||||
|
// );
|
||||||
|
|
||||||
configData = {}
|
configData = {}
|
||||||
|
|
||||||
|
//pridat sem i config area
|
||||||
function get_from_config(name, def_value) {
|
function get_from_config(name, def_value) {
|
||||||
|
def_value = def_value ? def_value : null
|
||||||
console.log("required", name, configData)
|
console.log("required", name, configData)
|
||||||
if ((configData["JS"]) && (configData["JS"][name] !== undefined)) {
|
if ((configData["JS"]) && (configData["JS"][name] !== undefined)) {
|
||||||
console.log("returned from config", configData["JS"][name])
|
console.log("returned from config", configData["JS"][name])
|
||||||
|
|||||||
66
v2realbot/static/js/dynamicbuttons.js
Normal file
66
v2realbot/static/js/dynamicbuttons.js
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
//ekvivalent to ready
|
||||||
|
$(function(){
|
||||||
|
|
||||||
|
//dynamicke buttony predelat na trdi se vstupem (nazev cfg klice, id conteineru)
|
||||||
|
var buttonConfig = get_from_config("analyze_buttons");
|
||||||
|
|
||||||
|
console.log("here")
|
||||||
|
|
||||||
|
buttonConfig.forEach(function(button) {
|
||||||
|
var $btnGroup = $('<div>', {class: 'btn-group'});
|
||||||
|
var $btn = $('<button>', {
|
||||||
|
type: 'button',
|
||||||
|
class: 'btn btn-primary',
|
||||||
|
text: button.label
|
||||||
|
});
|
||||||
|
|
||||||
|
var $form = $('<form>', {class: 'input-group'});
|
||||||
|
|
||||||
|
// Handling additional parameters
|
||||||
|
for (var key in button.additionalParameters) {
|
||||||
|
var param = button.additionalParameters[key];
|
||||||
|
var $input;
|
||||||
|
|
||||||
|
if (param.type === 'select') {
|
||||||
|
$input = $('<select>', {class: 'form-select', name: key});
|
||||||
|
param.options.forEach(function(option) {
|
||||||
|
$input.append($('<option>', {value: option, text: option}));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$input = $('<input>', {
|
||||||
|
type: param.type === 'number' ? 'number' : 'text',
|
||||||
|
class: 'form-control',
|
||||||
|
name: key,
|
||||||
|
placeholder: key
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$form.append($input);
|
||||||
|
}
|
||||||
|
|
||||||
|
$btnGroup.append($btn).append($form);
|
||||||
|
$('#buttons-container').append($btnGroup);
|
||||||
|
|
||||||
|
// Event listener for button
|
||||||
|
$btn.on('click', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
var formData = $form.serializeArray().reduce(function(obj, item) {
|
||||||
|
obj[item.name] = item.value;
|
||||||
|
return obj;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: button.apiEndpoint,
|
||||||
|
method: 'POST',
|
||||||
|
data: formData,
|
||||||
|
success: function(response) {
|
||||||
|
console.log('API Call Successful:', response);
|
||||||
|
},
|
||||||
|
error: function(error) {
|
||||||
|
console.error('API Call Failed:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user