Skip to content
Open
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
29 changes: 14 additions & 15 deletions desktop/js/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,26 @@ if (!jeeFrontEnd.log) {

//searching
document.getElementById('in_searchLogFilter')?.addEventListener('keyup', function(event) {
let search = event.target.value
if (search == '') {
const raw = event.target.value
if (raw == '') {
jeeP.logListButtons.seen()
return
}
const not = search.startsWith(":not(")
if (not) {
search = search.replace(':not(', '')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to handle also ), currently if we do :not(toto), search will search toto) and not toto

}
search = jeedomUtils.normTextLower(search)

// Multi-term: comma-separated terms, each term can be prefixed with :not()
// e.g. "error,warning" → show entries matching either
// "error,:not(daemon)" → show entries matching "error" but not "daemon"
const terms = raw.split(',').map(function(t) { return t.trim() }).filter(function(t) { return t.length > 0 })

jeeP.logListButtons.unseen()
jeeP.logListButtons.forEach(_bt => {
let match = false
const text = jeedomUtils.normTextLower(_bt.textContent)
if (text.includes(search)) {
match = true
}
if (not) match = !match
if (match) {
_bt.seen()
}
const match = terms.some(function(term) {
const not = term.startsWith(':not(')
const search = jeedomUtils.normTextLower(not ? term.slice(5, -1) : term)
return not ? !text.includes(search) : text.includes(search)
})
if (match) _bt.seen()
})
})

Expand Down
Loading