UNPKG

zigbee2mqtt-windfront

Version:

[![Version](https://img.shields.io/npm/v/zigbee2mqtt-windfront.svg)](https://npmjs.org/package/zigbee2mqtt-windfront) [![CI](https://github.com/Nerivec/zigbee2mqtt-windfront/actions/workflows/ci.yml/badge.svg)](https://github.com/Nerivec/zigbee2mqtt-windf

2 lines (1 loc) 4.17 kB
import{u as I,h as T,i as A,b as _,a as r,r as t,j as s,N as E,M,A as F,l as G,S as D,T as O,F as h,a2 as C,k as L,a3 as P,c as H,a4 as v,e as V,C as N,a5 as z,a6 as B}from"./index-C9teBVht.js";import{C as $}from"./CheckboxField-ZdCJFDzF.js";import{D as q}from"./DebouncedInput-CB_1_bR4.js";import{S as p}from"./SelectField-Cjwi2kGD.js";import{u as R}from"./useSearch-DWt9mTiA.js";import"./envs-CSqIi4cL.js";const U={error:"bg-error text-error-content",warning:"bg-warning text-warning-content",info:"bg-info text-info-content",debug:"bg-accent text-accent-content opacity-50"},J=t.memo(({sourceIdx:l})=>{const{t:a}=_(["logs","common"]),x=r(L(e=>e.bridgeInfo[l].config.advanced.log_level)),o=r(L(e=>e.logs[l])),c=r(e=>e.logsLimit),u=r(e=>e.setLogsLimit),n=r(e=>e.clearLogs),[m,i,j]=R(),[d,S]=t.useState("all"),[f,w]=t.useState(!1),b=t.useMemo(()=>o.filter(e=>(d==="all"||e.level===d)&&(f||i.length===0||e.message.toLowerCase().includes(i))),[i,f,d,o]),y=t.useCallback((e,g)=>i.length>0&&e.toLowerCase().includes(i)?U[g]:P[g],[i]),k=t.useCallback(async e=>{await H(l,"bridge/request/options",{options:{advanced:{log_level:e}}})},[l]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-row flex-wrap gap-3 items-top",children:[s.jsxs(p,{name:"log_level",label:a(e=>e.show_only,{ns:"common"}),value:d,onChange:e=>S(e.target.value),className:"select select-sm",children:[s.jsx("option",{value:"all",children:"all"},"all"),v.map(e=>s.jsx("option",{value:e,children:e},e))]}),s.jsxs("fieldset",{className:"fieldset",children:[s.jsx("legend",{className:"fieldset-legend",children:a(e=>e.filter_by_text)}),s.jsxs("div",{className:"join",children:[s.jsxs("label",{className:"input input-sm w-64 join-item",children:[s.jsx(h,{icon:V}),s.jsx(q,{onChange:j,placeholder:a(e=>e.search,{ns:"common"}),value:m})]}),s.jsx(N,{item:"",onClick:j,className:"btn btn-sm btn-square btn-warning btn-outline join-item",title:a(e=>e.clear,{ns:"common"}),disabled:m.length===0,children:s.jsx(h,{icon:z})})]})]}),s.jsx($,{name:"highlight_only",label:a(e=>e.highlight_only),checked:f,onChange:e=>w(e.target.checked),className:"checkbox checkbox-sm"}),s.jsx("fieldset",{className:"fieldset self-end",children:s.jsxs(N,{item:l,onClick:n,className:"btn btn-sm btn-outline btn-warning btn-primary",disabled:o.length===0,children:[s.jsx(h,{icon:C}),a(e=>e.clear,{ns:"common"})]})}),s.jsxs("div",{className:"ml-auto flex flex-row gap-3",children:[s.jsx(p,{name:"log_limit",label:a(e=>e.logs_limit),onChange:e=>{u(Number.parseInt(e.target.value,10))},value:c,className:"select select-sm",children:B.map(e=>s.jsx("option",{value:e,children:e},e))}),s.jsx(p,{name:"log_level_config",label:a(e=>e.log_level_config),value:x,onChange:e=>!e.target.validationMessage&&k(e.target.value),className:"select select-sm",children:v.map(e=>s.jsx("option",{value:e,children:e},e))})]})]}),s.jsx("div",{className:"mockup-code w-full mt-1 mb-3",children:b.length>0?b.map((e,g)=>s.jsx("pre",{"data-prefix":g,className:y(e.message,e.level),children:s.jsxs("code",{children:["[",e.timestamp,"] ",e.message]})},`${g}-${e.timestamp}`)):s.jsx("pre",{"data-prefix":"~",children:s.jsxs("code",{children:["[",new Date().toLocaleString(),"] ",a(e=>e.empty_logs_message)]})})})]})}),K=({isActive:l})=>l?"menu-active":void 0;function se(){const l=I(),{sourceIdx:a}=T(),[x,o]=A(a),{t:c}=_(["logs","common"]),u=r(n=>n.clearAllLogs);return t.useEffect(()=>{(!a||!o)&&l("/logs/0",{replace:!0})},[a,o,l]),s.jsxs(s.Fragment,{children:[s.jsx(E,{children:M&&s.jsxs("div",{className:"flex-1 flex flex-col",children:[s.jsx("div",{className:"menu menu-horizontal flex-1 pb-0",children:F.map((n,m)=>s.jsx("li",{children:s.jsx(G,{to:`/logs/${m}`,className:K,children:s.jsx(D,{idx:m,alwaysShowName:!0})})},n))}),s.jsx("div",{className:"menu menu-horizontal justify-end",children:s.jsxs(O,{onClick:u,className:"btn btn-sm btn-outline btn-warning btn-primary",title:c(n=>n.clear_all,{ns:"common"}),modalDescription:c(n=>n.dialog_confirmation_prompt,{ns:"common"}),modalCancelLabel:c(n=>n.cancel,{ns:"common"}),children:[s.jsx(h,{icon:C}),c(n=>n.clear_all,{ns:"common"})]})})]})}),s.jsx(J,{sourceIdx:x},a)]})}export{se as default};