Port genPresets from WLED-MM
author [email protected]
Generate presets and playlists to act as demo mode or during testing
Summary by CodeRabbit
-
New Features
- Added buttons in the "Info" modal to generate and save presets.
- Introduced functionality to automatically create and display presets and playlists based on available effects.
- Enabled users to save the generated presets directly from the interface.
Walkthrough
New UI controls for generating and saving presets were added inside the "Info" modal in the HTML. Corresponding JavaScript functions were introduced to programmatically generate a presets JSON from existing effects, categorize them into playlists, display the JSON, and provide an option to save it by uploading to the server.
Changes
| Files | Change Summary |
|---|---|
| wled00/data/index.htm | Added "Generate presets" and "Save generated presets" buttons inside the "Info" modal, plus a hidden textarea for displaying generated JSON. |
| wled00/data/index.js | Added genPresets(), uploadFileWithText(), and savePresetsGen() functions to generate presets JSON, handle file upload, and save generated presets. |
📜 Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 0bc8be333caab40fd7e72f00dff7ad43912fc2b2 and affd6423e1ce8acc2847216948a95b951cfc6e88.
📒 Files selected for processing (1)
-
wled00/data/index.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- wled00/data/index.js
⏰ Context from checks skipped due to timeout of 90000ms (20)
- GitHub Check: wled_build / Build Environments (usermods)
- GitHub Check: wled_build / Build Environments (esp32_wrover)
- GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi)
- GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
- GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_opi)
- GitHub Check: wled_build / Build Environments (lolin_s2_mini)
- GitHub Check: wled_build / Build Environments (esp32_eth)
- GitHub Check: wled_build / Build Environments (esp32c3dev)
- GitHub Check: wled_build / Build Environments (esp01_1m_full_compat)
- GitHub Check: wled_build / Build Environments (esp32dev_V4)
- GitHub Check: wled_build / Build Environments (esp32dev)
- GitHub Check: wled_build / Build Environments (nodemcuv2_compat)
- GitHub Check: wled_build / Build Environments (esp01_1m_full_160)
- GitHub Check: wled_build / Build Environments (esp8266_2m_160)
- GitHub Check: wled_build / Build Environments (esp8266_2m_compat)
- GitHub Check: wled_build / Build Environments (nodemcuv2_160)
- GitHub Check: wled_build / Build Environments (esp01_1m_full)
- GitHub Check: wled_build / Build Environments (esp8266_2m)
- GitHub Check: wled_build / Build Environments (nodemcuv2)
- GitHub Check: wled_build / Test cdata.js
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>, please review it. -
Explain this complex logic. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai explain this code block. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read src/utils.ts and explain its main purpose. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -
@coderabbitai help me debug CodeRabbit configuration file.
-
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
is this a feature that is useful for "daily use" or mainly for debugging? Not fully clear to me from the code what it actually can do.
I would have preferred this as an external, uploadable file and not part of the standard build.
I would have preferred this as an external, uploadable file and not part of the standard build.
Hm, could it be implemented as a usermod? addToJsonInfo() permits script injection.
Generate presets and playlists to act as demo mode or during testing
Reading the description is more helpful than the code ;)
I would have preferred this as an external, uploadable file and not part of the standard build.
Hm, could it be implemented as a usermod? addToJsonInfo() permits script injection.
The issue with making a usermod is then you need to remember to add to every build
It serves many purposes, both for formal testing and also useful for users to get a feel of what is supported
e.g Want a playlist that has all the audio effects - you've got it, want a playlist that lets you see all the new PS effects, you've got it, wanting to run a soak test of all effects - you've got it
You get a playlist for each "type" of effect, 1D/2D/2F etc All 2D, AnimARTrix
Might be worth trying throwing it at copilot to see if it can refactor the JavaScript to make it more compact. As fewer WLED users use 2D than on MM night also be worth only creating the 2D items if you have a 2D setup
I would have preferred this as an external, uploadable file and not part of the standard build.
Hm, could it be implemented as a usermod? addToJsonInfo() permits script injection.
The issue with making a usermod is then you need to remember to add to every build
Yes, that's exactly the goal. If I'm understanding @blazoncek correctly, he's raising an objection to including this feature in all builds (presumably on space usage grounds). Putting it in a module makes it easy to exclude if space is tight and you don't need it for your application. Personally I'd be happy to include this as a module in the default module set for our reference build.
(Looking forward, I am still hoping to move any current core feature with a WLED_DISABLE_X option to a library module; call them "core mods" instead of "usermods", but the API is the same. The implication is that we'll have some list of core modules we include in standard builds, but allow modders with custom builds to enable/disable stuff cleanly via platformio_override.ini, and minimize/reduce the #ifdef spam in the code.)
Sorry for late reply. What I wanted to say is that IMO generation of presets from existing effects is not what a regular user needs.
So it does not belong into regular UI IMO.
Unfortunately we cannot have UI built in a similar fashion as object code with WLED_DISABLE_XXXX compile parameter for C++, so some other method is needed.
I'm also not sure if usermod is good way as it can't inject huge amount of text in info dialog.
Hey! This pull request has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs. Thank you for contributing to WLED! ❤️
Would making this an external but more elaborate tool be useful? The approach I have used in https://github.com/wled/WLED/pull/4982 allows to download and open a tool in one click and stores it in FS. Only downside is that it requires internet connection on the client device when first loading it.