Skip to content

Commit

Permalink
tooltip on unmatched attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Goulven.Furet authored and Goulven.Furet committed Oct 19, 2023
1 parent 079fc74 commit 0caec17
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,47 @@ public class AggregatedAttribute implements IAttribute {
private Set<UnindexedKeyValTimestamp> sources = new HashSet<>();


/**
* Number of sources for this attribute
* @return
*/
public int sourcesCount() {
return sources.size();
}

/**
* The number of different values for this item
* @return
*/
public long distinctValues () {
return sources.stream().map(e-> e.getValue()).distinct().count();
}


public boolean hasConflicts() {
return distinctValues() > 1;
}

public String bgRow() {
String ret="table-default";
int sCount = sourcesCount();
long dValues = distinctValues();

if (sCount == 0) {
ret="table-danger";
} else if (sCount == 1) {
ret="table-default";
} else {
ret="table-info";
}

if (dValues > 1) {
ret = "table-danger";
}

return ret;
}

// TODO : Simple, but does not allow to handle conflicts, and so on
@Override
public int hashCode() {
Expand Down
2 changes: 2 additions & 0 deletions ui/src/main/resources/i18n/messages_fr.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
attribute.sourcing = {0} source(s) de donnée(s), {1} conflit(s)

ecoscore.WARRANTY.tooltip = La garantie est de {0} an(s).
ecoscore.DATA-QUALITY.tooltip = La qualité de la donnée est de {1} sur 5.
ecoscore.REPAIRABILITY_INDEX.tooltip = L''indice de réparabilité est de {0} sur 10 ({1}/5 en valeur relative).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div th:if="${product.attributes.unmapedAttributes.size()} > 0" class="card shadow my-3">
<div class="card-header"><h2 class="h5">Toutes les caractéristiques</h2></div>
<div class="card-body">
<table id="allAttributes" class="table table-striped" style="width: 100%">
<table id="allAttributes" class="table table-responsive" style="width: 100%">
<thead>
<tr>
<th>Nom</th>
Expand All @@ -10,10 +10,19 @@
</thead>
<tbody>

<tr th:each="attr : ${product.attributes.unmapedAttributes}">
<td><span th:text="${attr.name}"></span></td>
<td><span th:text="${attr.value}"></span> </td>
</tr>
<th:block th:each="attr : ${product.attributes.unmapedAttributes}">


<th:block th:with="sourcesCount = ${attr.sourcesCount()}, conflicts = ${attr.hasConflicts()}">
<tr th:class="${attr.bgRow()}" data-bs-toggle="tooltip" data-bs-placement="top" th:title="#{attribute.sourcing(${sourcesCount}, ${attr.distinctValues()})}">
<td><span th:text="${attr.name}"></span></td>
<td><span th:text="${attr.value}"></span> </td>
</tr>
</th:block>



</th:block>

</tbody>

Expand Down

0 comments on commit 0caec17

Please sign in to comment.