"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9299],{51372:(I,u,n)=>{n.r(u),n.d(u,{ServerStats:()=>N});var t=n(74848),e=n(32196),g=n(96540),f=n(32264),m=n(40845),r=n(55852),l=n(31678),d=n(16233),y=n(70255),S=n(10860),x=n(67061),p=n(56034),j=n(14578);const v=({content:s,footer:o,isLoading:i})=>{const c=(0,m.of)(A);return(0,t.jsxs)(S.Z,{className:c.container,children:[s.map((a,h)=>(0,t.jsxs)(x.B,{justifyContent:"space-between",alignItems:"center",children:[(0,t.jsxs)(x.B,{alignItems:"center",children:[(0,t.jsx)("span",{className:(0,e.cx)({[c.indent]:!!a.indent}),children:a.name}),a.tooltip&&(0,t.jsx)(p.m,{content:String(a.tooltip),placement:"auto-start",children:(0,t.jsx)(j.I,{name:"info-circle",className:c.tooltip})})]}),i?(0,t.jsx)(y.A,{width:60}):(0,t.jsx)("span",{className:a.highlight?c.highlight:"",children:a.value})]},h)),o&&(0,t.jsx)("div",{children:o})]})},A=s=>({container:(0,e.css)({display:"flex",flexDirection:"column",gap:s.spacing(2),padding:s.spacing(2)}),indent:(0,e.css)({marginLeft:s.spacing(2)}),tooltip:(0,e.css)({color:s.colors.secondary.text}),highlight:(0,e.css)({color:s.colors.warning.text,padding:`${s.spacing(.5)} ${s.spacing(1)}`,marginRight:`-${s.spacing(1)}`})});var D=n(17172);const C=async()=>(0,D.AI)().get("api/admin/stats").catch(s=>(console.error(s),null)),N=()=>{const[s,o]=(0,g.useState)(null),[i,c]=(0,g.useState)(!0),a=(0,m.of)(T),h=d.TP.hasPermission(l.AccessControlAction.DataSourcesRead),$=d.TP.hasPermission(l.AccessControlAction.UsersRead);return(0,g.useEffect)(()=>{d.TP.hasPermission(l.AccessControlAction.ActionServerStatsRead)&&C().then(R=>{o(R),c(!1)})},[]),d.TP.hasPermission(l.AccessControlAction.ActionServerStatsRead)?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h2",{className:a.title,children:"Instance statistics"}),!i&&!s?(0,t.jsx)("p",{className:a.notFound,children:"No stats found."}):(0,t.jsxs)("div",{className:a.row,children:[(0,t.jsx)(v,{isLoading:i,content:[{name:"Dashboards (starred)",value:`${s?.dashboards} (${s?.stars})`},{name:"Tags",value:s?.tags},{name:"Playlists",value:s?.playlists},{name:"Snapshots",value:s?.snapshots}],footer:(0,t.jsx)(r.z9,{href:"/dashboards",variant:"secondary",children:"Manage dashboards"})}),(0,t.jsxs)("div",{className:a.doubleRow,children:[(0,t.jsx)(v,{isLoading:i,content:[{name:"Data sources",value:s?.datasources}],footer:h&&(0,t.jsx)(r.z9,{href:"/datasources",variant:"secondary",children:"Manage data sources"})}),(0,t.jsx)(v,{isLoading:i,content:[{name:"Alerts",value:s?.alerts}],footer:(0,t.jsx)(r.z9,{href:"/alerting/list",variant:"secondary",children:"Manage alerts"})})]}),(0,t.jsx)(v,{isLoading:i,content:[{name:"Organisations",value:s?.orgs},{name:"Users total",value:s?.users},{name:"Active sessions",value:s?.activeSessions},{name:"Active users in last 30 days",value:s?.activeUsers},...P(s,f.$)],footer:$&&(0,t.jsx)(r.z9,{href:"/admin/users",variant:"secondary",children:"Manage users"})})]})]}):null},P=(s,o)=>!o.anonymousEnabled||!s?.activeDevices?[]:o.anonymousDeviceLimit?[{name:"Active anonymous devices",value:`${s.activeDevices} / ${o.anonymousDeviceLimit}`,tooltip:"Detected devices that are not logged in, in last 30 days.",highlight:s.activeDevices>o.anonymousDeviceLimit}]:[{name:"Active anonymous devices",value:`${s.activeDevices}`,tooltip:"Detected devices that are not logged in, in last 30 days."}],T=s=>({title:(0,e.css)({marginBottom:s.spacing(4)}),row:(0,e.css)({display:"flex",justifyContent:"space-between",width:"100%","& > div:not(:last-of-type)":{marginRight:s.spacing(2)},"& > div":{width:"33.3%"}}),doubleRow:(0,e.css)({display:"flex",flexDirection:"column","& > div:first-of-type":{marginBottom:s.spacing(2)}}),notFound:(0,e.css)({fontSize:s.typography.h6.fontSize,textAlign:"center",height:"290px"})})}}]);

//# sourceMappingURL=ServerStats.c5fc88804389ce2f7709.js.map