Compare commits

...

12 commits
v1.1.25 ... dev

Author SHA1 Message Date
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
5c05df26cf fix(camera): btn refreshPhoto
All checks were successful
Build & Deploy on Dev / build (push) Successful in 2m23s
2026-05-25 15:49:56 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
ef5e6d9017 fix: startChecking onClickConfirm Dialog
All checks were successful
Build & Deploy on Dev / build (push) Successful in 2m47s
2026-05-21 09:00:40 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
049143a385 fix: fetchCheckTime fetchCheckStatus
All checks were successful
Build & Deploy on Dev / build (push) Successful in 2m20s
2026-05-20 17:25:06 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
ce97f7984a fix: Watch notification counter on socket
All checks were successful
Build & Deploy on Dev / build (push) Successful in 8m22s
2026-05-20 11:28:59 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
d4f53653d2 Merge branch 'develop' of https://github.com/Frappet/bma-ehr-checkin into develop
All checks were successful
Build & Deploy on Dev / build (push) Successful in 4m32s
2026-05-15 14:02:06 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
7afdc64e8f feat: noti checkin 2026-05-15 14:01:31 +07:00
526567c599 fixed camera error in ios 16.x
All checks were successful
Build & Deploy on Dev / build (push) Successful in 2m26s
2026-05-11 14:22:18 +07:00
58c1dfb5cc เพิ่มข้อความแจ้งเตือกรณีลืมลงเวลาออก
All checks were successful
Build & Deploy on Dev / build (push) Successful in 2m32s
2026-05-08 18:15:54 +07:00
9e69d33963 fix camera ios 18.x check inline page camera 2026-05-08 17:24:36 +07:00
30a8f01441 fix permission request & display photo center 2026-05-08 11:30:41 +07:00
92f9137cbb memory agent 2026-05-08 11:27:03 +07:00
9fde2b3984 Fix mobile photo capture fallbacks
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-08 11:13:39 +07:00
15 changed files with 1062 additions and 194 deletions

View file

@ -7,3 +7,8 @@
## Project Issues & Fixes ## Project Issues & Fixes
- [Position Orientation Change Fix](issue_position_orientation_change_fix.md) - Fix for position map not displaying on screen orientation changes - [Position Orientation Change Fix](issue_position_orientation_change_fix.md) - Fix for position map not displaying on screen orientation changes
- [Active Camera Scope](project_active_camera_scope.md) - Current camera issue work should stay in HomeView.vue, not legacy MapView.vue
- [Front Camera Preview Alignment](issue_front_camera_preview_alignment.md) - Keep popup preview orientation aligned with normalized saved photos
- [iOS Native Photo Mirroring](issue_ios_native_photo_mirroring.md) - Do not flip iOS native-capture photos during normalization
- [iOS Native Camera Popup](issue_ios_native_camera_popup_control.md) - Inline-first on iOS; native activates only after inline fails (prior native-first seed was reverted)
- [iOS 16 Inline White Preview](issue_ios16_inline_camera_white_preview.md) - Safari iOS 16 white preview needs single mount plus explicit video readiness

View file

@ -0,0 +1,11 @@
---
name: front_camera_preview_alignment
description: HomeView inline camera flow should show a non-mirrored preview and keep the saved/uploaded image in the same orientation the user saw while shooting
type: project
---
When fixing front-camera capture issues in `HomeView.vue`, keep the in-page preview and the final saved/uploaded image in the same non-mirrored orientation.
**Why:** Users rejected flows where the live in-page preview looked mirrored or differed from the final image. The expected behavior is “what I see while shooting is what gets used.”
**How to apply:** In the inline `simple-vue-camera` flow, avoid extra front-camera mirroring in either preview styling or snapshot normalization. Treat the in-page preview as the canonical orientation for `img`/`fileImg`.

View file

@ -0,0 +1,11 @@
---
name: ios16-inline-camera-white-preview
description: Safari iOS 16 inline preview can stay white when multiple simple-vue-camera instances mount and playback readiness is assumed too early
type: project
---
In `HomeView.vue`, Safari on iOS 16.x can show a white in-page camera preview when more than one `simple-vue-camera` instance is mounted for responsive layouts and the app treats `camera.start()` as sufficient proof that the preview is rendering.
**Why:** `simple-vue-camera` uses a hard-coded `id="video"` internally and does not explicitly call `video.play()` during `start()`. On mobile/xs, mounting both desktop and mobile camera components at once creates a fragile setup for Safari, where the active preview can remain white even though permission and stream startup succeeded.
**How to apply:** Keep only the active responsive camera instance mounted in `HomeView.vue`, and after `camera.start()` explicitly prepare/check the underlying video element (`playsinline`, `muted`, `play()`, non-zero dimensions, ready state). If the preview still does not become render-ready, remount once and then fall back to native capture.

