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
feat: dockge set/update agent friendly name #414
base: master
Are you sure you want to change the base?
feat: dockge set/update agent friendly name #414
Conversation
Add the option to set a friendly name to a dockge remote agent. If the field is not used the `agent.url` will be displayed
Hey @cyril59310, thanks for your feedback. The translation can be added - for sure. Currently trying to refactor the code a bit to enable renaming - which seems more difficult as expected .. |
In the file
please add |
adding `Friendly Name` to en.json
allow updates and removal of `friendly name`
@cyril59310 point 2 of your request is now also done. Only need to update codebase and remove all debug options |
6529f6d
to
96b5205
Compare
adding the `friendlyname` option to the running and paused container
96b5205
to
8f142af
Compare
when create a new stack via UI the friendly name should also be displayed
Thanks again @cyril59310 . This is now also implemented |
Merge branch 'feat/dockge-agents-friendly-name' into feat/dockge-agents-friendly-name-editable
add a query to update the friendlyname correctly
remove edit-pen for controller which cannot have a friendlyname for now
Finally I was able to get the @larswmh maybe need help this time with syntaxing/linting issues for sqlite statement. Or even a better solution than a "hardcoded" query |
fix linting issues
fix tsc check by updating var type
remove if condition and update to proper values to prevent duplicates
1e688f8
to
dcc48d3
Compare
I made some suggestions in order to add translation keys for our translators. |
@@ -7,6 +7,7 @@ export async function up(knex: Knex): Promise<void> { | |||
table.string("url", 255).notNullable().unique(); | |||
table.string("username", 255).notNullable(); | |||
table.string("password", 255).notNullable(); | |||
table.string("friendlyname", 255); |
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.
This file cannot be modified. Have to create a new file.
Migration guide:
https://github.com/louislam/uptime-kuma/tree/master/db/knex_migrations
Also the naming convention, it should be friendly_name
.
Will come back later, as I would like to finish the next milestone of Uptime Kuma first.
*/ | ||
async add(url : string, username : string, password : string) : Promise<Agent> { | ||
async add(url : string, username : string, password : string, friendlyname : string) : Promise<Agent> { |
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.
Name Conventions
- Javascript/Typescript: camelCaseType
- SQLite: snake_case (Underscore)
- CSS/SCSS: kebab-case (Dash)
https://github.com/louislam/dockge/blob/master/CONTRIBUTING.md#name-conventions
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 feature!
Have some code feedback
*/ | ||
|
||
async update(friendlyname : string, updatedFriendlyName : string) { | ||
await R.exec("UPDATE agent SET friendlyname = " + updatedFriendlyName + " WHERE friendlyname = " + friendlyname + ""); |
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.
SQL injection vuln here - if name has quotes this will break.
You can use parameter bindings to build queries safely:
await R.exec("UPDATE agent SET friendlyname = ? WHERE friendlyname = ?", [
updatedFriendlyName,
friendlyname
]);
https://github.com/louislam/redbean-node/blob/master/docs/Query.md
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.
Instead of a raw query, you could utilize the redbean ORM methods. See: https://github.com/louislam/redbean-node/blob/master/docs/Create-Update-Bean.md
Something like this if by ID (primary key):
const agent = await R.load('agent', id);
agent.friendlyName = friendlyName;
await R.store(agent);
Or by URL:
const agent = await R.findOne('agent', ' url = ? ', [url]);
agent.friendlyName = friendlyName;
await R.store(agent);
* @param updatedFriendlyName | ||
*/ | ||
|
||
async update(friendlyname : string, updatedFriendlyName : string) { |
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.
I would consider accepting the agent's id
or the url
here for identifying the agent to update instead of friendly name.
ID is the primary key, so thats probably best to use for updating the agent. But URL is always set and has a unique constraint, so it will work too.
friendlyname: this.friendlyname, | ||
updatedFriendlyName: this.updatedFriendlyName |
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.
Why is updatedFriendlyName
also here on the model? Shouldn't just friendlyName
be sufficient?
Long time no see. Will have a look the next days on all your feedback. Many thanks 🙏🏻 |
https://github.com/louislam/dockge/blob/master/CONTRIBUTING.md
Tick the checkbox if you understand [x]:
Disclaimer
I am not a Software programmer and only have basic understandings on any Programming Languages used in the project, so please be patient and maybe assist me with further development of this feature
Description
Since
dockge agents
is still a beta feature and in the future maybe more and more remote instances will be added I wanted to enable the option for setting a friendly name for a remote instance. If the name is not set via the prompt. The defaultagent.url
will be displayedFixes #345
Type of change
New feature (non-breaking change which adds functionality)
My code follows the style guidelines of this project
I ran ESLint and other linters for modified files
I have performed a self-review of my own code and tested it
I have commented my code, particularly in hard-to-understand areas
(including JSDoc for methods)
My changes generate no new warnings
My code needed automated testing. I have added them (this is optional task)
Screenshots