Form changes Horizon - Upload Daily Field Work Photo
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m24s
Details
Specific Folder FTP Upload / ftp-deploy (push) Successful in 1m24s
Details
This commit is contained in:
parent
d9fa99e414
commit
de0ef5dcaa
|
|
@ -366,33 +366,47 @@
|
||||||
const photoInput = document.getElementById('field-upload_photo');
|
const photoInput = document.getElementById('field-upload_photo');
|
||||||
|
|
||||||
$('#start-photo-camera').on('click', async function () {
|
$('#start-photo-camera').on('click', async function () {
|
||||||
try {
|
try {
|
||||||
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
||||||
throw new Error('Camera access is not supported by this browser.');
|
throw new Error('Camera access requires HTTPS or localhost.');
|
||||||
}
|
}
|
||||||
|
|
||||||
photoStream = await navigator.mediaDevices.getUserMedia({
|
// This triggers the browser's native camera permission prompt
|
||||||
video: { facingMode: { ideal: 'environment' } },
|
photoStream = await navigator.mediaDevices.getUserMedia({
|
||||||
audio: false
|
video: { facingMode: { ideal: 'environment' } },
|
||||||
});
|
audio: false
|
||||||
|
});
|
||||||
|
|
||||||
video.srcObject = photoStream;
|
video.srcObject = photoStream;
|
||||||
video.style.display = 'block';
|
video.style.display = 'block';
|
||||||
preview.style.display = 'none';
|
preview.style.display = 'none';
|
||||||
|
|
||||||
$('#start-photo-camera').hide();
|
$('#start-photo-camera').hide();
|
||||||
$('#capture-photo').show();
|
$('#capture-photo').show();
|
||||||
$('#retake-photo').hide();
|
$('#retake-photo').hide();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Swal.fire({
|
console.error('Camera error:', error);
|
||||||
icon: 'error',
|
|
||||||
title: 'Camera Unavailable',
|
if (error.name === 'NotAllowedError' ||
|
||||||
text: 'Please allow camera access and try again.'
|
error.name === 'PermissionDeniedError') {
|
||||||
});
|
|
||||||
}
|
Swal.fire({
|
||||||
|
icon: 'warning',
|
||||||
|
title: 'Camera Permission Required',
|
||||||
|
text: 'Please allow camera access in your browser settings and click Open Camera again.'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Camera Unavailable',
|
||||||
|
text: 'Unable to access your camera. Please check your camera and try again.'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#capture-photo').on('click', function () {
|
$('#capture-photo').on('click', function () {
|
||||||
if (!photoStream || !video.videoWidth) {
|
if (!photoStream || !video.videoWidth) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue