Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gui: Add search bar for logging (fixes #9252) #9255

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

DAlba-sudo
Copy link

@DAlba-sudo DAlba-sudo commented Dec 3, 2023

Purpose

Adds search functionality to the GUI logs. There is a conversation regarding this addition here: #9252.

Testing

I tested by building from source with the changes and ensuring that current logging functionality was persisted, as well as checking that the search bar works correctly and is reasonably performant.

Screenshots

image

Documentation

#9252 was the original issue that was raised.
As for documenting the code:

An input of type text is added to the logging html file, ng-keyup callback calls logging.filter.

<input type="text" id="logSearchInput" class="form-control" style="margin-bottom: 10px;" ng-keyup="logging.filter($event)">

The function logging.filter does the following:

  1. If the text in the input is less than 3, it doesn't proceed with the search and "resets" the variables related to maintaining state.
  2. Otherwise, the logging.entries array is searched for entries that match the query using the javascript includes function.
    • This is then added to logging.filtered array. When the logging text area is redrawn, we select the array to draw from based on whether we are filtering or not (that's why I've also added logging.isFiltering).
    • The logging.filtered array is cleared and re-parsed upon a new input.

Authorship

DAlba-sudo, d.alba.work@gmail.com

Your name and email will be added automatically to the AUTHORS file
based on the commit metadata.

calmh and others added 7 commits November 15, 2023 10:53
…hing#9215)

This adds our short device ID to the basic auth realm. This has at least
two consequences:

- It is different from what's presented by another device on the same
address (e.g., if I use SSH forwards to different dives on the same
local address), preventing credentials for one from being sent to
another.

- It is different from what we did previously, meaning we avoid cached
credentials from old versions interfering with the new login flow.

I don't *think* there should be things that depend on our precise realm
string, so this shouldn't break any existing setups...

Sneakily this also changes the session cookie and CSRF name, because I
think `id.Short().String()` is nicer than `id.String()[:5]` and the
short ID is two characters longer. That's also not a problem...
@acolomb
Copy link
Member

acolomb commented Dec 4, 2023

Will it still update the filtered view when new messages come in that match the pattern?

@DAlba-sudo
Copy link
Author

Will it still update the filtered view when new messages come in that match the pattern?

The version in the PR does not, although it makes a lot of sense come to think of it. Let me add that in real quick. Here's what I'll do:

  1. logging.filter assumes it'll be called from the ng-keyup callback, which makes it slightly hard to also place in the logging.fetch where the entries array is being updated. I'll change logging.filter to not depend on the $event being passed in, and make a 'wrapper' function to call logging.filter within the context of said ng-keyup event.
    • then I can use the same filter functionality on the current logging.fetch to update entries in real-time as they come in.

By the way, this is the first time I do a PR in a more official/organized project where I am not the owner. For cases like this where updating code in a commit is required, at what point do you prefer a new PR is made versus simple appending a commit to a PR?

Appreciate the help/patience,
DAlba-sudo

@acolomb
Copy link
Member

acolomb commented Dec 4, 2023

Thank you. Just push more commits to this PR's branch, that's fine. It will be squashed when merging anyway.

@DAlba-sudo
Copy link
Author

Latest push to this branch includes the following changes:

  • filtered content will refresh even when no key is pressed (so long as your search query is greater than 2 characters long).
  • the logs that are filtered are also sent to the logging.entries array as expected.

@tomasz1986 tomasz1986 changed the title gui/core: added search bar for logging gui: Add search bar for logging (fixes #9252) Dec 11, 2023
@calmh
Copy link
Member

calmh commented Dec 11, 2023

Nice, two things however... Now it's always case sensitive, instead of never. :) And I think it's quite unintuitive that nothing happens until you type the third character... I start typing in the filter field, and nothing happens, I'm not sure if it's working? Then once you reach the hidden invisible limit it does

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants