File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.86bee2b1.js
Back
import{_ as u,A as h,r as p,o as r,b as c,c as f,j as g,d as i,t as m}from"./index.d09cba45.js";import{L as y}from"./Loading.10020070.js";const v={components:{Loading:y},data(){return{ipAddress:null,isTimingIn:!1,isTimingOut:!1,mediaStream:null,location:null,capturedImage:null}},async mounted(){this.startCamera(),this.getLocation(),await this.fetchIPAddress()},methods:{async startCamera(){try{const t=await navigator.mediaDevices.getUserMedia({video:!0});this.mediaStream=t,this.$refs.video&&(this.$refs.video.srcObject=t)}catch(t){console.error("Error accessing camera:",t)}},async capture(t){this.isTimingIn=!0;const e=this.$refs.video,s=this.$refs.canvas;s.width=e.videoWidth,s.height=e.videoHeight,s.getContext("2d").drawImage(e,0,0,s.width,s.height);const l=await new Promise(n=>s.toBlob(n,"image/jpeg")),o=URL.createObjectURL(l);this.capturedImage=o;const a=new Date;let d={employee_id:this.$store.userSettings.getActiveUser.employees?this.$store.userSettings.getActiveUser.employees.employee_id:"",time_keeping_id:this.$store.userSettings.getActiveUser.employees?this.$store.userSettings.getActiveUser.employees.employee_id:"",in_out:t=="in"?"I":"O",datetimelog:a.toISOString(),ip_address:this.ipAddress,latitude:this.location.latitude,longitude:this.location.longitude,image:o,type:"online"};this.saveRecord(d),this.isTimingIn=!1},async saveRecord(t){await h.createTITO(t).then(e=>{e.status==201&&this.$swal.fire({title:"Great!",text:"Record successfully saved.",icon:"success",timer:2e3})}).catch(e=>{console.log(e),e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},async timeOut(){this.isTimingOut=!0,await this.captureImage("time-out"),this.isTimingOut=!1},async fetchIPAddress(){try{const e=await(await fetch("https://api.ipify.org?format=json")).json();this.ipAddress=e.ip}catch(t){console.error("Error fetching IP address:",t)}},async captureImage(t){const e=this.$refs.video,s=this.$refs.canvas;s.width=e.videoWidth,s.height=e.videoHeight,s.getContext("2d").drawImage(e,0,0,s.width,s.height),await new Promise(l=>s.toBlob(l,"image/jpeg"))},getLocation(){navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{this.location={latitude:t.coords.latitude,longitude:t.coords.longitude}},t=>{console.error("Error getting location:",t)}):console.error("Geolocation is not supported by this browser.")},closeThis(){this.$emit("close")}},beforeDestroy(){this.mediaStream&&this.mediaStream.getTracks().forEach(t=>t.stop())}},x={class:"container w-full h-full p-4 bg-white rounded-lg shadow-lg flex flex-col items-center space-y-4"},w={class:"flex flex-col items-center space-y-2"},_={ref:"video",width:"320",height:"240",autoplay:"",class:"border border-gray-300 rounded-lg shadow-md"},b={ref:"canvas",style:{display:"none"}},I={key:1,class:"text-center"},T={class:"text-gray-600"},O={class:"text-gray-600"},C={key:2,class:"text-slate-500 italic p-4 animate-pulse"},L={key:3,class:"text-center"},k=["src"],A={class:"flex flex-wrap justify-center gap-3 mt-4"};function S(t,e,s,l,o,a){const d=p("Loading");return r(),c("div",x,[!o.location&&!o.ipAddress?(r(),f(d,{key:0,text:"Fetching record"})):g("",!0),e[5]||(e[5]=i("h1",{class:"text-3xl font-bold text-gray-800 mb-4"},"Online TITO",-1)),i("div",w,[i("video",_,null,512),i("canvas",b,null,512)]),o.location?(r(),c("div",I,[e[3]||(e[3]=i("h2",{class:"text-xl font-semibold text-gray-700 mt-4"},"Current Location:",-1)),i("p",T,"Latitude: "+m(o.location.latitude),1),i("p",O,"Longitude: "+m(o.location.longitude),1)])):(r(),c("div",C," Loading Location ... ")),o.capturedImage?(r(),c("div",L,[e[4]||(e[4]=i("h2",{class:"text-xl font-semibold text-gray-700 mb-2"},"Captured Image:",-1)),i("img",{src:o.capturedImage,alt:"Captured Image",class:"border border-gray-300 rounded-lg shadow-md"},null,8,k)])):g("",!0),i("div",A,[i("button",{onClick:e[0]||(e[0]=n=>a.capture("in")),class:"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg transition duration-300 ease-in-out"}," Time In "),i("button",{onClick:e[1]||(e[1]=n=>a.capture("out")),class:"bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded-lg transition duration-300 ease-in-out"}," Time Out "),i("button",{onClick:e[2]||(e[2]=(...n)=>a.closeThis&&a.closeThis(...n)),class:"bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded-lg transition duration-300 ease-in-out"}," Close ")])])}const U=u(v,[["render",S]]);export{U as O};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings