feat: Enhance FaceAI functionality and improve login process
All checks were successful
Publish FaceAI Container / publish (push) Successful in 4m43s
All checks were successful
Publish FaceAI Container / publish (push) Successful in 4m43s
- Added a retry mechanism for page navigation in `live-site-test-utils.js` to handle transient errors during login. - Introduced a new function `performLiveLoginRequest` to handle login requests via API, improving the login flow. - Updated the login process to utilize the new API request method, ensuring a more robust authentication. - Implemented new utility functions in `rus-ecom-240621.js` for managing FaceAI state and filtering. - Created `faceai_photo_lookup.jsp` to handle photo lookups, returning JSON responses for better integration with the frontend. - Updated `faceai_return.php` to redirect users with appropriate parameters after FaceAI processing. - Modified `fotoCR.jsp` and `fotoCR-en.jsp` to include FaceAI photo IDs in the image elements for better tracking. - Enhanced the UI to display the number of matched photos dynamically based on FaceAI results.
This commit is contained in:
parent
6f191de115
commit
bba8026b7c
17 changed files with 1077 additions and 95 deletions
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/faceai_config.php';
|
||||
require_once __DIR__ . '/faceai_simulator_view.php';
|
||||
|
||||
$config = faceai_config();
|
||||
|
||||
|
|
@ -39,31 +38,28 @@ try {
|
|||
'token' => $token
|
||||
));
|
||||
$result = faceai_fetch_json($bridgeUrl);
|
||||
$returnUrl = (string) ($result['returnUrl'] ?? '');
|
||||
$matches = is_array($result['matches'] ?? null) ? $result['matches'] : array();
|
||||
$photos = array_map(static function ($match) {
|
||||
$photoId = (string) ($match['photoId'] ?? ($match['id'] ?? ''));
|
||||
|
||||
return array(
|
||||
'id' => $photoId,
|
||||
'photoId' => $photoId,
|
||||
'label' => (string) ($match['label'] ?? $photoId),
|
||||
'checkpoint' => (string) ($match['checkpoint'] ?? '-'),
|
||||
'previewUrl' => (string) ($match['previewUrl'] ?? ''),
|
||||
'score' => $match['score'] ?? null,
|
||||
);
|
||||
}, $matches);
|
||||
if ($returnUrl === '') {
|
||||
throw new RuntimeException('Missing legacy return URL.');
|
||||
}
|
||||
|
||||
faceai_sim_render_page(array(
|
||||
'raceId' => (string) ($result['raceId'] ?? ($payload['raceId'] ?? '')),
|
||||
'lang' => (string) ($result['lang'] ?? 'it'),
|
||||
'raceSlug' => (string) ($result['raceId'] ?? ($payload['raceId'] ?? '')),
|
||||
'raceName' => (string) ($result['raceName'] ?? ('Race ' . ($payload['raceId'] ?? ''))),
|
||||
'returnUrl' => (string) ($result['returnUrl'] ?? 'faceai_simulator.php'),
|
||||
'banner' => 'Vista filtrata da FaceAI. Sono state trovate <strong>' . count($photos) . '</strong> foto corrispondenti per l utente corrente.',
|
||||
'totalLabel' => count($photos) . ' foto da FaceAI',
|
||||
'photos' => $photos,
|
||||
'showSimulatorBootstrap' => false
|
||||
));
|
||||
$photoIds = array();
|
||||
foreach ($matches as $match) {
|
||||
$photoId = trim((string) ($match['photoId'] ?? ($match['id'] ?? '')));
|
||||
if ($photoId === '') {
|
||||
continue;
|
||||
}
|
||||
$photoIds[$photoId] = true;
|
||||
}
|
||||
|
||||
header('Location: ' . faceai_build_url($returnUrl, array(
|
||||
'faceaiMatchSource' => 'faceai',
|
||||
'faceaiMatchCount' => count($photoIds),
|
||||
'faceaiPhotoIds' => implode(',', array_keys($photoIds))
|
||||
)), true, 302);
|
||||
exit;
|
||||
} catch (Throwable $error) {
|
||||
faceai_render_message_page('Errore return FaceAI', $error->getMessage(), array(), 500);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue