Skip to content

feat: add sorting to status pages #5766

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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

MarshuMax
Copy link

@MarshuMax MarshuMax commented Apr 11, 2025

This PR implements group and global sorting and searching features with corresponding UI improvements. Resolves #1936.

Features

  • Introduced global and group-level sorting with a status bar
  • Implemented global search functionality with improved logic
  • Added certificate expiration label and persistence of sorting state
  • Enhanced UI layout: background styling, component positioning
  • Performed language adaptation and canonical annotation cleanups

Additional Notes

  • A sorting option (ascending/descending) and search bar are now available both globally and within individual groups
  • Global sorting can be applied while also setting specific sorting rules for one or more selected groups

image

Closes #1936

- Add global/group sorting with status bar
- Implement global search functionality
- Adjust sort/search layout and positioning
- Add certificate expiration label support
- Apply language adaptation and background styling
- Add canonical annotations
@CommanderStorm
Copy link
Collaborator

Sorry, a +1.1k rewrite of one component implementing different features is not reviewable.
You will need to split this apart.

Looking at the screenshot:

  • From the UI side, this does not really fit into our existing style. Look at how buttons are rounded for exampe.
  • In terms of functionality, I think this is a bit too complex. This adds multiple search bars and multiple sorting options.

@CommanderStorm CommanderStorm requested a review from Copilot April 11, 2025 11:34
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • src/lang/en.json: Language not supported
  • src/lang/zh-CN.json: Language not supported
Comments suppressed due to low confidence (1)

src/pages/StatusPage.vue:778

  • The new monitor reordering logic would benefit from unit test coverage to ensure that monitors are ordered correctly under various heartbeat conditions.
