Skip to content

Commit

Permalink
Merge pull request #288 from WDAqua/fix_registration_for_questionansw…
Browse files Browse the repository at this point in the history
…ering_frontend

Fix registration for questionanswering frontend
  • Loading branch information
anbo-de authored Jul 18, 2024
2 parents 22389d6 + 29883b7 commit f03ec9b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion qanary_pipeline-template/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>qa.pipeline</artifactId>
<groupId>eu.wdaqua.qanary</groupId>
<version>3.9.2</version>
<version>3.9.3</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -15,6 +16,7 @@
import de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent;
import de.codecentric.boot.admin.server.notify.AbstractEventNotifier;
import eu.wdaqua.qanary.business.QanaryComponent;
import org.springframework.cache.annotation.Cacheable;
import reactor.core.publisher.Mono;

public class QanaryComponentRegistrationChangeNotifier extends AbstractEventNotifier {
Expand Down Expand Up @@ -45,22 +47,29 @@ protected Mono<Void> doNotify(InstanceEvent event, Instance instance) {
instance.getRegistration().getServiceUrl());
}
} else {
availableComponents.put(instanceName, null);
availableComponents.put(instanceName, instance);
}
} else {
logger.debug("Instance {} ({}) {}", instanceName, event.getInstance(), event.getType());
}
});
}

protected void addAvailableComponent(String instanceName, Instance instance) {
protected void addAvailableComponent(String instanceName, Instance instance) {
this.getAvailableComponents().put(instanceName, instance);
}

public List<String> getAvailableComponentNames() {
return new ArrayList<>(availableComponents.keySet());
}

@Cacheable(value = "availableComponents") // TODO: Handle changes ?
public Map<String, String> getComponentsAndAvailability(Map<String, Instance> availableComponents) {
Map<String,String> comps = availableComponents.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e->e.getValue().getStatusInfo().getStatus()));
logger.info("Comps: {}", comps);
return comps;
}

public Map<String, Instance> getAvailableComponents() {
return this.availableComponents;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public QanaryQuestionAnsweringController( //
* expose the model with the component names
*/
@ModelAttribute("componentList")
public List<String> componentList() {
logger.info("available components: {}", myComponentNotifier.getAvailableComponentNames());
return myComponentNotifier.getAvailableComponentNames();
public Map<String,String> componentList() {
logger.info("available components: {}", myComponentNotifier.getAvailableComponentNames());
return myComponentNotifier.getComponentsAndAvailability(myComponentNotifier.getAvailableComponents());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ <h2>Currently available Qanary components</h2>
<div id="componentfilterbox"><input title="filter components" type="text" id="componentfilterinput" onkeyup="filterComponentList()" name="componentfilterinput" placeholder="filter components"></div>
</div>
<ul id="sortable">
<li th:each="component : ${componentList}">
<input type="checkbox" name="componentlist[]" th:id="'componentlist'+${component}" th:value="${component}" />
<label th:for="'componentlist'+${component}" th:title="'activate '+${component}+' for the QA pipeline'" th:text="${component}" />
<span th:id="'annotationcount'+${component}"></span>
<li th:each="component : ${componentList}" th:style="'background-color: ' + (${component.value == 'OFFLINE'} ? '#999' : '')">
<input type="checkbox" name="componentlist[]" th:id="'componentlist'+${component.key}" th:value="${component.key}" th:attrappend="disabled=${component.value == 'OFFLINE' ? 'disabled' : null}"/>
<label th:for="'componentlist'+${component.key}" th:title="'activate '+${component.key}+' for the QA pipeline'" th:text="${component.key}" />
<span th:id="'annotationcount'+${component.key}"></span>
</li>
</ul>
</div>
</div>
</div>

0 comments on commit f03ec9b

Please sign in to comment.