platypush/platypush/backend/http/webapp/dist/static/js/5324.f88d40e4.js

2 lines
8.9 KiB
JavaScript

"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[5324],{5324:function(t,a,e){e.r(a),e.d(a,{default:function(){return pt}});var s=e(6252),n=e(9963);const i={class:"camera"},r={class:"camera-container"},l={class:"frame-container",ref:"frameContainer"},o={key:0,class:"no-frame"},c=["src"],h={class:"controls"},p={class:"left"},u=["disabled"],d=(0,s._)("i",{class:"fa fa-play"},null,-1),m=[d],g=["disabled"],_=(0,s._)("i",{class:"fa fa-stop"},null,-1),f=[_],y=["disabled"],w=(0,s._)("i",{class:"fas fa-camera"},null,-1),C=[w],v={class:"right"},b=(0,s._)("i",{class:"fas fa-volume-mute"},null,-1),S=[b],k=(0,s._)("i",{class:"fas fa-volume-up"},null,-1),z=[k],x=(0,s._)("i",{class:"fas fa-cog"},null,-1),$=[x],F={class:"audio-container"},U={key:0,autoplay:"",preload:"none",ref:"player"},M=["src"],D={key:0,class:"url"},V={class:"row"},q=(0,s._)("span",{class:"name"},"Stream URL",-1),P=["value"],A={class:"params"},L={class:"row"},O=(0,s._)("span",{class:"name"},"Device",-1),W={class:"row"},H=(0,s._)("span",{class:"name"},"Width",-1),j={class:"row"},G=(0,s._)("span",{class:"name"},"Height",-1),I={class:"row"},R=(0,s._)("span",{class:"name"},"Horizontal Flip",-1),T={class:"row"},Z=(0,s._)("span",{class:"name"},"Vertical Flip",-1),Y={class:"row"},E=(0,s._)("span",{class:"name"},"Rotate",-1),X={class:"row"},B=(0,s._)("span",{class:"name"},"Scale-X",-1),J={class:"row"},K=(0,s._)("span",{class:"name"},"Scale-Y",-1),N={class:"row"},Q=(0,s._)("span",{class:"name"},"Frames per second",-1),tt={class:"row"},at=(0,s._)("span",{class:"name"},"Grayscale",-1);function et(t,a,e,d,_,w){const b=(0,s.up)("Slot"),k=(0,s.up)("Modal");return(0,s.wg)(),(0,s.iD)("div",i,[(0,s._)("div",r,[(0,s._)("div",l,[t.streaming||t.capturing||t.captured?(0,s.kq)("",!0):((0,s.wg)(),(0,s.iD)("div",o,"The camera is not active")),(0,s._)("img",{class:"frame",src:t.url,ref:"frame",alt:""},null,8,c)],512),(0,s._)("div",h,[(0,s._)("div",p,[t.streaming?((0,s.wg)(),(0,s.iD)("button",{key:1,type:"button",onClick:a[1]||(a[1]=(...a)=>t.stopStreaming&&t.stopStreaming(...a)),disabled:t.capturing,title:"Stop video"},f,8,g)):((0,s.wg)(),(0,s.iD)("button",{key:0,type:"button",onClick:a[0]||(a[0]=(...t)=>w.startStreaming&&w.startStreaming(...t)),disabled:t.capturing,title:"Start video"},m,8,u)),t.streaming?(0,s.kq)("",!0):((0,s.wg)(),(0,s.iD)("button",{key:2,type:"button",onClick:a[2]||(a[2]=(...t)=>w.capture&&w.capture(...t)),disabled:t.streaming||t.capturing,title:"Take a picture"},C,8,y))]),(0,s._)("div",v,[t.audioOn?((0,s.wg)(),(0,s.iD)("button",{key:1,type:"button",onClick:a[4]||(a[4]=(...a)=>t.stopAudio&&t.stopAudio(...a)),title:"Stop audio"},z)):((0,s.wg)(),(0,s.iD)("button",{key:0,type:"button",onClick:a[3]||(a[3]=(...a)=>t.startAudio&&t.startAudio(...a)),title:"Start audio"},S)),(0,s._)("button",{type:"button",onClick:a[5]||(a[5]=a=>t.$refs.paramsModal.show()),title:"Settings"},$)])])]),(0,s._)("div",F,[t.audioOn?((0,s.wg)(),(0,s.iD)("audio",U,[(0,s._)("source",{src:`/sound/stream.aac?t=${(new Date).getTime()}`},null,8,M),(0,s.Uk)(" Your browser does not support audio elements ")],512)):(0,s.kq)("",!0)]),t.url?.length?((0,s.wg)(),(0,s.iD)("div",D,[(0,s._)("label",V,[q,(0,s._)("input",{name:"url",type:"text",value:w.fullURL,disabled:"disabled"},null,8,P)])])):(0,s.kq)("",!0),(0,s.Wm)(k,{ref:"paramsModal",title:"Camera Parameters"},{default:(0,s.w5)((()=>[(0,s._)("div",A,[(0,s._)("label",L,[O,(0,s.wy)((0,s._)("input",{name:"device",type:"text","onUpdate:modelValue":a[6]||(a[6]=a=>t.attrs.device=a),onChange:a[7]||(a[7]=(...a)=>t.onDeviceChanged&&t.onDeviceChanged(...a))},null,544),[[n.nr,t.attrs.device]])]),(0,s._)("label",W,[H,(0,s.wy)((0,s._)("input",{name:"width",type:"text","onUpdate:modelValue":a[8]||(a[8]=a=>t.attrs.resolution[0]=a),onChange:a[9]||(a[9]=(...a)=>t.onSizeChanged&&t.onSizeChanged(...a))},null,544),[[n.nr,t.attrs.resolution[0]]])]),(0,s._)("label",j,[G,(0,s.wy)((0,s._)("input",{name:"height",type:"text","onUpdate:modelValue":a[10]||(a[10]=a=>t.attrs.resolution[1]=a),onChange:a[11]||(a[11]=(...a)=>t.onSizeChanged&&t.onSizeChanged(...a))},null,544),[[n.nr,t.attrs.resolution[1]]])]),(0,s._)("label",I,[R,(0,s.wy)((0,s._)("input",{name:"horizontal_flip",type:"checkbox","onUpdate:modelValue":a[12]||(a[12]=a=>t.attrs.horizontal_flip=a),onChange:a[13]||(a[13]=(...a)=>t.onFlipChanged&&t.onFlipChanged(...a))},null,544),[[n.e8,t.attrs.horizontal_flip]])]),(0,s._)("label",T,[Z,(0,s.wy)((0,s._)("input",{name:"vertical_flip",type:"checkbox","onUpdate:modelValue":a[14]||(a[14]=a=>t.attrs.vertical_flip=a),onChange:a[15]||(a[15]=(...a)=>t.onFlipChanged&&t.onFlipChanged(...a))},null,544),[[n.e8,t.attrs.vertical_flip]])]),(0,s._)("label",Y,[E,(0,s.wy)((0,s._)("input",{name:"rotate",type:"text","onUpdate:modelValue":a[16]||(a[16]=a=>t.attrs.rotate=a),onChange:a[17]||(a[17]=(...a)=>t.onSizeChanged&&t.onSizeChanged(...a))},null,544),[[n.nr,t.attrs.rotate]])]),(0,s._)("label",X,[B,(0,s.wy)((0,s._)("input",{name:"scale_x",type:"text","onUpdate:modelValue":a[18]||(a[18]=a=>t.attrs.scale_x=a),onChange:a[19]||(a[19]=(...a)=>t.onSizeChanged&&t.onSizeChanged(...a))},null,544),[[n.nr,t.attrs.scale_x]])]),(0,s._)("label",J,[K,(0,s.wy)((0,s._)("input",{name:"scale_y",type:"text","onUpdate:modelValue":a[20]||(a[20]=a=>t.attrs.scale_y=a),onChange:a[21]||(a[21]=(...a)=>t.onSizeChanged&&t.onSizeChanged(...a))},null,544),[[n.nr,t.attrs.scale_y]])]),(0,s._)("label",N,[Q,(0,s.wy)((0,s._)("input",{name:"fps",type:"text","onUpdate:modelValue":a[22]||(a[22]=a=>t.attrs.fps=a),onChange:a[23]||(a[23]=(...a)=>t.onFpsChanged&&t.onFpsChanged(...a))},null,544),[[n.nr,t.attrs.fps]])]),(0,s._)("label",tt,[at,(0,s.wy)((0,s._)("input",{name:"grayscale",type:"checkbox","onUpdate:modelValue":a[24]||(a[24]=a=>t.attrs.grayscale=a),onChange:a[25]||(a[25]=(...a)=>t.onGrayscaleChanged&&t.onGrayscaleChanged(...a))},null,544),[[n.e8,t.attrs.grayscale]])]),(0,s.Wm)(b)])])),_:1},512)])}var st=e(8637),nt={name:"CameraMixin",mixins:[st.Z],props:{cameraPlugin:{type:String,required:!0}},data(){return{streaming:!1,capturing:!1,captured:!1,audioOn:!1,url:null,attrs:{}}},computed:{params(){return{resolution:this.attrs.resolution,device:this.attrs.device?.length?this.attrs.device:null,horizontal_flip:parseInt(0+this.attrs.horizontal_flip),vertical_flip:parseInt(0+this.attrs.vertical_flip),rotate:parseFloat(this.attrs.rotate),scale_x:parseFloat(this.attrs.scale_x),scale_y:parseFloat(this.attrs.scale_y),fps:parseFloat(this.attrs.fps),grayscale:parseInt(0+this.attrs.grayscale)}}},methods:{getUrl(t,a){return"/camera/"+t+"/"+a+"?"+Object.entries(this.params).filter((t=>null!=t[1]&&(""+t[1]).length>0)).map((([t,a])=>t+"="+a)).join("&")},_startStreaming(t){this.streaming||(this.streaming=!0,this.capturing=!1,this.captured=!1,this.url=this.getUrl(t,"video."+this.attrs.stream_format))},stopStreaming(){this.streaming&&(this.streaming=!1,this.capturing=!1,this.url=null)},_capture(t){this.capturing||(this.streaming=!1,this.capturing=!0,this.captured=!0,this.url=this.getUrl(t,"photo.jpg")+"&t="+(new Date).getTime())},onFrameLoaded(){this.capturing&&(this.capturing=!1)},onDeviceChanged(){},onFlipChanged(){},onSizeChanged(){const t=t=>t*Math.PI/180,a=t(this.params.rotate);let e=Math.round(this.params.scale_x*Math.abs(this.params.resolution[0]*Math.cos(a)+this.params.resolution[1]*Math.sin(a))),s=Math.round(this.params.scale_y*Math.abs(this.params.resolution[0]*Math.sin(a)+this.params.resolution[1]*Math.cos(a)));e>window.innerWidth&&(s=Math.round(s*(window.innerWidth/e)),e=window.innerWidth),s>window.innerHeight&&(e=Math.round(e*(window.innerHeight/s)),s=window.innerHeight),this.$refs.frameContainer.style.width=`${e}px`,this.$refs.frameContainer.style.height=`${s}px`},onFpsChanged(){},onGrayscaleChanged(){},startAudio(){this.audioOn=!0},async stopAudio(){this.audioOn=!1,await this.request("sound.stop_recording")}},created(){const t=this.$root.config[`camera.${this.cameraPlugin}`]||{};this.attrs={resolution:t.resolution||[640,480],device:t.device,horizontal_flip:t.horizontal_flip||0,vertical_flip:t.vertical_flip||0,rotate:t.rotate||0,scale_x:t.scale_x||1,scale_y:t.scale_y||1,fps:t.fps||16,grayscale:t.grayscale||0,stream_format:t.stream_format||"mjpeg"}},mounted(){this.$refs.frame.addEventListener("load",this.onFrameLoaded),this.onSizeChanged(),this.$watch((()=>this.attrs.resolution),this.onSizeChanged),this.$watch((()=>this.attrs.horizontal_flip),this.onSizeChanged),this.$watch((()=>this.attrs.vertical_flip),this.onSizeChanged),this.$watch((()=>this.attrs.rotate),this.onSizeChanged),this.$watch((()=>this.attrs.scale_x),this.onSizeChanged),this.$watch((()=>this.attrs.scale_y),this.onSizeChanged)}};const it=nt;var rt=it,lt=e(9417),ot={name:"Camera",components:{Modal:lt.Z},mixins:[rt],props:{cameraPlugin:{type:String,required:!0}},computed:{fullURL(){return`${window.location.protocol}//${window.location.host}${this.url}`}},methods:{startStreaming(){this._startStreaming(this.cameraPlugin)},capture(){this._capture(this.cameraPlugin)}}},ct=e(3744);const ht=(0,ct.Z)(ot,[["render",et]]);var pt=ht}}]);
//# sourceMappingURL=5324.f88d40e4.js.map