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

Release 3.10.0 example project update #470

Merged
merged 1 commit into from
Sep 26, 2024
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
@@ -1,11 +1,14 @@
package com.yoti.docscan.demo.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import com.yoti.api.client.Media;
import com.yoti.api.client.docs.DocScanClient;
import com.yoti.api.client.docs.DocScanException;
import com.yoti.api.client.docs.session.create.CreateSessionResult;
import com.yoti.api.client.docs.session.devicemetadata.MetadataResponse;
import com.yoti.api.client.docs.session.retrieve.GetSessionResult;
import com.yoti.docscan.demo.service.DocScanService;

Expand All @@ -23,6 +26,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
Expand Down Expand Up @@ -68,8 +72,13 @@ public String getIndex(final Model model, HttpSession httpSession) {
}

@RequestMapping(value = "/success", method = RequestMethod.GET)
public String getUserSession(final Model model, HttpSession httpSession) {
String sessionId = (String) httpSession.getAttribute(DOC_SCAN_SESSION_ID);
public String getUserSession(@RequestParam(value = "sessionId") String sessionIdQueryParam, final Model model, HttpSession httpSession) {
String sessionId;
if (sessionIdQueryParam != null) {
sessionId = sessionIdQueryParam;
} else {
sessionId = (String) httpSession.getAttribute(DOC_SCAN_SESSION_ID);
}

if (sessionId == null || sessionId.equals("")) {
return "redirect:/";
Expand Down Expand Up @@ -117,6 +126,11 @@ public ResponseEntity<byte[]> getMedia(
return new ResponseEntity<>(media.getContent(), headers, HttpStatus.OK);
}

@RequestMapping(value = "/tracked-devices", method = RequestMethod.GET)
public @ResponseBody List<MetadataResponse> getTrackedDevices(@RequestParam(value = "sessionId") String sessionId) throws DocScanException {
return docScanService.getTrackedDevices(sessionId);
}

@RequestMapping(value = "/privacy-policy", method = RequestMethod.GET)
public String showPrivacyPolicyPage() {
return "privacy";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.yoti.docscan.demo.service;

import java.util.Arrays;
import java.util.List;

import com.yoti.api.client.Media;
import com.yoti.api.client.docs.DocScanClient;
Expand All @@ -22,6 +23,7 @@
import com.yoti.api.client.docs.session.create.objective.ProofOfAddressObjective;
import com.yoti.api.client.docs.session.create.task.RequestedIdDocTextExtractionTask;
import com.yoti.api.client.docs.session.create.task.RequestedSupplementaryDocTextExtractionTask;
import com.yoti.api.client.docs.session.devicemetadata.MetadataResponse;
import com.yoti.api.client.docs.session.retrieve.GetSessionResult;
import com.yoti.api.client.spi.remote.call.YotiConstants;

Expand Down Expand Up @@ -148,4 +150,8 @@ public String getIframeUrl(CreateSessionResult createSessionResult) {
public Media getMedia(String sessionId, String mediaId) throws DocScanException {
return docScanClient.getMediaContent(sessionId, mediaId);
}

public List<MetadataResponse> getTrackedDevices(String sessionId) throws DocScanException {
return docScanClient.getTrackedDevices(sessionId);
}
}
45 changes: 45 additions & 0 deletions examples/doc-scan/src/main/resources/templates/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,40 @@ <h5>Media</h5>
</div>
</div>

<!-- Expanded Document Fields -->
<div class="card" th:if="${document.getExpandedDocumentFields() != null}">
<div class="card-header" th:id="${'expanded-document-fields-' + iter.index}">
<h4 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse"
th:attr="data-target='#collapse-expanded-document-fields-' + ${iter.index}"
th:attrappend="aria-controls='collapse-expanded-document-fields-' + ${iter.index}"
aria-expanded="true">
Expanded Document Fields
</button>
</h4>
</div>
<div th:id="${'collapse-expanded-document-fields-' + iter.index}" class="collapse"
th:aria-labelledby="${'expanded-document-fields-' + iter.index}">
<div class="card-body">
<th:block th:if="${document.getExpandedDocumentFields().getMedia() != null}">
<h5>Media</h5>
<table class="table table-striped table-light">
<tbody>
<tr>
<td>ID</td>
<td>
<a th:href="${'/media?mediaId=' + document.getDocumentFields().getMedia().getId()}"
th:text="${document.getDocumentFields().getMedia().getId()}">
</a>
</td>
</tr>
</tbody>
</table>
</th:block>
</div>
</div>
</div>

<!-- Document ID Photo -->
<div class="card" th:if="${document.getDocumentIdPhoto() != null}">
<div class="card-header" th:id="${'document-id-photo-' + iter.index}">
Expand Down Expand Up @@ -1010,6 +1044,17 @@ <h4 class="mb-0">
</th:block>
</th:block>

<div class="row pt-4">
<div class="col">
<h2>
Tracked Devices
<a th:href="${'/tracked-devices?sessionId=' + sessionResult.getSessionId()}">
<span class="badge badge-success" th:href="${'/tracked-devices?sessionId=' + sessionResult.getSessionId()}" th:text="GET">
</span>
</a>
</h2>
</div>
</div>
</div>

<div th:replace="fragments/components :: footer"></div>
Expand Down