Skip to content

Commit

Permalink
Product admin mode
Browse files Browse the repository at this point in the history
  • Loading branch information
goulven authored and goulven committed Dec 6, 2024
1 parent 1ddf8ea commit 4927feb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import org.open4goods.commons.services.VerticalsConfigService;
import org.open4goods.commons.services.ai.AiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.constraints.NotBlank;

/**
* This controller allows informations and communications about DatasourceConfigurations
Expand All @@ -41,7 +41,7 @@ public class ProductController {



@GetMapping(path="/product/")
@GetMapping(path="/product/", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary="Get a product from it's GTIN")
@PreAuthorize("hasAuthority('"+RolesConstants.ROLE_ADMIN+"')")
public Product get( @RequestParam final Long gtin) throws ResourceNotFoundException {
Expand Down
84 changes: 33 additions & 51 deletions ui/src/main/resources/templates/default/product.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,38 @@
<!-- Authenticated section -->
<th:block th:if="${user}">

<!-- Categories -->
<h1 class="text-center"> Mode admin</h1>
<div class="text-center">
<a target="_blank" th:text="'Source JSON de '+ ${product.gtin()}" th:href="'https://api.nudger.fr/product/?gtin='+${product.gtin()}"></a>
</div>
<!-- Categories
<th:block th:insert="~{inc/product-categories.html}"></th:block>

<!-- Unmatched Attribute table -->
<th:block th:insert="~{inc/product-unmatched-attributes.html}"></th:block>

<div class="card shadow mb-3 my-3">
<div class="card-header">
<h2 class="h5">Development Mode</h2>
</div>
<p>This section only appears to the Nudger team.</p>

<div class="card-body">

<h1 th:text="'taxonomy : ' + ${product.googleTaxonomyId}"></h1>

<!-- Resources -->
<th:block th:insert="~{inc/product-resources.html}"></th:block>

<!-- Mapped categories -->
-->



<!-- Offer names -->
<div class="row">
<div class="col-lg-12">
<div class="card shadow my-3">
<div class="card-header">
<h2 class="h5">Offernames</h2>
</div>
<div class="card-body">
<ul>
<li th:each="item, stat : ${product.offerNames}"
th:text="${item}"></li>
</ul>

</div>
</div>
</div>
</div>

<!-- Mapped categories -->
<div class="card shadow my-3">
<div class="card-header">
<h2 class="h5">Mapped Categories</h2>
<h2 class="h5">Categories</h2>
</div>
<div class="card-body">
<th:block th:each="item, stat : ${product.categoriesByDatasources}">
Expand All @@ -152,38 +161,11 @@ <h2 class="h5">Mapped Categories</h2>
</div>
</div>

</div>
</div>

<!-- The Raw JSON -->
<div class="card shadow my-3">
<div class="card-header">
<h2 class="h5">JSON</h2>
</div>
<div class="card-body">

<pre style="height: 500px">
<code id="json-output" class="json"></code>
</pre>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.10.0/highlight.min.js"></script>

<script th:inline="javascript">
/*<![CDATA[*/

const jsonObject = /*[[${raw}]]*/ '';

/*]]>*/

// Insert formatted JSON into the <code> element
document.getElementById('json-output').textContent = JSON.stringify(jsonObject, null, 2);

// Highlight the JSON
hljs.highlightAll();

</script>

</div>
</div>
<!-- Unmatched Attribute table -->
<th:block th:insert="~{inc/product-unmatched-attributes.html}"></th:block>
<!-- Resources -->
<th:block th:insert="~{inc/product-resources.html}"></th:block>

</th:block>

Expand Down

0 comments on commit 4927feb

Please sign in to comment.