diffs to monaco editor
This commit is contained in:
@ -42,3 +42,54 @@ CREATE INDEX "index_runner_header_pk" ON "runner_header" (
|
|||||||
CREATE INDEX "index_runner_header_strat" ON "runner_header" (
|
CREATE INDEX "index_runner_header_strat" ON "runner_header" (
|
||||||
"strat_id"
|
"strat_id"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###a pak tato cast na odstraneni data sloupce
|
||||||
|
CREATE TABLE "sqlb_temp_table_2" (
|
||||||
|
"runner_id" varchar(32) NOT NULL,
|
||||||
|
"strat_id" TEXT,
|
||||||
|
"batch_id" TEXT,
|
||||||
|
"symbol" TEXT,
|
||||||
|
"name" TEXT,
|
||||||
|
"note" TEXT,
|
||||||
|
"started" TEXT,
|
||||||
|
"stopped" TEXT,
|
||||||
|
"mode" TEXT,
|
||||||
|
"account" TEXT,
|
||||||
|
"bt_from" TEXT,
|
||||||
|
"bt_to" TEXT,
|
||||||
|
"strat_json" TEXT,
|
||||||
|
"settings" TEXT,
|
||||||
|
"ilog_save" INTEGER,
|
||||||
|
"profit" NUMERIC,
|
||||||
|
"trade_count" INTEGER,
|
||||||
|
"end_positions" INTEGER,
|
||||||
|
"end_positions_avgp" NUMERIC,
|
||||||
|
"metrics" TEXT,
|
||||||
|
"stratvars_toml" TEXT,
|
||||||
|
PRIMARY KEY("runner_id")
|
||||||
|
);
|
||||||
|
INSERT INTO "main"."sqlb_temp_table_2" ("account","batch_id","bt_from","bt_to","end_positions","end_positions_avgp","ilog_save","metrics","mode","name","note","profit","runner_id","settings","started","stopped","strat_id","strat_json","stratvars_toml","symbol","trade_count") SELECT "account","batch_id","bt_from","bt_to","end_positions","end_positions_avgp","ilog_save","metrics","mode","name","note","profit","runner_id","settings","started","stopped","strat_id","strat_json","stratvars_toml","symbol","trade_count" FROM "main"."runner_header"
|
||||||
|
PRAGMA defer_foreign_keys;
|
||||||
|
PRAGMA defer_foreign_keys = '1';
|
||||||
|
DROP TABLE "main"."runner_header"
|
||||||
|
ALTER TABLE "main"."sqlb_temp_table_2" RENAME TO "runner_header"
|
||||||
|
PRAGMA defer_foreign_keys = '0';
|
||||||
|
CREATE INDEX "index_runner_header_pk" ON "runner_header" (
|
||||||
|
"runner_id"
|
||||||
|
);
|
||||||
|
CREATE INDEX "index_runner_header_strat" ON "runner_header" (
|
||||||
|
"strat_id"
|
||||||
|
);
|
||||||
|
CREATE INDEX "index_runner_header_batch" ON "runner_header" (
|
||||||
|
"batch_id"
|
||||||
|
);
|
||||||
|
RELEASE "db4s_renamecolumn_1697637283072384";
|
||||||
|
PRAGMA database_list;
|
||||||
|
SELECT type,name,sql,tbl_name FROM "main".sqlite_master;
|
||||||
|
SELECT type,name,sql,tbl_name FROM sqlite_temp_master;
|
||||||
|
PRAGMA "main".foreign_key_check
|
||||||
|
RELEASE "db4s_edittable_1697637265835032";
|
||||||
|
PRAGMA foreign_keys = '1';
|
||||||
@ -510,7 +510,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="diffModal" class="modal fade" style="--bs-modal-width: 900px;">
|
<div id="diffModal" class="modal fade" style="--bs-modal-width: 1800px;">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<form method="post" id="diffForm">
|
<form method="post" id="diffForm">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -519,7 +519,6 @@
|
|||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div id="diff_content"></div>
|
|
||||||
<div class="form-group" style="float: left; width: 470px;">
|
<div class="form-group" style="float: left; width: 470px;">
|
||||||
<label id="diff_first" for="first" class="form-label">First</label>
|
<label id="diff_first" for="first" class="form-label">First</label>
|
||||||
<div id="diff_first_id"></div>
|
<div id="diff_first_id"></div>
|
||||||
@ -529,7 +528,10 @@
|
|||||||
<label id="diff_second" for="second" class="form-label">Second</label>
|
<label id="diff_second" for="second" class="form-label">Second</label>
|
||||||
<div id="diff_second_id"></div>
|
<div id="diff_second_id"></div>
|
||||||
<div id="second" name="second"></div>
|
<div id="second" name="second"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div id="diff_content" style="height:700px;border:1px solid black;"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
//ARCHIVE TABLES
|
//ARCHIVE TABLES
|
||||||
|
let editor_diff_arch1
|
||||||
|
let editor_diff_arch2
|
||||||
|
|
||||||
|
|
||||||
function refresh_arch_and_callback(row, callback) {
|
function refresh_arch_and_callback(row, callback) {
|
||||||
console.log("entering refresh")
|
console.log("entering refresh")
|
||||||
@ -74,6 +77,10 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
//button compare arch
|
//button compare arch
|
||||||
$('#button_compare_arch').click(function () {
|
$('#button_compare_arch').click(function () {
|
||||||
|
if (editor_diff_arch1) {editor_diff_arch1.dispose()}
|
||||||
|
if (editor_diff_stratin1) {editor_diff_stratin1.dispose()}
|
||||||
|
if (editor_diff_arch2) {editor_diff_arch2.dispose()}
|
||||||
|
if (editor_diff_stratin2) {editor_diff_stratin2.dispose()}
|
||||||
window.$('#diffModal').modal('show');
|
window.$('#diffModal').modal('show');
|
||||||
rows = archiveRecords.rows('.selected').data();
|
rows = archiveRecords.rows('.selected').data();
|
||||||
|
|
||||||
@ -162,14 +169,14 @@ $(document).ready(function () {
|
|||||||
console.log(data1.metrics)
|
console.log(data1.metrics)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
record1["profit"] = JSON.parse(data1.metrics).profit
|
record1["profit"] = JSON.parse(data1.metrics.profit)
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log(e.message)
|
console.log(e.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
record1.stratvars_conf = TOML.parse(record1.stratvars_conf);
|
//record1.stratvars_conf = TOML.parse(record1.stratvars_conf);
|
||||||
record1.add_data_conf = TOML.parse(record1.add_data_conf);
|
//record1.add_data_conf = TOML.parse(record1.add_data_conf);
|
||||||
// record1.note = rows[0].note;
|
// record1.note = rows[0].note;
|
||||||
// record1.history = "";
|
// record1.history = "";
|
||||||
//jsonString1 = JSON.stringify(record1, null, 2);
|
//jsonString1 = JSON.stringify(record1, null, 2);
|
||||||
@ -190,13 +197,13 @@ $(document).ready(function () {
|
|||||||
console.log(data2.metrics)
|
console.log(data2.metrics)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
record2["profit"] = JSON.parse(data2.metrics).profit
|
record2["profit"] = JSON.parse(data2.metrics.profit)
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log(e.message)
|
console.log(e.message)
|
||||||
}
|
}
|
||||||
record2.stratvars_conf = TOML.parse(record2.stratvars_conf);
|
//record2.stratvars_conf = TOML.parse(record2.stratvars_conf);
|
||||||
record2.add_data_conf = TOML.parse(record2.add_data_conf);
|
//record2.add_data_conf = TOML.parse(record2.add_data_conf);
|
||||||
// record2.note = rows[1].note;
|
// record2.note = rows[1].note;
|
||||||
// record2.history = "";
|
// record2.history = "";
|
||||||
//jsonString2 = JSON.stringify(record2, null, 2);
|
//jsonString2 = JSON.stringify(record2, null, 2);
|
||||||
@ -206,12 +213,42 @@ $(document).ready(function () {
|
|||||||
$('#diff_first_id').text(data1.id);
|
$('#diff_first_id').text(data1.id);
|
||||||
$('#diff_second_id').text(data2.id);
|
$('#diff_second_id').text(data2.id);
|
||||||
|
|
||||||
var delta = compareObjects(record1, record2)
|
//monaco
|
||||||
const htmlMarkup2 = `<pre>{\n${generateHTML(record2, delta)}}\n</pre>`;
|
require(["vs/editor/editor.main"], () => {
|
||||||
document.getElementById('second').innerHTML = htmlMarkup2;
|
editor_diff_arch1 = monaco.editor.createDiffEditor(document.getElementById('diff_content'),
|
||||||
|
{
|
||||||
|
language: 'toml',
|
||||||
|
theme: 'tomlTheme-dark',
|
||||||
|
originalEditable: false,
|
||||||
|
automaticLayout: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
console.log(record1.stratvars_conf)
|
||||||
|
console.log(record2.stratvars_conf)
|
||||||
|
editor_diff_arch1.setModel({
|
||||||
|
original: monaco.editor.createModel(record1.stratvars_conf, 'toml'),
|
||||||
|
modified: monaco.editor.createModel(record2.stratvars_conf, 'toml'),
|
||||||
|
});
|
||||||
|
editor_diff_arch2 = monaco.editor.createDiffEditor(document.getElementById('diff_content'),
|
||||||
|
{
|
||||||
|
language: 'toml',
|
||||||
|
theme: 'tomlTheme-dark',
|
||||||
|
originalEditable: false,
|
||||||
|
automaticLayout: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
editor_diff_arch2.setModel({
|
||||||
|
original: monaco.editor.createModel(record1.add_data_conf, 'toml'),
|
||||||
|
modified: monaco.editor.createModel(record2.add_data_conf, 'toml'),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const htmlMarkup1 = `<pre>{\n${generateHTML(record1, delta)}}\n</pre>`;
|
// var delta = compareObjects(record1, record2)
|
||||||
document.getElementById('first').innerHTML = htmlMarkup1;
|
// const htmlMarkup2 = `<pre>{\n${generateHTML(record2, delta)}}\n</pre>`;
|
||||||
|
// document.getElementById('second').innerHTML = htmlMarkup2;
|
||||||
|
|
||||||
|
// const htmlMarkup1 = `<pre>{\n${generateHTML(record1, delta)}}\n</pre>`;
|
||||||
|
// document.getElementById('first').innerHTML = htmlMarkup1;
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
//$('#button_compare').attr('disabled','disabled');
|
//$('#button_compare').attr('disabled','disabled');
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
let editor_diff_stratin1
|
||||||
|
let editor_diff_stratin2
|
||||||
//on button
|
//on button
|
||||||
function store_api_key(event) {
|
function store_api_key(event) {
|
||||||
key = document.getElementById("api-key").value;
|
key = document.getElementById("api-key").value;
|
||||||
@ -40,7 +42,7 @@ function is_stratin_running(id) {
|
|||||||
|
|
||||||
function refresh_stratin_and_callback(row, callback) {
|
function refresh_stratin_and_callback(row, callback) {
|
||||||
var request = $.ajax({
|
var request = $.ajax({
|
||||||
url: "/stratin/"+row.id,
|
url: "/stratins/"+row.id,
|
||||||
beforeSend: function (xhr) {
|
beforeSend: function (xhr) {
|
||||||
xhr.setRequestHeader('X-API-Key',
|
xhr.setRequestHeader('X-API-Key',
|
||||||
API_KEY); },
|
API_KEY); },
|
||||||
@ -61,12 +63,11 @@ function refresh_stratin_and_callback(row, callback) {
|
|||||||
// Handling the responses of both requests
|
// Handling the responses of both requests
|
||||||
$.when(request).then(function(response) {
|
$.when(request).then(function(response) {
|
||||||
// Both requests have completed successfully
|
// Both requests have completed successfully
|
||||||
var result = response[0];
|
|
||||||
|
|
||||||
console.log("Result from first request:", result);
|
//console.log("Result from request:", result);
|
||||||
console.log("calling compare")
|
console.log("calling calbback")
|
||||||
//call callback function
|
//call callback function
|
||||||
callback(result)
|
callback(response)
|
||||||
|
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
// Handle errors from either request here
|
// Handle errors from either request here
|
||||||
@ -377,6 +378,10 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
//button compare stratin
|
//button compare stratin
|
||||||
$('#button_compare').click(function () {
|
$('#button_compare').click(function () {
|
||||||
|
if (editor_diff_arch1) {editor_diff_arch1.dispose()}
|
||||||
|
if (editor_diff_stratin1) {editor_diff_stratin1.dispose()}
|
||||||
|
if (editor_diff_arch2) {editor_diff_arch2.dispose()}
|
||||||
|
if (editor_diff_stratin2) {editor_diff_stratin2.dispose()}
|
||||||
window.$('#diffModal').modal('show');
|
window.$('#diffModal').modal('show');
|
||||||
rows = stratinRecords.rows('.selected').data();
|
rows = stratinRecords.rows('.selected').data();
|
||||||
|
|
||||||
@ -453,8 +458,8 @@ $(document).ready(function () {
|
|||||||
// rec1.script = rows[0].script;
|
// rec1.script = rows[0].script;
|
||||||
// rec1.open_rush = rows[0].open_rush;
|
// rec1.open_rush = rows[0].open_rush;
|
||||||
// rec1.close_rush = rows[0].close_rush;
|
// rec1.close_rush = rows[0].close_rush;
|
||||||
rec1.stratvars_conf = TOML.parse(rec1.stratvars_conf);
|
//rec1.stratvars_conf = TOML.parse(rec1.stratvars_conf);
|
||||||
rec1.add_data_conf = TOML.parse(rec1.add_data_conf);
|
//rec1.add_data_conf = TOML.parse(rec1.add_data_conf);
|
||||||
// rec1.note = rows[0].note;
|
// rec1.note = rows[0].note;
|
||||||
rec1.history = "";
|
rec1.history = "";
|
||||||
//jsonString1 = JSON.stringify(rec1, null, 2);
|
//jsonString1 = JSON.stringify(rec1, null, 2);
|
||||||
@ -468,8 +473,8 @@ $(document).ready(function () {
|
|||||||
// rec2.script = rows[1].script;
|
// rec2.script = rows[1].script;
|
||||||
// rec2.open_rush = rows[1].open_rush;
|
// rec2.open_rush = rows[1].open_rush;
|
||||||
// rec2.close_rush = rows[1].close_rush;
|
// rec2.close_rush = rows[1].close_rush;
|
||||||
rec2.stratvars_conf = TOML.parse(rec2.stratvars_conf);
|
//rec2.stratvars_conf = TOML.parse(rec2.stratvars_conf);
|
||||||
rec2.add_data_conf = TOML.parse(rec2.add_data_conf);
|
//rec2.add_data_conf = TOML.parse(rec2.add_data_conf);
|
||||||
// rec2.note = rows[1].note;
|
// rec2.note = rows[1].note;
|
||||||
rec2.history = "";
|
rec2.history = "";
|
||||||
//jsonString2 = JSON.stringify(rec2, null, 2);
|
//jsonString2 = JSON.stringify(rec2, null, 2);
|
||||||
@ -478,14 +483,53 @@ $(document).ready(function () {
|
|||||||
//document.getElementById('first').innerHTML = '<pre>'+JSON.stringify(rec1, null, 2)+'</pre>'
|
//document.getElementById('first').innerHTML = '<pre>'+JSON.stringify(rec1, null, 2)+'</pre>'
|
||||||
$('#diff_first').text(rec1.name);
|
$('#diff_first').text(rec1.name);
|
||||||
$('#diff_second').text(rec2.name);
|
$('#diff_second').text(rec2.name);
|
||||||
|
$('#diff_first_id').text(rec1.id);
|
||||||
|
$('#diff_second_id').text(rec2.id);
|
||||||
|
|
||||||
var delta = compareObjects(rec1, rec2)
|
//monaco
|
||||||
const htmlMarkup2 = `<pre>{\n${generateHTML(rec2, delta)}}\n</pre>`;
|
require(["vs/editor/editor.main"], () => {
|
||||||
document.getElementById('second').innerHTML = htmlMarkup2;
|
editor_diff_stratin = monaco.editor.createDiffEditor(document.getElementById('diff_content'),
|
||||||
|
{
|
||||||
|
language: 'toml',
|
||||||
|
theme: 'tomlTheme-dark',
|
||||||
|
originalEditable: false,
|
||||||
|
automaticLayout: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
//console.log("prga",rec1.stratvars_conf)
|
||||||
|
//console.log("druga", rec2.stratvars_conf)
|
||||||
|
editor_diff_stratin1.setModel({
|
||||||
|
original: monaco.editor.createModel(rec1.stratvars_conf, 'toml'),
|
||||||
|
modified: monaco.editor.createModel(rec2.stratvars_conf, 'toml'),
|
||||||
|
});
|
||||||
|
|
||||||
//var delta1 = compareObjects(rec2, rec1)
|
editor_diff_stratin1.setModel({
|
||||||
const htmlMarkup1 = `<pre>{\n${generateHTML(rec1, delta)}}\n</pre>`;
|
original: monaco.editor.createModel(rec1.add_data_conf, 'toml'),
|
||||||
document.getElementById('first').innerHTML = htmlMarkup1;
|
modified: monaco.editor.createModel(rec2.add_data_conf, 'toml'),
|
||||||
|
});
|
||||||
|
editor_diff_stratin2 = monaco.editor.createDiffEditor(document.getElementById('diff_content'),
|
||||||
|
{
|
||||||
|
language: 'toml',
|
||||||
|
theme: 'tomlTheme-dark',
|
||||||
|
originalEditable: false,
|
||||||
|
automaticLayout: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
editor_diff_stratin2.setModel({
|
||||||
|
original: monaco.editor.createModel(record1.add_data_conf, 'toml'),
|
||||||
|
modified: monaco.editor.createModel(record2.add_data_conf, 'toml'),
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// var delta = compareObjects(rec1, rec2)
|
||||||
|
// const htmlMarkup2 = `<pre>{\n${generateHTML(rec2, delta)}}\n</pre>`;
|
||||||
|
// document.getElementById('second').innerHTML = htmlMarkup2;
|
||||||
|
|
||||||
|
// //var delta1 = compareObjects(rec2, rec1)
|
||||||
|
// const htmlMarkup1 = `<pre>{\n${generateHTML(rec1, delta)}}\n</pre>`;
|
||||||
|
// document.getElementById('first').innerHTML = htmlMarkup1;
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
//$('#button_compare').attr('disabled','disabled');
|
//$('#button_compare').attr('disabled','disabled');
|
||||||
@ -613,10 +657,10 @@ $(document).ready(function () {
|
|||||||
//edit button
|
//edit button
|
||||||
$('#button_edit').click(function () {
|
$('#button_edit').click(function () {
|
||||||
row = stratinRecords.row('.selected').data();
|
row = stratinRecords.row('.selected').data();
|
||||||
if (row== undefined) {
|
if (row == undefined) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
console.log(row)
|
||||||
refresh_stratin_and_callback(row, show_edit_modal)
|
refresh_stratin_and_callback(row, show_edit_modal)
|
||||||
|
|
||||||
function show_edit_modal(row) {
|
function show_edit_modal(row) {
|
||||||
@ -665,17 +709,17 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
function show_stratvars_edit_modal(row) {
|
function show_stratvars_edit_modal(row) {
|
||||||
|
|
||||||
$('#stratvar_id').val(row.id);
|
$('#stratvar_id').val(row.id);
|
||||||
require(["vs/editor/editor.main"], () => {
|
require(["vs/editor/editor.main"], () => {
|
||||||
editor = monaco.editor.create(document.getElementById('stratvars_editor'), {
|
editor = monaco.editor.create(document.getElementById('stratvars_editor'), {
|
||||||
value: row.stratvars_conf,
|
value: row.stratvars_conf,
|
||||||
language: 'toml',
|
language: 'toml',
|
||||||
theme: 'tomlTheme-dark',
|
theme: 'tomlTheme-dark',
|
||||||
automaticLayout: true
|
automaticLayout: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
window.$('#stratvarsModal').modal('show');
|
window.$('#stratvarsModal').modal('show');
|
||||||
//$('#stratvars_editor_val').val(row.stratvars_conf);
|
//$('#stratvars_editor_val').val(row.stratvars_conf);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} );
|
} );
|
||||||
|
|||||||
Reference in New Issue
Block a user