AdminSettings.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import { useAsync } from 'react-use';
  4. import { NavModel } from '@grafana/data';
  5. import { getBackendSrv } from '@grafana/runtime';
  6. import Page from 'app/core/components/Page/Page';
  7. import { getNavModel } from 'app/core/selectors/navModel';
  8. import { StoreState } from 'app/types';
  9. type Settings = { [key: string]: { [key: string]: string } };
  10. interface Props {
  11. navModel: NavModel;
  12. }
  13. function AdminSettings({ navModel }: Props) {
  14. const { loading, value: settings } = useAsync(
  15. () => getBackendSrv().get('/api/admin/settings') as Promise<Settings>,
  16. []
  17. );
  18. return (
  19. <Page navModel={navModel}>
  20. <Page.Contents isLoading={loading}>
  21. <div className="grafana-info-box span8" style={{ margin: '20px 0 25px 0' }}>
  22. These system settings are defined in grafana.ini or custom.ini (or overridden in ENV variables). To change
  23. these you currently need to restart Grafana.
  24. </div>
  25. {settings && (
  26. <table className="filter-table">
  27. <tbody>
  28. {Object.entries(settings).map(([sectionName, sectionSettings], i) => (
  29. <React.Fragment key={`section-${i}`}>
  30. <tr>
  31. <td className="admin-settings-section">{sectionName}</td>
  32. <td />
  33. </tr>
  34. {Object.entries(sectionSettings).map(([settingName, settingValue], j) => (
  35. <tr key={`property-${j}`}>
  36. <td style={{ paddingLeft: '25px' }}>{settingName}</td>
  37. <td style={{ whiteSpace: 'break-spaces' }}>{settingValue}</td>
  38. </tr>
  39. ))}
  40. </React.Fragment>
  41. ))}
  42. </tbody>
  43. </table>
  44. )}
  45. </Page.Contents>
  46. </Page>
  47. );
  48. }
  49. const mapStateToProps = (state: StoreState) => ({
  50. navModel: getNavModel(state.navIndex, 'server-settings'),
  51. });
  52. export default connect(mapStateToProps)(AdminSettings);