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

Feat: Support URL parameters to change Dashboard filters #4496

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

NihadBadalov
Copy link

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

Support URL parameters to change Dashboard filters.

The following work:

  • /dashboard?filter=true&status=up
  • /dashboard?filter=true&status=up&status=down
  • /dashboard?filter=true&status=up&status=down&status=pending&status=maintenance

If the filter URL parameter is set to false, the filters are not going to be in effect.

Fixes #3672

Type of change

Please delete any options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods)
  • My changes generates no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

image image

Copy link
Collaborator

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

I have a few requests:

  • you currently have a paramerter to enable/disable filters via the query => this is not nessesary
  • Please use the vue-router's query attributes instead of URL on mount: https://vueschool.io/lessons/router-query-params
  • It might be better to look at if storing the filters only in the url might be benefitial
  • you currently have only the status being filtereable, please include the other filters too
    image

@CommanderStorm CommanderStorm marked this pull request as draft February 15, 2024 12:00
@CommanderStorm CommanderStorm added the question Further information is requested label Feb 15, 2024
@NihadBadalov

This comment has been minimized.

@CommanderStorm

This comment has been minimized.

@NihadBadalov

This comment has been minimized.

- Add URL filtering to the remaining filters
- Remove the required `filter=true` parameter
- Use vue-router instead of `URL`
@NihadBadalov
Copy link
Author

Added URL filtering to the remaining filters.
Removed the required filter=true parameter.
Using vue-router instead of URL.

Note that tags can be searched by their names and IDs. This means the following - considering the tag never-maint has an ID of 1, maint - 2 - are equal:

  • /dashboard/3?status=up&active=running,paused&tags=never-maint,maint
  • /dashboard/3?status=up&active=running,paused&tags=1,2

@NihadBadalov
Copy link
Author

@CommanderStorm Not sure I'll be able to do this but I'll give it a try anyway. How do you want this implemented? Everything gets read off the URL queries/parameters or the information gets still stored inside of a variable (filterState) but all the changes get reflected on the URL?

It might be better to look at if storing the filters only in the url might be benefitial

@CommanderStorm
Copy link
Collaborator

The current approach is run via the mounted-lifecycle hook.
While this may work, this is a bit cumbersome and also not reactive.
The current approach also has the downside (I think, would need to test) of slowing down site-loads => making it feel slower.

I would shift the whole state we store for the filters to the URL.
Currently, this state is store here:

filterState: {
status: null,
active: null,
tags: null,
}

@NihadBadalov

This comment was marked as resolved.

Copy link
Collaborator

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

Overall, this is coming along nicely 👍🏻

I have left a few comments where I think this PR can be simplified

src/components/MonitorList.vue Show resolved Hide resolved
src/components/MonitorList.vue Outdated Show resolved Hide resolved
src/components/MonitorListFilter.vue Outdated Show resolved Hide resolved
src/components/MonitorListFilter.vue Outdated Show resolved Hide resolved
);

return {
status: filters["status"] ? filters["status"].split(",") : [],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here you try to store the query as a comma separated string.
I think there is a simpler way, as vue-router seems to allow storing lists ⇒ should be able to retrieve it
https://stackoverflow.com/questions/50692081/vue-js-router-query-array

Is there a reason for this approach I am not seeing?

Copy link
Author

Choose a reason for hiding this comment

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

Didn't know that existed. Very nice, will rewrite that part for tags.

Copy link
Author

Choose a reason for hiding this comment

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

@CommanderStorm Do you want me to rewrite that for every filter? The current approach works well, is it not fine?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, please consider using the tools provided via the vue router instead of inventing a new way of storing lists.
This should significantly clean up the code ^^

src/components/MonitorListFilter.vue Outdated Show resolved Hide resolved
@NihadBadalov
Copy link
Author

Will get this done sometime this week

@NihadBadalov NihadBadalov marked this pull request as ready for review March 11, 2024 22:41
Copy link
Collaborator

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

I don't think, in the current state, another review makes sense.

Please refer to my review above. There are a lot of them which are not resolved
=> let's continue the discussion there.

src/lang/ru-RU.json Outdated Show resolved Hide resolved
@CommanderStorm CommanderStorm marked this pull request as draft March 12, 2024 02:57
@CommanderStorm CommanderStorm added the needs:work this PR needs work label May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:work this PR needs work question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support URL parameters so we can link directly to filtered dashboard view
2 participants