feat: dockge agent friendly name

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
This commit is contained in:
stroskler 2024-02-01 07:18:52 +00:00 committed by stroskler
parent 4a9173f5dc
commit c0fc76a0c8
No known key found for this signature in database
GPG key ID: BFC1D7C45DD50847
5 changed files with 18 additions and 4 deletions

View file

@ -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;
}
@ -276,6 +278,7 @@ export class AgentManager {
url: "",
username: "",
endpoint: "",
friendlyname: "",
};
for (let endpoint in list) {

View file

@ -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);
});
}

View file

@ -23,6 +23,7 @@ export class Agent extends BeanModel {
url: this.url,
username: this.username,
endpoint: this.endpoint,
friendlyname: this.friendlyname
};
}

View file

@ -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);

View file

@ -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]" />
@ -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>
@ -126,6 +134,7 @@ export default {
url: "http://",
username: "",
password: "",
friendlyname: "",
}
};
},