simple-ui: add poll-time to the TargetView's details (#2484)

This commit is contained in:
Mohamed Zenadi
2025-06-23 07:39:31 +02:00
committed by GitHub
parent 5a64bc6870
commit 8262fc05c6
2 changed files with 7 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ public interface Constants {
String CREATED_AT = "Created at";
String LAST_MODIFIED_BY = "Last modified by";
String LAST_MODIFIED_AT = "Last modified at";
String LAST_POLL = "Last Poll";
String SECURITY_TOKEN = "Security Token";
String ATTRIBUTES = "Attributes";

View File

@@ -344,6 +344,7 @@ public class TargetView extends TableView<MgmtTarget, String> {
private final TextField lastModifiedBy = Utils.textField(Constants.LAST_MODIFIED_BY);
private final TextField lastModifiedAt = Utils.textField(Constants.LAST_MODIFIED_AT);
private final TextField securityToken = Utils.textField(Constants.SECURITY_TOKEN);
private final TextField lastPoll = Utils.textField(Constants.LAST_POLL);
private final TextArea targetAttributes = new TextArea(Constants.ATTRIBUTES);
private transient MgmtTarget target;
@@ -354,7 +355,8 @@ public class TargetView extends TableView<MgmtTarget, String> {
description,
createdBy, createdAt,
lastModifiedBy, lastModifiedAt,
securityToken, targetAttributes)
securityToken, lastPoll, targetAttributes
)
.forEach(field -> {
field.setReadOnly(true);
add(field);
@@ -376,6 +378,9 @@ public class TargetView extends TableView<MgmtTarget, String> {
lastModifiedBy.setValue(target.getLastModifiedBy());
lastModifiedAt.setValue(new Date(target.getLastModifiedAt()).toString());
securityToken.setValue(target.getSecurityToken());
MgmtPollStatus pollStatus = target.getPollStatus();
lastPoll.setValue(new Date(pollStatus.getLastRequestAt()).toString());
final ResponseEntity<MgmtTargetAttributes> response = hawkbitClient.getTargetRestApi().getAttributes(target.getControllerId());
if (response.getStatusCode().is2xxSuccessful()) {
targetAttributes.setValue(Objects.requireNonNullElse(response.getBody(), Collections.emptyMap()).entrySet().stream()