frontend icon indicating copy to clipboard operation
frontend copied to clipboard

Picture Elements Visual editor

Open karwosts opened this issue 1 year ago • 3 comments

Proposed change

A visual editor for picture elements card.

Possible enhancements:

  • [ ] Service call button could have a service control, but I'm not sure how targets/data/service_data fit together yet for this element, as the documentation only mentions service_data.
  • [ ] Confirm dialog when deleting an element (?)
  • [ ] Directly open the element editor after adding new element.
  • [ ] "Element Editor" heading could specify the element type.
  • [ ] Limited support for "custom" elements, which currently will force the entire thing to yaml-mode.

Early render:

picture-elements-2

More final styling:

image

Type of change

  • [ ] Dependency upgrade
  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [x] New feature (thank you!)
  • [ ] Breaking change (fix/feature causing existing functionality to break)
  • [ ] Code quality improvements to existing code or addition of tests

Example configuration


Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • [ ] The code change is tested and works locally.
  • [ ] There is no commented out code in this PR.
  • [ ] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

karwosts avatar Feb 07 '24 18:02 karwosts

Could be ready for a review.

karwosts avatar Feb 10 '24 01:02 karwosts

I've had a test run on your pull request and it makes the card easier to configure :+1: (even the yaml per element is great to have).

Some quick notes:

  • The elements miss the required fields. It would help to mark them as required everywhere where needed.
  • I couldn't get the conditional element to be added, it throws an error when you add it although it shows in the yaml.
  • The options are placed within an expansion panel probably to save some place. It feels like there may exist a better UI solution.

About service control:

service: fan.set_percentage
target:
  entity_id: fan.ceiling_fan
data:
  percentage: 100

would be equivalent to

service: fan.set_percentage 
service_data:
  entity_id: fan.ceiling_fan
  percentage: 100

silamon avatar Feb 14 '24 20:02 silamon

Thanks for giving it a spin 👍

I couldn't get the conditional element to be added, it throws an error when you add it although it shows in the yaml.

Good find, yeah I let a little bug slip in when modifying the string rendering, should be fixed now.

karwosts avatar Feb 14 '24 20:02 karwosts

The service call button could have a service control, would be a great thing to have here but it's double. There's no usable selector and the config needs to be tweaked to what the card wants. The others can be added if really needed imo.

silamon avatar May 06 '24 06:05 silamon

Walkthrough

Walkthrough

The updates enhance the configuration and usability of Lovelace elements in the Home Assistant UI. Key improvements include the addition of a getConfigElement method for editing element configurations, new functions for creating and managing picture elements, and expanded translation keys to support diverse element types. These changes collectively refine the editor experience and provide users with more customization options.

Changes

File Path Change Summary
src/panels/lovelace/elements/types.ts Added optional title property to various element configuration interfaces.
src/panels/lovelace/types.ts Introduced LovelaceElementConstructor and LovelacePictureElementEditor interfaces for enhanced editor functionality.
src/panels/lovelace/elements/hui-*.ts Added getConfigElement method and asserted _config.entity as non-null in state badge, state icon, and state label elements.
src/panels/lovelace/create-element/create-element-base.ts Updated constructor type in CreateElementConfigTypes interface for improved type safety.
src/panels/lovelace/create-element/create-picture-element.ts Introduced createPictureElementElement and getPictureElementClass functions for managing picture elements.
src/panels/lovelace/editor/hui-picture-elements-card-row-editor.ts Introduced HuiPictureElementsCardRowEditor class for managing picture elements in a card.
src/translations/en.json Introduced new translation keys for enhanced picture elements card functionality and editing options.
src/panels/lovelace/editor/hui-element-editor.ts Added LovelaceElementConfig to ConfigChangedEvent interface, expanding event handling capabilities.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

coderabbitai[bot] avatar Jul 13 '24 10:07 coderabbitai[bot]

I think there are some improvements to make UX wise, as you mentioned yourself in the PR description, but this is good start!

bramkragten avatar Jul 19 '24 15:07 bramkragten

  • [ ] Service call button could have a service control, but I'm not sure how targets/data/service_data fit together yet for this element, as the documentation only mentions service_data.

After #21440 is in, it will support target/data combination streamlined to other parts in Home Assistant. That should enable to show a service control component.

silamon avatar Jul 20 '24 08:07 silamon