frontail
frontail copied to clipboard
--ui-highlight regex word
did ./preset/defatult.json support regex for maching word ?
Hey. It should because it uses String.prototype.replace
https://github.com/mthenw/frontail/blob/master/lib/web/assets/app.js#L148
can u explain to me. how to ? and i cant use multiple word highlight
{ "words": { "error": "color: red;" },
"words": {
"warning": "color: yellow;"
}
}
thanks before
Oh, sorry it's not possible right now. I forgot how patterns are defined. Not sure when I will have a time to implement that though.
Is the highlighting feature still working? I'm having trouble getting it to work.
Its a great UI anyhow though! Great work!
fyi:
{ frontail: '4.0.1',
npm: '3.10.9',
ares: '1.10.1-DEV',
cldr: '29.0',
http_parser: '2.7.0',
icu: '57.1',
modules: '51',
node: '7.1.0',
openssl: '1.0.2j',
tz: '2016b',
unicode: '8.0',
uv: '1.10.0',
v8: '5.4.500.36',
zlib: '1.2.8' }
Edit: Sorry my mistake apparently. Now its working as expected. Also managed to define multiple highlighting conditions so now I'm more than satisfied!
Sorry for bothering you!
@NickBuilder yup, working for me. Could you create separate issue with description what is not working?
I'd also be interested to use regex for highlighting. @mthenw are you still willing to look into this feature? Thanks for your work on this great little project!
In particular I'd be interesed in grouping, example:
2017-03-20 01:25:53 [ItemStateChangedEvent] - BD_Heating_ActTemp changed from 20.80 to 20.70
I want to highlight "BD_Heating_ActTemp" hence highlighting needs to be similar to
"words": {
"] - (\\w*) changed.*": "color: yellow;"
}
+1
+1
+1 nice to have feature, any news or deadline for this? (thanks and keep up the good work)
Hi all, I found a solution to this issue!
All you need to do is add the new function after function var _highlightWord = function(line) { ... }
in file /usr/local/lib/node_modules/frontail/web/assets/app.js
var _highlightRegExpr = function(line) {
var output = line;
if (_highlightConfig && _highlightConfig.regexpr) {
Object.keys(_highlightConfig.regexpr).forEach((pattern) => {
output = output.replace(new RegExp(pattern, 'gm'), _highlightConfig.regexpr[pattern]);
});
}
return output;
};
Change the code on line 326 in the same file from p.innerHTML = _highlightWord(data);
to p.innerHTML = _highlightRegExpr(_highlightWord(data));
Then add a new section called regexpr to the file /usr/local/lib/node_modules/frontail/preset/default.json My variant is:
{
"regexpr":{
"(received command )(.*)":"$1<b>$2</b>",
"(predicted to become )(.*)":"$1<b>$2</b>",
"(changed from )(.*)(\\sto\\s)(.*)":"$1<b>$2</b>$3<b>$4</b>",
"\\'([^\\']+)\\'":"<u>'$1'</u>",
"\\[(INFO |ERROR|WARN )\\]":"<b class=\"$1\">$&</b>"
},
"lines":{
},
"words":{
}
}
And voilà.