Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few things in the Hibernate Search Dev UI #17769

Merged
merged 4 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class HibernateSearchElasticsearchDevConsoleProcessor {

@BuildStep(onlyIf = IsDevelopment.class)
public DevConsoleRuntimeTemplateInfoBuildItem collectBeanInfo() {
return new DevConsoleRuntimeTemplateInfoBuildItem("entityTypes", new HibernateSearchSupplier());
return new DevConsoleRuntimeTemplateInfoBuildItem("indexedEntityTypes", new HibernateSearchSupplier());
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="{urlbase}/entity-types" class="badge badge-light">
<i class="fa fa-search fa-fw"></i>
Indexed entity types <span class="badge badge-light">{info:entityTypes.size()}</span></a>
Indexed entity types <span class="badge badge-light">{info:indexedEntityTypes.size()}</span></a>
<br>
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,32 @@
<form method="post" enctype="application/x-www-form-urlencoded">
<input id="index" type="submit" class="btn btn-primary mb-2" value="Reindex Entities" >
<table id="table" class="table table-striped">
<colgroup>
<col span="1" style="width: 5%;">
<col span="1" style="width: 30%;">
<col span="1" style="width: 65%;">
</colgroup>
<thead class="thead-dark">
<tr>
<th scope="col">
<div class="custom-control">
<input type="checkbox" class="form-check-input" id="check-all">
</div>
</th>
<th scope="col">Entity name</th>
<th scope="col">Entity type</th>
</tr>
</thead>
<tbody>
{#for entityType in info:entityTypes}
{#for indexedEntityType in info:indexedEntityTypes}
<tr>
<td>
<div class="custom-control">
<input type="checkbox" class="form-check-input checkbox" name="{entityType}" id="{entityType}">
<input type="checkbox" class="form-check-input checkbox" name="{indexedEntityType.jpaName}" id="{indexedEntityType.jpaName}">
</div>
</td>
<td>{entityType}</td>
<td>{indexedEntityType.jpaName}</td>
<td>{indexedEntityType.javaClass}</td>
</tr>
{/for}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected void handlePostAsync(RoutingContext event, MultiMap form) throws Excep
}
SearchMapping mapping = HibernateSearchSupplier.searchMapping();
if (mapping == null) {
flashMessage(event, "There aren't any indexed entity types!", FlashScopeUtil.FlashMessageStatus.ERROR);
flashMessage(event, "There are no indexed entity types.", FlashScopeUtil.FlashMessageStatus.ERROR);
return;
}
mapping.scope(Object.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,37 @@
import org.hibernate.search.mapper.orm.mapping.SearchMapping;

import io.quarkus.arc.Arc;
import io.quarkus.hibernate.search.orm.elasticsearch.runtime.devconsole.HibernateSearchSupplier.DevUiIndexedEntity;

public class HibernateSearchSupplier implements Supplier<List<DevUiIndexedEntity>> {

public class HibernateSearchSupplier implements Supplier<List<String>> {
@Override
public List<String> get() {
public List<DevUiIndexedEntity> get() {
SearchMapping mapping = searchMapping();
if (mapping == null) {
return Collections.emptyList();
}
return mapping.allIndexedEntities().stream().map(SearchIndexedEntity::jpaName).sorted()
return mapping.allIndexedEntities().stream().map(DevUiIndexedEntity::new).sorted()
.collect(Collectors.toList());

}

public static SearchMapping searchMapping() {
return Arc.container().instance(SearchMapping.class).get();
}

public static class DevUiIndexedEntity implements Comparable<DevUiIndexedEntity> {

public final String jpaName;
public final String javaClass;

DevUiIndexedEntity(SearchIndexedEntity<?> searchIndexedEntity) {
this.jpaName = searchIndexedEntity.jpaName();
this.javaClass = searchIndexedEntity.javaClass().getName();
}

@Override
public int compareTo(DevUiIndexedEntity o) {
return this.jpaName.compareTo(o.jpaName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
{#insert style/}
</style>

<script src="{devRootAppend}/resources/js/jquery.min.js"></script>
<script src="{devRootAppend}/resources/js/bootstrap.bundle.min.js"></script>
<script src="{devRootAppend}/resources/js/dev-console.js"></script>

<title>
{#if currentExtensionName && currentExtensionName != 'Eclipse Vert.x - HTTP'}
{currentExtensionName} ›
Expand Down Expand Up @@ -100,10 +104,7 @@

{#include logmanagerModals}{/include}
{#include testsModals}{/include}

<script src="{devRootAppend}/resources/js/jquery.min.js"></script>
<script src="{devRootAppend}/resources/js/bootstrap.bundle.min.js"></script>
<script src="{devRootAppend}/resources/js/dev-console.js"></script>

<script src="{devRootAppend}/resources/js/logstream.js"></script>
<script src="{devRootAppend}/resources/js/tests.js"></script>

Expand Down