PageSourceSearch

https://app.bisol-energija.si/assets/SitesOverview-CsNHq9O6.js

js bisol-energija.si collected 2026-10-02 00:41:00 UTC 14,803 bytes, 11 lines download raw bytes

1import{i as M,r as y,a6 as ae,a7 as z,a8 as ne,n as T,l as S,a9 as ie,h as U,aa as P,ab as le,ac as K,ad as B,j as t,J as q,c as p,U as $,u as _,ae as b,af as oe,ag as re,ah as ce,ai as de,aj as he,ak as ue,al as H,A as W,am as me,an as xe,ao as pe,ap as fe,aq as _e,ar as ge,as as ye,at as Q,au as je,av as Se,V as v,p as V,aw as Ne,W as be,ax as Ae,Q as ke,R as ve,X as Ce,a1 as Ee}from"./index-Dx_4q206.js";function Oe(e,s){const n=M(),a=n.getQueryCache();return y.useSyncExternalStore(y.useCallback(r=>a.subscribe(ae.batchCalls(r)),[a]),()=>n.isFetching(e),()=>n.isFetching(e))}/**
2 * @license lucide-react v1.45.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const G={name:"search-x",size:24,node:[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]};G.node;const Te=z(G);/**
7 * @license lucide-react v1.45.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Y={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};Y.node;const we=z(Y),Le=(e,s)=>ne({url:T.Alerts.All(),listKey:n=>S.AlertsAllSitesInfinite(ie,n,s),countsKey:()=>S.AlertsCount("all-sites",s),confirmed:e,scopeFilter:s});var c=(e=>(e.Offline="offline",e.Fault="fault",e.Attention="attention",e.Ok="ok",e.Uncommissioned="uncommissioned",e))(c||{});const A=["offline","fault","attention","ok","uncommissioned"],Ie=1,Re=()=>A.reduce((e,s)=>({...e,[s]:0}),{}),De=e=>{const s=U(),n=P(),a=le({queryKey:S.SitesStatusCounts(e),queryFn:async()=>{const{data:o}=await s.get(T.Sites.SitesStatus,{params:{search:e,page_number:1,page_size:Ie}});return o},staleTime:30*1e3,refetchOnMount:"always",enabled:n,placeholderData:B}),r=y.useMemo(()=>{var m;const o={...Re(),...((m=a.data)==null?void 0:m.counts)??{}};return{total:A.reduce((h,u)=>h+(o[u]??0),0),counts:o}},[a.data]),i=K(a.isLoading);return{data:r,isLoading:i,isError:a.isError,isFetching:a.isFetching,refetch:a.refetch}},Fe={[c.Offline]:"--shade-400",[c.Fault]:"--accent-red-600",[c.Attention]:"--accent-yellow-500",[c.Ok]:"--accent-green-400",[c.Uncommissioned]:"--shade-300"},Z={[c.Offline]:"bg-shade-400",[c.Fault]:"bg-accent-red-600",[c.Attention]:"bg-accent-yellow-500",[c.Ok]:"bg-accent-green-400",[c.Uncommissioned]:"bg-shade-300"},Me={[c.Offline]:"border-l-shade-400",[c.Fault]:"border-l-accent-red-600",[c.Attention]:"border-l-accent-yellow-500",[c.Ok]:"border-l-accent-green-400",[c.Uncommissioned]:"border-l-shade-300"},w={[c.Offline]:"site_health.status_offline",[c.Fault]:"site_health.status_fault",[c.Attention]:"site_health.status_attention",[c.Ok]:"site_health.status_ok",[c.Uncommissioned]:"site_health.status_uncommissioned"},ze=({counts:e})=>A.map(s=>({id:s,count:e[s]??0,colorVar:Fe[s],dotClassName:Z[s],labelKey:w[s],status:s})).filter(({count:s})=>s>0).sort((s,n)=>n.count-s.count),C="min-h-[275px]",X=({title:e,description:s,className:n,children:a})=>t.jsx(q,{className:p("h-full",C),children:t.jsxs($,{className:p("flex h-full flex-col px-5",n),children:[t.jsx("h2",{className:"text-sm font-semibold text-shade-500",children:e}),t.jsx("p",{className:"mt-0.5 text-xs text-shade-300",children:s}),a]})}),I=14,E=56,Ue=18,Pe=`${(E-Ue)/E*100}%`,Ke=({slices:e,total:s,labels:n,activeIndex:a,onSelect:r,onHoverIndex:i})=>{const{t:o}=_(),m={labels:n,datasets:[{data:e.map(({count:d})=>d),backgroundColor:e.map(({colorVar:d})=>b(d)),hoverBackgroundColor:e.map(({colorVar:d})=>b(d)),borderWidth:0,hoverBorderWidth:0,spacing:3,offset:e.map((d,l)=>l===a?I:0),hoverOffset:I}]},h={type:"doughnutLabel",content:()=>[`${s}`,o("site_health.summary_locations")],drawTime:"beforeDraw",font:[{size:24,weight:"600"},{size:11}],color:[b("--shade-600"),b("--shade-400")]},u={responsive:!0,maintainAspectRatio:!1,radius:E,cutout:Pe,onClick:(d,l)=>l[0]&&r(e[l[0].index]),onHover:(d,l)=>{var g;i(l[0]?l[0].index:null);const f=(g=d.native)==null?void 0:g.target;f&&(f.style.cursor=l[0]?"pointer":"default")}
11,plugins:{legend:{display:!1},datalabels:{display:!1},annotation:{annotations:{centerLabel:h}},tooltip:{displayColors:!1,callbacks:{label:({dataIndex:d,label:l})=>`${l}: ${o("site_health.summary_share",{count:e[d].count,percent:Math.round(e[d].count/s*100)})}`}}}};return t.jsx("div",{className:"relative size-[140px] shrink-0",onMouseLeave:()=>i(null),children:t.jsx(oe,{data:m,options:u})})},Be=({summary:e,onSelectStatus:s})=>{const{t:n}=_(),[a,r]=y.useState(null),i=y.useMemo(()=>ze(e),[e]),{total:o}=e;if(!o)return null;const m=i.map(({labelKey:u})=>n(u)),h=u=>s(u.status);return t.jsx(X,{title:n("site_health.summary_title"),description:n("site_health.summary_description"),children:t.jsxs("div",{className:"mt-4 flex flex-1 flex-col items-center justify-center gap-5 sm:flex-row sm:items-center sm:justify-start sm:gap-6",children:[t.jsx(Ke,{slices:i,total:o,labels:m,activeIndex:a,onSelect:h,onHoverIndex:r}),t.jsx("ul",{className:"min-w-0",children:i.map((u,d)=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>h(u),onMouseEnter:()=>r(d),onMouseLeave:()=>r(null),onFocus:()=>r(d),onBlur:()=>r(null),className:p("flex w-full items-center gap-2.5 rounded-md px-2 py-1 text-left","transition-colors",d===a&&"bg-shade-100"),children:[t.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:t.jsx("span",{className:p("size-2 rounded-full",u.dotClassName)})}),t.jsx("span",{className:"w-7 shrink-0 text-right text-sm font-semibold tabular-nums text-shade-600",children:u.count}),t.jsx("span",{className:"truncate text-sm text-shade-500",children:n(u.labelKey)})]})},u.id))})]})})},R=({alert:e})=>{const{t:s}=_(),n=re(),a=ce(e),r=s(de(e.alert_level));return t.jsxs("div",{className:"flex items-start gap-2.5 py-2.5",children:[t.jsx("span",{className:"mt-0.5 shrink-0",title:r,"aria-label":r,role:"img",children:he(e.alert_level,"size-4")}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm font-medium",children:(a==null?void 0:a.title)??e.alert_code}),!!(a!=null&&a.body)&&t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.body})]}),t.jsx("span",{className:"shrink-0 text-xs whitespace-nowrap text-shade-300",children:ue(new Date(e.created_at),{addSuffix:!0,locale:n})})]})},qe=3,$e=({alerts:e})=>{const{t:s}=_(),n=H(),a=e.slice(0,qe),r=({entity_type:i,entity_code:o})=>i===me.Site?o:void 0;return t.jsx(X,{title:s("site_health.latest_alerts_title"),description:s("site_health.latest_alerts_description"),children:a.length?t.jsx("ul",{className:"-mx-2 mt-4 divide-y divide-shade-100",children:a.map(i=>{const o=r(i);return t.jsx("li",{children:o?t.jsx("button",{type:"button",onClick:()=>n(W.SiteAlerts.path({site_code:o})),className:"w-full cursor-pointer rounded-md px-2 text-left transition-colors hover:bg-shade-100",children:t.jsx(R,{alert:i})}):t.jsx("div",{className:"px-2",children:t.jsx(R,{alert:i})})},i.alert_id)})}):t.jsx("p",{className:"mt-4 text-sm text-shade-300",children:s("site_health.latest_alerts_empty")})})},k=e=>{const s=Number(e);return Number.isFinite(s)&&s>0?s:null},He=e=>{if(e!=null)return e?c.Ok:c.Offline},We=e=>({site:{site_code:e.site_code,site_name:e.site_name,controller_code:"",site_address:e.site_address,opt_type:pe.MinCost,role:xe.READER},status:e.state,controllerStatus:He(e.is_reporting),capacity:{solarPowerKW:k(e.installed_production_power_kW),batteryPowerKW:k(e.installed_storage_power_kW),batteryCapacityKWh:k(e.installed_storage_capacity_kWh)}}),O=12,Qe=(e,s)=>{var h,u,d;const n=U(),a=P(),r=async l=>{const{data:f}=await n.get(T.Sites.SitesStatus,{params:{state:e,search:s,page_number:l,page_size:O}});return f},i=fe({queryKey:S.SitesStatus(e,s,O),initialPageParam:1,queryFn:({pageParam:l=1})=>r(l),getNextPageParam:l=>{if(l)return l.current_page<l.total_pages?l.current_page+1:void 0},staleTime:30*1e3,refetchOnMount:"always",enabled:a,placeholderData:B}),o=y.useMemo(()=>{var l;return(((l=i.data)==null?void 0:l.pages)??[]).flatMap(f=>(f.items??[]).map(We))},[i.data]),m=K(i.isLoading);return{data:o,total:((d=(u=(h=i.data)==null?void 0:h.pages)==null?void 0:u[0])==null?void 0:d.total_count)??0,hasNextPage:i.hasNextPage,fetchNextPage:()=>i.fetchNextPage(),isLoading:m,isError:i.isError,isFetching:i.isFetching,refetch:i.refetch}},Ve=e=>{const{street_name:s,house_num:n,post_num:a,post_name:r}=e.site_address??{}
11,i=[s,n].filter(Boolean).join(" "),o=[a,r].filter(Boolean).join(" ");return[i,o].filter(Boolean).join(", ")},Ge=({capacity:{solarPowerKW:e,batteryPowerKW:s,batteryCapacityKWh:n},className:a})=>{const{t:r}=_(),{formatNumber:i}=_e();if(e===null&&s===null)return null;const o=[s!==null&&`${i(s)} kW`,n!==null&&`${i(n)} kWh`].filter(Boolean).join(" / "),m=[e!==null&&{id:"solar",Icon:we,value:`${i(e)} kW`,label:r("site_health.solar")},!!o&&{id:"battery",Icon:ge,value:o,label:r("site_health.battery")}].filter(h=>!!h);return t.jsx("p",{className:p("flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-shade-400",a),children:m.map(({id:h,Icon:u,value:d,label:l})=>t.jsxs("span",{title:`${l}: ${d}`,className:"flex items-center gap-1 tabular-nums",children:[t.jsx(u,{className:"size-3.5 shrink-0"}),d,t.jsx("span",{className:"sr-only",children:l})]},h))})},Ye={[c.Ok]:"from-accent-green-50 to-accent-green-100 text-accent-green-500",[c.Offline]:"from-accent-red-50 to-accent-red-100 text-accent-red-500"},Ze="from-shade-100 to-shade-200 text-shade-400",Xe=({reporting:e})=>{const{t:s}=_(),n=e===c.Ok||e===c.Offline,a=n?`${s("site_health.status_controller")}: ${s(w[e])}`:s("general.site");return t.jsxs("div",{title:a,className:p("flex size-9 shrink-0 items-center justify-center rounded-full bg-gradient-to-br",n?Ye[e]:Ze),children:[t.jsx(ye,{className:"size-5"}),t.jsx("span",{className:"sr-only",children:a})]})},Je=({health:e})=>{const s=H(),{site:n,status:a,controllerStatus:r,capacity:i}=e,o=Ve(n),m=()=>s(W.SiteAlerts.path({site_code:n.site_code}));return t.jsx(q,{role:"button",tabIndex:0,onClick:m,onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),m())},className:p("cursor-pointer transition-shadow hover:shadow-md","border-l-4",Me[a]),children:t.jsx($,{className:"px-5",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Xe,{reporting:r}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate font-semibold",children:n.site_name}),!!o&&t.jsx("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:o}),t.jsx(Ge,{capacity:i,className:"mt-1.5"})]})]})})})},et=({id:e,title:s,count:n,isOpen:a,onToggle:r,forceOpen:i,dotClassName:o,isLoading:m,isError:h,children:u})=>{const{t:d}=_(),l=i||a;return t.jsxs("section",{id:e,className:"flex scroll-mt-4 flex-col gap-4",children:[t.jsxs("button",{type:"button",onClick:()=>!i&&r(),"aria-expanded":l,className:p("flex w-full items-center gap-2 text-left","sticky top-0 z-10 -mx-1 bg-shade-100 px-1 py-2",i?"cursor-default":"cursor-pointer"),children:[!!o&&t.jsx("span",{className:p("size-2 shrink-0 rounded-full",o)}),t.jsx("h2",{className:"text-sm font-semibold text-shade-500",children:s}),t.jsx("span",{className:"text-sm text-shade-300",children:m||h?"–":n}),!i&&t.jsx(Q,{className:p("size-4 text-shade-300 transition-transform",l&&"rotate-180")})]}),t.jsx(je,{isOpen:l,children:h?t.jsx("p",{className:"text-sm text-accent-red-500",children:d("site_health.section_error")}):m||n?u:t.jsx("p",{className:"text-sm text-shade-300",children:d("site_health.section_empty")})})]})},tt=2,st="h-[116px] rounded-xl",at=({status:e,id:s,search:n,isOpen:a,onToggle:r,forceOpen:i})=>{const{t:o}=_(),{data:m,total:h,hasNextPage:u,fetchNextPage:d,isLoading:l,isError:f}=Qe(e,n);return t.jsxs(et,{id:s,title:o(w[e]),count:h,dotClassName:Z[e],isOpen:a,onToggle:r,forceOpen:i,isLoading:l,isError:f,children:[t.jsx(Se,{breakpointCols:{default:2,1e3:1},className:"flex gap-6",columnClassName:"flex flex-col gap-6",children:l?Array.from({length:tt},(g,N)=>t.jsx(v,{className:st},N)):m.map(g=>t.jsx(Je,{health:g},g.site.site_code))}),u&&t.jsx("div",{className:"mt-4 flex justify-center",children:t.jsxs(V,{variant:"link",size:"sm",className:"text-shade-500 hover:text-shade-600",onClick:d,children:[o("site_health.show_more",{count:Math.min(h-m.length,O)}),t.jsx(Q,{className:"size-4"})]})})]})},D={[c.Offline]:!0,[c.Fault]:!0,[c.Attention]:!0,[c.Ok]:!1,[c.Uncommissioned]:!1},F=e=>`site-health-section-${e}`,J=[S.SitesStatus.prefix,S.AlertsAllSitesInfinite.prefix],nt=e=>J.some(s=>s.every((n,a)=>e[a]===n)),it=()=>{const{t:e}=_(),[s,n]=y.useState(""),a=Ne(s,300),{data:r,isLoading:i,isError:o,refetch:m}=De(a),{data:h}
11=Le(!1),u=M(),d=()=>J.forEach(x=>u.invalidateQueries({queryKey:x})),l=Oe({predicate:({queryKey:x})=>nt(x)})>0,[f,g]=y.useState({}),N=!!a.trim(),L=!i&&N&&!r.total,ee=(x,j)=>g(se=>({...se,[x]:j})),te=x=>{g(j=>({...j,[x]:!0})),requestAnimationFrame(()=>{var j;return(j=document.getElementById(F(x)))==null?void 0:j.scrollIntoView({behavior:"smooth",block:"start"})})};return o?t.jsx(be,{Icon:Ae,title:e("alerts.error_title"),description:e("alerts.error_description"),onRetry:m}):t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx(ke,{value:s,onChange:n,placeholder:e("site_health.search_placeholder"),variant:"white",className:"w-full sm:w-72"}),t.jsxs(V,{variant:"ghost",size:"sm",onClick:d,disabled:l,loading:l,children:[!l&&t.jsx(ve,{className:"size-4"}),e("general.refresh")]})]}),!L&&t.jsx("div",{className:"grid grid-cols-1 items-stretch gap-6 0_5xl:grid-cols-[max-content_minmax(0,1fr)]",children:i?t.jsxs(t.Fragment,{children:[t.jsx(v,{className:p(C,"rounded-xl 0_5xl:w-[24rem]")}),t.jsx(v,{className:p(C,"rounded-xl")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Be,{summary:r,onSelectStatus:te}),t.jsx($e,{alerts:h})]})}),L?t.jsx(Ce,{Icon:Te,title:e("site_health.empty_search_title"),description:e("site_health.empty_search_description",{search:s.trim()})}):A.map(x=>t.jsx(at,{status:x,id:F(x),search:a,isOpen:f[x]??D[x],onToggle:()=>ee(x,!(f[x]??D[x])),forceOpen:N},x))]})},ot=()=>{const{t:e}=_();return t.jsx(Ee,{breadcrumbs:[{label:e("general.admin")},{label:e("site_health.title")}],title:e("site_health.title"),description:e("site_health.description"),hideBack:!0,isAdminPage:!0,children:t.jsx(it,{})})};export{ot as default};

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.