frontail icon indicating copy to clipboard operation
frontail copied to clipboard

--ui-highlight regex word

Open rochmad opened this issue 8 years ago • 10 comments

did ./preset/defatult.json support regex for maching word ?

rochmad avatar Feb 26 '16 07:02 rochmad

Hey. It should because it uses String.prototype.replace https://github.com/mthenw/frontail/blob/master/lib/web/assets/app.js#L148

mthenw avatar Feb 26 '16 08:02 mthenw

can u explain to me. how to ? and i cant use multiple word highlight

{ "words": { "error": "color: red;" },

"words": {
    "warning": "color: yellow;"
}

}

thanks before

rochmad avatar Feb 26 '16 08:02 rochmad

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.

mthenw avatar Feb 26 '16 12:02 mthenw

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 avatar Nov 24 '16 22:11 NickBuilder

@NickBuilder yup, working for me. Could you create separate issue with description what is not working?

mthenw avatar Nov 25 '16 11:11 mthenw

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;"
}

ThomDietrich avatar Mar 20 '17 00:03 ThomDietrich

+1

chetanpatil1984 avatar Jul 13 '17 18:07 chetanpatil1984

+1

branko-tanovic-modoolar avatar Feb 08 '18 18:02 branko-tanovic-modoolar

+1 nice to have feature, any news or deadline for this? (thanks and keep up the good work)

x-drum avatar Jun 17 '18 14:06 x-drum

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à.

log

aliasnameless avatar Jan 31 '23 14:01 aliasnameless