unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
2 lines (1 loc) • 3.18 kB
JavaScript
var f=Object.defineProperty;var k=(t,e,r)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var o=(t,e,r)=>k(t,typeof e!="symbol"?e+"":e,r);import{bz as C,b as w,r as p,cV as P,j as s,C as v,W as S,dc as j,iQ as N,iR as I,iS as R,i_ as A,i$ as M,j0 as T,iW as L,iV as W,iU as _,iP as u}from"./index-DEkgmbaI.js";import{u as q,N as E}from"./NetworkPrometheusAPIWarning-fuwV0YDl.js";import{L as D}from"./index-ZiL5S4gH.js";import{u as g}from"./unknownify-B7hmSXnj.js";class ${constructor(e){o(this,"current",0);o(this,"all");this.all=e}next(){const e=this.all[this.current];return this.current=(this.current+1)%this.all.length,e}}const m=["circle","rect","rectRounded","rectRot","triangle"],z=(t,e)=>t.map(r=>({x:r[0],y:e(r[1])})),H=(t,e)=>({locale:e.locale,responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},color:t.palette.text.secondary,plugins:{tooltip:{backgroundColor:t.palette.background.paper,bodyColor:t.palette.text.primary,titleColor:t.palette.action.active,borderColor:t.palette.primary.main,borderWidth:1,padding:10,boxPadding:5,usePointStyle:!0,callbacks:{title:r=>u(1e3*r[0].parsed.x,e.locale)},itemSort:(r,a)=>a.parsed.y-r.parsed.y},legend:{position:"bottom",align:"start",labels:{boxWidth:10,boxHeight:10,usePointStyle:!0,padding:24}},title:{text:"Top 10 requests per second in the last 6 hours",position:"top",align:"start",display:!0,font:{size:16,weight:"400"},color:t.palette.text.primary,padding:{bottom:32}}},scales:{y:{type:"linear",title:{display:!0,text:"Requests per second",color:t.palette.text.secondary},suggestedMin:0,ticks:{precision:0,color:t.palette.text.secondary},grid:{color:t.palette.divider,borderColor:t.palette.divider}},x:{type:"time",time:{unit:"minute"},grid:{display:!0,color:t.palette.divider,borderColor:t.palette.divider},ticks:{callback:(r,a,i)=>u(i[a].value*1e3,e.locale)}}}});class V{constructor(e){o(this,"items");o(this,"picked",new Map);this.items=new $(e)}pick(e){return this.picked.has(e)||this.picked.set(e,this.items.next()),this.picked.get(e)}}const B=(t,e)=>{var r;if((r=e==null?void 0:e.data)!=null&&r.result){const a=new V([t.palette.success,t.palette.error,t.palette.primary,t.palette.warning]);return e.data.result.map((i,x)=>{var c,d;const n=g((c=i.metric)==null?void 0:c.endpoint),y=g((d=i.metric)==null?void 0:d.appName),l=a.pick(n),b=i.values||[];return{label:`${n}: ${y}`,borderColor:l.main,backgroundColor:l.main,data:z(b,h=>Number.parseFloat(h)),elements:{point:{radius:4,pointStyle:m[x%m.length]},line:{borderDash:[8,4]}}}})}return[]},J=()=>{const{locationSettings:t}=C(),{metrics:e}=q(),r=w(),a=p.useMemo(()=>H(r,t),[r,t]);P("Network - Traffic");const i=p.useMemo(()=>({datasets:B(r,e)}),[r,e,t]);return s.jsx(v,{condition:i.datasets.length===0,show:s.jsxs(S,{severity:"warning",children:["No data available.",s.jsx(E,{})]}),elseShow:s.jsx(j,{sx:{display:"grid",gap:4},children:s.jsx("div",{style:{height:400},children:s.jsx(D,{data:i,options:a,"aria-label":"An instance metrics line chart with two lines: requests per second for admin API and requests per second for client API"})})})})};N.register(I,R,A,M,T,L,W,_);export{J as NetworkTraffic,J as default};