View file

@ -0,0 +1,11 @@
---
name: ios_native_camera_popup_control
description: iOS uses inline camera first (same as Android); native fallback triggers only after inline fails. The prior "native-first on iOS" approach was reverted per product requirement.
type: project
---
In `HomeView.vue`, the inline camera is **always attempted first** on iOS (and every other platform). The hidden `<input type="file" capture="user">` is only activated by `switchToNativePhotoCapture()` / `enableNativePhotoCaptureFallback()` after inline capture is proven to fail.
**Why:** The product requirement is "use inline camera whenever the device supports inline capture; use native device capture only when inline is not supported or fails." iOS Safari supports `getUserMedia` since iOS 14.3, so inline-first is viable. A prior session hard-coded `useNativePhotoCapture = computed(() => isIOSDevice || preferNativePhotoCapture.value)`, bypassing inline on iOS entirely — that line was reverted.
**How to apply:** `preferNativePhotoCapture` must start `false` on all devices. Never seed it with `isIOSDevice`. All failure paths (`openCamera` permission denied, `camera.start()` throw, invalid snapshot blob, invalid image on submit) already call `switchToNativePhotoCapture()` which sets `preferNativePhotoCapture = true` so subsequent taps go directly to native — covering the first-tap fallback automatically.

View file

@ -0,0 +1,11 @@
---
name: ios_native_photo_mirroring
description: Native photo capture on iOS in HomeView should not be horizontally mirrored during normalization
type: project
---
For `HomeView.vue`, native photo capture on iOS should not apply horizontal mirroring during image normalization.
**Why:** The iOS fallback uses the native still-photo picker, and the returned photo can already be in the correct orientation. Applying the same mirror correction used for other front-camera paths flips the image incorrectly on iOS.
**How to apply:** Keep platform-specific normalization for native capture. Do not assume the iOS file-input photo path behaves the same as `simple-vue-camera` snapshots or Android fallback capture.

View file

@ -0,0 +1,11 @@
---
name: Active camera investigation scope
description: Current camera issue investigations should focus on HomeView.vue; the legacy Google Map MapView.vue flow is not in active use
type: project
---
Current camera issue work should focus on `HomeView.vue`; do not investigate or modify the legacy Google Map `MapView.vue` flow for this issue.
**Why:** The user clarified that `MapView.vue` is an older Google Map implementation from earlier work and is not the path currently used in production for this check-in flow.
**How to apply:** For follow-up debugging or fixes related to the current camera/upload issue, scope analysis and implementation to `HomeView.vue` unless the user explicitly re-opens `MapView.vue`.

View file

@ -34,6 +34,7 @@
"quasar": "^2.11.1", "quasar": "^2.11.1",
"register-service-worker": "^1.7.2", "register-service-worker": "^1.7.2",
"simple-vue-camera": "^1.1.3", "simple-vue-camera": "^1.1.3",
"socket.io-client": "^4.8.3",
"vite-plugin-pwa": "^0.16.7", "vite-plugin-pwa": "^0.16.7",
"vue": "^3.4.15", "vue": "^3.4.15",
"vue-router": "^4.1.6", "vue-router": "^4.1.6",

View file

@ -1,3 +1,12 @@
<script setup lang="ts">
import { onMounted } from 'vue'
import { useSocketStore } from '@/stores/socket'
onMounted(() => {
useSocketStore()
})
</script>
<template> <template>
<router-view /> <router-view />
</template> </template>

7
src/api/socket.ts Normal file
View file

@ -0,0 +1,7 @@
import env from "./index";
const socket = `${env.API_URI}/org-socket`;
export default {
socket,
};

View file

