"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9299],{32882(B,x,t){t.r(x),t.d(x,{ServerStats:()=>$});var n=t(74848),i=t(22803),u=t(96540),o=t(92745),j=t(43173),y=t(63142),l=t(41654),d=t(45861),v=t(11257),g=t(15130),S=t(70255),f=t(8073),p=t(45967),A=t(30703);const h=({content:s,footer:e,isLoading:r})=>{const c=(0,y.of)(D);return(0,n.jsxs)(f.Z,{noMargin:!0,className:c.container,children:[s.map((a,m)=>(0,n.jsxs)(l.B,{justifyContent:"space-between",alignItems:"center",children:[(0,n.jsxs)(l.B,{alignItems:"center",children:[(0,n.jsx)("span",{className:(0,i.cx)({[c.indent]:!!a.indent}),children:a.name}),a.tooltip&&(0,n.jsx)(p.m,{content:String(a.tooltip),placement:"auto-start",children:(0,n.jsx)(A.I,{name:"info-circle",className:c.tooltip})})]}),r?(0,n.jsx)(S.A,{width:60}):(0,n.jsx)("span",{className:a.highlight?c.highlight:"",children:a.value})]},m)),e&&(0,n.jsx)("div",{children:e})]})},D=s=>({container:(0,i.css)({display:"flex",flexDirection:"column",gap:s.spacing(2),padding:s.spacing(2)}),indent:(0,i.css)({marginLeft:s.spacing(2)}),tooltip:(0,i.css)({color:s.colors.secondary.text}),highlight:(0,i.css)({color:s.colors.warning.text,padding:`${s.spacing(.5)} ${s.spacing(1)}`,marginRight:`-${s.spacing(1)}`})});var P=t(68143);const T=async()=>(0,P.AI)().get("api/admin/stats").catch(s=>(console.error(s),null)),$=()=>{const[s,e]=(0,u.useState)(null),[r,c]=(0,u.useState)(!0),a=(0,y.of)(I),m=g.TP.hasPermission(v.w.DataSourcesRead),N=g.TP.hasPermission(v.w.UsersRead);return(0,u.useEffect)(()=>{g.TP.hasPermission(v.w.ActionServerStatsRead)&&T().then(z=>{e(z),c(!1)})},[]),g.TP.hasPermission(v.w.ActionServerStatsRead)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h2",{className:a.title,children:(0,n.jsx)(o.x6,{i18nKey:"admin.server-settings.title",children:"Instance statistics"})}),!r&&!s?(0,n.jsx)("p",{className:a.notFound,children:(0,n.jsx)(o.x6,{i18nKey:"admin.server-settings.not-found",children:"No stats found."})}):(0,n.jsxs)(l.B,{gap:2,direction:{xs:"column",md:"row"},children:[(0,n.jsx)(h,{isLoading:r,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,n.jsx)(d.z9,{href:"/dashboards",variant:"secondary",children:(0,n.jsx)(o.x6,{i18nKey:"admin.server-settings.dashboards-button",children:"Manage dashboards"})})}),(0,n.jsxs)(l.B,{direction:"column",gap:2,children:[(0,n.jsx)(h,{isLoading:r,content:[{name:"Data sources",value:s?.datasources}],footer:m&&(0,n.jsx)(d.z9,{href:"/datasources",variant:"secondary",children:(0,n.jsx)(o.x6,{i18nKey:"admin.server-settings.data-sources-button",children:"Manage data sources"})})}),(0,n.jsx)(h,{isLoading:r,content:[{name:"Alerts",value:s?.alerts}],footer:(0,n.jsx)(d.z9,{href:"/alerting/list",variant:"secondary",children:(0,n.jsx)(o.x6,{i18nKey:"admin.server-settings.alerts-button",children:"Manage alerts"})})})]}),(0,n.jsx)(h,{isLoading:r,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},...C(s,j.$)],footer:N&&(0,n.jsx)(d.z9,{href:"/admin/users",variant:"secondary",children:(0,n.jsx)(o.x6,{i18nKey:"admin.server-settings.users-button",children:"Manage users"})})})]})]}):null},C=(s,e)=>!e.anonymousEnabled||!s?.activeDevices?[]:e.anonymousDeviceLimit?[{name:"Active anonymous devices",value:`${s.activeDevices} / ${e.anonymousDeviceLimit}`,tooltip:"Detected devices that are not logged in, in last 30 days.",highlight:s.activeDevices>e.anonymousDeviceLimit}]:[{name:"Active anonymous devices",value:`${s.activeDevices}`,tooltip:"Detected devices that are not logged in, in last 30 days."}],I=s=>({title:(0,i.css)({marginBottom:s.spacing(4)}),notFound:(0,i.css)({fontSize:s.typography.h6.fontSize,textAlign:"center",height:"290px"})})}}]);

//# sourceMappingURL=ServerStats.3bb255b683e08d0c371d.js.map