UNPKG

@larva.io/webcomponents

Version:

Fentrica SmartUnits WebComponents package

5 lines 5.72 kB
/*! * (C) Fentrica http://fentrica.com - Seee LICENSE.md */ import{r,c as t,h as e}from"./p-C4h1muVj.js";import{R as n,d as a}from"./p-BN3DZ42s.js";import{h as i}from"./p-DAuPur-P.js";import{e as l,h as s}from"./p-CozWii6U.js";import{a as o,g as c,c as u,b as f,d as m}from"./p-DtEBBD52.js";import{c as p,t as d,a as h}from"./p-B8THl2h4.js";import{i as v}from"./p-CT2-YPhM.js";import{i as g}from"./p-C7eoH3L1.js";import{a as b,s as j,o as _,b as w}from"./p-BqlmSTpF.js";import{i as D,b as y}from"./p-BCe7Jf0F.js";import{k}from"./p-Ca1ORAt0.js";import{i as C}from"./p-C_HhfJYh.js";import{b as B}from"./p-Bt4QT_oL.js";import"./p-Cdm8hPvp.js";import"./p-t09QJ_DI.js";import"./p-DxhwjcHT.js";import"./p-BkGzfcoF.js";import"./p-C56buD75.js";function H(r,t,e,n){if(!g(r)){return r}t=p(t,r);var a=-1,i=t.length,l=i-1,s=r;while(s!=null&&++a<i){var c=d(t[a]),u=e;if(c==="__proto__"||c==="constructor"||c==="prototype"){return r}if(a!=l){var f=s[c];u=undefined;if(u===undefined){u=g(f)?f:v(t[a+1])?[]:{}}}o(s,c,u);s=s[c]}return r}function N(r,t,e){var n=-1,a=t.length,i={};while(++n<a){var s=t[n],o=l(r,s);if(e(o,s)){H(i,p(s,r),o)}}return i}function O(r,t){return N(r,t,(function(t,e){return s(r,e)}))}function T(r){var t=r==null?0:r.length;return t?b(r):[]}function Y(r){return j(_(r,undefined,T),r+"")}var L=Y((function(r,t){return r==null?{}:O(r,t)}));function R(r){var t=r==null?0:r.length;return t?r[t-1]:undefined}function x(r,t,e){var n=-1,a=r.length;if(t<0){t=-t>a?0:a+t}e=e>a?a:e;if(e<0){e+=a}a=t>e?0:e-t>>>0;t>>>=0;var i=Array(a);while(++n<a){i[n]=r[n+t]}return i}function A(r,t){return t.length<2?r:l(r,x(t,0,-1))}function F(r,t){t=p(t,r);r=A(r,t);return r==null||delete r[d(R(t))]}var P="[object Object]";var z=Function.prototype,J=Object.prototype;var M=z.toString;var q=J.hasOwnProperty;var E=M.call(Object);function Q(r){if(!D(r)||y(r)!=P){return false}var t=c(r);if(t===null){return true}var e=q.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&M.call(e)==E}function U(r){return Q(r)?undefined:r}var W=1,G=2,I=4;var K=Y((function(r,t){var e={};if(r==null){return e}var n=false;t=h(t,(function(t){t=p(t,r);n||(n=t.length>1);return t}));u(r,f(r),e);if(n){e=m(e,W|G|I,U)}var a=t.length;while(a--){F(e,t[a])}return e}));function S(r,t){return h(t,(function(t){return r[t]}))}function V(r){return r==null?[]:S(r,k(r))}function Z(r,t,e,n){if(r==null){return[]}if(!C(t)){t=t==null?[]:[t]}e=e;if(!C(e)){e=e==null?[]:[e]}return w(r,t,e)}const X="slot-fb[hidden],slot[hidden]{display:initial !important}.circle{background-color:var(--lar-background-color-step-200, #333333) !important;border-radius:50%;display:inline-block;padding:0.5rem;width:2rem;height:2rem;margin-right:1rem}.circle lar-icon{display:block;width:100%;height:100%}lar-list-item{background-color:var(--lar-background-color-step-100, rgb(25.5, 25.5, 25.5)) !important;color:var(--lar-text-color, #fff) !important}h4{padding:0;margin:0;white-space:break-spaces}.date,small{color:var(--lar-text-color-step-150, rgb(216.75, 216.75, 216.75)) !important}lar-badge{margin-top:0.2rem;margin-right:0.3rem;font-weight:normal}";const $=class{constructor(e){r(this,e);this.request=t(this,"request");this.config=B;this.logreceived=false;this.logdata=[];this.logcount=0}async response(r){if(this.modal){this.modal.setAttribute("icon-small","")}this.logreceived=true;this.logdata=r.logs;this.logcount=r.count}componentDidLoad(){this.request.emit()}async error(r,t=5e3){this.logreceived=true;let n="error_messages.";if(typeof r==="string"){n+=r}else if(r&&r.message&&typeof r.message==="string"){n+=r.message}else{n+="UNKNOWN_ERROR"}e("lar-translate",{t:n})}static parseData(r,t){let e={};if(r&&n.isSecurityEvent(t)){e=L(r,["name","sn","io","state","zone"])}else{e=K(r,["user","flow"])}return V(e).toString()}renderLogList(){const r=[];const t=Z(this.logdata,"createdAt","desc");const l=this.config.get("formatDateTime","DD.MM.YYYY HH:mm");if(t.length===0){r.push(e("lar-list-header",null,e("lar-translate",{t:"log.nologs"})));return r}let s;let o;t.forEach((t=>{let c="tertiary";let u="info";const f=i(new Date(t.createdAt));const m=f.month()+1;const p=f.year();const d=Number(t.code);const h=a.getLogLevel(d);const v=a.getEventMessage(d);const g=Number(t.qualify);if(s!==m||o!==p){r.push(e("lar-list-header",null,e("lar-translate",{t:"date.months."+m})," ",p));s=m;o=p}if(h===a.LogLevel.ERROR){c="danger"}else if(h===a.LogLevel.WARNING){c="warning"}if(g===a.Qualify.RESTORE){c="success"}if(n.isUserEvent(d)){u="user"}else if(n.isSecurityEvent(d)){u="warning";if(n.isFireAlarm(d)){u="fire_alarm"}if(n.isMedicalAlarm(d)){u="medical_alarm"}if(n.isPanicAlarm(d)){u="panic_alarm"}if(n.isOtherAreaAlarm(d)){u="other_alarm"}}else if(n.isCloudEvent(d)){u="cloud"}else if(n.isSystemEvent(d)){u="device"}r.push(e("lar-list-item",null,e("div",{slot:"start",class:"circle"},e("lar-icon",{icon:u,color:c})),e("div",null,e("div",{class:"date"},e("small",null,i(new Date(t.createdAt)).format(l))),e("h4",null,e("lar-translate",{t:"log_entries."+d,fallback:v})),e("div",null,t.data&&t.data.user&&e("small",null,t.data.user.firstname," ",t.data.user.lastname)),t.data&&e("div",null,e("small",null,$.parseData(t.data,d))),g===a.Qualify.RESTORE&&e("div",null,e("small",null,e("lar-badge",{color:"success"},d===a.ReportEvent.SECURITY_PARTIAL_ARMED_DISARMED||d===a.ReportEvent.SECURITY_ARMED_DISARMED?e("lar-translate",{t:"log.armed"}):e("lar-translate",{t:"log.resolved"})))))))}));return r}render(){return[e("div",{key:"ff4fda3f33471cd7c103e7bea437448152fe69e5"},this.logreceived&&e("lar-list",{key:"28f2ec6bdce7fc267bbf2e09e3943c2ca233e087"},this.renderLogList()))]}};$.style=X;export{$ as lar_log_modal}; //# sourceMappingURL=p-2e929f5b.entry.js.map