Skip to content

Commit

Permalink
feat: dockge agent friendly name
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lohrbini committed Feb 1, 2024
1 parent 4a9173f commit c0fc76a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
5 changes: 4 additions & 1 deletion backend/agent-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ export class AgentManager {
* @param url
* @param username
* @param password
* @param friendlyname
*/
async add(url : string, username : string, password : string) : Promise<Agent> {
async add(url : string, username : string, password : string, friendlyname : string) : Promise<Agent> {
let bean = R.dispense("agent") as Agent;
bean.url = url;
bean.username = username;
bean.password = password;
bean.friendlyname = friendlyname;
await R.store(bean);
return bean;
}
Expand Down Expand Up @@ -276,6 +278,7 @@ export class AgentManager {
url: "",
username: "",
endpoint: "",
friendlyname: "",
};

for (let endpoint in list) {
Expand Down
1 change: 1 addition & 0 deletions backend/migrations/2023-12-20-2117-agent-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
table.boolean("active").notNullable().defaultTo(true);
});
}
Expand Down
1 change: 1 addition & 0 deletions backend/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class Agent extends BeanModel {
url: this.url,
username: this.username,
endpoint: this.endpoint,
friendlyname: this.friendlyname
};
}

Expand Down
2 changes: 1 addition & 1 deletion backend/socket-handlers/manage-agent-socket-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ManageAgentSocketHandler extends SocketHandler {
let data = requestData as LooseObject;
let manager = socket.instanceManager;
await manager.test(data.url, data.username, data.password);
await manager.add(data.url, data.username, data.password);
await manager.add(data.url, data.username, data.password, data.friendlyname);

// connect to the agent
manager.connect(data.url, data.username, data.password);
Expand Down
13 changes: 11 additions & 2 deletions frontend/src/pages/DashboardHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@
</template>

<!-- Agent Display Name -->
<span v-if="endpoint === ''">{{ $t("currentEndpoint") }}</span>
<a v-else :href="agent.url" target="_blank">{{ endpoint }}</a>
<template v-if="$root.agentStatusList[endpoint]">
<span v-if="endpoint === '' && agent.friendlyname === ''" class="badge bg-secondary me-2">Controller</span>
<span v-else-if="agent.friendlyname === ''" :href="agent.url">{{ endpoint }}</span>
<span v-else :href="agent.url">{{ agent.friendlyname }}</span>
</template>

<!-- Remove Button -->
<font-awesome-icon v-if="endpoint !== ''" class="ms-2 remove-agent" icon="trash" @click="showRemoveAgentDialog[agent.url] = !showRemoveAgentDialog[agent.url]" />
Expand Down Expand Up @@ -81,6 +84,11 @@
<input id="password" v-model="agent.password" type="password" class="form-control" required autocomplete="new-password">
</div>

<div class="mb-3">
<label for="friendlyname" class="form-label">{{ $t("Friendly Name") }}</label>
<input id="friendlyname" v-model="agent.friendlyname" type="text" class="form-control" optional>
</div>

<button type="submit" class="btn btn-primary" :disabled="connectingAgent">
<template v-if="connectingAgent">{{ $t("connecting") }}</template>
<template v-else>{{ $t("connect") }}</template>
Expand Down Expand Up @@ -126,6 +134,7 @@ export default {
url: "http://",
username: "",
password: "",
friendlyname: "",
}
};
},
Expand Down

0 comments on commit c0fc76a

Please sign in to comment.