platypush/platypush/backend/http/webapp/dist/static/js/1798.2ea76630.js

2 lines
12 KiB
JavaScript
Raw Normal View History

2022-10-07 02:23:12 +02:00
"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[1798],{1798:function(e,t,n){n.r(t),n.d(t,{default:function(){return S}});var i=n(6252),a=n(3577);const o={class:"weather"},r={key:1},s=["src","alt","width","height"],h={key:2,class:"temperature"},l=["textContent"];function c(e,t,n,c,u,d){const g=(0,i.up)("Loading"),p=(0,i.up)("skycons");return(0,i.wg)(),(0,i.iD)("div",o,[e.loading?((0,i.wg)(),(0,i.j4)(g,{key:0})):((0,i.wg)(),(0,i.iD)("h1",r,[d._showIcon&&e.weatherIcon&&"weather.darksky"===e.weatherPlugin?((0,i.wg)(),(0,i.j4)(p,{key:0,condition:e.weatherIcon,paused:!n.animate,size:n.iconSize,color:n.iconColor},null,8,["condition","paused","size","color"])):d._showIcon&&e.weatherIcon&&"weather.openweathermap"===e.weatherPlugin?((0,i.wg)(),(0,i.iD)("img",{key:1,src:`/icons/openweathermap/${n.iconColor||"dark"}/${e.weatherIcon}.png`,alt:e.weather?.summary,width:1.5*n.iconSize,height:1.5*n.iconSize,class:"owm-icon"},null,8,s)):(0,i.kq)("",!0),d._showTemperature&&e.weather?((0,i.wg)(),(0,i.iD)("span",h,(0,a.zw)(Math.round(parseFloat(e.weather.temperature))+"°"),1)):(0,i.kq)("",!0)])),d._showSummary&&e.weather&&e.weather.summary?((0,i.wg)(),(0,i.iD)("div",{key:2,class:"summary",textContent:(0,a.zw)(e.weather.summary)},null,8,l)):(0,i.kq)("",!0)])}var u=n(6813);const d=["width","height","data-condition"];function g(e,t,n,a,o,r){return(0,i.wg)(),(0,i.iD)("canvas",{width:r.width,height:r.height,"data-condition":n.condition},null,8,d)}var p=n(6452),f=n.n(p);function m(e){const t={};return t.paused=!e.interval,t.play=()=>{e.play(),t.paused=!1},t.pause=()=>{e.pause(),t.paused=!0},t}var w={props:{condition:{type:String,required:!0},size:{type:[Number,String],default:64},color:{type:String,default:"black"},paused:{type:Boolean,default:!1},speed:{type:[Number,String],default:1}},computed:{width(){return""+this.size},height(){return""+this.size},icon(){return this.condition.toUpperCase().replace(/[\s.-]/g,"_")}},mounted(){const e=new(f())({color:this.color,speed:this.speed});e.set(this.$el,f()[this.icon]),this.paused||e.play(),this.$emit("load",m(e))}},v=n(3744);const y=(0,v.Z)(w,[["render",g]]);var M=y,C=M,k=n(1232),b={name:"Weather",mixins:[u.Z],components:{Loading:k.Z,Skycons:C},props:{animate:{required:!1,default:!0},iconSize:{type:Number,required:!1,default:50},iconColor:{type:String,required:!1},showIcon:{required:!1,default:!0},showSummary:{required:!1,default:!0},showTemperature:{required:!1,default:!0},refreshSeconds:{type:Number,required:!1,default:900}},data:function(){return{weather:void 0,weatherIcon:void 0,weatherPlugin:void 0,loading:!1,weatherPlugins:["weather.openweathermap","weather.darksky"]}},computed:{_showSummary(){return this.parseBoolean(this.showSummary)},_showIcon(){return this.parseBoolean(this.showIcon)},_showTemperature(){return this.parseBoolean(this.showTemperature)}},methods:{async refresh(){this.loading=!0;try{const e=await this.request(`${this.weatherPlugin}.get_current_weather`);this.onWeatherChange(e)}finally{this.loading=!1}},onWeatherChange(e){this.weather||(this.weather={}),this.weather={...this.weather,...e},this.weatherIcon=this.weather.icon},initWeatherPlugin(){for(const e of this.weatherPlugins)if(this.$root.config[e]){this.weatherPlugin=e,console.debug(`Initialized weather UI - plugin: ${e}`);break}this.weatherPlugin||console.warn(`No weather plugins configured. Compatible plugins: ${this.weatherPlugins}`)}},mounted:function(){this.initWeatherPlugin(),this.refresh(),this.subscribe(this.onWeatherChange,null,"platypush.message.event.weather.NewWeatherConditionEvent"),setInterval(this.refresh,parseInt((1e3*this.refreshSeconds).toFixed(0)))}};const I=(0,v.Z)(b,[["render",c],["__scopeId","data-v-150b6d72"]]);var S=I},6452:function(e,t,n){var i,a;(function(){var e=n.g.requestAnimationFrame||n.g.webkitRequestAnimationFrame||n.g.mozRequestAnimationFrame||n.g.oRequestAnimationFrame||n.g.msRequestAnimationFrame,t=n.g.cancelAnimationFrame||n.g.webkitCancelAnimationFrame||n.g.mozCancelAnimationFrame||n.g.oCancelAnimationFrame||n.g.msCancelAnimationFrame;e&&t?(i=function
//# sourceMappingURL=1798.2ea76630.js.map