@ -4,6 +4,7 @@
import leave from '@/api/api.checkin' import leave from '@/api/api.checkin'
import history from '@/api/api.history' import history from '@/api/api.history'
import message from '@/api/api.message' import message from '@/api/api.message'
import socket from '@/api/socket'
const API = { const API = {
/**leave */ /**leave */
@ -12,6 +13,7 @@ const API = {
...history, ...history,
/**message */ /**message */
...message, ...message,
...socket,
} }
export default { export default {

View file

@ -163,8 +163,19 @@ function reattachAndResizeMap(retry = 0) {
mapView.value.container = activeContainer mapView.value.container = activeContainer
} }
// resize() method
try {
if (typeof mapView.value.resize === 'function') {
mapView.value.resize() mapView.value.resize()
}
} catch (error) {
console.warn('Map resize failed:', error)
}
if (typeof mapView.value.requestRender === 'function') {
mapView.value.requestRender?.() mapView.value.requestRender?.()
}
mapView.value mapView.value
.goTo( .goTo(
{ {
@ -285,7 +296,11 @@ async function initializeMap() {
geometry: userPoint, geometry: userPoint,
symbol: userSymbol, symbol: userSymbol,
}) })
// graphics
if (mapView.value && mapView.value.graphics && !mapView.value.destroyed) {
mapView.value.graphics.add(userGraphic) mapView.value.graphics.add(userGraphic)
}
// Get POI place server . // Get POI place server .
// await axios // await axios
// .get( // .get(
@ -381,12 +396,22 @@ async function initializeMap() {
geometry: poiPoint, geometry: poiPoint,
symbol: poiSymbol, symbol: poiSymbol,
}) })
// graphics goTo
if (mapView.value && !mapView.value.destroyed) {
if (mapView.value.graphics) {
mapView.value.graphics.add(poiGraphic) mapView.value.graphics.add(poiGraphic)
}
// POI // POI
if (typeof mapView.value.goTo === 'function') {
mapView.value.goTo({ mapView.value.goTo({
target: [userPoint, poiPoint], target: [userPoint, poiPoint],
zoom: zoomMap.value, zoom: zoomMap.value,
}).catch(() => {
// Ignore goTo errors
}) })
}
}
updateLocation(latitude, longitude, poiPlaceName.value) updateLocation(latitude, longitude, poiPlaceName.value)
}) })

View file

@ -1,52 +1,171 @@
import { useQuasar } from 'quasar' import { onBeforeUnmount, ref } from 'vue'
import { usePrivacyStore } from '@/stores/privacy' import { usePrivacyStore } from '@/stores/privacy'
type BrowserPermissionState = PermissionState | 'unsupported'
type PermissionQueryName = 'camera' | 'geolocation'
export function usePermissions() { export function usePermissions() {
const $q = useQuasar()
const privacyStore = usePrivacyStore() const privacyStore = usePrivacyStore()
const cameraPermissionState = ref<BrowserPermissionState>('prompt')
const locationPermissionState = ref<BrowserPermissionState>('prompt')
// const checkCameraPermission = (): boolean => { let cameraPermissionStatus: PermissionStatus | null = null
// if (!privacyStore.isAccepted) { let locationPermissionStatus: PermissionStatus | null = null
// privacyStore.modalPrivacy = true
// $q.notify({
// type: 'warning',
// message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งานกล้อง',
// position: 'top',
// })
// return false
// }
// return true
// }
// const checkLocationPermission = (): boolean => { const isPermissionsApiSupported = () =>
// if (!privacyStore.isAccepted) { typeof navigator !== 'undefined' && 'permissions' in navigator
// privacyStore.modalPrivacy = true
// $q.notify({ const setPermissionState = (
// type: 'warning', target: typeof cameraPermissionState | typeof locationPermissionState,
// message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งานแผนที่', state: BrowserPermissionState
// position: 'top', ) => {
// }) target.value = state
// return false }
// }
// return true const setPermissionChangeListener = (
// } name: PermissionQueryName,
status: PermissionStatus
) => {
status.onchange = () => {
const target =
name === 'camera' ? cameraPermissionState : locationPermissionState
setPermissionState(target, status.state)
}
}
async function queryPermissionState(name: PermissionQueryName) {
if (!isPermissionsApiSupported()) {
return null
}
try {
return await navigator.permissions.query({ name } as PermissionDescriptor)
} catch (error) {
return null
}
}
async function syncPermissionState(name: PermissionQueryName) {
const target =
name === 'camera' ? cameraPermissionState : locationPermissionState
const previousStatus =
name === 'camera' ? cameraPermissionStatus : locationPermissionStatus
if (previousStatus) {
previousStatus.onchange = null
}
const status = await queryPermissionState(name)
if (!status) {
if (target.value === 'prompt') {
setPermissionState(target, 'unsupported')
}
return
}
if (name === 'camera') {
cameraPermissionStatus = status
} else {
locationPermissionStatus = status
}
setPermissionState(target, status.state)
setPermissionChangeListener(name, status)
}
async function syncPermissionStates() {
await Promise.all([
syncPermissionState('camera'),
syncPermissionState('geolocation'),
])
}
const checkPrivacyAccepted = (): boolean => { const checkPrivacyAccepted = (): boolean => {
if (!privacyStore.isAccepted) { if (!privacyStore.isAccepted) {
privacyStore.modalPrivacy = true privacyStore.modalPrivacy = true
// $q.notify({
// type: 'warning',
// message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งาน',
// position: 'center',
// })
return false return false
} }
return true return true
} }
async function requestCameraPermission() {
if (!checkPrivacyAccepted()) {
return false
}
if (cameraPermissionState.value === 'granted') {
return true
}
if (!navigator.mediaDevices?.getUserMedia) {
setPermissionState(cameraPermissionState, 'unsupported')
return false
}
try {
const stream = await navigator.mediaDevices.getUserMedia({
video: { facingMode: 'user' },
audio: false,
})
stream.getTracks().forEach((track) => track.stop())
setPermissionState(cameraPermissionState, 'granted')
return true
} catch (error) {
setPermissionState(cameraPermissionState, 'denied')
return false
} finally {
await syncPermissionState('camera')
}
}
async function requestLocationPermission() {
if (!checkPrivacyAccepted()) {
return false
}
if (locationPermissionState.value === 'granted') {
return true
}
if (!navigator.geolocation) {
setPermissionState(locationPermissionState, 'unsupported')
return false
}
return new Promise<boolean>((resolve) => {
navigator.geolocation.getCurrentPosition(
async () => {
setPermissionState(locationPermissionState, 'granted')
await syncPermissionState('geolocation')
resolve(true)
},
async () => {
setPermissionState(locationPermissionState, 'denied')
await syncPermissionState('geolocation')
resolve(false)
}
)
})
}
onBeforeUnmount(() => {
if (cameraPermissionStatus) {
cameraPermissionStatus.onchange = null
}
if (locationPermissionStatus) {
locationPermissionStatus.onchange = null
}
})
return { return {
// checkCameraPermission, cameraPermissionState,
// checkLocationPermission, locationPermissionState,
checkPrivacyAccepted, checkPrivacyAccepted,
syncPermissionStates,
requestCameraPermission,
requestLocationPermission,
} }
} }

