[task] migrate dashboard carousel to Swiper React by butterfly-520-boy · Pull Request #4427 · apache/hertzbeat · GitHub
Skip to content

[task] migrate dashboard carousel to Swiper React - #4427

Closed
butterfly-520-boy wants to merge 10 commits into
apache:masterfrom
butterfly-520-boy:codex/dashboard-swiper-1344
Closed

butterfly-520-boy wants to merge 10 commits into
apache:masterfrom
butterfly-520-boy:codex/dashboard-swiper-1344

Conversation

@butterfly-520-boy

@butterfly-520-boy butterfly-520-boy commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What's changed?

Show monitored categories in a responsive Swiper React carousel on the React dashboard. Read the existing /api/summary endpoint and aggregate each category's total, available, unavailable and paused counts.

  • Show 4, 2 or 1 cards according to the viewport, with navigation, rewind, autoplay and hover pause.
  • Preserve card geometry and status labels across summary refreshes.
  • Treat the backend's successful apps: null response as an empty list; malformed data and failed requests still show an error instead of invented counts.
  • Include Swiper 14.3.0's full MIT license and copyright notice in the distribution license files; remove obsolete jQuery/Slick entries and texts.

Closes #1344.

Validation

  • Dashboard regression suite: 35 tests pass. The empty-instance test failed before the API normalization fix.
  • Full TypeScript check and production build pass; scoped ESLint/Prettier, source conventions, CJK scan and bundle checks pass.
  • All original frontend gates passed in an isolated Linux environment with Node 22 and pnpm 10: toolchain and architecture contracts, dependency boundaries, full formatting/lint/typecheck, 1,053 unit-test files (8,873 tests), production build, bundle budget, dead-code and diff checks.
  • Human validation against the local 2.0 backend and production frontend: empty, one and six categories; navigation/autoplay; hover pause/resume; at least two minutes of refresh stability; responsive 4/2/1 layout and restoration.
pnpm exec vitest run src/features/dashboard
pnpm build

Checklist

  • I have read the Contributing Guide.
  • I have added the necessary regression tests.
  • I have updated the distribution license information.

Add or update API

No backend endpoint or API signature changes. The carousel consumes the existing summary API.

AI assistance: Codex assisted implementation and tests.

Human validation: the author tested the current local revision through the IDEA backend and production frontend preview.

Risk notes: full backend/release E2E tests were not run for this frontend change. The separate development-mode monitor import issue is tracked in #4452; manual import and carousel validation used the production preview.

@github-actions github-actions Bot added the webapp label Oct 5, 2026

@Duansg Duansg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the migration. Could you also update the distribution’s license files for Swiper?

The existing jQuery/Slick dependencies are listed in both material/licenses/frontend/LICENSE and material/licenses/LICENSE, with their license texts under material/licenses/frontend/.

Please add Swiper’s version and MIT license entry to those lists, and include its copyright notice and full license text in material/licenses/frontend/LICENSE-swiper.txt. If jQuery, slick-carousel, and ngx-slick-carousel are no longer bundled, please remove their obsolete entries and license files as well.

This will keep the license information aligned with what HertzBeat distributes.

@butterfly-520-boy

Copy link
Copy Markdown
Contributor Author

@Duansg Duansg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi, thanks for providing the additional information. However, I tested this PR and found that it didn't produce the expected results. This may be related to the Swiper initialization logic. Have you tested it locally to see if it works?

@Duansg

Duansg commented Oct 9, 2026

Copy link
Copy Markdown
Member

Hi, thanks for providing the additional information. However, I tested this PR and found that it didn't produce the expected results. This may be related to the Swiper initialization logic. Have you tested it locally to see if it works?

You might want to check this out: https://swiperjs.com/element#parameters-as-props

@butterfly-520-boy

Copy link
Copy Markdown
Contributor Author

Yes, the issue does exist. However, when I previously tested it locally, I didn't stay on the page for long, and the card displayed normally within a short period. The current problem is that over time, the card gradually expands from its normal width to span the entire row, and the status label on the right also disappears. I will identify the root cause and fix this bug. Thank you for pointing it out.

@butterfly-520-boy

Copy link
Copy Markdown
Contributor Author

Just like this.
屏幕截图 2026-10-09 161900
屏幕截图 2026-10-09 161818

@Duansg

Duansg commented Oct 9, 2026

Copy link
Copy Markdown
Member

Just like this.

@butterfly-520-boy You might want to try adding monitoring for multiple categories, since I've noticed that they aren't displayed in a carousel.

@butterfly-520-boy

Copy link
Copy Markdown
Contributor Author

Just like this.

@butterfly-520-boy You might want to try adding monitoring for multiple categories, since I've noticed that they aren't displayed in a carousel.

Okay, I’ll follow this approach to fix the issue

@butterfly-520-boy

butterfly-520-boy commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the pointers! I've fixed the Swiper initialization and the card-width issue after statistics refreshes.

I tested the carousel locally with six monitoring categories, and all 15 related tests pass.

The screenshots below show the updated carousel.

@butterfly-520-boy

butterfly-520-boy commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Here's the screenshot.
Image_1791553119844_618.png

@Duansg

Duansg commented Oct 10, 2026

Copy link
Copy Markdown
Member

pls check ci

Duansg
Duansg previously approved these changes Oct 11, 2026

@Duansg Duansg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@thefullgc

Copy link
Copy Markdown
Member

The Angular app this PR builds on (angular.json, app.module.ts, the dashboard component) was replaced by a React + Vite frontend in the 2.0 merge. Can't be merged — if we still want the carousel swap it needs to be rebuilt on the new dashboard.

@butterfly-520-boy butterfly-520-boy changed the title [task] migrate dashboard carousel to Swiper [task] migrate dashboard carousel to Swiper React Oct 13, 2026
@zqr10159

Copy link
Copy Markdown
Member

Thanks @butterfly-520-boy for the contribution, the React migration, and the work on tests and license compliance. The direction for HertzBeat 2.0 has changed: we will not retain the monitor-category card carousel on the dashboard, so this feature is no longer planned. We are closing this PR for that reason, rather than asking you to spend more time updating it.

For future contributions, please start from the latest master branch and check that the task still applies to the current UI. Thank you again for your time and patience!

@butterfly-520-boy

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] <Use swiperjs to instead of slickjs in dashboard ui card scroll>

4 participants