Skip to content
This repository has been archived by the owner on Nov 22, 2017. It is now read-only.

Truncate default_fields after configurable number of lines in collapsed view (issue #165) #178

Open
wants to merge 5 commits into
base: kibana-ruby
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions KibanaConfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ module KibanaConfig
# Results to show per page
Per_page = 50

# Maximum number of lines from multiline fields to display in collapsed view.
# Affects all Default_fields
Max_lines = 5

# Timezone. Leave this set to 'user' to have the user's browser autocorrect.
# Otherwise, set a timezone string
# Examples: 'UTC', 'America/Phoenix', 'Europe/Athens', MST
Expand Down
2 changes: 2 additions & 0 deletions lib/kibana-app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def link_to url_fragment, mode=:full_url
result.response['kibana']['default_fields'] = KibanaConfig::Default_fields
# Enable clickable URL links
result.response['kibana']['clickable_urls'] = KibanaConfig::Clickable_URLs
# Truncate Default_fields after Max_lines in collapsed view
result.response['kibana']['maxlines'] = KibanaConfig::Max_lines

JSON.generate(result.response)
end
Expand Down
9 changes: 8 additions & 1 deletion public/lib/js/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,14 @@ function CreateLogTable(objArray, fields, theme, enableHeader) {
}

var value = value === undefined ? "-" : value.toString();
var value = xmlEnt(wbr(value),10);
var maxlines = window.resultjson.kibana.maxlines;
var value = xmlEnt(wbr(value, 10)).split('<br/>').slice(0);
if (value.length > maxlines) {
var omitted = value.length - maxlines;
var value = value.slice(0, maxlines).join('<br/>') + '<br/><small>[...' + omitted + ' lines omitted...]</small>';
} else {
var value = value.join('<br/>');
}
var value = value.replace(RegExp("@KIBANA_HIGHLIGHT_START@(.*?)@KIBANA_HIGHLIGHT_END@", "g"),
function (all, text, char) {
return "<span class='highlightedtext'>" + text + "</span>";
Expand Down