"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7641],{77977:(L,g,s)=>{s.r(g),s.d(g,{ServerStats:()=>C});var o=s(66681),t=s(85960),y=s(90857),u=s(47257),i=s(29165),l=s(95162),v=s(41879),S=s(34785),f=s(72435),h=s(13086),p=s(14607),E=s(97666);const d=({content:e,footer:n,isLoading:c})=>{const r=(0,u.wW)(A);return t.createElement(f.Z,{className:r.container},e.map((a,m)=>t.createElement(h.K,{key:m,justifyContent:"space-between",alignItems:"center"},t.createElement(h.K,{alignItems:"center"},t.createElement("span",{className:(0,o.cx)({[r.indent]:!!a.indent})},a.name),a.tooltip&&t.createElement(p.u,{content:String(a.tooltip),placement:"auto-start"},t.createElement(E.J,{name:"info-circle",className:r.tooltip}))),c?t.createElement(S.Z,{width:60}):t.createElement("span",{className:a.highlight?r.highlight:""},a.value))),n&&t.createElement("div",null,n))},A=e=>({container:(0,o.css)({display:"flex",flexDirection:"column",gap:e.spacing(2),padding:e.spacing(2)}),indent:(0,o.css)({marginLeft:e.spacing(2)}),tooltip:(0,o.css)({color:e.colors.secondary.text}),highlight:(0,o.css)({color:e.colors.warning.text,padding:`${e.spacing(.5)} ${e.spacing(1)}`,marginRight:`-${e.spacing(1)}`})});var x=s(85445);const D=async()=>(0,x.i)().get("api/admin/stats").catch(e=>(console.error(e),null)),C=()=>{const[e,n]=(0,t.useState)(null),[c,r]=(0,t.useState)(!0),a=(0,u.wW)(R),m=v.contextSrv.hasPermission(l.AccessControlAction.DataSourcesRead),$=v.contextSrv.hasPermission(l.AccessControlAction.UsersRead);return(0,t.useEffect)(()=>{v.contextSrv.hasPermission(l.AccessControlAction.ActionServerStatsRead)&&D().then(j=>{n(j),r(!1)})},[]),v.contextSrv.hasPermission(l.AccessControlAction.ActionServerStatsRead)?t.createElement(t.Fragment,null,t.createElement("h2",{className:a.title},"Instance statistics"),!c&&!e?t.createElement("p",{className:a.notFound},"No stats found."):t.createElement("div",{className:a.row},t.createElement(d,{isLoading:c,content:[{name:"Dashboards (starred)",value:`${e?.dashboards} (${e?.stars})`},{name:"Tags",value:e?.tags},{name:"Playlists",value:e?.playlists},{name:"Snapshots",value:e?.snapshots}],footer:t.createElement(i.Qj,{href:"/dashboards",variant:"secondary"},"Manage dashboards")}),t.createElement("div",{className:a.doubleRow},t.createElement(d,{isLoading:c,content:[{name:"Data sources",value:e?.datasources}],footer:m&&t.createElement(i.Qj,{href:"/datasources",variant:"secondary"},"Manage data sources")}),t.createElement(d,{isLoading:c,content:[{name:"Alerts",value:e?.alerts}],footer:t.createElement(i.Qj,{href:"/alerting/list",variant:"secondary"},"Manage alerts")})),t.createElement(d,{isLoading:c,content:[{name:"Organisations",value:e?.orgs},{name:"Users total",value:e?.users},{name:"Active sessions",value:e?.activeSessions},{name:"Active users in last 30 days",value:e?.activeUsers},...N(e,y.config)],footer:$&&t.createElement(i.Qj,{href:"/admin/users",variant:"secondary"},"Manage users")}))):null},N=(e,n)=>!n.anonymousEnabled||!n.featureToggles.displayAnonymousStats||!e?.activeDevices?[]:n.anonymousDeviceLimit?[{name:"Active anonymous devices",value:`${e.activeDevices} / ${n.anonymousDeviceLimit}`,tooltip:"Detected devices that are not logged in, in last 30 days.",highlight:e.activeDevices>n.anonymousDeviceLimit}]:[{name:"Active anonymous devices",value:`${e.activeDevices}`,tooltip:"Detected devices that are not logged in, in last 30 days."}],R=e=>({title:(0,o.css)({marginBottom:e.spacing(4)}),row:(0,o.css)({display:"flex",justifyContent:"space-between",width:"100%","& > div:not(:last-of-type)":{marginRight:e.spacing(2)},"& > div":{width:"33.3%"}}),doubleRow:(0,o.css)({display:"flex",flexDirection:"column","& > div:first-of-type":{marginBottom:e.spacing(2)}}),notFound:(0,o.css)({fontSize:e.typography.h6.fontSize,textAlign:"center",height:"290px"})})}}]);

//# sourceMappingURL=ServerStats.27f8595d38e698dca351.js.map