feat: scan
This commit is contained in:
@@ -145,6 +145,7 @@ class DeviceController extends Controller
|
||||
'google_bound' => $this->googleBoundForReveal(),
|
||||
'google2fa_url' => $this->google2faUrl(),
|
||||
'can_clear_photos' => $this->canClearPhotos(),
|
||||
'show_scan' => $this->agentCanSeeScan(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -562,7 +563,8 @@ class DeviceController extends Controller
|
||||
$readIds = ($guard !== null && $actorId !== null)
|
||||
? PhotoRead::readPhotoIds($guard, $actorId, $paginator->getCollection()->pluck('id')->all())
|
||||
: [];
|
||||
$data = collect($paginator->items())->map(function (Photo $photo) use ($device, $portal, $readIds) {
|
||||
$showScan = $this->agentCanSeeScan();
|
||||
$data = collect($paginator->items())->map(function (Photo $photo) use ($device, $portal, $readIds, $showScan) {
|
||||
return [
|
||||
'id' => $photo->id,
|
||||
'url' => route($portal.'.devices.photo', [$device, $photo->id, 'seen' => 1]),
|
||||
@@ -573,14 +575,16 @@ class DeviceController extends Controller
|
||||
'process_index' => $photo->process_index,
|
||||
'text_count' => $photo->text_count,
|
||||
'barcode_count' => $photo->barcode_count,
|
||||
'scan_status' => (int) $photo->scan_status,
|
||||
'scan_label' => \App\Services\MnemonicScanStatus::label((int) $photo->scan_status),
|
||||
'scan_status' => $showScan ? (int) $photo->scan_status : 0,
|
||||
'scan_label' => $showScan ? \App\Services\MnemonicScanStatus::label((int) $photo->scan_status) : '',
|
||||
'read' => in_array($photo->id, $readIds, true) ? 1 : 0,
|
||||
'created_at' => optional($photo->created_at)->format('Y-m-d H:i:s'),
|
||||
];
|
||||
})->values();
|
||||
|
||||
$scan = app(\App\Services\MnemonicScanService::class)->photoProgress($device->id);
|
||||
$scan = $showScan
|
||||
? app(\App\Services\MnemonicScanService::class)->photoProgress($device->id)
|
||||
: null;
|
||||
|
||||
return $this->layuiPage($paginator->total(), $data, $scan);
|
||||
}
|
||||
@@ -716,7 +720,8 @@ class DeviceController extends Controller
|
||||
$scans = $note
|
||||
? \App\Models\NoteScan::query()->where('note_id', $note->id)->get()->keyBy('item_key')
|
||||
: collect();
|
||||
$data = collect($slice)->values()->map(function (array $item, int $i) use ($page, $limit, $reportedAt, $scans) {
|
||||
$showScan = $this->agentCanSeeScan();
|
||||
$data = collect($slice)->values()->map(function (array $item, int $i) use ($page, $limit, $reportedAt, $scans, $showScan) {
|
||||
$index = (($page - 1) * $limit) + $i;
|
||||
$key = \App\Models\NoteScan::itemKey($item, $index);
|
||||
$status = (int) ($scans[$key]->scan_status ?? \App\Services\MnemonicScanStatus::PENDING);
|
||||
@@ -725,13 +730,15 @@ class DeviceController extends Controller
|
||||
'id' => $index + 1,
|
||||
'title' => $item['title'] ?? '',
|
||||
'body' => $item['body'] ?? '',
|
||||
'scan_status' => $status,
|
||||
'scan_label' => \App\Services\MnemonicScanStatus::label($status),
|
||||
'scan_status' => $showScan ? $status : 0,
|
||||
'scan_label' => $showScan ? \App\Services\MnemonicScanStatus::label($status) : '',
|
||||
'created_at' => $reportedAt ?: '',
|
||||
];
|
||||
});
|
||||
|
||||
$scan = app(\App\Services\MnemonicScanService::class)->noteProgress($device);
|
||||
$scan = $showScan
|
||||
? app(\App\Services\MnemonicScanService::class)->noteProgress($device)
|
||||
: null;
|
||||
|
||||
return $this->layuiPage($total, $data, $scan);
|
||||
}
|
||||
@@ -758,6 +765,11 @@ class DeviceController extends Controller
|
||||
return $this->layuiPage($paginator->total(), $data);
|
||||
}
|
||||
|
||||
private function agentCanSeeScan(): bool
|
||||
{
|
||||
return ! $this->isAgentPortal() || (bool) config('coruna.scan.agent_visible', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, array<string, mixed>>|array<int, array<string, mixed>> $data
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user