Compare commits
4 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c05df26cf | ||
|
|
ef5e6d9017 | ||
|
|
049143a385 | ||
|
|
ce97f7984a |
3 changed files with 107 additions and 51 deletions
|
|
@ -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)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { ref } from 'vue'
|
||||||
import config from '@/app.config'
|
import config from '@/app.config'
|
||||||
import { getToken } from '@/plugins/auth'
|
import { getToken } from '@/plugins/auth'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
@ -10,6 +11,7 @@ interface sockeBackup {
|
||||||
|
|
||||||
export const useSocketStore = defineStore('socket', () => {
|
export const useSocketStore = defineStore('socket', () => {
|
||||||
let socket: Socket
|
let socket: Socket
|
||||||
|
const notificationCounter = ref(0);
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
socket = io(new URL(config.API.socket).origin, {
|
socket = io(new URL(config.API.socket).origin, {
|
||||||
|
|
@ -19,6 +21,7 @@ export const useSocketStore = defineStore('socket', () => {
|
||||||
|
|
||||||
socket.on('socket-notification', (payload) => {
|
socket.on('socket-notification', (payload) => {
|
||||||
let body: sockeBackup = JSON.parse(payload)
|
let body: sockeBackup = JSON.parse(payload)
|
||||||
|
notificationCounter.value++
|
||||||
notifyStatus(body.message, body.success)
|
notifyStatus(body.message, body.success)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -94,5 +97,5 @@ export const useSocketStore = defineStore('socket', () => {
|
||||||
|
|
||||||
init()
|
init()
|
||||||
|
|
||||||
return {}
|
return { notificationCounter }
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import {
|
||||||
import { useQuasar } from 'quasar'
|
import { useQuasar } from 'quasar'
|
||||||
import { format } from 'date-fns'
|
import { format } from 'date-fns'
|
||||||
import Camera from 'simple-vue-camera'
|
import Camera from 'simple-vue-camera'
|
||||||
|
import { storeToRefs } from 'pinia'
|
||||||
|
|
||||||
import config from '@/app.config'
|
import config from '@/app.config'
|
||||||
import http from '@/plugins/http'
|
import http from '@/plugins/http'
|
||||||
|
|
@ -18,6 +19,7 @@ import { useCounterMixin } from '@/stores/mixin'
|
||||||
import { usePermissions } from '@/composables/usePermissions'
|
import { usePermissions } from '@/composables/usePermissions'
|
||||||
import { usePrivacyStore } from '@/stores/privacy'
|
import { usePrivacyStore } from '@/stores/privacy'
|
||||||
import { usePositionKeycloakStore } from '@/stores/positionKeycloak'
|
import { usePositionKeycloakStore } from '@/stores/positionKeycloak'
|
||||||
|
import { useSocketStore } from '@/stores/socket'
|
||||||
|
|
||||||
import type { FormRef, OptionReason } from '@/interface/response/checkin'
|
import type { FormRef, OptionReason } from '@/interface/response/checkin'
|
||||||
|
|
||||||
|
|
@ -32,6 +34,8 @@ const {
|
||||||
syncPermissionStates,
|
syncPermissionStates,
|
||||||
requestCameraPermission,
|
requestCameraPermission,
|
||||||
} = usePermissions()
|
} = usePermissions()
|
||||||
|
const socketStore = useSocketStore()
|
||||||
|
const { notificationCounter } = storeToRefs(socketStore)
|
||||||
const privacyStore = usePrivacyStore()
|
const privacyStore = usePrivacyStore()
|
||||||
const positionKeycloakStore = usePositionKeycloakStore()
|
const positionKeycloakStore = usePositionKeycloakStore()
|
||||||
const MOCK_CHECK_DELAY_MS = 800
|
const MOCK_CHECK_DELAY_MS = 800
|
||||||
|
|
@ -634,19 +638,18 @@ async function fetchCheckStatus() {
|
||||||
/** inQueue เป็น true */
|
/** inQueue เป็น true */
|
||||||
isDisabledCheckTime.value = true
|
isDisabledCheckTime.value = true
|
||||||
msgCheckTime.value = 'ระบบกำลังประมวลผล'
|
msgCheckTime.value = 'ระบบกำลังประมวลผล'
|
||||||
if (intervalId.value === undefined) {
|
// if (intervalId.value === undefined) {
|
||||||
intervalId.value = setInterval(async () => {
|
// intervalId.value = setInterval(async () => {
|
||||||
try {
|
// try {
|
||||||
await fetchCheckStatus()
|
// await fetchCheckStatus()
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error('Error in interval fetchCheckStatus:', error)
|
// console.error('Error in interval fetchCheckStatus:', error)
|
||||||
// หยุด interval ถ้าเกิด error
|
// // หยุด interval ถ้าเกิด error
|
||||||
stopChecking()
|
// stopChecking()
|
||||||
}
|
// }
|
||||||
}, 3000)
|
// }, 3000)
|
||||||
console.log('startChecking called, intervalId:', intervalId.value)
|
// console.log('startChecking called, intervalId:', intervalId.value)
|
||||||
}
|
// }
|
||||||
// hideLoader()
|
|
||||||
} else {
|
} else {
|
||||||
/** inQueue เป็น false */
|
/** inQueue เป็น false */
|
||||||
isDisabledCheckTime.value = false
|
isDisabledCheckTime.value = false
|
||||||
|
|
@ -1248,6 +1251,11 @@ watch(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/** Watch notification counter on socket */
|
||||||
|
watch(notificationCounter, () => {
|
||||||
|
startChecking()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -1405,13 +1413,13 @@ watch(
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="cameraIsOn">
|
<div v-if="cameraIsOn && img == null">
|
||||||
<div
|
<div
|
||||||
v-if="$q.screen.gt.xs"
|
v-if="$q.screen.gt.xs"
|
||||||
class="absolute-bottom-right q-ma-md"
|
class="absolute-bottom-right q-ma-md"
|
||||||
>
|
>
|
||||||
<q-btn
|
<q-btn
|
||||||
v-if="availableCameras.length > 1 && img == null"
|
v-if="availableCameras.length > 1"
|
||||||
round
|
round
|
||||||
push
|
push
|
||||||
icon="flip_camera_ios"
|
icon="flip_camera_ios"
|
||||||
|
|
@ -1421,7 +1429,6 @@ watch(
|
||||||
@click="switchCamera"
|
@click="switchCamera"
|
||||||
/>
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
v-if="img == null"
|
|
||||||
round
|
round
|
||||||
push
|
push
|
||||||
icon="photo_camera"
|
icon="photo_camera"
|
||||||
|
|
@ -1429,8 +1436,41 @@ watch(
|
||||||
color="positive"
|
color="positive"
|
||||||
@click="capturePhoto"
|
@click="capturePhoto"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div
|
||||||
|
class="absolute-bottom text-subtitle2 text-center q-py-sm"
|
||||||
|
style="background: #00000021"
|
||||||
|
>
|
||||||
|
<q-btn
|
||||||
|
v-if="availableCameras.length > 1"
|
||||||
|
round
|
||||||
|
icon="flip_camera_ios"
|
||||||
|
size="16px"
|
||||||
|
style="background: #424242; color: white"
|
||||||
|
@click="switchCamera"
|
||||||
|
unelevated
|
||||||
|
class="q-mr-xs"
|
||||||
|
/>
|
||||||
|
<q-btn
|
||||||
|
round
|
||||||
|
icon="photo_camera"
|
||||||
|
size="18px"
|
||||||
|
style="background: #263238; color: white"
|
||||||
|
@click="capturePhoto"
|
||||||
|
unelevated
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Refresh button - shows when photo is captured regardless of camera state -->
|
||||||
|
<div v-if="img != null && !useNativePhotoCapture">
|
||||||
|
<div
|
||||||
|
v-if="$q.screen.gt.xs"
|
||||||
|
class="absolute-bottom-right q-ma-md"
|
||||||
|
>
|
||||||
<q-btn
|
<q-btn
|
||||||
v-else
|
|
||||||
round
|
round
|
||||||
push
|
push
|
||||||
icon="refresh"
|
icon="refresh"
|
||||||
|
|
@ -1445,31 +1485,12 @@ watch(
|
||||||
style="background: #00000021"
|
style="background: #00000021"
|
||||||
>
|
>
|
||||||
<q-btn
|
<q-btn
|
||||||
v-if="availableCameras.length > 1 && img == null"
|
|
||||||
round
|
|
||||||
icon="flip_camera_ios"
|
|
||||||
size="16px"
|
|
||||||
style="background: #424242; color: white"
|
|
||||||
@click="switchCamera"
|
|
||||||
unelevated
|
|
||||||
class="q-mr-xs"
|
|
||||||
/>
|
|
||||||
<q-btn
|
|
||||||
round
|
|
||||||
v-if="img == null"
|
|
||||||
icon="photo_camera"
|
|
||||||
size="18px"
|
|
||||||
style="background: #263238; color: white"
|
|
||||||
@click="capturePhoto"
|
|
||||||
unelevated
|
|
||||||
/>
|
|
||||||
<q-btn
|
|
||||||
v-else
|
|
||||||
round
|
round
|
||||||
icon="refresh"
|
icon="refresh"
|
||||||
size="18px"
|
size="18px"
|
||||||
style="background: #263238; color: white"
|
style="background: #263238; color: white"
|
||||||
@click="refreshPhoto"
|
@click="refreshPhoto"
|
||||||
|
unelevated
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1541,13 +1562,13 @@ watch(
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="cameraIsOn">
|
<div v-if="cameraIsOn && img == null">
|
||||||
<div
|
<div
|
||||||
class="absolute-bottom text-subtitle2 text-center q-py-sm"
|
class="absolute-bottom text-subtitle2 text-center q-py-sm"
|
||||||
style="background: #00000021"
|
style="background: #00000021"
|
||||||
>
|
>
|
||||||
<q-btn
|
<q-btn
|
||||||
v-if="availableCameras.length > 1 && img == null"
|
v-if="availableCameras.length > 1"
|
||||||
round
|
round
|
||||||
icon="flip_camera_ios"
|
icon="flip_camera_ios"
|
||||||
size="16px"
|
size="16px"
|
||||||
|
|
@ -1558,15 +1579,22 @@ watch(
|
||||||
/>
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
round
|
round
|
||||||
v-if="img == null"
|
|
||||||
icon="photo_camera"
|
icon="photo_camera"
|
||||||
size="18px"
|
size="18px"
|
||||||
style="background: #263238; color: white"
|
style="background: #263238; color: white"
|
||||||
@click="capturePhoto"
|
@click="capturePhoto"
|
||||||
unelevated
|
unelevated
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Refresh button - shows when photo is captured regardless of camera state -->
|
||||||
|
<div v-if="img != null && !useNativePhotoCapture">
|
||||||
|
<div
|
||||||
|
class="absolute-bottom text-subtitle2 text-center q-py-sm"
|
||||||
|
style="background: #00000021"
|
||||||
|
>
|
||||||
<q-btn
|
<q-btn
|
||||||
v-else
|
|
||||||
round
|
round
|
||||||
icon="refresh"
|
icon="refresh"
|
||||||
size="18px"
|
size="18px"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue