mainsail-crew / mainsail

Mainsail is the popular web interface for managing and controlling 3D printers with Klipper.
https://docs.mainsail.xyz
GNU General Public License v3.0
1.74k stars 376 forks source link

feat(History): add option to show stats in different values #2007

Closed meteyou closed 3 weeks ago

meteyou commented 2 months ago

Description

This PR adds an option to switch the stats (circle or table) in the history page between amount, filament and time.

Related Tickets & Documents

fixes #1966

Mobile & Desktop Screenshots/Recordings

Circle Amount: image

Circle Filament: image

Circle Time: image

Table Amount: image

Table Filament: image

Table Time: image

[optional] Are there any post-deployment tasks we need to perform?

none

Summary by Sourcery

Introduce a feature to toggle the display of history statistics between different units (amount, filament, time) and refactor the code to improve maintainability by using a mixin for history statistics logic.

New Features:

Enhancements:

github-actions[bot] commented 2 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 0
meteyou commented 2 months ago

@sourcery-ai review

sourcery-ai[bot] commented 2 months ago

Reviewer's Guide by Sourcery

This pull request adds a new feature to the history page, allowing users to switch between different statistical views (amount, filament, time) for both the circle chart and table display. The implementation involves refactoring existing components, introducing a new mixin for shared logic, and updating the UI to include toggle buttons for the new options.

File-Level Changes

Change Details Files
Introduced a new HistoryStatsMixin to handle shared logic for history statistics
  • Created a new file 'src/components/mixins/historyStats.ts'
  • Implemented methods to process and format chart data
  • Added logic to group small entries for better data representation
src/components/mixins/historyStats.ts
Updated HistoryAllPrintStatusChart component to support multiple value types
  • Added a new prop 'valueName' to switch between amount, filament, and time
  • Updated chart options to format tooltip values based on the selected value type
  • Refactored the component to use the new HistoryStatsMixin
src/components/charts/HistoryAllPrintStatusChart.vue
Refactored HistoryAllPrintStatusTable component
  • Created a new HistoryAllPrintStatusTableItem component for individual table rows
  • Updated the table to use the new item component and support multiple value types
  • Integrated the HistoryStatsMixin for shared logic
src/components/charts/HistoryAllPrintStatusTable.vue
src/components/charts/HistoryAllPrintStatusTableItem.vue
Updated HistoryStatisticsPanel to include new toggle options
  • Added a new button group to switch between amount, filament, and time views
  • Updated child components to receive the selected value type
src/components/panels/HistoryStatisticsPanel.vue
Modified server history state types and getters
  • Added new fields 'valueFilament' and 'valueTime' to ServerHistoryStateAllPrintStatusEntry
  • Created a new type 'HistoryStatsValueNames' for the available value options
  • Removed redundant getters from the history store
src/store/server/history/types.ts
src/store/server/history/getters.ts
Updated localization files
  • Added new translations for 'Amount', 'Filament', and 'Time' in the History section
src/locales/en.json

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
meteyou commented 2 months ago

@sourcery-ai review

github-actions[bot] commented 2 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 0
github-actions[bot] commented 2 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 0
meteyou commented 2 months ago

@sourcery-ai review

github-actions[bot] commented 2 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 0
github-actions[bot] commented 2 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 0
github-actions[bot] commented 2 months ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 0
rackrick commented 3 weeks ago

@meteyou there still two pending comments. I would at least adjust the rounding before merging.

github-actions[bot] commented 3 weeks ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 0
github-actions[bot] commented 3 weeks ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 0
github-actions[bot] commented 3 weeks ago
Language file analysis report: File Missing Keys Unused Keys
en.json 0 0