log highlighting and better compare

This commit is contained in:
David Brazda
2023-10-19 13:32:37 +02:00
parent 538f722015
commit 9bd4a84d2a
12 changed files with 2321 additions and 36 deletions

View File

@@ -1,4 +1,3 @@
var tradeDetails = new Map();
var toolTip = null
var CHART_SHOW_TEXT = get_from_config("CHART_SHOW_TEXT", false)
@@ -943,6 +942,7 @@ function fetch_log_data(timestamp, runner_id) {
function display_log(iterLogList, timestamp) {
//console.log("Incoming logline object")
var lines = document.getElementById('lines')
var line = document.createElement('div')
line.classList.add("line")
@@ -966,11 +966,17 @@ function display_log(iterLogList, timestamp) {
highlighted = (parseInt(logLine.time) == parseInt(timestamp)) ? "highlighted" : ""
logcnt++;
row = '<div data-bs-toggle="collapse" class="'+ highlighted + ' shj-lang-log" onclick="set_timestamp(' + logLine.time + ')" data-bs-target="#rec'+logcnt+'">'+logLine.time + " " + logLine.event + ' - '+ (logLine.message == undefined ? "" : logLine.message) +'</div>'
hdr = logLine.time + " " + logLine.event + ' - '+ (logLine.message == undefined ? "" : logLine.message)
hdr = Prism.highlight(hdr, Prism.languages.log, 'log');
row = '<div data-bs-toggle="collapse" class="'+ highlighted + ' shj-lang-log" onclick="set_timestamp(' + logLine.time + ')" data-bs-target="#rec'+logcnt+'">'
+hdr + '</div>'
str_row = JSON.stringify(logLine.details, null, 2)
//row_detail = '<div id="rec'+logcnt+'" data-toggle="collapse" data-target="#rec'+logcnt+'"class="collapse pidi"><pre>' + str_row + '</pre></div>'
row_detail = '<div id="rec'+logcnt+'" class="collapse pidi shj-lang-log"><pre>' + str_row + '</pre></div>'
const html = Prism.highlight(str_row, Prism.languages.json, 'json');
//console.log("tady", html)
row_detail = '<div id="rec'+logcnt+'" class="collapse pidi shj-lang-log"><pre><code class="language-log">' + html + '</code></pre></div>'
var lines = document.getElementById('lines')
var line = document.createElement('div')

View File

@@ -2,7 +2,6 @@
let editor_diff_arch1
let editor_diff_arch2
function refresh_arch_and_callback(row, callback) {
console.log("entering refresh")
var request = $.ajax({
@@ -215,7 +214,7 @@ $(document).ready(function () {
//monaco
require(["vs/editor/editor.main"], () => {
editor_diff_arch1 = monaco.editor.createDiffEditor(document.getElementById('diff_content'),
editor_diff_arch1 = monaco.editor.createDiffEditor(document.getElementById('diff_content1'),
{
language: 'toml',
theme: 'tomlTheme-dark',
@@ -229,7 +228,7 @@ $(document).ready(function () {
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'),
editor_diff_arch2 = monaco.editor.createDiffEditor(document.getElementById('diff_content2'),
{
language: 'toml',
theme: 'tomlTheme-dark',
@@ -625,7 +624,7 @@ var archiveRecords =
},
},
{
targets: [5,6],
targets: [5],
render: function ( data, type, row ) {
now = new Date(data)
if (type == "sort") {
@@ -647,6 +646,29 @@ var archiveRecords =
}
},
},
{
targets: [6],
render: function ( data, type, row ) {
now = new Date(data)
if (type == "sort") {
return new Date(data).getTime();
}
var date = new Date(data);
tit = date.toLocaleString('cs-CZ', {
timeZone: 'America/New_York',
})
if (isToday(now)) {
//return local time only
return '<div title="'+tit+'" class="token level comment">'+ 'dnes ' + format_date(data,false,true)+'</div>'
}
else
{
//return local datetime
return '<div title="'+tit+'" class="token level number">'+ format_date(data,false,false)+'</div>'
}
},
},
{
targets: [9,10],
render: function ( data, type, row ) {
@@ -661,9 +683,15 @@ var archiveRecords =
{
targets: [2],
render: function ( data, type, row ) {
return '<div class="tdname" title="'+data+'">'+data+'</div>'
return '<div class="tdname tdnowrap" title="'+data+'">'+data+'</div>'
},
},
// {
// targets: [4],
// render: function ( data, type, row ) {
// return '<div class="tdname tdnowrap" title="'+data+'">'+data+'</div>'
// },
// },
{
targets: [16],
render: function ( data, type, row ) {
@@ -673,10 +701,19 @@ var archiveRecords =
catch (error) {
}
var res = JSON.stringify(data)
const unquoted = res.replace(/"([^"]+)":/g, '$1:')
return '<div class="tdmetrics" title="'+unquoted+'">'+unquoted+'</div>'
var unquoted = res.replace(/"([^"]+)":/g, '$1:')
//zobrazujeme jen kratkou summary pokud mame, jinak davame vse, do titlu davame vzdy vse
//console.log(data)
short = null
if ((data.profit) && (data.profit.sum)) {
short = data.profit.sum
}
else {
short = unquoted
}
return '<div class="tdmetrics" title="'+unquoted+'">'+short+'</div>'
},
},
{
@@ -685,6 +722,12 @@ var archiveRecords =
return '<div class="tdnote" title="'+data+'">'+data+'</div>'
},
},
{
targets: [13,14,15],
render: function ( data, type, row ) {
return '<div class="tdsmall">'+data+'</div>'
},
},
{
targets: [11],
render: function ( data, type, row ) {
@@ -739,5 +782,17 @@ var archiveRecords =
//}
} );
//WIP buttons to hide datatable columns
// document.querySelectorAll('a.toggle-vis').forEach((el) => {
// el.addEventListener('click', function (e) {
// e.preventDefault();
// let columnIdx = e.target.getAttribute('data-column');
// let column = archiveRecords.column(columnIdx);
// // Toggle the visibility
// column.visible(!column.visible());
// });
// });

View File

@@ -39,7 +39,7 @@ $(document).ready(function () {
console.log("jsme tu")
indConfig = configData["JS"].indConfig
console.log("after")
console.log(JSON.stringify(indConfig, null,null, 2))
//console.log(JSON.stringify(indConfig, null,null, 2))
console.log("before CHART_SHOW_TEXT",CHART_SHOW_TEXT)
var CHART_SHOW_TEXT = configData["JS"].CHART_SHOW_TEXT

View File

@@ -0,0 +1,27 @@
// https://www.json.org/json-en.html
Prism.languages.json = {
'property': {
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
lookbehind: true,
greedy: true
},
'string': {
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
lookbehind: true,
greedy: true
},
'comment': {
pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
greedy: true
},
'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
'punctuation': /[{}[\],]/,
'operator': /:/,
'boolean': /\b(?:false|true)\b/,
'null': {
pattern: /\bnull\b/,
alias: 'keyword'
}
};
Prism.languages.webmanifest = Prism.languages.json;

View File

@@ -0,0 +1,120 @@
// This is a language definition for generic log files.
// Since there is no one log format, this language definition has to support all formats to some degree.
//
// Based on https://github.com/MTDL9/vim-log-highlighting
Prism.languages.log = {
'string': {
// Single-quoted strings must not be confused with plain text. E.g. Can't isn't Susan's Chris' toy
pattern: /"(?:[^"\\\r\n]|\\.)*"|'(?![st] | \w)(?:[^'\\\r\n]|\\.)*'/,
greedy: true,
},
'exception': {
pattern: /(^|[^\w.])[a-z][\w.]*(?:Error|Exception):.*(?:(?:\r\n?|\n)[ \t]*(?:at[ \t].+|\.{3}.*|Caused by:.*))+(?:(?:\r\n?|\n)[ \t]*\.\.\. .*)?/,
lookbehind: true,
greedy: true,
alias: ['javastacktrace', 'language-javastacktrace'],
inside: Prism.languages['javastacktrace'] || {
'keyword': /\bat\b/,
'function': /[a-z_][\w$]*(?=\()/,
'punctuation': /[.:()]/
}
},
'level': [
{
pattern: /\b(?:ALERT|CRIT|CRITICAL|EMERG|EMERGENCY|ERR|ERROR|FAILURE|FATAL|SEVERE|-----)\b/,
alias: ['error', 'important']
},
{
pattern: /\b(?:WARN|WARNING|WRN|ENTRY|LP|SL)\b/,
alias: ['warning', 'important']
},
{
pattern: /\b(?:DISPLAY|INF|INFO|NOTICE|STATUS)\b/,
alias: ['info', 'keyword']
},
{
pattern: /\b(?:DBG|DEBUG|FINE|REVERSE|ADD|EXITADD|SIGNAL)\b/,
alias: ['debug', 'keyword']
},
{
pattern: /\b(?:FINER|FINEST|TRACE|TRC|VERBOSE|VRB|IND)\b/,
alias: ['trace', 'comment']
}
],
'property': {
pattern: /((?:^|[\]|])[ \t]*)[a-z_](?:[\w-]|\b\/\b)*(?:[. ]\(?\w(?:[\w-]|\b\/\b)*\)?)*:(?=\s)/im,
lookbehind: true
},
'separator': {
pattern: /(^|[^-+])-{3,}|={3,}|\*{3,}|- - /m,
lookbehind: true,
alias: 'comment'
},
'url': /\b(?:file|ftp|https?):\/\/[^\s|,;'"]*[^\s|,;'">.]/,
'email': {
pattern: /(^|\s)[-\w+.]+@[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+(?=\s)/,
lookbehind: true,
alias: 'url'
},
'ip-address': {
pattern: /\b(?:\d{1,3}(?:\.\d{1,3}){3})\b/,
alias: 'constant'
},
'mac-address': {
pattern: /\b[a-f0-9]{2}(?::[a-f0-9]{2}){5}\b/i,
alias: 'constant'
},
'domain': {
pattern: /(^|\s)[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*\.[a-z][a-z0-9-]+(?=\s)/,
lookbehind: true,
alias: 'constant'
},
'uuid': {
pattern: /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/i,
alias: 'constant'
},
'hash': {
pattern: /\b(?:[a-f0-9]{32}){1,2}\b/i,
alias: 'constant'
},
'file-path': {
pattern: /\b[a-z]:[\\/][^\s|,;:(){}\[\]"']+|(^|[\s:\[\](>|])\.{0,2}\/\w[^\s|,;:(){}\[\]"']*/i,
lookbehind: true,
greedy: true,
alias: 'string'
},
'date': {
pattern: RegExp(
/\b\d{4}[-/]\d{2}[-/]\d{2}(?:T(?=\d{1,2}:)|(?=\s\d{1,2}:))/.source +
'|' +
/\b\d{1,4}[-/ ](?:\d{1,2}|Apr|Aug|Dec|Feb|Jan|Jul|Jun|Mar|May|Nov|Oct|Sep)[-/ ]\d{2,4}T?\b/.source +
'|' +
/\b(?:(?:Fri|Mon|Sat|Sun|Thu|Tue|Wed)(?:\s{1,2}(?:Apr|Aug|Dec|Feb|Jan|Jul|Jun|Mar|May|Nov|Oct|Sep))?|Apr|Aug|Dec|Feb|Jan|Jul|Jun|Mar|May|Nov|Oct|Sep)\s{1,2}\d{1,2}\b/.source,
'i'
),
alias: 'number'
},
'time': {
pattern: /\b\d{1,2}:\d{1,2}:\d{1,2}(?:[.,:]\d+)?(?:\s?[+-]\d{2}:?\d{2}|Z)?\b/,
alias: 'number'
},
'boolean': /\b(?:false|null|true)\b/i,
'number': {
pattern: /(^|[^.\w])(?:0x[a-f0-9]+|0o[0-7]+|0b[01]+|v?\d[\da-f]*(?:\.\d+)*(?:e[+-]?\d+)?[a-z]{0,3}\b)\b(?!\.\w)/i,
lookbehind: true
},
'operator': /[;:?<=>~/@!$%&+\-|^(){}*#]/,
'punctuation': /[\[\].,]/
};

View File

@@ -0,0 +1,99 @@
code[class*=language-],pre[class*=language-] {
color: #ccc;
background: 0 0;
font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none
}
pre[class*=language-] {
padding: 1em;
margin: .5em 0;
overflow: auto
}
:not(pre)>code[class*=language-],pre[class*=language-] {
background: #2d2d2d
}
:not(pre)>code[class*=language-] {
padding: .1em;
border-radius: .3em;
white-space: normal
}
.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog {
color: #999
}
.token.punctuation {
color: #ccc
}
.token.attr-name,.token.deleted,.token.namespace,.token.tag {
color: #e2777a
}
.token.function-name {
color: #6196cc
}
.token.boolean {
color: #c39375;
}
.token.function {
color: #8f5734;
}
.token.number {
color: #828080;
}
.token.class-name,.token.constant,.token.property,.token.symbol {
color: #f29599;
}
.token.atrule,.token.builtin,.token.important,.token.selector {
color: #cc99cd
}
.token.keyword{
color: #9d8c98
}
.token.attr-value,.token.char,.token.regex,.token.string,.token.variable {
color: #889d90;
}
.token.entity,.token.operator,.token.url {
color: #67cdcc
}
.token.bold,.token.important {
font-weight: 700
}
.token.italic {
font-style: italic
}
.token.entity {
cursor: help
}
.token.inserted {
color: green
}

File diff suppressed because it is too large Load Diff

View File

@@ -488,7 +488,7 @@ $(document).ready(function () {
//monaco
require(["vs/editor/editor.main"], () => {
editor_diff_stratin = monaco.editor.createDiffEditor(document.getElementById('diff_content'),
editor_diff_stratin1 = monaco.editor.createDiffEditor(document.getElementById('diff_content1'),
{
language: 'toml',
theme: 'tomlTheme-dark',
@@ -503,11 +503,7 @@ $(document).ready(function () {
modified: monaco.editor.createModel(rec2.stratvars_conf, 'toml'),
});
editor_diff_stratin1.setModel({
original: monaco.editor.createModel(rec1.add_data_conf, 'toml'),
modified: monaco.editor.createModel(rec2.add_data_conf, 'toml'),
});
editor_diff_stratin2 = monaco.editor.createDiffEditor(document.getElementById('diff_content'),
editor_diff_stratin2 = monaco.editor.createDiffEditor(document.getElementById('diff_content2'),
{
language: 'toml',
theme: 'tomlTheme-dark',
@@ -516,8 +512,8 @@ $(document).ready(function () {
}
);
editor_diff_stratin2.setModel({
original: monaco.editor.createModel(record1.add_data_conf, 'toml'),
modified: monaco.editor.createModel(record2.add_data_conf, 'toml'),
original: monaco.editor.createModel(rec1.add_data_conf, 'toml'),
modified: monaco.editor.createModel(rec2.add_data_conf, 'toml'),
});
});