-
Notifications
You must be signed in to change notification settings - Fork 22
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 DIY widget #1546
base: master
Are you sure you want to change the base?
Add DIY widget #1546
Conversation
This is the editor behind VSCode. It will help with features that allow users to edit code.
This library makes it easy to add dragging and resizing on any component.
This is a widget that runs bare Javascript code created by the user. It does nothing this the user writes the code. The idea with this widget is to allow people to add any type of functionality to Cockpit without actually knowing the Cockpit codebase previously. We expect a lot of cool stuff to come from this!
063fe88
to
8a190f7
Compare
Still reviewing the code, but for now, you can adjust some interface details:
|
Nice catches, thanks! |
Some suggestions that could be implemented on this first version:
Some suggestions to be implemented in further versions of the DIY widget:
|
<div ref="htmlEditorContainer" class="editor-container" /> | ||
<div ref="cssEditorContainer" class="editor-container" /> | ||
<div ref="jsEditorContainer" class="editor-container" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could switch the two last to match Vue pattern:
<div ref="htmlEditorContainer" class="editor-container" />
<div ref="jsEditorContainer" class="editor-container" />
<div ref="cssEditorContainer" class="editor-container" />
const handleDialogOpen = async (): Promise<void> => { | ||
await initEditor() | ||
} | ||
|
||
const handleDialogClose = async (): Promise<void> => { | ||
finishEditor() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not wrong, but would be nice to have standardized function names such as: 'handleCloseDialog' and 'handleOpenDialog'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, it works well. Just need to adjust some small interface stuff mentioned above.
Also would be nice to have a small guide on how to work with the data lake variables.
finishEditor() | ||
} | ||
|
||
const applyChanges = (): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned on the functionality review, a ctrl+enter shortcut for this apply function would be very handy.
This allows the users to create their own widget, with custom HTML+JS+CSS code.
The widget has access to the data-lake and actions APIs (as shown in the video), so one can create rich widgets that interact with the entire Cockpit ecosystem.
I'm using the Monaco editor here (the one VSCode is based on), and the editor window can be dragged to facilitate editing.
In the video I show a simple widget that consists on the memory used by Cockpit (consumed from the data-lake) that changes its color based on a threshold.
diywidget.mp4