101
src/stores/socket.ts Normal file
View file

@ -0,0 +1,101 @@
import { ref } from 'vue'
import config from '@/app.config'
import { getToken } from '@/plugins/auth'
import { defineStore } from 'pinia'
import { Notify } from 'quasar'
import { io, Socket } from 'socket.io-client'
interface sockeBackup {
message: string
success?: boolean
}
export const useSocketStore = defineStore('socket', () => {
let socket: Socket
const notificationCounter = ref(0);
async function init() {
socket = io(new URL(config.API.socket).origin, {
auth: { token: await getToken() },
path: '/api/v1/org-socket',
})
socket.on('socket-notification', (payload) => {
let body: sockeBackup = JSON.parse(payload)
notificationCounter.value++
notifyStatus(body.message, body.success)
})
}
function notifyStatus(message: string, success?: boolean) {
Notify.create({
group: false,
type: success === undefined || success ? 'positive' : 'negative',
message: `${message}`,
position: 'top',
classes: 'custom-notification-top', // ใส่ class ที่เราสร้างไว้
timeout: success === undefined || success ? 3000 : 0,
actions:
success === undefined || success
? []
: [
{
icon: 'close',
color: 'white',
round: true,
},
],
progress: true,
})
}
function fnStyleNotiOrg() {
if (document.getElementById('notify-link-style')) return
const style = document.createElement('style')
style.id = 'notify-link-style'
style.textContent = `
.notify-link {
padding: 4px 8px;
border-radius: 4px;
text-decoration: none;
color: #fff;
border: 1px solid #fff;
transition: all 0.3s;
cursor: pointer;
margin:0 0 0 5px;
}
.notify-link:hover {
background-color: #ffffff;
color: #21BA45;
}
`
document.head.appendChild(style)
}
;(window as any).resetOrgPage = (type: string) => {
localStorage.setItem('org_type', type)
window.location.reload()
}
function notifyStatusOrg(type: string, message: string, success?: boolean) {
fnStyleNotiOrg()
Notify.create({
message: `${message} <a href="#" onclick="window.resetOrgPage('${type}')" class="notify-link">${
type == 'draft' ? 'ไปยังโครงสร้างแบบร่าง' : 'ไปยังโครงสร้างปัจจุบัน'
}</a>`,
html: true,
group: false,
type: success === undefined || success ? 'positive' : 'negative',
position: 'top',
timeout: 0,
actions: [
{
icon: 'close',
color: 'white',
round: true,
},
],
})
}
init()
return { notificationCounter }
})

View file

@ -100,7 +100,6 @@ $muti-tab: #87d4cc
.bg-muti-tab .bg-muti-tab
background: $muti-tab !important background: $muti-tab !important
/* editor */ /* editor */
.q-editor .q-editor
@ -122,7 +121,6 @@ $muti-tab: #87d4cc
margin-block-start: 0em margin-block-start: 0em
margin-block-end: 0em margin-block-end: 0em
.q-editor h3, .q-menu h3 .q-editor h3, .q-menu h3
font-size: 1.1rem font-size: 1.1rem
line-height: 1.5rem line-height: 1.5rem
@ -137,3 +135,6 @@ $muti-tab: #87d4cc
.q-tree .q-tree
color: #c8d3db color: #c8d3db
.custom-notification-top
margin-top: 180px !important

File diff suppressed because it is too large Load diff