if (!this.enableEditMode) {

@CommanderStorm CommanderStorm marked this pull request as draft April 12, 2025 10:54
@CommanderStorm CommanderStorm added the A:status-page Issues or PRs related to the status page label Apr 12, 2025
@MarshuMax MarshuMax force-pushed the sorting-and-search branch 2 times, most recently from 5564fc2 to 436ac1b Compare April 13, 2025 15:16
@MarshuMax
Copy link
Author

Hi @CommanderStorm ,

Thanks for the feedback!

Sorry, a +1.1k rewrite of one component implementing different features is not reviewable. You will need to split this apart.

I'll split the PR into smaller, more focused changes. I'll also add some necessary comments to make the logic clearer.

Looking at the screenshot:

  • From the UI side, this does not really fit into our existing style. Look at how buttons are rounded for exampe.

I'll update the UI to better match the existing style—thanks for pointing that out.

  • In terms of functionality, I think this is a bit too complex. This adds multiple search bars and multiple sorting options.

Do you have any suggestions regarding the sorting feature?
Also, would it still make sense to include a search function here, or do you think it's unnecessary?

I’ll revise the implementation based on your suggestions and follow up with updated PRs soon. Thanks again!

BR,
Marshu

@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Apr 15, 2025

I'd like to simplify this to one button on the top right (at the group level) with just sorting.
No search bar required

We could add it here (nicely out of the way) via a dropdown-button type interaction
image

Also note that the state for this should be an url query parameter
=> make it possible to share the exact sorting with others.

@MarshuMax
Copy link
Author

MarshuMax commented Apr 16, 2025

I'd like to simplify this to one button on the top right (at the group level) with just sorting. No search bar required

We could add it here (nicely out of the way) via a dropdown-button type interaction image

Ok, will remove the search functionality, and I believe what you're describing would work like this:
image

Also note that the state for this should be an url query parameter => make it possible to share the exact sorting with others.

I’d like to clarify a few points:

  1. Based on your description, it seems the sorting is group-level rather than global.
    Should we remove the global sorting then?

  2. Also, is it currently possible to share links with group-level sorting defined?
    If we want to show different sorting for each group, would the URL look something like this:
    group1_sort=name&group1_order=asc&group2_sort=uptime&group2_order=desc?

@CommanderStorm
Copy link
Collaborator

Based on your description, it seems the sorting is group-level rather than global.
Should we remove the global sorting then?

Yes, please do that. That has the addtional advantage of simplifies the PR ^^

Also, is it currently possible to share links with group-level sorting defined?
If we want to show different sorting for each group, would the URL look something like this:
group1_sort=name&group1_order=asc?

That sounds reasonable. Maybe sort_group1=name_asc since these are trigged by the same thing?
If simpler to implement the other way around, lets use your version, otherwise my.
That is hard bikeshedding theretorium.

@CommanderStorm
Copy link
Collaborator

you're describing would work like this

Yes, that is approximately what I was thinking about.
Maybe with an icon instead of text (more out of the way), but that is for you to decide what you like better.

@MarshuMax
Copy link
Author

MarshuMax commented Apr 19, 2025

Hi @CommanderStorm ,

Thank you for your suggestions. Based on your advice, I have made the following adjustments.

For the adjustments to the sorting

Removed the search functionality and global sorting. The group sorting options are now displayed through a dropdown button, as shown in the image below.
image

I replaced the "Sort by" text on the button with an upward arrow and a downward arrow. When no sorting option is selected, both arrows are gray. When the sorting is in ascending order, the upward arrow turns green; otherwise, the downward arrow turns green. Allow switching between ascending and descending order by clicking the already selected sorting attribute again.

Support for link-sharing of personal sorting

Implemented the link-sharing feature.
For example, I have two groups named group1 and group2. I defined the sorting rule for group1 as uptime in ascending order, and group2 as status in descending order. The link would be:
http://localhost:3000/status/guess?sort_group1=uptime_asc&sort_group2=status_desc.

When others visit this link, they will see the same sorting effects.
image

The current pull request is half the size of the original pull request, please check it when you have time. Thanks!

@CommanderStorm CommanderStorm added the pr:needs review this PR needs a review by maintainers or other community members label Apr 20, 2025
@MarshuMax MarshuMax marked this pull request as ready for review April 21, 2025 10:22
@CommanderStorm CommanderStorm changed the title feat: add group/global sorting and search with UI enhancements feat: add sorting to status pages May 7, 2025
@CommanderStorm CommanderStorm removed the pr:needs review this PR needs a review by maintainers or other community members label May 7, 2025
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.

Looks quite nicely.
I think this needs another round of polishing though.

The main bug is that the query part does not reflect the state..
image

I have commented in a few other places below too, but those should be minor

padding: 0.3rem 0.6rem;
min-width: 40px;
border-radius: 10px;
background-color: white;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks a bit off in the darkmode..
Could you make sure that the font is more readable?

image

We use variables to do this as far as I rememember.

<Editable v-model="group.element.name" :contenteditable="editMode" tag="span" data-testid="group-name" />
</div>

<div v-if="group.element && group.element.monitorList && group.element.monitorList.length > 1" class="sort-dropdown">
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like your atttention to detail 👍🏻
Most would have missed the monitorList.length > 1

</button>
<ul class="dropdown-menu dropdown-menu-end sort-menu" :aria-labelledby="'sortDropdown' + group.index">
<li>
<a class="dropdown-item sort-item" href="#" @click.prevent="setSort(group.element, 'status')">
Copy link
Collaborator

Choose a reason for hiding this comment

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

consider using a <button instead. Some accessibility tooling does interact poorly with <a href="#" as far as was reported to us.

For extra credits:
Add an aria-label or title (also appears for regular users on hover) what clicking this button does.

* @param {object} group object
* @returns {object|null} saved sorting settings
*/
getSavedSortSettings(group) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am a bit torn on this.
I think localStorage for this feature is not what I would like - I would like all state to be stored in the query exclusively.
Moving this to the query is also simpler from a code perspective..

Looking at the code below, you have a strong preference.
Is this something which you feel strongly about or would you be fine with using the query state instead?

Comment on lines +331 to +339

/**
* Get sort direction symbol
* @param {object} group object
* @returns {string} sort direction symbol
*/
getSortDirectionSymbol(group) {
return (group.sortDirection === "asc") ? "↑" : "↓";
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: not used in the code

Suggested change
/**
* Get sort direction symbol
* @param {object} group object
* @returns {string} sort direction symbol
*/
getSortDirectionSymbol(group) {
return (group.sortDirection === "asc") ? "↑" : "↓";
},

Comment on lines +525 to +526
handlePopState() {
this.loadSortSettingsFromURL();
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets inline this. Much readable what popstate does this way.

return;
}

const urlParams = new URLSearchParams(window.location.search);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the vue router already gives access to this.

Handling this manually seems like a lot of unnessesary work, especially in the reactivity department above.

I think the code would be much simpler if instead of hooking up events in the right places, we were to use a computed to sort and let vue handle the reactivity.

<Editable v-model="group.element.name" :contenteditable="editMode" tag="span" data-testid="group-name" />
</div>

<div v-if="group.element && group.element.monitorList && group.element.monitorList.length > 1" class="sort-dropdown">
Copy link
Collaborator

Choose a reason for hiding this comment

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

thinking about it, could you (if not, I am fine with this) move the code related to the PublicGroupListSortDropdown (horrible name, feel free to choose a different one) to its own component?

@CommanderStorm CommanderStorm added the pr:please address review comments this PR needs a bit more work to be mergable label May 7, 2025
@MarshuMax
Copy link
Author

Thanks for the review and detailed feedback! Just saw this I’ll go through the comments and update accordingly soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:status-page Issues or PRs related to the status page pr:please address review comments this PR needs a bit more work to be mergable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Status Page: Sort offline monitors at the top of the status page in 'offline' group
2 participants