"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7641],{68555:(f,i,a)=>{a.r(i),a.d(i,{ServerStats:()=>A});var s=a(42844),e=a(27702),d=a(66310),r=a(66670),g=a(90527),m=a(18771),n=a(91368),E=a(67704),h=a(73289);const S=async()=>(0,h.i)().get("api/admin/stats").catch(t=>(console.error(t),null)),A=()=>{const[t,u]=(0,e.useState)(null),[c,o]=(0,e.useState)(!1),l=(0,d.wW)(y),x=n.contextSrv.hasAccess(m.AccessControlAction.DataSourcesRead,n.contextSrv.isGrafanaAdmin),C=n.contextSrv.hasAccess(m.AccessControlAction.UsersRead,n.contextSrv.isGrafanaAdmin);return(0,e.useEffect)(()=>{n.contextSrv.hasAccess(m.AccessControlAction.ActionServerStatsRead,n.contextSrv.isGrafanaAdmin)&&(o(!0),S().then(N=>{u(N),o(!1)}))},[]),n.contextSrv.hasAccess(m.AccessControlAction.ActionServerStatsRead,n.contextSrv.isGrafanaAdmin)?e.createElement(e.Fragment,null,e.createElement("h2",{className:l.title},"Instance statistics"),c?e.createElement("div",{className:l.loader},e.createElement(E.a,{text:"Loading instance stats..."})):t?e.createElement("div",{className:l.row},e.createElement(v,{content:[{name:"Dashboards (starred)",value:`${t.dashboards} (${t.stars})`},{name:"Tags",value:t.tags},{name:"Playlists",value:t.playlists},{name:"Snapshots",value:t.snapshots}],footer:e.createElement(r.Qj,{href:"/dashboards",variant:"secondary"},"Manage dashboards")}),e.createElement("div",{className:l.doubleRow},e.createElement(v,{content:[{name:"Data sources",value:t.datasources}],footer:x&&e.createElement(r.Qj,{href:"/datasources",variant:"secondary"},"Manage data sources")}),e.createElement(v,{content:[{name:"Alerts",value:t.alerts}],footer:e.createElement(r.Qj,{href:"/alerting/list",variant:"secondary"},"Alerts")})),e.createElement(v,{content:[{name:"Organisations",value:t.orgs},{name:"Users total",value:t.users},{name:"Active users in last 30 days",value:t.activeUsers},{name:"Active sessions",value:t.activeSessions}],footer:C&&e.createElement(r.Qj,{href:"/admin/users",variant:"secondary"},"Manage users")})):e.createElement("p",{className:l.notFound},"No stats found.")):null},y=t=>({title:(0,s.css)`
      margin-bottom: ${t.spacing(4)};
    `,row:(0,s.css)`
      display: flex;
      justify-content: space-between;
      width: 100%;

      & > div:not(:last-of-type) {
        margin-right: ${t.spacing(2)};
      }

      & > div {
        width: 33.3%;
      }
    `,doubleRow:(0,s.css)`
      display: flex;
      flex-direction: column;

      & > div:first-of-type {
        margin-bottom: ${t.spacing(2)};
      }
    `,loader:(0,s.css)`
      height: 290px;
    `,notFound:(0,s.css)`
      font-size: ${t.typography.h6.fontSize};
      text-align: center;
      height: 290px;
    `}),v=({content:t,footer:u})=>{const c=(0,d.wW)(p);return e.createElement(g._,{className:c.container,disableHover:!0},e.createElement("div",{className:c.inner},e.createElement("div",{className:c.content},t.map(o=>e.createElement("div",{key:o.name,className:c.row},e.createElement("span",null,o.name),e.createElement("span",null,o.value)))),u&&e.createElement("div",null,u)))},p=t=>({container:(0,s.css)`
      padding: ${t.spacing(2)};
    `,inner:(0,s.css)`
      display: flex;
      flex-direction: column;
      width: 100%;
    `,content:(0,s.css)`
      flex: 1 0 auto;
    `,row:(0,s.css)`
      display: flex;
      justify-content: space-between;
      width: 100%;
      margin-bottom: ${t.spacing(2)};
      align-items: center;
    `})},67704:(f,i,a)=>{a.d(i,{a:()=>d});var s=a(27702),e=a(52419);const d=({text:r="Loading..."})=>s.createElement("div",{className:"page-loader-wrapper"},s.createElement(e.u,{text:r}))}}]);

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