PageSourceSearch

https://picockpit.com/dist/Kiosk-5189673b.js

js picockpit.com collected 2026-10-02 14:40:47 UTC 18,087 bytes, 1 lines download raw bytes

vendor: 1,624 bytes, line 1
1import{p as ae,aE as ne,aF as ie,ao as re,au as ce,a0 as le,b1 as ue,a1 as de,a2 as me,aM as he,a3 as fe,av as pe,ap as ve,b as E,R as $,i as be,q as ke,w as Y,T as ye,r as ge,c as Se,ab as we,o as Ce,ac as l,aA as _e,c1 as Te,az as Ue,O as A,n as Ve,J as Oe,b3 as L,b5 as v,b6 as d,b4 as p,b7 as f,ay as g,b8 as _,c2 as X,bA as B,bd as Pe,bG as xe,bz as Ne,bI as z,c3 as H,c4 as Ee,W as Ie,b9 as $e,bf as k,ae as O,ba as Ae,by as Le}from"./AppNotFound-05d3ab5c.js";import{m as I,k as Be,h as D}from"./Editor-b119a3ae.js";import{b as Je,u as Re,f as je,c as F,A as Ye}from"./AppOverview-0d398db3.js";import{V as De,u as Fe,s as M,a as Me,b as Xe}from"./GPIO-3f5cf0c9.js";function ze(e){const t=$(e);let s=-1;function o(){clearInterval(s)}function a(){o(),Ve(()=>t.value=e)}function n(i){const r=i?getComputedStyle(i):{transitionDuration:.2},c=parseFloat(r.transitionDuration)*1e3||200;if(o(),t.value<=0)return;const u=performance.now();s=window.setInterval(()=>{const y=performance.now()-u+c;t.value=Math.max(e-y,0),t.value<=0&&o()},c)}return Ce(o),{clear:o,time:t,start:n,reset:a}}const He=ae({multiLine:Boolean,text:String,timer:[Boolean,String],timeout:{type:[Number,String],default:5e3},vertical:Boolean,...ne({location:"bottom"}),...ie(),...re(),...ce(),...le(),...ue(Je({transition:"v-snackbar-transition"}),["persistent","noClickAnimation","scrim","scrollStrategy"])},"VSnackbar"),q=de()({name:"VSnackbar",props:He(),emits:{"update:modelValue":e=>!0},setup(e,t){let{slots:s}=t;const o=me(e,"modelValue"),{positionClasses:a}=he(e),{scopeId:n}=Re(),{themeClasses:i}=fe(e),{colorClasses:r,colorStyles:c,variantClasses:u}
1=pe(e),{roundedClasses:y}=ve(e),b=ze(Number(e.timeout)),S=E(),w=E(),x=$(!1),J=$(0),R=E(),W=be(De,void 0);ke(()=>!!W,()=>{const m=Fe();Oe(()=>{R.value=m.mainStyles.value})}),Y(o,U),Y(()=>e.timeout,U),ye(()=>{o.value&&U()});let N=-1;function U(){b.reset(),window.clearTimeout(N);const m=Number(e.timeout);if(!o.value||m===-1)return;const C=ge(w.value);b.start(C),N=window.setTimeout(()=>{o.value=!1},m)}function Q(){b.reset(),window.clearTimeout(N)}function Z(){x.value=!0,Q()}function ee(){x.value=!1,U()}function te(m){J.value=m.touches[0].clientY}function se(m){Math.abs(J.value-m.changedTouches[0].clientY)>50&&(o.value=!1)}const oe=Se(()=>e.location.split(" ").reduce((m,C)=>(m[`v-snackbar--${C}`]=!0,m),{}));return we(()=>{const m=F.filterProps(e),C=!!(s.default||s.text||e.text);return l(F,A({ref:S,class:["v-snackbar",{"v-snackbar--active":o.value,"v-snackbar--multi-line":e.multiLine&&!e.vertical,"v-snackbar--timer":!!e.timer,"v-snackbar--vertical":e.vertical},oe.value,a.value,e.class],style:[R.value,e.style]},m,{modelValue:o.value,"onUpdate:modelValue":V=>o.value=V,contentProps:A({class:["v-snackbar__wrapper",i.value,r.value,y.value,u.value],style:[c.value],onPointerenter:Z,onPointerleave:ee},m.contentProps),persistent:!0,noClickAnimation:!0,scrim:!1,scrollStrategy:"none",_disableGlobalStack:!0,onTouchstartPassive:te,onTouchend:se},n),{default:()=>{var V,j;return[_e(!1,"v-snackbar"),e.timer&&!x.value&&l("div",{key:"timer",class:"v-snackbar__timer"},[l(Te,{ref:w,color:typeof e.timer=="string"?e.timer:"info",max:e.timeout,"model-value":b.time.value},null)]),C&&l("div",{key:"content",class:"v-snackbar__content",role:"status","aria-live":"polite"},[((V=s.text)==null?void 0:V.call(s))??e.text,(j=s.default)==null?void 0:j.call(s)]),s.actions&&l(Ue,{defaults:{VBtn:{variant:"text",ripple:!1,slim:!0}}},{default:()=>[l("div",{class:"v-snackbar__actions"},[s.actions({isActive:o})])]})]},activator:s.activator})}),je({},S)}}),qe={data(){return{infoSnackbar:{show:!1,color:"success",text:"",timeout:-1}}},methods:{notify(e){const t={timeout:-1,color:"error",text:"missing error",show:!0};"color"in e&&(t.color=e.color),"text"in e&&(t.text=e.text),"timeout"in e&&(t.timeout=e.timeout*1e3),Object.assign(this.infoSnackbar,t),console.log("Notification:",t.color,t.text)}}};function Ge(e,t,s,o,a,n){return p(),v(q,{color:a.infoSnackbar.color,modelValue:a.infoSnackbar.show,"onUpdate:modelValue":t[1]||(t[1]=i=>a.infoSnackbar.show=i),timeout:a.infoSnackbar.timeout},{actions:d(()=>[l(g,{color:"white",onClick:t[0]||(t[0]=i=>a.infoSnackbar.show=!1)},{default:d(()=>[f(" mdi-close ")]),_:1})]),default:d(()=>[f(_(a.infoSnackbar.text)+" ",1)]),_:1},8,["color","modelValue","timeout"])}const Ke=L(qe,[["render",Ge]]);async function T(e){if(e.status!=200){const t=await e.json(),s=`${t.statusCode}: ${t.error}`;throw console.log(s),new Error(s)}}async function We(e){const t=e.tags.replaceAll(" ",""),s=await fetch(`/api/v2.0/system/client/${e._id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,tags:t==""?[]:t.split(","),description:e.description})});await T(s)}async function G(e){const t=await fetch(`/api/v2.0/system/client/configuration/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}});await T(t);let s=await t.json();return s.config==""?(console.log("Creating new default config for: ",e),K(e,""),G(e)):(s=s.config.replace(/'/g,'"'),JSON.parse(s))}async function K(e,t){let s;t===""?s="{'core':{'v1':{'update_hostname':false}},'apps':{'kiosk':{'v1':{'enable':true,'auto_start':false,'pages':[{'url':'https://buyzero.de','duration':45},{'url':'https://businessbreeze.net/','duration':30}]}},'webrtcvideo':{'v1':{'enable':false}}}}":s=JSON.stringify(t).replace(/"/g,"'");const o=`{"config": "${s}"}`;await fetch(`/api/v2.0/system/client/configuration/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:o})}async function Qe(){const e=await fetch("/api/v2.0/system/client/clients",{method:"GET",headers:{"Content-Type":"application/json"}});await T(e);let t=await e.json();for(let o of t)o.type="node";let s=[...t];return s=s.map(o=>({...o,tags:o.tags.join(",")})),s}async function Ze(e){const t=await fetch("/api/v2.0/system/client/set_active_clients",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:e})});await T(t)}async function et(e){const t=await fetch(`/api/v2.0/system/client/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});await T(t)}const tt=Object.freeze(Object.defineProperty({__proto__:null,deleteNode:et,getConfig:G,readNodes:Qe,updateActiveNodes:Ze,updateConfig:K,updateNode:We},Symbol.toStringTag,{value:"Module"}));class h{constructor(t,s,o){const a=new URL(t.replace("tf://","http://")).hostname;Date.now().toString(),this.nonce=this.genNonce(64);const n=`pi/${a}/com.picockpit/fetch/req`,i=`pi/${a}/com.picockpit/fetch/res`;return this.res_topic=I.subscribe(i,this.onResponse.bind(this)),o&&o.timeout&&(this.timeoutId=setTimeout(()=>{this.onResponse("TIMEOUT",{nonce:this.nonce,status:0,res:{headers:{},text:JSON.stringify({statusCode:0,message:"Call timed out."})}}),o.timeoutHandler&&o.timeoutHandler()},o.timeout)),console.log(`TF Req: ${t}`),this.req=I.send_message(n,{nonce:this.nonce,url:t,payload:s}),new Promise((r,c)=>{this.resolve=r,this.reject=c})}genNonce(t){const s="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let o="";for(let a=0;a<t;a++){const n=Math.floor(Math.random()*s.length);o+=s[n]}return o}onResponse(t,s){clearTimeout(this.timeoutId),s.nonce===this.nonce&&(s.error?this.reject(s.error):this.resolve({headers:{...s.res.headers,get:o=>s.res.headers[o.toLowerCase()]},status:s.res.status,text:()=>s.res.text,json:()=>JSON.parse(s.res.text)}),I.unsubscribe(this.res_topic))}}const st=e=>{const{touchstartX:t,touchendX:s,touchstartY:o,touchendY:a}=e,n=.5,i=16;e.offsetX=s-t,e.offsetY=a-o,Math.abs(e.offsetY)<n*Math.abs(e.offsetX)&&(e.left&&s<t-i&&e.left(e),e.right&&s>t+i&&e.right(e)),Math.abs(e.offsetX)<n*Math.abs(e.offsetY)&&(e.up&&a<o-i&&e.up(e),e.down&&a>o+i&&e.down(e))};function ot(e,t){var o;const s=e.changedTouches[0];t.touchstartX=s.clientX,t.touchstartY=s.clientY,(o=t.start)==null||o.call(t,{originalEvent:e,...t})}function at(e,t){var o;const s=e.changedTouches[0];t.touchendX=s.clientX,t.touchendY=s.clientY,(o=t.end)==null||o.call(t,{originalEvent:e,...t}),st(t)}function nt(e,t){var o;const s=e.changedTouches[0];t.touchmoveX=s.clientX,t.touchmoveY=s.clientY,(o=t.move)==null||o.call(t,{originalEvent:e,...t})}function it(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const t={touchstartX:0,touchstartY:0,touchendX:0,touchendY:0,touchmoveX:0,touchmoveY:0,offsetX:0,offsetY:0,left:e.left,right:e.right,up:e.up,down:e.down,start:e.start,move:e.move,end:e.end};return{touchstart:s=>ot(s,t),touchend:s=>at(s,t),touchmove:s=>nt(s,t)}}function rt(e,t){var r;const s=t.value,o=s!=null&&s.parent?e.parentElement:e,a=(s==null?void 0:s.options)??{passive:!0},n=(r=t.instance)==null?void 0:r.$.uid;if(!o||!n)return;const i=it(t.value);o._touchHandlers=o._touchHandlers??Object.create(null),o._touchHandlers[n]=i,X(i).forEac
1h(c=>{o.addEventListener(c,i[c],a)})}function ct(e,t){var n,i;const s=(n=t.value)!=null&&n.parent?e.parentElement:e,o=(i=t.instance)==null?void 0:i.$.uid;if(!(s!=null&&s._touchHandlers)||!o)return;const a=s._touchHandlers[o];X(a).forEach(r=>{s.removeEventListener(r,a[r])}),delete s._touchHandlers[o]}const lt={mounted:rt,unmounted:ct},_t=lt,ut={components:{Notifier:Ke},props:{icon:{type:String,default:"",required:!0},title:{type:String,default:"",required:!0}},i18n:{messages:{en:{offline:"Client is offline"},de:{offline:"Der Client ist offline"}}},computed:{...Be(["apps","piName","piSerial","piOnline","clientVersion"])},name:"appWrapper",methods:{getClientUUID(){return this.piSerial}}};function dt(e,t,s,o,a,n){const i=B("Notifier");return p(),v(z,{fluid:""},{default:d(()=>[Pe("h1",null,[l(g,{start:""},{default:d(()=>[f(_(s.icon),1)]),_:1}),f(" "+_(s.title),1)]),e.piOnline?Ne(e.$slots,"default",{key:1}):(p(),v(xe,{key:0,type:"warning"},{default:d(()=>[f(_(e.$t("offline")),1)]),_:1})),l(i,{ref:"notifier"},null,512)]),_:3})}const mt=L(ut,[["render",dt]]);function ht(e,t){const s=typeof e=="string"?B(e):e,o=ft(s,t);return{mounted:o,updated:o,unmounted(a){H(null,a)}}}function ft(e,t){return function(s,o,a){var b,S,w;const n=typeof t=="function"?t(o):t,i=((b=o.value)==null?void 0:b.text)??o.value??(n==null?void 0:n.text),r=Ee(o.value)?o.value:{},c=()=>i??s.innerHTML,u=(a.ctx===o.instance.$?(S=pt(a,o.instance.$))==null?void 0:S.provides:(w=a.ctx)==null?void 0:w.provides)??o.instance.$.provides,y=Ie(e,A(n,r),c);y.appContext=Object.assign(Object.create(null),o.instance.$.appContext,{provides:u}),H(y,s)}}function pt(e,t){const s=new Set,o=n=>{var i,r;for(const c of n){if(!c)continue;if(c===e)return!0;s.add(c);let u;if(c.suspense?u=o([c.ssContent]):Array.isArray(c.children)?u=o(c.children):(i=c.component)!=null&&i.vnode&&(u=o([(r=c.component)==null?void 0:r.subTree])),u)return u;s.delete(c)}return!1};if(!o([t.subTree]))throw new Error("Could not find original vnode");const a=Array.from(s).reverse();for(const n of a)if(n.component)return n.component;return t}const P=ht(Ye,e=>{var t;return{activator:"parent",location:((t=e.arg)==null?void 0:t.replace("-"," "))??"top",text:typeof e.value=="boolean"?void 0:e.value}}),vt={components:{AppWrapper:mt},props:{crud:{type:Object,default:()=>tt}},data(){return{addOrUpdate:!1,aouUrl:"",aouSec:"2",updIndex:null,urlsJson:"",autoStart:!1,browserParamsJson:"",availableBrowserParams:[],snackbar:{visible:!1,message:"",timeout:3e3},items:[{url:"https://picockpit.com/raspberry-pi/",seconds:"5"},{url:"https://pi3g.com",seconds:"5"},{url:"https://businessbreeze.de",seconds:"5"}],headers:[{title:"URL",value:"url"},{title:"Seconds",value:"seconds"},{title:"Actions",value:"actions",sortable:!1}]}},mounted:function(){this.getConfigOnLoad()},methods:{async getConfigOnLoad(){var e,t,s,o,a,n;try{const i=M.getters.clientId,r=await this.crud.getConfig(i),c=((s=(t=(e=r.apps)==null?void 0:e.kiosk)==null?void 0:t.v1)==null?void 0:s.pages)||[];this.items=c.map(u=>({url:u.url,seconds:u.duration.toString()})),this.autoStart=!!((n=(a=(o=r.apps)==null?void 0:o.kiosk)==null?void 0:a.v1)!=null&&n.auto_start)}catch(i){this.showSnackbar("Failed to load config: "+i.message)}},async updateConfig(){try{const e=M.getters.clientId,t=await this.crud.getConfig(e);t.apps.kiosk.v1.auto_start=this.autoStart,t.apps.kiosk.v1.pages=this.items.map(a=>({url:a.url,duration:parseInt(a.seconds,10)})),await this.crud.updateConfig(e,t);const s=this.$refs.kiosk.getClientUUID(),o=await new h(`tf://${s}/core/update_config`,{method:"POST"}).promise;this.showSnackbar("Config updated")}catch(e){this.showSnackbar("Failed to update config: "+e.message)}},showAddUpdUrl(){this.addOrUpdate=!0},addUrl(){this.addOrUpdate=!1,this.updIndex!=null?(this.items[this.updIndex].url=this.aouUrl,this.items[this.updIndex].seconds=this.aouSec,this.updIndex=null):this.items.push({url:this.aouUrl,seconds:this.aouSec})},updUrl(e,t){this.addOrUpdate=!0,this.aouUrl=e.url,this.aouSec=e.seconds,this.updIndex=t},delUrl(e,t){console.log(e,t),this.items.splice(t,1)},mvNext(e,t){if(t<this.items.length-1){const s=this.items[t+1];this.items.splice(t+1,1,this.items[t]),this.items.splice(t,1,s)}},mvPrev(e,t){if(t>0){const s=this.items[t-1];this.items.splice(t-1,1,this.items[t]),this.items.splice(t,1,s)}},async call(e,t={}){const s=this.$refs.kiosk.getClientUUID();
1new h(`tf://${s}/kiosk/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},{timeout:5e3})},slidesStart(){this.call("start",{action:"start",items:this.items})},slidesStop(){this.call("stop",{action:"stop"})},async startBrowser(e,t){try{const s=await new h(`tf://${t}/${e}/start-browser`,{method:"POST"}).promise;this.showSnackbar("Browser started successfully")}catch(s){this.showSnackbar("Failed to start the browser: "+s.message)}},async stopBrowser(e,t){try{const s=await new h(`tf://${t}/kiosk/stop-browser`,{method:"POST"}).promise;this.showSnackbar("Browser stopped successfully")}catch(s){this.showSnackbar("Failed to stop the browser: "+s.message)}},async startSlideshow(e,t){try{const s=await new h(`tf://${t}/${e}/start-slideshow`,{method:"POST"}).promise;this.showSnackbar("Slideshow started successfully")}catch(s){this.showSnackbar("Failed to start the slideshow: "+s.message)}},async stopSlideshow(e,t){try{const s=await new h(`tf://${t}/${e}/stop-slideshow`,{method:"POST"}).promise;this.showSnackbar("Slideshow stopped successfully")}catch(s){this.showSnackbar("Failed to stop the slideshow: "+s.message)}},async fetchUrls(){try{const e=await new h("tf://localhost:3000/get-urls",{method:"GET"}).promise;this.urlsJson=JSON.stringify(e,null,2)}catch(e){this.showSnackbar("Failed to fetch URLs: "+e.message)}},async fetchBrowserParams(){try{const e=await new h("tf://localhost:3000/get-browser-params",{method:"GET"}).promise;this.browserParamsJson=JSON.stringify(e,null,2)}catch(e){this.showSnackbar("Failed to fetch browser params: "+e.message)}},async fetchAvailableBrowserParams(){try{const e=await new h("tf://localhost:3000/get-available-browser-params",{method:"GET"}).promise;this.availableBrowserParams=e}catch(e){this.showSnackbar("Failed to fetch available browser params: "+e.message)}},async updateUrls(){try{const e=JSON.parse(this.urlsJson);await new h("tf://localhost:3000/set-urls",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newUrls:e})}).promise,this.showSnackbar("URLs updated successfully")}catch(e){this.showSnackbar("Failed to update URLs: "+e.message)}},async updateBrowserParams(){try{const e=JSON.parse(this.browserParamsJson);await new h("tf://localhost:3000/set-browser-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newParams:e})}).promise,this.showSnackbar("Browser params updated successfully")}catch(e){this.showSnackbar("Failed to update browser params: "+e.message)}},showSnackbar(e){this.snackbar.message=e,this.snackbar.visible=!0}}},bt={key:0,class:"d-flex justify-end ga-4"};function kt(e,t,s,o,a,n){const i=B("AppWrapper");return p(),v(i,{ref:"kiosk",icon:"mdi-storefront",title:"Kiosk"},{default:d(()=>[l(z,null,{default:d(()=>[l($e,{class:"ga-3 mb-4 mt-10"},{default:d(()=>[l(k,{onClick:n.slidesStart,text:"Start Slideshow"},null,8,["onClick"]),l(k,{onClick:n.slidesStop,text:"Stop Slideshow"},null,8,["onClick"]),l(k,{onClick:n.showAddUpdUrl,text:"Add URL",color:"primary"},null,8,["onClick"])]),_:1}),l(Me,{modelValue:a.autoStart,"onUpdate:modelValue":t[0]||(t[0]=r=>a.autoStart=r),label:"Auto Start Slideshow on Boot"},null,8,["modelValue"]),l(Xe,{items:a.items,headers:a.headers},{"item.actions":d(({item:r,index:c})=>[O((p(),v(g,{size:"small",onClick:u=>n.mvPrev(r,c)},{default:d(()=>[f(" mdi-menu-up ")]),_:2},1032,["onClick"])),[[P,"Move Up"]]),O((p(),v(g,{size:"small",onClick:u=>n.mvNext(r,c)},{default:d(()=>[f(" mdi-menu-down ")]),_:2},1032,["onClick"])),[[P,"Move Down"]]),O((p(),v(g,{size:"small",onClick:u=>n.updUrl(r,c)},{default:d(()=>[f(" mdi-pencil ")]),_:2},1032,["onClick"])),[[P,"Edit"]]),O((p(),v(g,{size:"small",onClick:u=>n.delUrl(r,c)},{default:d(()=>[f(" mdi-delete ")]),_:2},1032,["onClick"])),[[P,"Delete"]])]),_:1},8,["items","headers"]),a.addOrUpdate?(p(),Ae("div",bt,[l(D,{label:"URL",modelValue:a.aouUrl,"onUpdate:modelValue":t[1]||(t[1]=r=>a.aouUrl=r)},null,8,["modelValue"]),l(D,{label:"Seconds",class:"w-25 flex-grow-0",modelValue:a.aouSec,"onUpdate:modelValue":t[2]||(t[2]=r=>a.aouSec=r)},null,8,["modelValue"]),l(k,{class:"mt-2",text:"Ok",onClick:n.addUrl,color:"primary"},null,8,["onClick"]),l(k,{class:"mt-2",text:"Cancel",onClick:t[3]||(t[3]=r=>a.addOrUpdate=!1)})])):Le("",!0),l(k,{onClick:n.updateConfig,text:"Save changes",color:"primary"},null,8,["onClick"]),l(q,{modelValue:a.snackbar.visible,"onUpdate:modelValue":t[5]||(t[5]=r=>a.snackbar.visible=r),timeout:a.snackbar.timeout},{default:d(()=>[f(_(a.snackbar.message)+" ",1),l(k,{onClick:t[4]||(t[4]=r=>a.snackbar.visible=!1)},{default:d(()=>[f("Close")]),_:1})]),_:1},8,["modelValue","timeout"])]),_:1})]),_:1},512)}const yt=L(vt,[["render",kt],["__scopeId","data-v-12c7a77c"]]),Tt=Object.freeze(Object.defineProperty({__proto__:null,default:yt},Symbol.toStringTag,{value:"Module"}));
1export{mt as A,Tt as K,Ke as N,lt as T,q as V,_t as a,tt as c,et as d,h as m};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.