Skip to content
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

Add Vanilla JavaScript actions #1438

Merged

Conversation

rafaellehmkuhl
Copy link
Member

@rafaellehmkuhl rafaellehmkuhl commented Nov 6, 2024

With this, the user can create vanilla JavaScript methods that can be called from anywhere in the application.
This basically allows one to extend Cockpit capabilities to the infinite and beyond.

I also exposed the cockpit-actions and data-lake methods globally, so the user can call those from their functions. They are accessible under window.cockpit.

Once we merge the DIY widget, I will change the current v-text-field with a proper Monaco editor.

image

Fix #569

@rafaellehmkuhl rafaellehmkuhl force-pushed the add-free-javascript-actions branch 2 times, most recently from 29cd35c to 38ee5bb Compare November 10, 2024 22:16
@rafaellehmkuhl rafaellehmkuhl marked this pull request as ready for review November 10, 2024 22:17
Copy link
Contributor

@ArturoManzoli ArturoManzoli left a comment

Choose a reason for hiding this comment

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

Since there is no 'auto save', if the user is typing its code on the dialog and accidentally clicks on the backdrop, the dialog will close and all code will be lost.

Make the v-dialog persistent using a prop with this name, or make the text persistent on the 'JavaScript Code' input field.

Comment on lines +319 to 20
import JavascriptActionConfig from '@/components/configuration/JavascriptActionConfig.vue'
import MavlinkMessageActionConfig from '@/components/configuration/MavlinkMessageActionConfig.vue'
Copy link
Contributor

@ArturoManzoli ArturoManzoli Nov 11, 2024

Choose a reason for hiding this comment

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

Since you have made the atomization for the JavascriptActionConfig and MavlinkMessageActionConfig components, placing them inside src/components, I think would be nice to also do the same with the 'HTTP Request Actions' part on this template.

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitely! Will do that now.

This way free JavaScript functions, for example, can take advantage of them.
With this, the user can create vanilla JavaScript methods that can be called from anywhere in the application. This basically allows one to extend Cockpit capabilities to anything.
@ArturoManzoli ArturoManzoli merged commit a44a54e into bluerobotics:master Nov 12, 2024
10 checks passed
@rafaellehmkuhl rafaellehmkuhl deleted the add-free-javascript-actions branch November 21, 2024 01:25
@ES-Alexander ES-Alexander added the docs-needed Change needs to be documented label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-needed Change needs to be documented
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow arbitrary Javascript code to be called from Cockpit Actions
3 participants