platypush/platypush/backend/http/webapp/dist/static/js/1798-legacy.b42f39d9.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 T}});n(2222);var i=n(6252),a=n(3577),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){var f,p=(0,i.up)("Loading"),g=(0,i.up)("skycons");return(0,i.wg)(),(0,i.iD)("div",o,[e.loading?((0,i.wg)(),(0,i.j4)(p,{key:0})):((0,i.wg)(),(0,i.iD)("h1",r,[d._showIcon&&e.weatherIcon&&"weather.darksky"===e.weatherPlugin?((0,i.wg)(),(0,i.j4)(g,{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/".concat(n.iconColor||"dark","/").concat(e.weatherIcon,".png"),alt:null===(f=e.weather)||void 0===f?void 0:f.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(6347),d=n(4648),f=n(8534),p=(n(5666),n(9653),n(6977),n(6813));const g=["width","height","data-condition"];function m(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,g)}var v=n(6452),w=n.n(v);function y(e){const t={};return t.paused=!e.interval,t.play=()=>{e.play(),t.paused=!1},t.pause=()=>{e.pause(),t.paused=!0},t}var M={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(w())({color:this.color,speed:this.speed});e.set(this.$el,w()[this.icon]),this.paused||e.play(),this.$emit("load",y(e))}},C=n(3744);const k=(0,C.Z)(M,[["render",m]]);var b=k,I=b,S=n(1232),P={name:"Weather",mixins:[p.Z],components:{Loading:S.Z,Skycons:I},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:function(){return this.parseBoolean(this.showSummary)},_showIcon:function(){return this.parseBoolean(this.showIcon)},_showTemperature:function(){return this.parseBoolean(this.showTemperature)}},methods:{refresh:function(){var e=this;return(0,f.Z)(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return e.loading=!0,t.prev=1,t.next=4,e.request("".concat(e.weatherPlugin,".get_current_weather"));case 4:n=t.sent,e.onWeatherChange(n);case 6:return t.prev=6,e.loading=!1,t.finish(6);case 9:case"end":return t.stop()}}),t,null,[[1,,6,9]])})))()},onWeatherChange:function(e){this.weather||(this.weather={}),this.weather=(0,d.Z)((0,d.Z)({},this.weather),e),this.weatherIcon=this.weather.icon},initWeatherPlugin:function(){var e,t=(0,u.Z)(this.weatherPlugins);try{for(t.s();!(e=t.n()).done;){var n=e.value;if(this.$root.config[n]){this.weatherPlugin=n,console.debug("Initialized weather UI - plugin: ".concat(n));break}}}catch(i){t.e(i)}finally{t.f()}this.weatherPlugin||console.warn("No weather plugins configured. Compatible plugins: ".concat(this.weatherPlugins))}},mounted:function(){this.initWeatherPlugin(),this.refresh(),this.subscribe(this.onWeatherChange,null,"platypush.message.event.weather.NewWeatherCondi
//# sourceMappingURL=1798-legacy.b42f39d9.js.map