"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9299],{43388:(B,x,t)=>{t.r(x),t.d(x,{ServerStats:()=>T});var n=t(74848),i=t(22803),u=t(96540),j=t(32370),y=t(29675),l=t(48583),d=t(54594),r=t(11817),v=t(61491),g=t(61351),S=t(70255),f=t(6210),A=t(6736),p=t(79784);const h=({content:s,footer:e,isLoading:o})=>{const c=(0,y.of)(D);return(0,n.jsxs)(f.Z,{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)(A.m,{content:String(a.tooltip),placement:"auto-start",children:(0,n.jsx)(p.I,{name:"info-circle",className:c.tooltip})})]}),o?(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),margin:0,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 C=t(28082);const P=async()=>(0,C.AI)().get("api/admin/stats").catch(s=>(console.error(s),null)),T=()=>{const[s,e]=(0,u.useState)(null),[o,c]=(0,u.useState)(!0),a=(0,y.of)(z),m=g.TP.hasPermission(v.AccessControlAction.DataSourcesRead),I=g.TP.hasPermission(v.AccessControlAction.UsersRead);return(0,u.useEffect)(()=>{g.TP.hasPermission(v.AccessControlAction.ActionServerStatsRead)&&P().then(N=>{e(N),c(!1)})},[]),g.TP.hasPermission(v.AccessControlAction.ActionServerStatsRead)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h2",{className:a.title,children:(0,n.jsx)(r.x6,{i18nKey:"admin.server-settings.title",children:"Instance statistics"})}),!o&&!s?(0,n.jsx)("p",{className:a.notFound,children:(0,n.jsx)(r.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:o,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)(r.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:o,content:[{name:"Data sources",value:s?.datasources}],footer:m&&(0,n.jsx)(d.z9,{href:"/datasources",variant:"secondary",children:(0,n.jsx)(r.x6,{i18nKey:"admin.server-settings.data-sources-button",children:"Manage data sources"})})}),(0,n.jsx)(h,{isLoading:o,content:[{name:"Alerts",value:s?.alerts}],footer:(0,n.jsx)(d.z9,{href:"/alerting/list",variant:"secondary",children:(0,n.jsx)(r.x6,{i18nKey:"admin.server-settings.alerts-button",children:"Manage alerts"})})})]}),(0,n.jsx)(h,{isLoading:o,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},...$(s,j.$)],footer:I&&(0,n.jsx)(d.z9,{href:"/admin/users",variant:"secondary",children:(0,n.jsx)(r.x6,{i18nKey:"admin.server-settings.users-button",children:"Manage users"})})})]})]}):null},$=(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."}],z=s=>({title:(0,i.css)({marginBottom:s.spacing(4)}),notFound:(0,i.css)({fontSize:s.typography.h6.fontSize,textAlign:"center",height:"290px"})})}}]);

//# sourceMappingURL=ServerStats.84b7adee7acdf8b0677f.js.map