From 2e09fd99877c5cb16ac9819407d8cbd7a9bec4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20K=C3=B6ninger?= Date: Mon, 23 Dec 2024 16:15:28 +0100 Subject: [PATCH] feat(#1939): implement UI button to retrigger service detection (#3938) --- .../discovery/InstanceDiscoveryListener.java | 8 +++++- .../frontend/views/applications/i18n.de.json | 1 + .../frontend/views/applications/i18n.en.json | 1 + .../frontend/views/applications/index.vue | 14 +++++++++- .../config/AdminServerWebConfiguration.java | 8 +++--- .../server/web/ApplicationsController.java | 15 +++++++++-- .../web/client/RefreshInstancesEvent.java | 27 +++++++++++++++++++ 7 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/web/client/RefreshInstancesEvent.java diff --git a/spring-boot-admin-server-cloud/src/main/java/de/codecentric/boot/admin/server/cloud/discovery/InstanceDiscoveryListener.java b/spring-boot-admin-server-cloud/src/main/java/de/codecentric/boot/admin/server/cloud/discovery/InstanceDiscoveryListener.java index 1cda69fa7f1..fd4a2c5d8ab 100644 --- a/spring-boot-admin-server-cloud/src/main/java/de/codecentric/boot/admin/server/cloud/discovery/InstanceDiscoveryListener.java +++ b/spring-boot-admin-server-cloud/src/main/java/de/codecentric/boot/admin/server/cloud/discovery/InstanceDiscoveryListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2023 the original author or authors. + * Copyright 2014-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ import de.codecentric.boot.admin.server.domain.values.InstanceId; import de.codecentric.boot.admin.server.domain.values.Registration; import de.codecentric.boot.admin.server.services.InstanceRegistry; +import de.codecentric.boot.admin.server.web.client.RefreshInstancesEvent; /** * Listener for Heartbeats events to publish all services to the instance registry. @@ -105,6 +106,11 @@ public void onInstanceRegistered(InstanceRegisteredEvent event) { discover(); } + @EventListener + public void onRefreshInstances(RefreshInstancesEvent event) { + discover(); + } + @EventListener public void onParentHeartbeat(ParentHeartbeatEvent event) { discoverIfNeeded(event.getValue()); diff --git a/spring-boot-admin-server-ui/src/main/frontend/views/applications/i18n.de.json b/spring-boot-admin-server-ui/src/main/frontend/views/applications/i18n.de.json index 98dad65be8a..c24b046e14a 100644 --- a/spring-boot-admin-server-ui/src/main/frontend/views/applications/i18n.de.json +++ b/spring-boot-admin-server-ui/src/main/frontend/views/applications/i18n.de.json @@ -28,6 +28,7 @@ "status": "Status", "label": "Anwendungen", "shutdown": "Möchten Sie die Anwendung {name} herunterfahren?", + "refreshed": "Anwendungen wurden aktualisiert.", "restart": "Möchten Sie Anwendung {name} neu starten?", "restarted": "Die Anwendung wurde neu gestartet.", "unregister": "Möchten Sie die Anwendung {name} deregistrieren?", diff --git a/spring-boot-admin-server-ui/src/main/frontend/views/applications/i18n.en.json b/spring-boot-admin-server-ui/src/main/frontend/views/applications/i18n.en.json index bb795a3e599..8a0ae213ca4 100644 --- a/spring-boot-admin-server-ui/src/main/frontend/views/applications/i18n.en.json +++ b/spring-boot-admin-server-ui/src/main/frontend/views/applications/i18n.en.json @@ -32,6 +32,7 @@ "offline": "offline", "shutdown": "Shutdown application {name}?", "shutdown_successful": "Successfully shutdown application {name}.", + "refreshed": "Applications refreshed.", "restart": "Restart application {name}?", "restarted": "Successfully restarted application {name}.", "unregister": "Deregister application {name}?", diff --git a/spring-boot-admin-server-ui/src/main/frontend/views/applications/index.vue b/spring-boot-admin-server-ui/src/main/frontend/views/applications/index.vue index ec8f0057b31..71728ef925b 100644 --- a/spring-boot-admin-server-ui/src/main/frontend/views/applications/index.vue +++ b/spring-boot-admin-server-ui/src/main/frontend/views/applications/index.vue @@ -1,5 +1,5 @@